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

Side by Side Diff: chrome/browser/ui/sad_tab.cc

Issue 2869223002: Metrics logging for user engagement of the Reload and Feedback buttons (Closed)
Patch Set: Fix Mac build Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/DEPS ('k') | components/ui_metrics/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/sad_tab.h" 5 #include "chrome/browser/ui/sad_tab.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "chrome/browser/net/referrer.h" 9 #include "chrome/browser/net/referrer.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_finder.h" 11 #include "chrome/browser/ui/browser_finder.h"
12 #include "chrome/browser/ui/browser_list.h" 12 #include "chrome/browser/ui/browser_list.h"
13 #include "chrome/browser/ui/chrome_pages.h" 13 #include "chrome/browser/ui/chrome_pages.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
16 #include "chrome/grit/generated_resources.h" 16 #include "chrome/grit/generated_resources.h"
17 #include "components/feedback/feedback_util.h" 17 #include "components/feedback/feedback_util.h"
18 #include "components/strings/grit/components_strings.h" 18 #include "components/strings/grit/components_strings.h"
19 #include "components/ui_metrics/sadtab_metrics_types.h"
19 #include "content/public/browser/navigation_controller.h" 20 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
21 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
22 23
23 #if defined(OS_CHROMEOS) 24 #if defined(OS_CHROMEOS)
24 #include "chrome/browser/memory/oom_memory_details.h" 25 #include "chrome/browser/memory/oom_memory_details.h"
25 #endif 26 #endif
26 27
27 namespace { 28 namespace {
28 29
29 // These stats should use the same counting approach and bucket size as tab 30 // These stats should use the same counting approach and bucket size as tab
30 // discard events in memory::OomPriorityManager so they can be directly 31 // discard events in memory::OomPriorityManager so they can be directly
31 // compared. 32 // compared.
32 33
33 // This macro uses a static counter to track how many times it's hit in a 34 // This macro uses a static counter to track how many times it's hit in a
34 // session. See Tabs.SadTab.CrashCreated in histograms.xml for details. 35 // session. See Tabs.SadTab.CrashCreated in histograms.xml for details.
35 #define UMA_SAD_TAB_COUNTER(histogram_name) \ 36 #define UMA_SAD_TAB_COUNTER(histogram_name) \
36 { \ 37 { \
37 static int count = 0; \ 38 static int count = 0; \
38 ++count; \ 39 ++count; \
39 UMA_HISTOGRAM_COUNTS_1000(histogram_name, count); \ 40 UMA_HISTOGRAM_COUNTS_1000(histogram_name, count); \
40 } 41 }
41 42
42 // This enum backs an UMA histogram, so it should be treated as append-only. 43 void RecordEvent(bool feedback, ui_metrics::SadTabEvent event) {
43 // A Java counterpart will be generated for this enum.
44 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.tab
45 enum SadTabEvent {
46 DISPLAYED,
47 BUTTON_CLICKED,
48 HELP_LINK_CLICKED,
49 MAX_SAD_TAB_EVENT
50 };
51
52 void RecordEvent(bool feedback, SadTabEvent event) {
53 if (feedback) { 44 if (feedback) {
54 UMA_HISTOGRAM_ENUMERATION("Tabs.SadTab.Feedback.Event", event, 45 UMA_HISTOGRAM_ENUMERATION(ui_metrics::kSadTabFeedbackHistogramKey, event,
55 SadTabEvent::MAX_SAD_TAB_EVENT); 46 ui_metrics::SadTabEvent::MAX_SAD_TAB_EVENT);
56 } else { 47 } else {
57 UMA_HISTOGRAM_ENUMERATION("Tabs.SadTab.Reload.Event", event, 48 UMA_HISTOGRAM_ENUMERATION(ui_metrics::kSadTabReloadHistogramKey, event,
58 SadTabEvent::MAX_SAD_TAB_EVENT); 49 ui_metrics::SadTabEvent::MAX_SAD_TAB_EVENT);
59 } 50 }
60 } 51 }
61 52
62 constexpr char kCategoryTagCrash[] = "Crash"; 53 constexpr char kCategoryTagCrash[] = "Crash";
63 54
64 bool ShouldShowFeedbackButton() { 55 bool ShouldShowFeedbackButton() {
65 #if defined(GOOGLE_CHROME_BUILD) 56 #if defined(GOOGLE_CHROME_BUILD)
66 const int kMinSecondsBetweenCrashesForFeedbackButton = 10; 57 const int kMinSecondsBetweenCrashesForFeedbackButton = 10;
67 58
68 static int64_t last_called_ts = 0; 59 static int64_t last_called_ts = 0;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 #if defined(OS_CHROMEOS) 208 #if defined(OS_CHROMEOS)
218 case chrome::SAD_TAB_KIND_KILLED_BY_OOM: 209 case chrome::SAD_TAB_KIND_KILLED_BY_OOM:
219 UMA_SAD_TAB_COUNTER("Tabs.SadTab.KillDisplayed.OOM"); 210 UMA_SAD_TAB_COUNTER("Tabs.SadTab.KillDisplayed.OOM");
220 #endif 211 #endif
221 // Fallthrough 212 // Fallthrough
222 case chrome::SAD_TAB_KIND_KILLED: 213 case chrome::SAD_TAB_KIND_KILLED:
223 UMA_SAD_TAB_COUNTER("Tabs.SadTab.KillDisplayed"); 214 UMA_SAD_TAB_COUNTER("Tabs.SadTab.KillDisplayed");
224 break; 215 break;
225 } 216 }
226 217
227 RecordEvent(show_feedback_button_, SadTabEvent::DISPLAYED); 218 RecordEvent(show_feedback_button_, ui_metrics::SadTabEvent::DISPLAYED);
228 } 219 }
229 220
230 void SadTab::PerformAction(SadTab::Action action) { 221 void SadTab::PerformAction(SadTab::Action action) {
231 DCHECK(recorded_paint_); 222 DCHECK(recorded_paint_);
232 switch (action) { 223 switch (action) {
233 case Action::BUTTON: 224 case Action::BUTTON:
234 RecordEvent(show_feedback_button_, SadTabEvent::BUTTON_CLICKED); 225 RecordEvent(show_feedback_button_,
226 ui_metrics::SadTabEvent::BUTTON_CLICKED);
235 if (show_feedback_button_) { 227 if (show_feedback_button_) {
236 ShowFeedbackPage( 228 ShowFeedbackPage(
237 FindBrowserWithWebContents(web_contents_), 229 FindBrowserWithWebContents(web_contents_),
238 kFeedbackSourceSadTabPage, 230 kFeedbackSourceSadTabPage,
239 l10n_util::GetStringUTF8(kind_ == SAD_TAB_KIND_CRASHED 231 l10n_util::GetStringUTF8(kind_ == SAD_TAB_KIND_CRASHED
240 ? IDS_CRASHED_TAB_FEEDBACK_MESSAGE 232 ? IDS_CRASHED_TAB_FEEDBACK_MESSAGE
241 : IDS_KILLED_TAB_FEEDBACK_MESSAGE), 233 : IDS_KILLED_TAB_FEEDBACK_MESSAGE),
242 std::string(kCategoryTagCrash)); 234 std::string(kCategoryTagCrash));
243 } else { 235 } else {
244 web_contents_->GetController().Reload(content::ReloadType::NORMAL, 236 web_contents_->GetController().Reload(content::ReloadType::NORMAL,
245 true); 237 true);
246 } 238 }
247 break; 239 break;
248 case Action::HELP_LINK: 240 case Action::HELP_LINK:
249 RecordEvent(show_feedback_button_, SadTabEvent::HELP_LINK_CLICKED); 241 RecordEvent(show_feedback_button_,
242 ui_metrics::SadTabEvent::HELP_LINK_CLICKED);
250 content::OpenURLParams params(GURL(GetHelpLinkURL()), content::Referrer(), 243 content::OpenURLParams params(GURL(GetHelpLinkURL()), content::Referrer(),
251 WindowOpenDisposition::CURRENT_TAB, 244 WindowOpenDisposition::CURRENT_TAB,
252 ui::PAGE_TRANSITION_LINK, false); 245 ui::PAGE_TRANSITION_LINK, false);
253 web_contents_->OpenURL(params); 246 web_contents_->OpenURL(params);
254 break; 247 break;
255 } 248 }
256 } 249 }
257 250
258 SadTab::SadTab(content::WebContents* web_contents, SadTabKind kind) 251 SadTab::SadTab(content::WebContents* web_contents, SadTabKind kind)
259 : web_contents_(web_contents), 252 : web_contents_(web_contents),
(...skipping 19 matching lines...) Expand all
279 // Fall through 272 // Fall through
280 case chrome::SAD_TAB_KIND_KILLED: 273 case chrome::SAD_TAB_KIND_KILLED:
281 UMA_SAD_TAB_COUNTER("Tabs.SadTab.KillCreated"); 274 UMA_SAD_TAB_COUNTER("Tabs.SadTab.KillCreated");
282 LOG(WARNING) << "Tab Killed: " 275 LOG(WARNING) << "Tab Killed: "
283 << web_contents->GetURL().GetOrigin().spec(); 276 << web_contents->GetURL().GetOrigin().spec();
284 break; 277 break;
285 } 278 }
286 } 279 }
287 280
288 } // namespace chrome 281 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/DEPS ('k') | components/ui_metrics/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698