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

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: 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 kHistogramContentSuggestionsBackgroundFetchAge[] =
55 "NewTabPage.ContentSuggestions.BackgroundFetchAge";
Marc Treib 2016/12/15 10:16:41 nit: I'm not super happy with the term "Age" here
markusheintz_ 2016/12/15 12:42:07 Excellent name suggestion!! I find it much better
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 age of the remote content suggestion based on the last
274 // background fetch time. This is different from the actual content age as
Marc Treib 2016/12/15 10:16:41 Also here: It's not the age of the suggestion, it'
markusheintz_ 2016/12/15 12:42:07 That's what I describe in the comment. I simplifie
275 // it records the time span between fetching the suggestions and viewing
276 // them.
277 UMA_HISTOGRAM_CUSTOM_TIMES(kHistogramContentSuggestionsBackgroundFetchAge,
278 base::Time::Now() - last_background_fetch_time,
279 base::TimeDelta::FromSeconds(1),
280 base::TimeDelta::FromDays(3),
281 /*bucket_count=*/100);
267 } 282 }
268 } 283 }
269 284
270 void OnSuggestionOpened(int global_position, 285 void OnSuggestionOpened(int global_position,
271 Category category, 286 Category category,
272 int category_position, 287 int category_position,
273 base::Time publish_date, 288 base::Time publish_date,
274 float score, 289 float score,
275 WindowOpenDisposition disposition) { 290 WindowOpenDisposition disposition) {
276 UMA_HISTOGRAM_ENUMERATION(kHistogramOpened, global_position, 291 UMA_HISTOGRAM_ENUMERATION(kHistogramOpened, global_position,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 365 }
351 366
352 void OnCategoryDismissed(Category category) { 367 void OnCategoryDismissed(Category category) {
353 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed, 368 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed,
354 static_cast<int>(GetHistogramCategory(category)), 369 static_cast<int>(GetHistogramCategory(category)),
355 static_cast<int>(HistogramCategories::COUNT)); 370 static_cast<int>(HistogramCategories::COUNT));
356 } 371 }
357 372
358 } // namespace metrics 373 } // namespace metrics
359 } // namespace ntp_snippets 374 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698