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

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

Issue 2574073003: [NTPSnippets] Records the time since last successful bg fetch. (Closed)
Patch Set: Address comments 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 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 <string> 7 #include <string>
8 #include <type_traits> 8 #include <type_traits>
9 9
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 const char kHistogramArticlesUsageTimeLocal[] = 44 const char kHistogramArticlesUsageTimeLocal[] =
45 "NewTabPage.ContentSuggestions.UsageTimeLocal"; 45 "NewTabPage.ContentSuggestions.UsageTimeLocal";
46 const char kHistogramVisitDuration[] = 46 const char kHistogramVisitDuration[] =
47 "NewTabPage.ContentSuggestions.VisitDuration"; 47 "NewTabPage.ContentSuggestions.VisitDuration";
48 const char kHistogramMoreButtonShown[] = 48 const char kHistogramMoreButtonShown[] =
49 "NewTabPage.ContentSuggestions.MoreButtonShown"; 49 "NewTabPage.ContentSuggestions.MoreButtonShown";
50 const char kHistogramMoreButtonClicked[] = 50 const char kHistogramMoreButtonClicked[] =
51 "NewTabPage.ContentSuggestions.MoreButtonClicked"; 51 "NewTabPage.ContentSuggestions.MoreButtonClicked";
52 const char kHistogramCategoryDismissed[] = 52 const char kHistogramCategoryDismissed[] =
53 "NewTabPage.ContentSuggestions.CategoryDismissed"; 53 "NewTabPage.ContentSuggestions.CategoryDismissed";
54 const char kHistogramContentSuggestionsTimeSinceLastBackgroundFetch[] =
55 "NewTabPage.ContentSuggestions.TimeSinceLastBackgroundFetch";
54 56
55 const char kPerCategoryHistogramFormat[] = "%s.%s"; 57 const char kPerCategoryHistogramFormat[] = "%s.%s";
56 58
57 // This mostly corresponds to the KnownCategories enum, but it is contiguous 59 // This mostly corresponds to the KnownCategories enum, but it is contiguous
58 // and contains exactly the values to be recorded in UMA. Don't remove or 60 // and contains exactly the values to be recorded in UMA. Don't remove or
59 // reorder elements, only add new ones at the end (before COUNT), and keep in 61 // reorder elements, only add new ones at the end (before COUNT), and keep in
60 // sync with ContentSuggestionsCategory in histograms.xml. 62 // sync with ContentSuggestionsCategory in histograms.xml.
61 enum class HistogramCategories { 63 enum class HistogramCategories {
62 EXPERIMENTAL, 64 EXPERIMENTAL,
63 RECENT_TABS, 65 RECENT_TABS,
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 243 }
242 244
243 UMA_HISTOGRAM_ENUMERATION(kHistogramCountOnNtpOpened, suggestions_total, 245 UMA_HISTOGRAM_ENUMERATION(kHistogramCountOnNtpOpened, suggestions_total,
244 kMaxSuggestionsTotal); 246 kMaxSuggestionsTotal);
245 } 247 }
246 248
247 void OnSuggestionShown(int global_position, 249 void OnSuggestionShown(int global_position,
248 Category category, 250 Category category,
249 int category_position, 251 int category_position,
250 base::Time publish_date, 252 base::Time publish_date,
253 base::Time last_background_fetch_time,
251 float score) { 254 float score) {
252 UMA_HISTOGRAM_ENUMERATION(kHistogramShown, global_position, 255 UMA_HISTOGRAM_ENUMERATION(kHistogramShown, global_position,
253 kMaxSuggestionsTotal); 256 kMaxSuggestionsTotal);
254 LogCategoryHistogramEnumeration(kHistogramShown, category, category_position, 257 LogCategoryHistogramEnumeration(kHistogramShown, category, category_position,
255 kMaxSuggestionsPerCategory); 258 kMaxSuggestionsPerCategory);
256 259
257 base::TimeDelta age = base::Time::Now() - publish_date; 260 base::TimeDelta age = base::Time::Now() - publish_date;
258 LogCategoryHistogramAge(kHistogramShownAge, category, age); 261 LogCategoryHistogramAge(kHistogramShownAge, category, age);
259 262
260 LogCategoryHistogramScore(kHistogramShownScore, category, score); 263 LogCategoryHistogramScore(kHistogramShownScore, category, score);
261 264
265 // TODO(markusheintz): Discuss whether the code below should be move into a
266 // separate method called OnSuggestionsListShown.
262 // When the first of the articles suggestions is shown, then we count this as 267 // When the first of the articles suggestions is shown, then we count this as
263 // a single usage of content suggestions. 268 // a single usage of content suggestions.
264 if (category.IsKnownCategory(KnownCategories::ARTICLES) && 269 if (category.IsKnownCategory(KnownCategories::ARTICLES) &&
265 category_position == 0) { 270 category_position == 0) {
266 RecordContentSuggestionsUsage(); 271 RecordContentSuggestionsUsage();
272
273 // Records the time since the last background fetch of the remote content
274 // suggestions.
275 UMA_HISTOGRAM_CUSTOM_TIMES(
276 kHistogramContentSuggestionsTimeSinceLastBackgroundFetch,
277 base::Time::Now() - last_background_fetch_time,
278 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(3),
Marc Treib 2016/12/15 12:47:22 Should we make the max a bit bigger, to also captu
279 /*bucket_count=*/100);
267 } 280 }
268 } 281 }
269 282
270 void OnSuggestionOpened(int global_position, 283 void OnSuggestionOpened(int global_position,
271 Category category, 284 Category category,
272 int category_position, 285 int category_position,
273 base::Time publish_date, 286 base::Time publish_date,
274 float score, 287 float score,
275 WindowOpenDisposition disposition) { 288 WindowOpenDisposition disposition) {
276 UMA_HISTOGRAM_ENUMERATION(kHistogramOpened, global_position, 289 UMA_HISTOGRAM_ENUMERATION(kHistogramOpened, global_position,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 363 }
351 364
352 void OnCategoryDismissed(Category category) { 365 void OnCategoryDismissed(Category category) {
353 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed, 366 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed,
354 static_cast<int>(GetHistogramCategory(category)), 367 static_cast<int>(GetHistogramCategory(category)),
355 static_cast<int>(HistogramCategories::COUNT)); 368 static_cast<int>(HistogramCategories::COUNT));
356 } 369 }
357 370
358 } // namespace metrics 371 } // namespace metrics
359 } // namespace ntp_snippets 372 } // namespace ntp_snippets
OLDNEW
« 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