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_tiles/metrics.h" | 5 #include "components/ntp_tiles/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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 return kHistogramPopularName; | 52 return kHistogramPopularName; |
53 case NTPTileSource::WHITELIST: | 53 case NTPTileSource::WHITELIST: |
54 return kHistogramWhitelistName; | 54 return kHistogramWhitelistName; |
55 case NTPTileSource::SUGGESTIONS_SERVICE: | 55 case NTPTileSource::SUGGESTIONS_SERVICE: |
56 return kHistogramServerName; | 56 return kHistogramServerName; |
57 } | 57 } |
58 NOTREACHED(); | 58 NOTREACHED(); |
59 return std::string(); | 59 return std::string(); |
60 } | 60 } |
61 | 61 |
62 const char* GetIconTypeSuffix(MostVisitedTileType type) { | 62 const char* GetIconTypeSuffix(NTPTileType type) { |
63 switch (type) { | 63 switch (type) { |
64 case ICON_COLOR: | 64 case ICON_COLOR: |
65 return kIconTypeSuffixColor; | 65 return kIconTypeSuffixColor; |
66 case ICON_DEFAULT: | 66 case ICON_DEFAULT: |
67 return kIconTypeSuffixGray; | 67 return kIconTypeSuffixGray; |
68 case ICON_REAL: | 68 case ICON_REAL: |
69 return kIconTypeSuffixReal; | 69 return kIconTypeSuffixReal; |
70 case NONE: // Fall through. | 70 case NONE: // Fall through. |
71 case NUM_RECORDED_TILE_TYPES: // Fall through. | 71 case NUM_RECORDED_TILE_TYPES: // Fall through. |
72 case THUMBNAIL: // Fall through. | 72 case THUMBNAIL: // Fall through. |
73 case UNKNOWN_TILE_TYPE: | 73 case UNKNOWN_TILE_TYPE: |
74 break; | 74 break; |
75 } | 75 } |
76 return nullptr; | 76 return nullptr; |
77 } | 77 } |
78 | 78 |
79 } // namespace | 79 } // namespace |
80 | 80 |
81 void RecordPageImpression(const std::vector<TileImpression>& tiles, | 81 void RecordPageImpression(const std::vector<TileImpression>& tiles, |
82 rappor::RapporService* rappor_service) { | 82 rappor::RapporService* rappor_service) { |
83 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.NumberOfTiles", tiles.size()); | 83 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.NumberOfTiles", tiles.size()); |
84 | 84 |
85 for (int index = 0; index < static_cast<int>(tiles.size()); index++) { | 85 for (int index = 0; index < static_cast<int>(tiles.size()); index++) { |
86 NTPTileSource source = tiles[index].source; | 86 NTPTileSource source = tiles[index].source; |
87 MostVisitedTileType tile_type = tiles[index].type; | 87 NTPTileType tile_type = tiles[index].type; |
88 const GURL& url = tiles[index].url; | 88 const GURL& url = tiles[index].url; |
89 | 89 |
90 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestionsImpression", index, | 90 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestionsImpression", index, |
91 kMaxNumTiles); | 91 kMaxNumTiles); |
92 | 92 |
93 std::string source_name = GetSourceHistogramName(source); | 93 std::string source_name = GetSourceHistogramName(source); |
94 std::string impression_histogram = base::StringPrintf( | 94 std::string impression_histogram = base::StringPrintf( |
95 "NewTabPage.SuggestionsImpression.%s", source_name.c_str()); | 95 "NewTabPage.SuggestionsImpression.%s", source_name.c_str()); |
96 LogHistogramEvent(impression_histogram, index, kMaxNumTiles); | 96 LogHistogramEvent(impression_histogram, index, kMaxNumTiles); |
97 | 97 |
(...skipping 15 matching lines...) Expand all Loading... |
113 base::StringPrintf("NTP.SuggestionsImpressions.%s", icon_type_suffix), | 113 base::StringPrintf("NTP.SuggestionsImpressions.%s", icon_type_suffix), |
114 url); | 114 url); |
115 | 115 |
116 std::string icon_impression_histogram = base::StringPrintf( | 116 std::string icon_impression_histogram = base::StringPrintf( |
117 "NewTabPage.SuggestionsImpression.%s", icon_type_suffix); | 117 "NewTabPage.SuggestionsImpression.%s", icon_type_suffix); |
118 LogHistogramEvent(icon_impression_histogram, index, kMaxNumTiles); | 118 LogHistogramEvent(icon_impression_histogram, index, kMaxNumTiles); |
119 } | 119 } |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 void RecordTileClick(int index, | 123 void RecordTileClick(int index, NTPTileSource source, NTPTileType tile_type) { |
124 NTPTileSource source, | |
125 MostVisitedTileType tile_type) { | |
126 UMA_HISTOGRAM_ENUMERATION("NewTabPage.MostVisited", index, kMaxNumTiles); | 124 UMA_HISTOGRAM_ENUMERATION("NewTabPage.MostVisited", index, kMaxNumTiles); |
127 | 125 |
128 std::string histogram = base::StringPrintf( | 126 std::string histogram = base::StringPrintf( |
129 "NewTabPage.MostVisited.%s", GetSourceHistogramName(source).c_str()); | 127 "NewTabPage.MostVisited.%s", GetSourceHistogramName(source).c_str()); |
130 LogHistogramEvent(histogram, index, kMaxNumTiles); | 128 LogHistogramEvent(histogram, index, kMaxNumTiles); |
131 | 129 |
132 const char* icon_type_suffix = GetIconTypeSuffix(tile_type); | 130 const char* icon_type_suffix = GetIconTypeSuffix(tile_type); |
133 if (icon_type_suffix) { | 131 if (icon_type_suffix) { |
134 std::string icon_histogram = | 132 std::string icon_histogram = |
135 base::StringPrintf("NewTabPage.MostVisited.%s", icon_type_suffix); | 133 base::StringPrintf("NewTabPage.MostVisited.%s", icon_type_suffix); |
136 LogHistogramEvent(icon_histogram, index, kMaxNumTiles); | 134 LogHistogramEvent(icon_histogram, index, kMaxNumTiles); |
137 } | 135 } |
138 | 136 |
139 if (tile_type < NUM_RECORDED_TILE_TYPES) { | 137 if (tile_type < NUM_RECORDED_TILE_TYPES) { |
140 UMA_HISTOGRAM_ENUMERATION("NewTabPage.TileTypeClicked", tile_type, | 138 UMA_HISTOGRAM_ENUMERATION("NewTabPage.TileTypeClicked", tile_type, |
141 NUM_RECORDED_TILE_TYPES); | 139 NUM_RECORDED_TILE_TYPES); |
142 | 140 |
143 std::string histogram = | 141 std::string histogram = |
144 base::StringPrintf("NewTabPage.TileTypeClicked.%s", | 142 base::StringPrintf("NewTabPage.TileTypeClicked.%s", |
145 GetSourceHistogramName(source).c_str()); | 143 GetSourceHistogramName(source).c_str()); |
146 LogHistogramEvent(histogram, tile_type, NUM_RECORDED_TILE_TYPES); | 144 LogHistogramEvent(histogram, tile_type, NUM_RECORDED_TILE_TYPES); |
147 } | 145 } |
148 } | 146 } |
149 | 147 |
150 } // namespace metrics | 148 } // namespace metrics |
151 } // namespace ntp_tiles | 149 } // namespace ntp_tiles |
OLD | NEW |