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

Side by Side Diff: components/ntp_snippets/content_suggestions_metrics.cc

Issue 2707783004: [remote suggestions] Add a new histogram for recording the time since a snippet was fetched. (Closed)
Patch Set: Address comments of comments Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/ntp_snippets/content_suggestions_metrics.h" 5 #include "components/ntp_snippets/content_suggestions_metrics.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <string> 8 #include <string>
9 #include <type_traits> 9 #include <type_traits>
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 const char kHistogramVisitDuration[] = 52 const char kHistogramVisitDuration[] =
53 "NewTabPage.ContentSuggestions.VisitDuration"; 53 "NewTabPage.ContentSuggestions.VisitDuration";
54 const char kHistogramMoreButtonShown[] = 54 const char kHistogramMoreButtonShown[] =
55 "NewTabPage.ContentSuggestions.MoreButtonShown"; 55 "NewTabPage.ContentSuggestions.MoreButtonShown";
56 const char kHistogramMoreButtonClicked[] = 56 const char kHistogramMoreButtonClicked[] =
57 "NewTabPage.ContentSuggestions.MoreButtonClicked"; 57 "NewTabPage.ContentSuggestions.MoreButtonClicked";
58 const char kHistogramMovedUpCategoryNewIndex[] = 58 const char kHistogramMovedUpCategoryNewIndex[] =
59 "NewTabPage.ContentSuggestions.MovedUpCategoryNewIndex"; 59 "NewTabPage.ContentSuggestions.MovedUpCategoryNewIndex";
60 const char kHistogramCategoryDismissed[] = 60 const char kHistogramCategoryDismissed[] =
61 "NewTabPage.ContentSuggestions.CategoryDismissed"; 61 "NewTabPage.ContentSuggestions.CategoryDismissed";
62 const char kHistogramContentSuggestionsTimeSinceLastBackgroundFetch[] = 62 const char kHistogramTimeSinceSuggestionFetched[] =
63 "NewTabPage.ContentSuggestions.TimeSinceLastBackgroundFetch"; 63 "NewTabPage.ContentSuggestions.TimeSinceSuggestionFetched";
64 64
65 const char kPerCategoryHistogramFormat[] = "%s.%s"; 65 const char kPerCategoryHistogramFormat[] = "%s.%s";
66 66
67 // This mostly corresponds to the KnownCategories enum, but it is contiguous 67 // This mostly corresponds to the KnownCategories enum, but it is contiguous
68 // and contains exactly the values to be recorded in UMA. Don't remove or 68 // and contains exactly the values to be recorded in UMA. Don't remove or
69 // reorder elements, only add new ones at the end (before COUNT), and keep in 69 // reorder elements, only add new ones at the end (before COUNT), and keep in
70 // sync with ContentSuggestionsCategory in histograms.xml. 70 // sync with ContentSuggestionsCategory in histograms.xml.
71 enum HistogramCategories { 71 enum HistogramCategories {
72 EXPERIMENTAL, 72 EXPERIMENTAL,
73 RECENT_TABS, 73 RECENT_TABS,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramShown, global_position, 228 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramShown, global_position,
229 kMaxSuggestionsTotal); 229 kMaxSuggestionsTotal);
230 LogCategoryHistogramPosition(kHistogramShown, category, position_in_category, 230 LogCategoryHistogramPosition(kHistogramShown, category, position_in_category,
231 kMaxSuggestionsPerCategory); 231 kMaxSuggestionsPerCategory);
232 232
233 base::TimeDelta age = base::Time::Now() - publish_date; 233 base::TimeDelta age = base::Time::Now() - publish_date;
234 LogCategoryHistogramAge(kHistogramShownAge, category, age); 234 LogCategoryHistogramAge(kHistogramShownAge, category, age);
235 235
236 LogCategoryHistogramScore(kHistogramShownScore, category, score); 236 LogCategoryHistogramScore(kHistogramShownScore, category, score);
237 237
238 if (category.IsKnownCategory(KnownCategories::ARTICLES)) {
239 // Records the time since the fetch time of the displayed snippet.
240 UMA_HISTOGRAM_CUSTOM_TIMES(
241 kHistogramTimeSinceSuggestionFetched, base::Time::Now() - fetch_date,
242 base::TimeDelta::FromDays(0), base::TimeDelta::FromDays(7),
Marc Treib 2017/02/22 13:38:11 I think the min value can't be 0. FromSeconds(1)?
markusheintz_ 2017/02/22 13:42:04 done. already uploaded. sry I forgot
243 /*bucket_count=*/100);
244 }
245
238 // TODO(markusheintz): Discuss whether the code below should be move into a 246 // TODO(markusheintz): Discuss whether the code below should be move into a
239 // separate method called OnSuggestionsListShown. 247 // separate method called OnSuggestionsListShown.
240 // When the first of the articles suggestions is shown, then we count this as 248 // When the first of the articles suggestions is shown, then we count this as
241 // a single usage of content suggestions. 249 // a single usage of content suggestions.
242 if (category.IsKnownCategory(KnownCategories::ARTICLES) && 250 if (category.IsKnownCategory(KnownCategories::ARTICLES) &&
243 position_in_category == 0) { 251 position_in_category == 0) {
244 RecordContentSuggestionsUsage(); 252 RecordContentSuggestionsUsage();
245
246 // Records the time since the last background fetch of the remote content
247 // suggestions.
248 UMA_HISTOGRAM_CUSTOM_TIMES(
249 kHistogramContentSuggestionsTimeSinceLastBackgroundFetch,
250 base::Time::Now() - fetch_date, base::TimeDelta::FromSeconds(1),
251 base::TimeDelta::FromDays(7),
252 /*bucket_count=*/100);
253 } 253 }
254 } 254 }
255 255
256 void OnSuggestionOpened(int global_position, 256 void OnSuggestionOpened(int global_position,
257 Category category, 257 Category category,
258 int category_index, 258 int category_index,
259 int position_in_category, 259 int position_in_category,
260 base::Time publish_date, 260 base::Time publish_date,
261 float score, 261 float score,
262 WindowOpenDisposition disposition) { 262 WindowOpenDisposition disposition) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 } 352 }
353 353
354 void OnCategoryDismissed(Category category) { 354 void OnCategoryDismissed(Category category) {
355 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed, 355 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed,
356 GetHistogramCategory(category), 356 GetHistogramCategory(category),
357 HistogramCategories::COUNT); 357 HistogramCategories::COUNT);
358 } 358 }
359 359
360 } // namespace metrics 360 } // namespace metrics
361 } // namespace ntp_snippets 361 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698