1 // Copyright (c) 2020 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "ash/system/phonehub/phone_hub_metrics.h"
6 
7 #include "base/metrics/histogram_functions.h"
8 #include "base/metrics/user_metrics.h"
9 
10 namespace ash {
11 namespace phone_hub_metrics {
12 
13 namespace {
14 
GetInterstitialScreenEventHistogramName(Screen screen)15 std::string GetInterstitialScreenEventHistogramName(Screen screen) {
16   switch (screen) {
17     case Screen::kConnectionError:
18       return "Ash.PhoneHub.InterstitialScreenEvent.ConnectionError";
19     case Screen::kBluetoothOrWifiDisabled:
20       return "Ash.PhoneHub.InterstitialScreenEvent.BluetoothOrWifiDisabled";
21     case Screen::kReconnecting:
22       return "Ash.PhoneHub.InterstitialScreenEvent.Reconnecting";
23     case Screen::kInitialConnecting:
24       return "Ash.PhoneHub.InterstitialScreenEvent.InitialConnecting";
25     case Screen::kOnboardingExistingMultideviceUser:
26       return "Ash.PhoneHub.InterstitialScreenEvent.Onboarding."
27              "ExistingMultideviceUser";
28     case Screen::kOnboardingNewMultideviceUser:
29       return "Ash.PhoneHub.InterstitialScreenEvent.Onboarding."
30              "NewMultideviceUser";
31     case Screen::kOnboardingDismissPrompt:
32       return "Ash.PhoneHub.InterstitialScreenEvent.OnboardingDismissPrompt";
33     default:
34       DCHECK(false) << "Invalid interstitial screen";
35       return "";
36   }
37 }
38 
39 }  // namespace
40 
LogInterstitialScreenEvent(Screen screen,InterstitialScreenEvent event)41 void LogInterstitialScreenEvent(Screen screen, InterstitialScreenEvent event) {
42   base::UmaHistogramEnumeration(GetInterstitialScreenEventHistogramName(screen),
43                                 event);
44 }
45 
LogScreenOnBubbleOpen(Screen screen)46 void LogScreenOnBubbleOpen(Screen screen) {
47   base::UmaHistogramEnumeration("Ash.PhoneHub.ScreenOnBubbleOpen", screen);
48 }
49 
LogScreenOnBubbleClose(Screen screen)50 void LogScreenOnBubbleClose(Screen screen) {
51   base::UmaHistogramEnumeration("Ash.PhoneHub.ScreenOnBubbleClose", screen);
52 }
53 
LogScreenOnSettingsButtonClicked(Screen screen)54 void LogScreenOnSettingsButtonClicked(Screen screen) {
55   base::UmaHistogramEnumeration("Ash.PhoneHub.Screen.OnSettingsButtonClicked",
56                                 screen);
57 }
58 
LogNotificationOptInEvent(InterstitialScreenEvent event)59 void LogNotificationOptInEvent(InterstitialScreenEvent event) {
60   base::UmaHistogramEnumeration("Ash.PhoneHub.NotificationOptIn", event);
61 }
62 
LogTabContinuationChipClicked(int tab_index)63 void LogTabContinuationChipClicked(int tab_index) {
64   base::UmaHistogramCounts100("Ash.PhoneHub.TabContinuationChipClicked",
65                               tab_index);
66 }
67 
LogQuickActionClick(QuickAction action)68 void LogQuickActionClick(QuickAction action) {
69   base::UmaHistogramEnumeration("Ash.PhoneHub.QuickActionClicked", action);
70 }
71 
LogNotificationCount(int count)72 void LogNotificationCount(int count) {
73   base::UmaHistogramCounts100("Ash.PhoneHub.NotificationCount", count);
74 }
75 
LogNotificationInteraction(NotificationInteraction interaction)76 void LogNotificationInteraction(NotificationInteraction interaction) {
77   base::UmaHistogramEnumeration("PhoneHub.NotificationInteraction",
78                                 interaction);
79 }
80 
81 }  // namespace phone_hub_metrics
82 }  // namespace ash
83