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

Unified Diff: components/ntp_snippets/content_suggestions_metrics.cc

Issue 2574073003: [NTPSnippets] Records the time since last successful bg fetch. (Closed)
Patch Set: Rebase & address last comment treib Created 4 years 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 33d61743ca4a5a31b617d7eda8f0842074a26c4f..4f61eed1fa9af77c9dbb0f6ea8386caaae14bbf1 100644
--- a/components/ntp_snippets/content_suggestions_metrics.cc
+++ b/components/ntp_snippets/content_suggestions_metrics.cc
@@ -51,6 +51,8 @@ const char kHistogramMoreButtonClicked[] =
"NewTabPage.ContentSuggestions.MoreButtonClicked";
const char kHistogramCategoryDismissed[] =
"NewTabPage.ContentSuggestions.CategoryDismissed";
+const char kHistogramContentSuggestionsTimeSinceLastBackgroundFetch[] =
+ "NewTabPage.ContentSuggestions.TimeSinceLastBackgroundFetch";
const char kPerCategoryHistogramFormat[] = "%s.%s";
@@ -248,6 +250,7 @@ void OnSuggestionShown(int global_position,
Category category,
int category_position,
base::Time publish_date,
+ base::Time last_background_fetch_time,
float score) {
UMA_HISTOGRAM_ENUMERATION(kHistogramShown, global_position,
kMaxSuggestionsTotal);
@@ -259,11 +262,21 @@ void OnSuggestionShown(int global_position,
LogCategoryHistogramScore(kHistogramShownScore, category, score);
+ // TODO(markusheintz): Discuss whether the code below should be move into a
+ // separate method called OnSuggestionsListShown.
// 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) {
RecordContentSuggestionsUsage();
+
+ // Records the time since the last background fetch of the remote content
+ // suggestions.
+ UMA_HISTOGRAM_CUSTOM_TIMES(
+ kHistogramContentSuggestionsTimeSinceLastBackgroundFetch,
+ base::Time::Now() - last_background_fetch_time,
+ base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(7),
+ /*bucket_count=*/100);
}
}
« 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