Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(512)

Unified Diff: components/ntp_snippets/content_suggestions_metrics.cc

Issue 2609413005: [NTP::SectionOrder] Add category position metric for opened suggestions. (Closed)
Patch Set: added TODO. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/ntp_snippets/content_suggestions_metrics.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/content_suggestions_metrics.cc
diff --git a/components/ntp_snippets/content_suggestions_metrics.cc b/components/ntp_snippets/content_suggestions_metrics.cc
index 4f61eed1fa9af77c9dbb0f6ea8386caaae14bbf1..87f40998e4a1d3e3f6de8af2bc65af55331475d2 100644
--- a/components/ntp_snippets/content_suggestions_metrics.cc
+++ b/components/ntp_snippets/content_suggestions_metrics.cc
@@ -20,6 +20,7 @@ namespace {
const int kMaxSuggestionsPerCategory = 10;
finkm 2017/01/05 16:31:29 Hmmm ... since we have the more button, a section
vitaliii 2017/01/05 17:02:46 I created a bug and added a TODO (as per our offli
const int kMaxSuggestionsTotal = 50;
finkm 2017/01/05 16:31:29 same as above
vitaliii 2017/01/05 17:02:46 same as above.
+const int kMaxCategories = 10;
const char kHistogramCountOnNtpOpened[] =
"NewTabPage.ContentSuggestions.CountOnNtpOpened";
@@ -28,6 +29,8 @@ const char kHistogramShownAge[] = "NewTabPage.ContentSuggestions.ShownAge";
const char kHistogramShownScore[] = "NewTabPage.ContentSuggestions.ShownScore";
const char kHistogramOpened[] = "NewTabPage.ContentSuggestions.Opened";
const char kHistogramOpenedAge[] = "NewTabPage.ContentSuggestions.OpenedAge";
+const char kHistogramOpenedCategoryPosition[] =
+ "NewTabPage.ContentSuggestions.OpenedCategoryPosition";
const char kHistogramOpenedScore[] =
"NewTabPage.ContentSuggestions.OpenedScore";
const char kHistogramOpenDisposition[] =
@@ -231,6 +234,16 @@ void RecordContentSuggestionsUsage() {
base::UserMetricsAction("NewTabPage_ContentSuggestions_ArticlesUsage"));
}
+int GetCategoryPosition(
+ Category category,
+ const ntp_snippets::ContentSuggestionsService* service) {
+ std::vector<Category> ordered_categories = service->GetCategories();
+ DCHECK(base::ContainsValue(ordered_categories, category));
+ auto it =
+ std::find(ordered_categories.begin(), ordered_categories.end(), category);
+ return it - ordered_categories.begin();
+}
+
} // namespace
void OnPageShown(
@@ -248,13 +261,14 @@ void OnPageShown(
void OnSuggestionShown(int global_position,
Category category,
- int category_position,
+ int position_in_category,
base::Time publish_date,
base::Time last_background_fetch_time,
float score) {
UMA_HISTOGRAM_ENUMERATION(kHistogramShown, global_position,
kMaxSuggestionsTotal);
- LogCategoryHistogramEnumeration(kHistogramShown, category, category_position,
+ LogCategoryHistogramEnumeration(kHistogramShown, category,
+ position_in_category,
kMaxSuggestionsPerCategory);
base::TimeDelta age = base::Time::Now() - publish_date;
@@ -267,7 +281,7 @@ void OnSuggestionShown(int global_position,
// When the first of the articles suggestions is shown, then we count this as
// a single usage of content suggestions.
if (category.IsKnownCategory(KnownCategories::ARTICLES) &&
- category_position == 0) {
+ position_in_category == 0) {
RecordContentSuggestionsUsage();
// Records the time since the last background fetch of the remote content
@@ -280,15 +294,23 @@ void OnSuggestionShown(int global_position,
}
}
-void OnSuggestionOpened(int global_position,
+void OnSuggestionOpened(const ContentSuggestionsService* service,
+ int global_position,
Category category,
- int category_position,
+ int position_in_category,
base::Time publish_date,
float score,
WindowOpenDisposition disposition) {
+ const int category_position = GetCategoryPosition(category, service);
+ UMA_HISTOGRAM_ENUMERATION(kHistogramOpenedCategoryPosition, category_position,
+ kMaxCategories);
+ LogCategoryHistogramEnumeration(kHistogramOpenedCategoryPosition, category,
+ category_position, kMaxCategories);
+
UMA_HISTOGRAM_ENUMERATION(kHistogramOpened, global_position,
kMaxSuggestionsTotal);
- LogCategoryHistogramEnumeration(kHistogramOpened, category, category_position,
+ LogCategoryHistogramEnumeration(kHistogramOpened, category,
+ position_in_category,
kMaxSuggestionsPerCategory);
base::TimeDelta age = base::Time::Now() - publish_date;
@@ -310,13 +332,13 @@ void OnSuggestionOpened(int global_position,
void OnSuggestionMenuOpened(int global_position,
Category category,
- int category_position,
+ int position_in_category,
base::Time publish_date,
float score) {
UMA_HISTOGRAM_ENUMERATION(kHistogramMenuOpened, global_position,
kMaxSuggestionsTotal);
LogCategoryHistogramEnumeration(kHistogramMenuOpened, category,
- category_position,
+ position_in_category,
kMaxSuggestionsPerCategory);
base::TimeDelta age = base::Time::Now() - publish_date;
@@ -327,19 +349,19 @@ void OnSuggestionMenuOpened(int global_position,
void OnSuggestionDismissed(int global_position,
Category category,
- int category_position,
+ int position_in_category,
bool visited) {
if (visited) {
UMA_HISTOGRAM_ENUMERATION(kHistogramDismissedVisited, global_position,
kMaxSuggestionsTotal);
LogCategoryHistogramEnumeration(kHistogramDismissedVisited, category,
- category_position,
+ position_in_category,
kMaxSuggestionsPerCategory);
} else {
UMA_HISTOGRAM_ENUMERATION(kHistogramDismissedUnvisited, global_position,
kMaxSuggestionsTotal);
LogCategoryHistogramEnumeration(kHistogramDismissedUnvisited, category,
- category_position,
+ position_in_category,
kMaxSuggestionsPerCategory);
}
}
« no previous file with comments | « components/ntp_snippets/content_suggestions_metrics.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698