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

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

Issue 2510053002: Add a count for Suggested Articles usage. (Closed)
Patch Set: 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') | tools/metrics/actions/actions.xml » ('J')
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
16 using base::RecordAction;
17 using base::UserMetricsAction;
Marc Treib 2016/11/17 11:10:23 nit: I'd prefer specifying the "base::" in the one
markusheintz_ 2016/11/17 13:48:47 done
18
15 namespace ntp_snippets { 19 namespace ntp_snippets {
16 namespace metrics { 20 namespace metrics {
17 21
18 namespace { 22 namespace {
19 23
20 const int kMaxSuggestionsPerCategory = 10; 24 const int kMaxSuggestionsPerCategory = 10;
21 const int kMaxSuggestionsTotal = 50; 25 const int kMaxSuggestionsTotal = 50;
22 26
23 const char kHistogramCountOnNtpOpened[] = 27 const char kHistogramCountOnNtpOpened[] =
24 "NewTabPage.ContentSuggestions.CountOnNtpOpened"; 28 "NewTabPage.ContentSuggestions.CountOnNtpOpened";
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // bucket is increased. 170 // bucket is increased.
167 void RecordContentSuggestionsUsage() { 171 void RecordContentSuggestionsUsage() {
168 const int kBucketSizeMins = 20; 172 const int kBucketSizeMins = 20;
169 const int kNumBuckets = 24 * 60 / kBucketSizeMins; 173 const int kNumBuckets = 24 * 60 / kBucketSizeMins;
170 174
171 base::Time::Exploded now_exploded; 175 base::Time::Exploded now_exploded;
172 base::Time::Now().LocalExplode(&now_exploded); 176 base::Time::Now().LocalExplode(&now_exploded);
173 size_t bucket = 177 size_t bucket =
174 (now_exploded.hour * 60 + now_exploded.minute) / kBucketSizeMins; 178 (now_exploded.hour * 60 + now_exploded.minute) / kBucketSizeMins;
175 179
176 UMA_HISTOGRAM_ENUMERATION(kHistogramUsageTimeLocal, bucket, kNumBuckets); 180 UMA_HISTOGRAM_ENUMERATION(kHistogramArticlesUsageTimeLocal, bucket,
Marc Treib 2016/11/17 11:10:23 Bad rebase? You renamed the constant here, but not
markusheintz_ 2016/11/17 13:48:46 Done.
181 kNumBuckets);
177 182
178 LOG(ERROR) << " ****************** Zine Usage"; 183 RecordAction(
184 UserMetricsAction("NewTabPage_ContentSuggestions_ArticlesUsageCount"));
Marc Treib 2016/11/17 11:10:23 "Count" is implied by the fact that it's a UserAct
markusheintz_ 2016/11/17 13:48:46 Done.
179 } 185 }
180 186
181 } // namespace 187 } // namespace
182 188
183 void OnPageShown( 189 void OnPageShown(
184 const std::vector<std::pair<Category, int>>& suggestions_per_category) { 190 const std::vector<std::pair<Category, int>>& suggestions_per_category) {
185 int suggestions_total = 0; 191 int suggestions_total = 0;
186 for (const std::pair<Category, int>& item : suggestions_per_category) { 192 for (const std::pair<Category, int>& item : suggestions_per_category) {
187 LogCategoryHistogramEnumeration(kHistogramCountOnNtpOpened, item.first, 193 LogCategoryHistogramEnumeration(kHistogramCountOnNtpOpened, item.first,
188 item.second, kMaxSuggestionsPerCategory); 194 item.second, kMaxSuggestionsPerCategory);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 299
294 void OnMoreButtonClicked(Category category, int position) { 300 void OnMoreButtonClicked(Category category, int position) {
295 // The "more" card can appear in addition to the actual suggestions, so add 301 // The "more" card can appear in addition to the actual suggestions, so add
296 // one extra bucket to this histogram. 302 // one extra bucket to this histogram.
297 LogCategoryHistogramEnumeration(kHistogramMoreButtonClicked, category, 303 LogCategoryHistogramEnumeration(kHistogramMoreButtonClicked, category,
298 position, kMaxSuggestionsPerCategory + 1); 304 position, kMaxSuggestionsPerCategory + 1);
299 } 305 }
300 306
301 } // namespace metrics 307 } // namespace metrics
302 } // namespace ntp_snippets 308 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/actions/actions.xml » ('j') | tools/metrics/actions/actions.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698