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

Unified Diff: chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc

Issue 2429283003: Desktop NTP metrics: Use ntp_tiles::metrics:: functions (Closed)
Patch Set: review Created 4 years, 2 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 | « chrome/browser/android/ntp/most_visited_sites_bridge.cc ('k') | components/ntp_tiles/metrics.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
diff --git a/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc b/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
index da644f5eb7dbd82671bbe493f153994754ac78fe..a8b828d0e4b2c0025898d8d2c11f24b4c9c857f5 100644
--- a/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
@@ -16,6 +16,7 @@
#include "chrome/common/search/search_urls.h"
#include "chrome/common/url_constants.h"
#include "components/browser_sync/profile_sync_service.h"
+#include "components/ntp_tiles/metrics.h"
#include "components/sync_sessions/sessions_sync_manager.h"
#include "components/sync_sessions/sync_sessions_metrics.h"
#include "content/public/browser/navigation_details.h"
@@ -25,35 +26,6 @@
namespace {
-// Name of the histogram keeping track of suggestion impressions.
-const char kMostVisitedImpressionHistogramName[] =
- "NewTabPage.SuggestionsImpression";
-
-// Format string to generate the name for the histogram keeping track of
-// suggestion impressions.
-const char kMostVisitedImpressionHistogramWithProvider[] =
- "NewTabPage.SuggestionsImpression.%s";
-
-// Name of the histogram keeping track of suggestion navigations.
-const char kMostVisitedNavigationHistogramName[] =
- "NewTabPage.MostVisited";
-
-// Format string to generate the name for the histogram keeping track of
-// suggestion navigations.
-const char kMostVisitedNavigationHistogramWithProvider[] =
- "NewTabPage.MostVisited.%s";
-
-std::string GetSourceName(NTPLoggingTileSource tile_source) {
- switch (tile_source) {
- case NTPLoggingTileSource::CLIENT:
- return "client";
- case NTPLoggingTileSource::SERVER:
- return "server";
- }
- NOTREACHED();
- return std::string();
-}
-
void RecordSyncSessionMetrics(content::WebContents* contents) {
if (!contents)
return;
@@ -69,6 +41,17 @@ void RecordSyncSessionMetrics(content::WebContents* contents) {
sessions);
}
+ntp_tiles::NTPTileSource ConvertTileSource(NTPLoggingTileSource tile_source) {
+ switch (tile_source) {
+ case NTPLoggingTileSource::CLIENT:
+ return ntp_tiles::NTPTileSource::TOP_SITES;
+ case NTPLoggingTileSource::SERVER:
+ return ntp_tiles::NTPTileSource::SUGGESTIONS_SERVICE;
+ }
+ NOTREACHED();
+ return ntp_tiles::NTPTileSource::TOP_SITES;
+}
+
} // namespace
DEFINE_WEB_CONTENTS_USER_DATA_KEY(NTPUserDataLogger);
@@ -142,36 +125,14 @@ void NTPUserDataLogger::LogMostVisitedImpression(
break;
}
- UMA_HISTOGRAM_ENUMERATION(kMostVisitedImpressionHistogramName, position,
- kNumMostVisited);
-
- // Cannot rely on UMA histograms macro because the name of the histogram is
- // generated dynamically.
- base::HistogramBase* counter = base::LinearHistogram::FactoryGet(
- base::StringPrintf(kMostVisitedImpressionHistogramWithProvider,
- GetSourceName(tile_source).c_str()),
- 1,
- kNumMostVisited,
- kNumMostVisited + 1,
- base::Histogram::kUmaTargetedHistogramFlag);
- counter->Add(position);
+ ntp_tiles::metrics::RecordTileImpression(position,
+ ConvertTileSource(tile_source));
}
void NTPUserDataLogger::LogMostVisitedNavigation(
int position, NTPLoggingTileSource tile_source) {
- UMA_HISTOGRAM_ENUMERATION(kMostVisitedNavigationHistogramName, position,
- kNumMostVisited);
-
- // Cannot rely on UMA histograms macro because the name of the histogram is
- // generated dynamically.
- base::HistogramBase* counter = base::LinearHistogram::FactoryGet(
- base::StringPrintf(kMostVisitedNavigationHistogramWithProvider,
- GetSourceName(tile_source).c_str()),
- 1,
- kNumMostVisited,
- kNumMostVisited + 1,
- base::Histogram::kUmaTargetedHistogramFlag);
- counter->Add(position);
+ ntp_tiles::metrics::RecordTileClick(position, ConvertTileSource(tile_source),
+ ntp_tiles::metrics::THUMBNAIL);
// Records the action. This will be available as a time-stamped stream
// server-side and can be used to compute time-to-long-dwell.
@@ -219,12 +180,15 @@ void NTPUserDataLogger::EmitNtpStatistics(base::TimeDelta load_time) {
DVLOG(1) << "Emitting NTP load time: " << load_time << ", "
<< "number of tiles: " << number_of_tiles;
+ ntp_tiles::metrics::RecordPageImpression(number_of_tiles);
+
LogLoadTimeHistogram("NewTabPage.LoadTime", load_time);
// Split between ML and MV.
std::string type = has_server_side_suggestions_ ?
"MostLikely" : "MostVisited";
LogLoadTimeHistogram("NewTabPage.LoadTime." + type, load_time);
+
// Split between Web and Local.
std::string source = ntp_url_.SchemeIsHTTPOrHTTPS() ? "Web" : "LocalNTP";
LogLoadTimeHistogram("NewTabPage.LoadTime." + source, load_time);
@@ -233,9 +197,6 @@ void NTPUserDataLogger::EmitNtpStatistics(base::TimeDelta load_time) {
std::string status = during_startup_ ? "Startup" : "NewTab";
LogLoadTimeHistogram("NewTabPage.LoadTime." + status, load_time);
- UMA_HISTOGRAM_CUSTOM_COUNTS(
- "NewTabPage.NumberOfTiles", number_of_tiles, 1, kNumMostVisited,
- kNumMostVisited + 1);
has_emitted_ = true;
during_startup_ = false;
}
« no previous file with comments | « chrome/browser/android/ntp/most_visited_sites_bridge.cc ('k') | components/ntp_tiles/metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698