Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1220)

Unified Diff: components/ntp_tiles/metrics.cc

Issue 2671983002: ntp_tiles: Add UMA histograms to correlate icon type to position (Closed)
Patch Set: Adopted histogram suffixes. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/ntp_tiles/metrics_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_tiles/metrics.cc
diff --git a/components/ntp_tiles/metrics.cc b/components/ntp_tiles/metrics.cc
index e407af25715fac4eb4370462e687af960b69d18e..4acc1c0d5c5fed99bf1db596d246579ac0be8581 100644
--- a/components/ntp_tiles/metrics.cc
+++ b/components/ntp_tiles/metrics.cc
@@ -26,6 +26,11 @@ const char kHistogramServerName[] = "server";
const char kHistogramPopularName[] = "popular";
const char kHistogramWhitelistName[] = "whitelist";
+// Suffixes for the various icon types.
+const char kIconTypeSuffixColor[] = "IconsColor";
+const char kIconTypeSuffixGray[] = "IconsGray";
+const char kIconTypeSuffixReal[] = "IconsReal";
+
// Log an event for a given |histogram| at a given element |position|. This
// routine exists because regular histogram macros are cached thus can't be used
// if the name of the histogram will change at a given call site.
@@ -54,6 +59,23 @@ std::string GetSourceHistogramName(NTPTileSource source) {
return std::string();
}
+const char* GetIconTypeSuffix(MostVisitedTileType type) {
+ switch (type) {
+ case ICON_COLOR:
+ return kIconTypeSuffixColor;
+ case ICON_DEFAULT:
+ return kIconTypeSuffixGray;
+ case ICON_REAL:
+ return kIconTypeSuffixReal;
+ case NONE: // Fall through.
+ case NUM_RECORDED_TILE_TYPES: // Fall through.
+ case THUMBNAIL: // Fall through.
+ case UNKNOWN_TILE_TYPE:
+ break;
+ }
+ return nullptr;
+}
+
} // namespace
void RecordPageImpression(const std::vector<TileImpression>& tiles,
@@ -89,25 +111,16 @@ void RecordPageImpression(const std::vector<TileImpression>& tiles,
base::StringPrintf("NewTabPage.TileType.%s", source_name.c_str());
LogHistogramEvent(tile_type_histogram, tile_type, NUM_RECORDED_TILE_TYPES);
- switch (tile_type) {
- case NONE:
- break;
- case ICON_COLOR:
- rappor::SampleDomainAndRegistryFromGURL(
- rappor_service, "NTP.SuggestionsImpressions.IconsColor", url);
- break;
- case ICON_DEFAULT:
- rappor::SampleDomainAndRegistryFromGURL(
- rappor_service, "NTP.SuggestionsImpressions.IconsGray", url);
- break;
- case ICON_REAL:
- rappor::SampleDomainAndRegistryFromGURL(
- rappor_service, "NTP.SuggestionsImpressions.IconsReal", url);
- break;
- case NUM_RECORDED_TILE_TYPES: // Fall through.
- case THUMBNAIL: // Fall through.
- case UNKNOWN_TILE_TYPE:
- NOTREACHED();
+ const char* icon_type_suffix = GetIconTypeSuffix(tile_type);
+ if (icon_type_suffix) {
+ rappor::SampleDomainAndRegistryFromGURL(
+ rappor_service,
+ base::StringPrintf("NTP.SuggestionsImpressions.%s", icon_type_suffix),
+ url);
+
+ std::string icon_impression_histogram = base::StringPrintf(
+ "NewTabPage.SuggestionsImpression.%s", icon_type_suffix);
+ LogHistogramEvent(icon_impression_histogram, index, kMaxNumTiles);
}
}
@@ -130,6 +143,13 @@ void RecordTileClick(int index,
"NewTabPage.MostVisited.%s", GetSourceHistogramName(source).c_str());
LogHistogramEvent(histogram, index, kMaxNumTiles);
+ const char* icon_type_suffix = GetIconTypeSuffix(tile_type);
+ if (icon_type_suffix) {
+ std::string icon_histogram =
+ base::StringPrintf("NewTabPage.MostVisited.%s", icon_type_suffix);
+ LogHistogramEvent(icon_histogram, index, kMaxNumTiles);
+ }
+
if (tile_type < NUM_RECORDED_TILE_TYPES) {
UMA_HISTOGRAM_ENUMERATION("NewTabPage.TileTypeClicked", tile_type,
NUM_RECORDED_TILE_TYPES);
« no previous file with comments | « no previous file | components/ntp_tiles/metrics_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698