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

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

Issue 2510053002: Add a count for Suggested Articles usage. (Closed)
Patch Set: sync Created 4 years, 1 month 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
« no previous file with comments | « no previous file | tools/metrics/actions/actions.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/metrics/user_metrics.h"
12 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
13 #include "base/template_util.h" 14 #include "base/template_util.h"
14 15
15 namespace ntp_snippets { 16 namespace ntp_snippets {
16 namespace metrics { 17 namespace metrics {
17 18
18 namespace { 19 namespace {
19 20
20 const int kMaxSuggestionsPerCategory = 10; 21 const int kMaxSuggestionsPerCategory = 10;
21 const int kMaxSuggestionsTotal = 50; 22 const int kMaxSuggestionsTotal = 50;
(...skipping 11 matching lines...) Expand all
33 "NewTabPage.ContentSuggestions.OpenDisposition"; 34 "NewTabPage.ContentSuggestions.OpenDisposition";
34 const char kHistogramMenuOpened[] = "NewTabPage.ContentSuggestions.MenuOpened"; 35 const char kHistogramMenuOpened[] = "NewTabPage.ContentSuggestions.MenuOpened";
35 const char kHistogramMenuOpenedAge[] = 36 const char kHistogramMenuOpenedAge[] =
36 "NewTabPage.ContentSuggestions.MenuOpenedAge"; 37 "NewTabPage.ContentSuggestions.MenuOpenedAge";
37 const char kHistogramMenuOpenedScore[] = 38 const char kHistogramMenuOpenedScore[] =
38 "NewTabPage.ContentSuggestions.MenuOpenedScore"; 39 "NewTabPage.ContentSuggestions.MenuOpenedScore";
39 const char kHistogramDismissedUnvisited[] = 40 const char kHistogramDismissedUnvisited[] =
40 "NewTabPage.ContentSuggestions.DismissedUnvisited"; 41 "NewTabPage.ContentSuggestions.DismissedUnvisited";
41 const char kHistogramDismissedVisited[] = 42 const char kHistogramDismissedVisited[] =
42 "NewTabPage.ContentSuggestions.DismissedVisited"; 43 "NewTabPage.ContentSuggestions.DismissedVisited";
43 const char kHistogramUsageTimeLocal[] = 44 const char kHistogramArticlesUsageTimeLocal[] =
44 "NewTabPage.ContentSuggestions.UsageTimeLocal"; 45 "NewTabPage.ContentSuggestions.UsageTimeLocal";
45 const char kHistogramVisitDuration[] = 46 const char kHistogramVisitDuration[] =
46 "NewTabPage.ContentSuggestions.VisitDuration"; 47 "NewTabPage.ContentSuggestions.VisitDuration";
47 const char kHistogramMoreButtonShown[] = 48 const char kHistogramMoreButtonShown[] =
48 "NewTabPage.ContentSuggestions.MoreButtonShown"; 49 "NewTabPage.ContentSuggestions.MoreButtonShown";
49 const char kHistogramMoreButtonClicked[] = 50 const char kHistogramMoreButtonClicked[] =
50 "NewTabPage.ContentSuggestions.MoreButtonClicked"; 51 "NewTabPage.ContentSuggestions.MoreButtonClicked";
51 52
52 const char kPerCategoryHistogramFormat[] = "%s.%s"; 53 const char kPerCategoryHistogramFormat[] = "%s.%s";
53 54
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // bucket is increased. 167 // bucket is increased.
167 void RecordContentSuggestionsUsage() { 168 void RecordContentSuggestionsUsage() {
168 const int kBucketSizeMins = 20; 169 const int kBucketSizeMins = 20;
169 const int kNumBuckets = 24 * 60 / kBucketSizeMins; 170 const int kNumBuckets = 24 * 60 / kBucketSizeMins;
170 171
171 base::Time::Exploded now_exploded; 172 base::Time::Exploded now_exploded;
172 base::Time::Now().LocalExplode(&now_exploded); 173 base::Time::Now().LocalExplode(&now_exploded);
173 size_t bucket = 174 size_t bucket =
174 (now_exploded.hour * 60 + now_exploded.minute) / kBucketSizeMins; 175 (now_exploded.hour * 60 + now_exploded.minute) / kBucketSizeMins;
175 176
176 UMA_HISTOGRAM_ENUMERATION(kHistogramUsageTimeLocal, bucket, kNumBuckets); 177 UMA_HISTOGRAM_ENUMERATION(kHistogramArticlesUsageTimeLocal, bucket,
178 kNumBuckets);
177 179
178 LOG(ERROR) << " ****************** Zine Usage"; 180 base::RecordAction(
181 base::UserMetricsAction("NewTabPage_ContentSuggestions_ArticlesUsage"));
179 } 182 }
180 183
181 } // namespace 184 } // namespace
182 185
183 void OnPageShown( 186 void OnPageShown(
184 const std::vector<std::pair<Category, int>>& suggestions_per_category) { 187 const std::vector<std::pair<Category, int>>& suggestions_per_category) {
185 int suggestions_total = 0; 188 int suggestions_total = 0;
186 for (const std::pair<Category, int>& item : suggestions_per_category) { 189 for (const std::pair<Category, int>& item : suggestions_per_category) {
187 LogCategoryHistogramEnumeration(kHistogramCountOnNtpOpened, item.first, 190 LogCategoryHistogramEnumeration(kHistogramCountOnNtpOpened, item.first,
188 item.second, kMaxSuggestionsPerCategory); 191 item.second, kMaxSuggestionsPerCategory);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 296
294 void OnMoreButtonClicked(Category category, int position) { 297 void OnMoreButtonClicked(Category category, int position) {
295 // The "more" card can appear in addition to the actual suggestions, so add 298 // The "more" card can appear in addition to the actual suggestions, so add
296 // one extra bucket to this histogram. 299 // one extra bucket to this histogram.
297 LogCategoryHistogramEnumeration(kHistogramMoreButtonClicked, category, 300 LogCategoryHistogramEnumeration(kHistogramMoreButtonClicked, category,
298 position, kMaxSuggestionsPerCategory + 1); 301 position, kMaxSuggestionsPerCategory + 1);
299 } 302 }
300 303
301 } // namespace metrics 304 } // namespace metrics
302 } // namespace ntp_snippets 305 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/actions/actions.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698