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

Side by Side Diff: chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc

Issue 83943002: Adding UMA metric to record the type of suggestion displayed on the NTP's Most Visited section. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h" 5 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "chrome/browser/search/search.h" 8 #include "chrome/browser/search/search.h"
9 #include "chrome/common/search_urls.h" 9 #include "chrome/common/search_urls.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
11 #include "content/public/browser/navigation_details.h" 11 #include "content/public/browser/navigation_details.h"
12 12
13 namespace {
14
15 // Used to track if suggestions were issued by the client or the server.
16 enum SuggestionsType {
17 CLIENT_SIDE = 0,
18 SERVER_SIDE = 1,
19 SUGGESTIONS_TYPE_COUNT = 2
20 };
21
22 } // namespace
23
13 DEFINE_WEB_CONTENTS_USER_DATA_KEY(NTPUserDataLogger); 24 DEFINE_WEB_CONTENTS_USER_DATA_KEY(NTPUserDataLogger);
14 25
15 NTPUserDataLogger::~NTPUserDataLogger() {} 26 NTPUserDataLogger::~NTPUserDataLogger() {}
16 27
17 void NTPUserDataLogger::EmitThumbnailErrorRate() { 28 void NTPUserDataLogger::EmitThumbnailErrorRate() {
Mathieu 2013/11/22 19:58:19 update function name to indicate expanded role
beaudoin 2013/11/22 20:09:35 Renamed and called independently. Done.
18 DCHECK_LE(number_of_thumbnail_errors_, number_of_thumbnail_attempts_); 29 DCHECK_LE(number_of_thumbnail_errors_, number_of_thumbnail_attempts_);
19 if (number_of_thumbnail_attempts_ != 0) { 30 if (number_of_thumbnail_attempts_ != 0) {
20 UMA_HISTOGRAM_PERCENTAGE( 31 UMA_HISTOGRAM_PERCENTAGE(
21 "NewTabPage.ThumbnailErrorRate", 32 "NewTabPage.ThumbnailErrorRate",
22 GetPercentError(number_of_thumbnail_errors_, 33 GetPercentError(number_of_thumbnail_errors_,
23 number_of_thumbnail_attempts_)); 34 number_of_thumbnail_attempts_));
24 } 35 }
25 DCHECK_LE(number_of_fallback_thumbnails_used_, 36 DCHECK_LE(number_of_fallback_thumbnails_used_,
26 number_of_fallback_thumbnails_requested_); 37 number_of_fallback_thumbnails_requested_);
27 if (number_of_fallback_thumbnails_requested_ != 0) { 38 if (number_of_fallback_thumbnails_requested_ != 0) {
28 UMA_HISTOGRAM_PERCENTAGE( 39 UMA_HISTOGRAM_PERCENTAGE(
29 "NewTabPage.ThumbnailFallbackRate", 40 "NewTabPage.ThumbnailFallbackRate",
30 GetPercentError(number_of_fallback_thumbnails_used_, 41 GetPercentError(number_of_fallback_thumbnails_used_,
31 number_of_fallback_thumbnails_requested_)); 42 number_of_fallback_thumbnails_requested_));
32 } 43 }
44 UMA_HISTOGRAM_ENUMERATION(
45 "NewTabPage.SuggestionsType",
46 server_side_suggestions_ ? SERVER_SIDE : CLIENT_SIDE,
47 SUGGESTIONS_TYPE_COUNT);
33 number_of_thumbnail_attempts_ = 0; 48 number_of_thumbnail_attempts_ = 0;
34 number_of_thumbnail_errors_ = 0; 49 number_of_thumbnail_errors_ = 0;
35 number_of_fallback_thumbnails_requested_ = 0; 50 number_of_fallback_thumbnails_requested_ = 0;
36 number_of_fallback_thumbnails_used_ = 0; 51 number_of_fallback_thumbnails_used_ = 0;
52 server_side_suggestions_ = false;
37 } 53 }
38 54
39 void NTPUserDataLogger::EmitMouseoverCount() { 55 void NTPUserDataLogger::EmitMouseoverCount() {
40 UMA_HISTOGRAM_COUNTS("NewTabPage.NumberOfMouseOvers", number_of_mouseovers_); 56 UMA_HISTOGRAM_COUNTS("NewTabPage.NumberOfMouseOvers", number_of_mouseovers_);
41 number_of_mouseovers_ = 0; 57 number_of_mouseovers_ = 0;
42 } 58 }
43 59
44 void NTPUserDataLogger::LogEvent(NTPLoggingEventType event) { 60 void NTPUserDataLogger::LogEvent(NTPLoggingEventType event) {
45 switch (event) { 61 switch (event) {
46 case NTP_MOUSEOVER: 62 case NTP_MOUSEOVER:
47 number_of_mouseovers_++; 63 number_of_mouseovers_++;
48 break; 64 break;
49 case NTP_THUMBNAIL_ATTEMPT: 65 case NTP_THUMBNAIL_ATTEMPT:
50 number_of_thumbnail_attempts_++; 66 number_of_thumbnail_attempts_++;
51 break; 67 break;
52 case NTP_THUMBNAIL_ERROR: 68 case NTP_THUMBNAIL_ERROR:
53 number_of_thumbnail_errors_++; 69 number_of_thumbnail_errors_++;
54 break; 70 break;
55 case NTP_FALLBACK_THUMBNAIL_REQUESTED: 71 case NTP_FALLBACK_THUMBNAIL_REQUESTED:
56 number_of_fallback_thumbnails_requested_++; 72 number_of_fallback_thumbnails_requested_++;
57 break; 73 break;
58 case NTP_FALLBACK_THUMBNAIL_USED: 74 case NTP_FALLBACK_THUMBNAIL_USED:
59 number_of_fallback_thumbnails_used_++; 75 number_of_fallback_thumbnails_used_++;
60 break; 76 break;
77 case NTP_SERVER_SIDE_SUGGESTION:
78 server_side_suggestions_ = true;
79 break;
61 default: 80 default:
62 NOTREACHED(); 81 NOTREACHED();
63 } 82 }
64 } 83 }
65 84
66 // content::WebContentsObserver override 85 // content::WebContentsObserver override
67 void NTPUserDataLogger::NavigationEntryCommitted( 86 void NTPUserDataLogger::NavigationEntryCommitted(
68 const content::LoadCommittedDetails& load_details) { 87 const content::LoadCommittedDetails& load_details) {
69 if (!load_details.previous_url.is_valid()) 88 if (!load_details.previous_url.is_valid())
70 return; 89 return;
71 90
72 if (search::MatchesOriginAndPath(ntp_url_, load_details.previous_url)) { 91 if (search::MatchesOriginAndPath(ntp_url_, load_details.previous_url)) {
73 EmitMouseoverCount(); 92 EmitMouseoverCount();
74 // Only log thumbnail error rates for Instant NTP pages, as we do not have 93 // Only log thumbnail error rates for Instant NTP pages, as we do not have
75 // this data for non-Instant NTPs. 94 // this data for non-Instant NTPs.
76 if (ntp_url_ != GURL(chrome::kChromeUINewTabURL)) 95 if (ntp_url_ != GURL(chrome::kChromeUINewTabURL))
77 EmitThumbnailErrorRate(); 96 EmitThumbnailErrorRate();
78 } 97 }
79 } 98 }
80 99
81 NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents) 100 NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents)
82 : content::WebContentsObserver(contents), 101 : content::WebContentsObserver(contents),
83 number_of_mouseovers_(0), 102 number_of_mouseovers_(0),
84 number_of_thumbnail_attempts_(0), 103 number_of_thumbnail_attempts_(0),
85 number_of_thumbnail_errors_(0), 104 number_of_thumbnail_errors_(0),
86 number_of_fallback_thumbnails_requested_(0), 105 number_of_fallback_thumbnails_requested_(0),
87 number_of_fallback_thumbnails_used_(0) { 106 number_of_fallback_thumbnails_used_(0),
107 server_side_suggestions_(false) {
88 } 108 }
89 109
90 size_t NTPUserDataLogger::GetPercentError(size_t errors, size_t events) const { 110 size_t NTPUserDataLogger::GetPercentError(size_t errors, size_t events) const {
91 return (100 * errors) / events; 111 return (100 * errors) / events;
92 } 112 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698