OLD | NEW |
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 |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/metrics/histogram_functions.h" | 12 #include "base/metrics/histogram_functions.h" |
13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
14 #include "base/metrics/user_metrics.h" | 14 #include "base/metrics/user_metrics.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 | 16 |
17 namespace ntp_snippets { | 17 namespace ntp_snippets { |
18 namespace metrics { | 18 namespace metrics { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 const int kMaxSuggestionsPerCategory = 10; | 22 const int kMaxSuggestionsPerCategory = 10; |
23 const int kMaxSuggestionsTotal = 50; | 23 const int kMaxSuggestionsTotal = 50; |
24 const int kMaxCategories = 10; | 24 const int kMaxCategories = 10; |
25 | 25 |
26 const char kHistogramCountOnNtpOpened[] = | 26 const char kHistogramCountOnNtpOpened[] = |
27 "NewTabPage.ContentSuggestions.CountOnNtpOpened"; | 27 "NewTabPage.ContentSuggestions.CountOnNtpOpened"; |
| 28 const char kHistogramSectionCountOnNtpOpened[] = |
| 29 "NewTabPage.ContentSuggestions.SectionCountOnNtpOpened"; |
28 const char kHistogramShown[] = "NewTabPage.ContentSuggestions.Shown"; | 30 const char kHistogramShown[] = "NewTabPage.ContentSuggestions.Shown"; |
29 const char kHistogramShownAge[] = "NewTabPage.ContentSuggestions.ShownAge"; | 31 const char kHistogramShownAge[] = "NewTabPage.ContentSuggestions.ShownAge"; |
30 const char kHistogramShownScore[] = | 32 const char kHistogramShownScore[] = |
31 "NewTabPage.ContentSuggestions.ShownScoreNormalized"; | 33 "NewTabPage.ContentSuggestions.ShownScoreNormalized"; |
32 const char kHistogramOpened[] = "NewTabPage.ContentSuggestions.Opened"; | 34 const char kHistogramOpened[] = "NewTabPage.ContentSuggestions.Opened"; |
33 const char kHistogramOpenedAge[] = "NewTabPage.ContentSuggestions.OpenedAge"; | 35 const char kHistogramOpenedAge[] = "NewTabPage.ContentSuggestions.OpenedAge"; |
34 const char kHistogramOpenedCategoryIndex[] = | 36 const char kHistogramOpenedCategoryIndex[] = |
35 "NewTabPage.ContentSuggestions.OpenedCategoryIndex"; | 37 "NewTabPage.ContentSuggestions.OpenedCategoryIndex"; |
36 const char kHistogramOpenedScore[] = | 38 const char kHistogramOpenedScore[] = |
37 "NewTabPage.ContentSuggestions.OpenedScoreNormalized"; | 39 "NewTabPage.ContentSuggestions.OpenedScoreNormalized"; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramArticlesUsageTimeLocal, bucket, | 207 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramArticlesUsageTimeLocal, bucket, |
206 kNumBuckets); | 208 kNumBuckets); |
207 | 209 |
208 base::RecordAction( | 210 base::RecordAction( |
209 base::UserMetricsAction("NewTabPage_ContentSuggestions_ArticlesUsage")); | 211 base::UserMetricsAction("NewTabPage_ContentSuggestions_ArticlesUsage")); |
210 } | 212 } |
211 | 213 |
212 } // namespace | 214 } // namespace |
213 | 215 |
214 void OnPageShown( | 216 void OnPageShown( |
215 const std::vector<std::pair<Category, int>>& suggestions_per_category) { | 217 const std::vector<std::pair<Category, int>>& suggestions_per_category, |
| 218 int visible_categories_count) { |
216 int suggestions_total = 0; | 219 int suggestions_total = 0; |
217 for (const std::pair<Category, int>& item : suggestions_per_category) { | 220 for (const std::pair<Category, int>& item : suggestions_per_category) { |
218 LogCategoryHistogramPosition(kHistogramCountOnNtpOpened, item.first, | 221 LogCategoryHistogramPosition(kHistogramCountOnNtpOpened, item.first, |
219 item.second, kMaxSuggestionsPerCategory); | 222 item.second, kMaxSuggestionsPerCategory); |
220 suggestions_total += item.second; | 223 suggestions_total += item.second; |
221 } | 224 } |
222 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramCountOnNtpOpened, suggestions_total, | 225 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramCountOnNtpOpened, suggestions_total, |
223 kMaxSuggestionsTotal); | 226 kMaxSuggestionsTotal); |
| 227 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramSectionCountOnNtpOpened, |
| 228 visible_categories_count, kMaxCategories); |
224 } | 229 } |
225 | 230 |
226 void OnSuggestionShown(int global_position, | 231 void OnSuggestionShown(int global_position, |
227 Category category, | 232 Category category, |
228 int position_in_category, | 233 int position_in_category, |
229 base::Time publish_date, | 234 base::Time publish_date, |
230 float score, | 235 float score, |
231 base::Time fetch_date) { | 236 base::Time fetch_date) { |
232 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramShown, global_position, | 237 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramShown, global_position, |
233 kMaxSuggestionsTotal); | 238 kMaxSuggestionsTotal); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 void RecordCategoryDismissed() { | 380 void RecordCategoryDismissed() { |
376 base::RecordAction(base::UserMetricsAction("Suggestions.Category.Dismissed")); | 381 base::RecordAction(base::UserMetricsAction("Suggestions.Category.Dismissed")); |
377 } | 382 } |
378 | 383 |
379 void RecordFetchAction() { | 384 void RecordFetchAction() { |
380 base::RecordAction(base::UserMetricsAction("Suggestions.Category.Fetch")); | 385 base::RecordAction(base::UserMetricsAction("Suggestions.Category.Fetch")); |
381 } | 386 } |
382 | 387 |
383 } // namespace metrics | 388 } // namespace metrics |
384 } // namespace ntp_snippets | 389 } // namespace ntp_snippets |
OLD | NEW |