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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 return kHistogramWhitelistName; | 48 return kHistogramWhitelistName; |
49 case NTPTileSource::SUGGESTIONS_SERVICE: | 49 case NTPTileSource::SUGGESTIONS_SERVICE: |
50 return kHistogramServerName; | 50 return kHistogramServerName; |
51 } | 51 } |
52 NOTREACHED(); | 52 NOTREACHED(); |
53 return std::string(); | 53 return std::string(); |
54 } | 54 } |
55 | 55 |
56 } // namespace | 56 } // namespace |
57 | 57 |
58 void RecordImpressions(const NTPTilesVector& tiles) { | 58 void RecordTileImpression(int index, NTPTileSource source) { |
59 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.NumberOfTiles", tiles.size()); | 59 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestionsImpression", |
| 60 static_cast<int>(index), kMaxNumTiles); |
60 | 61 |
61 for (size_t i = 0; i < tiles.size(); i++) { | 62 std::string histogram = |
62 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestionsImpression", | 63 base::StringPrintf("NewTabPage.SuggestionsImpression.%s", |
63 static_cast<int>(i), kMaxNumTiles); | 64 GetSourceHistogramName(source).c_str()); |
| 65 LogHistogramEvent(histogram, static_cast<int>(index), kMaxNumTiles); |
| 66 } |
64 | 67 |
65 std::string histogram = | 68 void RecordPageImpression(int number_of_tiles) { |
66 base::StringPrintf("NewTabPage.SuggestionsImpression.%s", | 69 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.NumberOfTiles", number_of_tiles); |
67 GetSourceHistogramName(tiles[i].source).c_str()); | |
68 LogHistogramEvent(histogram, static_cast<int>(i), kMaxNumTiles); | |
69 } | |
70 } | 70 } |
71 | 71 |
72 void RecordImpressionTileTypes( | 72 void RecordImpressionTileTypes( |
73 const std::vector<MostVisitedTileType>& tile_types, | 73 const std::vector<MostVisitedTileType>& tile_types, |
74 const std::vector<NTPTileSource>& sources) { | 74 const std::vector<NTPTileSource>& sources) { |
75 int counts_per_type[NUM_TILE_TYPES] = {0}; | 75 int counts_per_type[NUM_RECORDED_TILE_TYPES] = {0}; |
76 for (size_t i = 0; i < tile_types.size(); ++i) { | 76 for (size_t i = 0; i < tile_types.size(); ++i) { |
77 MostVisitedTileType tile_type = tile_types[i]; | 77 MostVisitedTileType tile_type = tile_types[i]; |
| 78 DCHECK_LT(tile_type, NUM_RECORDED_TILE_TYPES); |
78 ++counts_per_type[tile_type]; | 79 ++counts_per_type[tile_type]; |
79 | 80 |
80 UMA_HISTOGRAM_ENUMERATION("NewTabPage.TileType", tile_type, NUM_TILE_TYPES); | 81 UMA_HISTOGRAM_ENUMERATION("NewTabPage.TileType", tile_type, |
| 82 NUM_RECORDED_TILE_TYPES); |
81 | 83 |
82 std::string histogram = base::StringPrintf( | 84 std::string histogram = base::StringPrintf( |
83 "NewTabPage.TileType.%s", GetSourceHistogramName(sources[i]).c_str()); | 85 "NewTabPage.TileType.%s", GetSourceHistogramName(sources[i]).c_str()); |
84 LogHistogramEvent(histogram, tile_type, NUM_TILE_TYPES); | 86 LogHistogramEvent(histogram, tile_type, NUM_RECORDED_TILE_TYPES); |
85 } | 87 } |
86 | 88 |
87 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsReal", | 89 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsReal", |
88 counts_per_type[ICON_REAL]); | 90 counts_per_type[ICON_REAL]); |
89 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsColor", | 91 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsColor", |
90 counts_per_type[ICON_COLOR]); | 92 counts_per_type[ICON_COLOR]); |
91 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsGray", | 93 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsGray", |
92 counts_per_type[ICON_DEFAULT]); | 94 counts_per_type[ICON_DEFAULT]); |
93 } | 95 } |
94 | 96 |
95 void RecordClick(int index, | 97 void RecordTileClick(int index, |
96 MostVisitedTileType tile_type, | 98 NTPTileSource source, |
97 NTPTileSource source) { | 99 MostVisitedTileType tile_type) { |
98 UMA_HISTOGRAM_ENUMERATION("NewTabPage.MostVisited", index, kMaxNumTiles); | 100 UMA_HISTOGRAM_ENUMERATION("NewTabPage.MostVisited", index, kMaxNumTiles); |
99 | 101 |
100 std::string histogram = base::StringPrintf( | 102 std::string histogram = base::StringPrintf( |
101 "NewTabPage.MostVisited.%s", GetSourceHistogramName(source).c_str()); | 103 "NewTabPage.MostVisited.%s", GetSourceHistogramName(source).c_str()); |
102 LogHistogramEvent(histogram, index, kMaxNumTiles); | 104 LogHistogramEvent(histogram, index, kMaxNumTiles); |
103 | 105 |
104 UMA_HISTOGRAM_ENUMERATION("NewTabPage.TileTypeClicked", tile_type, | 106 if (tile_type < NUM_RECORDED_TILE_TYPES) { |
105 NUM_TILE_TYPES); | 107 UMA_HISTOGRAM_ENUMERATION("NewTabPage.TileTypeClicked", tile_type, |
| 108 NUM_RECORDED_TILE_TYPES); |
106 | 109 |
107 histogram = base::StringPrintf("NewTabPage.TileTypeClicked.%s", | 110 std::string histogram = |
108 GetSourceHistogramName(source).c_str()); | 111 base::StringPrintf("NewTabPage.TileTypeClicked.%s", |
109 LogHistogramEvent(histogram, tile_type, NUM_TILE_TYPES); | 112 GetSourceHistogramName(source).c_str()); |
| 113 LogHistogramEvent(histogram, tile_type, NUM_RECORDED_TILE_TYPES); |
| 114 } |
110 } | 115 } |
111 | 116 |
112 } // namespace metrics | 117 } // namespace metrics |
113 } // namespace ntp_tiles | 118 } // namespace ntp_tiles |
OLD | NEW |