Commit 2af60d03 authored by David Black's avatar David Black Committed by Commit Bot

Fork show vs re-show histograms for proactive suggestions.

We want to differentiate between first show attempt/result and
subsequent re-show attempts/results in UMA histograms for proactive
suggestions so that we can measure engagement of users the first time
they are presented w/ content in comparison to re-presentations of the
same content.

To accomplish this we add:
- Assistant.ProactiveSuggestions.FirstShowAttempt
- Assistant.ProactiveSuggestions.FirstShowAttempt.<Prefix>.ByCategory
- Assistant.ProactiveSuggestions.FirstShowResult
- Assistant.ProactiveSuggestions.FirstShowResult.<Prefix>.ByCategory
- Assistant.ProactiveSuggestions.ReshowAttempt
- Assistant.ProactiveSuggestions.ReshowAttempt.<Prefix>.ByCategory
- Assistant.ProactiveSuggestions.ReshowResult
- Assistant.ProactiveSuggestions.ReshowResult.<Prefix>.ByCategory

We mark the following pre-existing histograms as obsolete:
- Assistant.ProactiveSuggestions.ShowAttempt
- Assistant.ProactiveSuggestions.ShowAttempt.<Suffix>
- Assistant.ProactiveSuggestions.ShowResult
- Assistant.ProactiveSuggestions.ShowResult.<Suffix>

Bug: b:144875278
Change-Id: I8af637b43bb485d8ed1a7356311dd25a9aabb7e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1951549
Commit-Queue: David Black <dmblack@google.com>
Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722688}
parent 3800ad18
......@@ -334,6 +334,13 @@ void AssistantProactiveSuggestionsController::MaybeShowUi() {
if (!proactive_suggestions)
return;
// For tracking purposes, we record a different histogram the first time we
// show a proactive suggestion than we do on subsequent shows. This allows us
// to measure user engagement the first time our entry point is presented in
// comparison to follow up presentations of the same content.
const bool has_shown_before = base::Contains(
proactive_suggestions_seen_by_user_, proactive_suggestions->hash());
// If the cached set of proactive suggestions is blacklisted, it should not be
// shown to the user. A set of proactive suggestions may be blacklisted as a
// result of duplicate suppression or as a result of the user explicitly
......@@ -342,7 +349,8 @@ void AssistantProactiveSuggestionsController::MaybeShowUi() {
proactive_suggestions->hash())) {
RecordProactiveSuggestionsShowAttempt(
proactive_suggestions->category(),
ProactiveSuggestionsShowAttempt::kAbortedByDuplicateSuppression);
ProactiveSuggestionsShowAttempt::kAbortedByDuplicateSuppression,
has_shown_before);
return;
}
......@@ -364,7 +372,7 @@ void AssistantProactiveSuggestionsController::MaybeShowUi() {
RecordProactiveSuggestionsShowAttempt(
view_->proactive_suggestions()->category(),
ProactiveSuggestionsShowAttempt::kSuccess);
ProactiveSuggestionsShowAttempt::kSuccess, has_shown_before);
// If duplicate suppression is enabled, the user should not be presented with
// this set of proactive suggestions again so we add it to our blacklist.
......@@ -393,8 +401,19 @@ void AssistantProactiveSuggestionsController::CloseUi(
if (!view_)
return;
// Cache the fact that this set of proactive suggestions was shown so that
// we can later recall that fact for subsequent presentations.
const bool has_shown_before =
!proactive_suggestions_seen_by_user_
.emplace(view_->proactive_suggestions()->hash())
.second;
// For tracking purposes, we record a different histogram the first time a
// proactive suggestion is closed than on we do on subsequent closes. This
// allows us to measure user engagement the first time our entry point is
// presented in comparison to follow up presentations of the same content.
RecordProactiveSuggestionsShowResult(
view_->proactive_suggestions()->category(), result);
view_->proactive_suggestions()->category(), result, has_shown_before);
auto_close_timer_.Stop();
......
......@@ -96,6 +96,12 @@ class AssistantProactiveSuggestionsController
// of the user explicitly closing the proactive suggestions view.
std::set<size_t> proactive_suggestions_blacklist_;
// We record different histograms the first time that a set of proactive
// suggestions are shown than we do on subsequent shows. This allows us to
// measure user engagement the first time the entry point is presented in
// comparison to follow up presentations of the same content.
std::set<size_t> proactive_suggestions_seen_by_user_;
base::WeakPtrFactory<AssistantProactiveSuggestionsController> weak_factory_{
this};
......
......@@ -73,64 +73,88 @@ void RecordProactiveSuggestionsRequestResult(
void RecordProactiveSuggestionsShowAttempt(
int category,
ProactiveSuggestionsShowAttempt attempt) {
constexpr char kShowAttemptHistogram[] =
"Assistant.ProactiveSuggestions.ShowAttempt";
ProactiveSuggestionsShowAttempt attempt,
bool has_seen_before) {
constexpr char kFirstShowAttemptHistogram[] =
"Assistant.ProactiveSuggestions.FirstShowAttempt";
constexpr char kReshowAttemptHistogram[] =
"Assistant.ProactiveSuggestions.ReshowAttempt";
// We use a different set of histograms depending on whether or not the set
// of proactive suggestions has already been seen. This allows us to measure
// user engagement the first time the entry point is presented in comparison
// to follow up presentations of the same content.
const std::string histogram =
has_seen_before ? kReshowAttemptHistogram : kFirstShowAttemptHistogram;
// We record an aggregate histogram for easily reporting cumulative show
// attempts across all content categories.
base::UmaHistogramEnumeration(kShowAttemptHistogram, attempt);
base::UmaHistogramEnumeration(histogram, attempt);
// We record sparse histograms for easily comparing show attempts between
// content categories.
switch (attempt) {
case ProactiveSuggestionsShowAttempt::kSuccess:
base::UmaHistogramSparse(
base::StringPrintf("%s.Success", kShowAttemptHistogram), category);
base::StringPrintf("%s.Success.ByCategory", histogram.c_str()),
category);
break;
case ProactiveSuggestionsShowAttempt::kAbortedByDuplicateSuppression:
base::UmaHistogramSparse(
base::StringPrintf("%s.AbortedByDuplicateSuppression",
kShowAttemptHistogram),
base::StringPrintf("%s.AbortedByDuplicateSuppression.ByCategory",
histogram.c_str()),
category);
break;
}
}
void RecordProactiveSuggestionsShowResult(
int category,
ProactiveSuggestionsShowResult result) {
constexpr char kShowResultHistogram[] =
"Assistant.ProactiveSuggestions.ShowResult";
void RecordProactiveSuggestionsShowResult(int category,
ProactiveSuggestionsShowResult result,
bool has_seen_before) {
constexpr char kFirstShowResultHistogram[] =
"Assistant.ProactiveSuggestions.FirstShowResult";
constexpr char kReshowResultHistogram[] =
"Assistant.ProactiveSuggestions.ReshowResult";
// We use a different set of histograms depending on whether or not the set
// of proactive suggestions has already been seen. This allows us to measure
// user engagement the first time the entry point is presented in comparison
// to follow up presentations of the same content.
const std::string histogram =
has_seen_before ? kReshowResultHistogram : kFirstShowResultHistogram;
// We record an aggregate histogram for easily reporting cumulative show
// results across all content categories.
base::UmaHistogramEnumeration(kShowResultHistogram, result);
base::UmaHistogramEnumeration(histogram, result);
// We record sparse histograms for easily comparing show results between
// content categories.
switch (result) {
case ProactiveSuggestionsShowResult::kClick:
base::UmaHistogramSparse(
base::StringPrintf("%s.Click", kShowResultHistogram), category);
base::StringPrintf("%s.Click.ByCategory", histogram.c_str()),
category);
break;
case ProactiveSuggestionsShowResult::kCloseByContextChange:
base::UmaHistogramSparse(
base::StringPrintf("%s.CloseByContextChange", kShowResultHistogram),
base::StringPrintf("%s.CloseByContextChange.ByCategory",
histogram.c_str()),
category);
break;
case ProactiveSuggestionsShowResult::kCloseByTimeout:
base::UmaHistogramSparse(
base::StringPrintf("%s.CloseByTimeout", kShowResultHistogram),
base::StringPrintf("%s.CloseByTimeout.ByCategory", histogram.c_str()),
category);
break;
case ProactiveSuggestionsShowResult::kCloseByUser:
base::UmaHistogramSparse(
base::StringPrintf("%s.CloseByUser", kShowResultHistogram), category);
base::StringPrintf("%s.CloseByUser.ByCategory", histogram.c_str()),
category);
break;
case ProactiveSuggestionsShowResult::kTeleport:
base::UmaHistogramSparse(
base::StringPrintf("%s.Teleport", kShowResultHistogram), category);
base::StringPrintf("%s.Teleport.ByCategory", histogram.c_str()),
category);
break;
}
}
......
......@@ -64,18 +64,35 @@ ASH_PUBLIC_EXPORT void RecordProactiveSuggestionsRequestResult(
// Records an |attempt| to show a proactive suggestion to the user in the
// specified content |category|. Note that |category| is an opaque int that is
// provided by the proactive suggestions server to represent the category of the
// associated content (e.g. news, shopping, etc.).
// associated content (e.g. news, shopping, etc.). Also note that we record a
// different set of histograms depending on whether or not the proactive
// suggestion has been seen before so that we can measure user engagement for
// the first show attempt in comparison to on subsequent attempts for the same
// content.
ASH_PUBLIC_EXPORT void RecordProactiveSuggestionsShowAttempt(
int category,
ProactiveSuggestionsShowAttempt attempt);
ProactiveSuggestionsShowAttempt attempt,
bool has_seen_before);
// Records a |result| from having shown a proactive suggestion to the user in
// the specified content |category|. Note that |category| is an opaque int that
// is provided by the proactive suggestions server to represent the category of
// the associated content (e.g. news, shopping, etc.).
// the associated content (e.g. news, shopping, etc.). Also note that we record
// a different set of histograms depending on whether or not the proactive
// suggestion has been seen before so that we can measure user engagement for
// the first show result in comparison to subsequent results for the same
// content.
ASH_PUBLIC_EXPORT void RecordProactiveSuggestionsShowResult(
int category,
ProactiveSuggestionsShowResult result);
ProactiveSuggestionsShowResult result,
bool has_seen_before);
// Records an impression of a proactive suggestions view. If provided, the
// opaque |category| of the associated content (e.g. news, shopping, etc.) as
// well as the |veId| associated w/ the type of view are also recorded.
ASH_PUBLIC_EXPORT void RecordProactiveSuggestionsViewImpression(
base::Optional<int> category,
base::Optional<int> veId);
// Records an impression of a proactive suggestions view. If provided, the
// opaque |category| of the associated content (e.g. news, shopping, etc.) as
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment