| 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_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 ++counts_per_type[tile_type]; | 78 ++counts_per_type[tile_type]; |
| 79 | 79 |
| 80 UMA_HISTOGRAM_ENUMERATION("NewTabPage.TileType", tile_type, NUM_TILE_TYPES); | 80 UMA_HISTOGRAM_ENUMERATION("NewTabPage.TileType", tile_type, NUM_TILE_TYPES); |
| 81 | 81 |
| 82 std::string histogram = base::StringPrintf( | 82 std::string histogram = base::StringPrintf( |
| 83 "NewTabPage.TileType.%s", GetSourceHistogramName(sources[i]).c_str()); | 83 "NewTabPage.TileType.%s", GetSourceHistogramName(sources[i]).c_str()); |
| 84 LogHistogramEvent(histogram, tile_type, NUM_TILE_TYPES); | 84 LogHistogramEvent(histogram, tile_type, NUM_TILE_TYPES); |
| 85 } | 85 } |
| 86 | 86 |
| 87 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsReal", | 87 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsReal", |
| 88 counts_per_type[ICON_REAL]); | 88 counts_per_type[ICON_REAL]); |
| 89 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsColor", | 89 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsColor", |
| 90 counts_per_type[ICON_COLOR]); | 90 counts_per_type[ICON_COLOR]); |
| 91 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsGray", | 91 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsGray", |
| 92 counts_per_type[ICON_DEFAULT]); | 92 counts_per_type[ICON_DEFAULT]); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void RecordClick(int index, | 95 void RecordTileClick(int index, NTPTileSource source) { |
| 96 MostVisitedTileType tile_type, | |
| 97 NTPTileSource source) { | |
| 98 UMA_HISTOGRAM_ENUMERATION("NewTabPage.MostVisited", index, kMaxNumTiles); | 96 UMA_HISTOGRAM_ENUMERATION("NewTabPage.MostVisited", index, kMaxNumTiles); |
| 99 | 97 |
| 100 std::string histogram = base::StringPrintf( | 98 std::string histogram = base::StringPrintf( |
| 101 "NewTabPage.MostVisited.%s", GetSourceHistogramName(source).c_str()); | 99 "NewTabPage.MostVisited.%s", GetSourceHistogramName(source).c_str()); |
| 102 LogHistogramEvent(histogram, index, kMaxNumTiles); | 100 LogHistogramEvent(histogram, index, kMaxNumTiles); |
| 101 } |
| 102 |
| 103 void RecordTileClickWithTileType(int index, |
| 104 NTPTileSource source, |
| 105 MostVisitedTileType tile_type) { |
| 106 RecordTileClick(index, source); |
| 103 | 107 |
| 104 UMA_HISTOGRAM_ENUMERATION("NewTabPage.TileTypeClicked", tile_type, | 108 UMA_HISTOGRAM_ENUMERATION("NewTabPage.TileTypeClicked", tile_type, |
| 105 NUM_TILE_TYPES); | 109 NUM_TILE_TYPES); |
| 106 | 110 |
| 107 histogram = base::StringPrintf("NewTabPage.TileTypeClicked.%s", | 111 std::string histogram = base::StringPrintf( |
| 108 GetSourceHistogramName(source).c_str()); | 112 "NewTabPage.TileTypeClicked.%s", GetSourceHistogramName(source).c_str()); |
| 109 LogHistogramEvent(histogram, tile_type, NUM_TILE_TYPES); | 113 LogHistogramEvent(histogram, tile_type, NUM_TILE_TYPES); |
| 110 } | 114 } |
| 111 | 115 |
| 112 } // namespace metrics | 116 } // namespace metrics |
| 113 } // namespace ntp_tiles | 117 } // namespace ntp_tiles |
| OLD | NEW |