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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 "NewTabPage.ContentSuggestions.MenuOpenedScore"; | 36 "NewTabPage.ContentSuggestions.MenuOpenedScore"; |
37 const char kHistogramVisitDuration[] = | 37 const char kHistogramVisitDuration[] = |
38 "NewTabPage.ContentSuggestions.VisitDuration"; | 38 "NewTabPage.ContentSuggestions.VisitDuration"; |
39 const char kHistogramMoreButtonShown[] = | 39 const char kHistogramMoreButtonShown[] = |
40 "NewTabPage.ContentSuggestions.MoreButtonShown"; | 40 "NewTabPage.ContentSuggestions.MoreButtonShown"; |
41 const char kHistogramMoreButtonClicked[] = | 41 const char kHistogramMoreButtonClicked[] = |
42 "NewTabPage.ContentSuggestions.MoreButtonClicked"; | 42 "NewTabPage.ContentSuggestions.MoreButtonClicked"; |
43 | 43 |
44 const char kPerCategoryHistogramFormat[] = "%s.%s"; | 44 const char kPerCategoryHistogramFormat[] = "%s.%s"; |
45 | 45 |
| 46 // Each suffix here should correspond to an entry under histogram suffix |
| 47 // ContentSuggestionCategory in histograms.xml. |
46 std::string GetCategorySuffix(Category category) { | 48 std::string GetCategorySuffix(Category category) { |
47 // TODO(treib): Find a way to produce a compile error if a known category | 49 // TODO(treib): Find a way to produce a compile error if a known category |
48 // isn't listed here. | 50 // isn't listed here. |
49 if (category.IsKnownCategory(KnownCategories::RECENT_TABS)) | 51 if (category.IsKnownCategory(KnownCategories::RECENT_TABS)) |
50 return "RecentTabs"; | 52 return "RecentTabs"; |
51 if (category.IsKnownCategory(KnownCategories::DOWNLOADS)) | 53 if (category.IsKnownCategory(KnownCategories::DOWNLOADS)) |
52 return "Downloads"; | 54 return "Downloads"; |
53 if (category.IsKnownCategory(KnownCategories::BOOKMARKS)) | 55 if (category.IsKnownCategory(KnownCategories::BOOKMARKS)) |
54 return "Bookmarks"; | 56 return "Bookmarks"; |
| 57 if (category.IsKnownCategory(KnownCategories::FOREIGN_TABS)) |
| 58 return "ForeignTabs"; |
55 if (category.IsKnownCategory(KnownCategories::ARTICLES)) | 59 if (category.IsKnownCategory(KnownCategories::ARTICLES)) |
56 return "Articles"; | 60 return "Articles"; |
57 // All other categories go into a single "Experimental" bucket. | 61 // All other categories go into a single "Experimental" bucket. |
58 return "Experimental"; | 62 return "Experimental"; |
59 } | 63 } |
60 | 64 |
61 std::string GetCategoryHistogramName(const char* base_name, Category category) { | 65 std::string GetCategoryHistogramName(const char* base_name, Category category) { |
62 return base::StringPrintf(kPerCategoryHistogramFormat, base_name, | 66 return base::StringPrintf(kPerCategoryHistogramFormat, base_name, |
63 GetCategorySuffix(category).c_str()); | 67 GetCategorySuffix(category).c_str()); |
64 } | 68 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 223 |
220 void OnMoreButtonClicked(Category category, int position) { | 224 void OnMoreButtonClicked(Category category, int position) { |
221 // The "more" card can appear in addition to the actual suggestions, so add | 225 // The "more" card can appear in addition to the actual suggestions, so add |
222 // one extra bucket to this histogram. | 226 // one extra bucket to this histogram. |
223 LogCategoryHistogramEnumeration(kHistogramMoreButtonClicked, category, | 227 LogCategoryHistogramEnumeration(kHistogramMoreButtonClicked, category, |
224 position, kMaxSuggestionsPerCategory + 1); | 228 position, kMaxSuggestionsPerCategory + 1); |
225 } | 229 } |
226 | 230 |
227 } // namespace metrics | 231 } // namespace metrics |
228 } // namespace ntp_snippets | 232 } // namespace ntp_snippets |
OLD | NEW |