1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_
6 #define CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_
11 #include "base/basictypes.h"
12 #include "chrome/browser/signin/signin_header_helper.h"
21 class ProfileMetrics {
23 struct ProfileCounts {
31 : total(0), signedin(0), supervised(0), unused(0), gaia_icon(0) {}
34 // Enum for counting the ways users were added.
36 ADD_NEW_USER_ICON = 0, // User adds new user from icon menu
37 ADD_NEW_USER_MENU, // User adds new user from menu bar
38 ADD_NEW_USER_DIALOG, // User adds new user from create-profile dialog
39 ADD_NEW_USER_MANAGER, // User adds new user from User Manager
40 NUM_PROFILE_ADD_METRICS
44 DELETE_PROFILE_SETTINGS = 0, // Delete profile from settings page.
45 DELETE_PROFILE_USER_MANAGER, // Delete profile from User Manager.
46 NUM_DELETE_PROFILE_METRICS
49 // Enum for counting the ways user profiles and menus were opened.
51 NTP_AVATAR_BUBBLE = 0, // User opens avatar icon menu from NTP
52 ICON_AVATAR_BUBBLE, // User opens avatar icon menu from icon
53 SWITCH_PROFILE_ICON, // User switches profiles from icon menu
54 SWITCH_PROFILE_MENU, // User switches profiles from menu bar
55 SWITCH_PROFILE_DOCK, // User switches profiles from dock (Mac-only)
56 OPEN_USER_MANAGER, // User opens the User Manager
57 SWITCH_PROFILE_MANAGER, // User switches profiles from the User Manager
58 SWITCH_PROFILE_UNLOCK, // User switches to lockd profile via User Manager
59 SWITCH_PROFILE_GUEST, // User switches to guest profile
60 NUM_PROFILE_OPEN_METRICS
63 // Enum for getting net counts for adding and deleting users.
64 enum ProfileNetUserCounts {
65 ADD_NEW_USER = 0, // Total count of add new user
66 PROFILE_DELETED, // User deleted a profile
67 NUM_PROFILE_NET_METRICS
70 // Sign in is logged once the user has entered their GAIA information.
71 // The options for sync are logged after the user has submitted the options
72 // form. See sync_setup_handler.h.
74 SYNC_CUSTOMIZE = 0, // User decided to customize sync
75 SYNC_CHOOSE, // User chose what to sync
76 SYNC_ENCRYPT, // User has chosen to encrypt all data
77 SYNC_PASSPHRASE, // User is using a passphrase
78 NUM_PROFILE_SYNC_METRICS
82 ORIGINAL = 0, // Refers to the original/default profile
83 SECONDARY, // Refers to a user-created profile
84 NUM_PROFILE_TYPE_METRICS
88 GAIA_OPT_IN = 0, // User changed to GAIA photo as avatar
89 GAIA_OPT_OUT, // User changed to not use GAIA photo as avatar
90 NUM_PROFILE_GAIA_METRICS
94 AUTH_UNNECESSARY, // Profile was not locked
95 AUTH_LOCAL, // Profile was authenticated locally
96 AUTH_ONLINE, // Profile was authenticated on-line
97 AUTH_FAILED, // Profile failed authentication
98 NUM_PROFILE_AUTH_METRICS
101 // Enum for tracking user interactions with the user menu and user manager.
102 // Interactions initiated from the content area are logged into a different
103 // histogram from those that were initiated from the avatar button.
104 // An example of the interaction beginning in the content area is
105 // clicking "Manage Accounts" within account selection on a Google property.
106 enum ProfileDesktopMenu {
107 // User opened the user menu, and clicked lock.
108 PROFILE_DESKTOP_MENU_LOCK = 0,
109 // User opened the user menu, and removed an account.
110 PROFILE_DESKTOP_MENU_REMOVE_ACCT,
111 // User opened the user menu, and started adding an account.
112 PROFILE_DESKTOP_MENU_ADD_ACCT,
113 // User opened the user menu, and changed the profile name.
114 PROFILE_DESKTOP_MENU_EDIT_NAME,
115 // User opened the user menu, and started selecting a new profile image.
116 PROFILE_DESKTOP_MENU_EDIT_IMAGE,
117 // User opened the user menu, and opened the user manager.
118 PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER,
119 NUM_PROFILE_DESKTOP_MENU_METRICS,
122 #if defined(OS_ANDROID)
123 // TODO(aruslan): http://crbug.com/379987 Move to a generator.
124 // Enum for tracking user interactions with the account management menu
126 // This should match its counterpart in AccountManagementScreenHelper.java.
127 enum ProfileAndroidAccountManagementMenu {
128 // User arrived at the Account management screen.
129 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_VIEW = 0,
130 // User arrived at the Account management screen, and clicked Add account.
131 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_ADD_ACCOUNT,
132 // User arrived at the Account management screen, and clicked Go incognito.
133 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_GO_INCOGNITO,
134 // User arrived at the Account management screen, and clicked on primary.
135 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_CLICK_PRIMARY_ACCOUNT,
136 // User arrived at the Account management screen, and clicked on secondary.
137 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_CLICK_SECONDARY_ACCOUNT,
138 // User arrived at the Account management screen, toggled Chrome signout.
139 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_TOGGLE_SIGNOUT,
140 // User toggled Chrome signout, and clicked Signout.
141 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_SIGNOUT_SIGNOUT,
142 // User toggled Chrome signout, and clicked Cancel.
143 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_SIGNOUT_CANCEL,
144 NUM_PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_METRICS,
146 #endif // defined(OS_ANDROID)
148 // Enum for tracking user interactions with the 'Not You?' bubble that users
149 // can navigate to from the Upgrade bubble after upgrade.
150 enum ProfileNewAvatarMenuNotYou {
151 // User views the 'Not You?' bubble.
152 PROFILE_AVATAR_MENU_NOT_YOU_VIEW = 0,
153 // User selects back from within the 'Not You?' bubble.
154 PROFILE_AVATAR_MENU_NOT_YOU_BACK,
155 // User adds a person from within the 'Not You?' bubble.
156 PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON,
157 // User chooses to disconnect (sign out) from within the 'Not You?' bubble.
158 PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT,
159 NUM_PROFILE_AVATAR_MENU_NOT_YOU_METRICS,
162 // Enum for tracking user interactions with the signin bubble that appears
163 // in the New Avatar Menu after using the Inline Signin flow.
164 enum ProfileNewAvatarMenuSignin {
165 // User viewed the signin bubble after successfully using the inline signin.
166 PROFILE_AVATAR_MENU_SIGNIN_VIEW = 0,
167 // User selected ok to dismiss the signin bubble.
168 PROFILE_AVATAR_MENU_SIGNIN_OK,
169 // User opened the settings from the signin bubble.
170 PROFILE_AVATAR_MENU_SIGNIN_SETTINGS,
171 NUM_PROFILE_AVATAR_MENU_SIGNIN_METRICS,
174 // Enum for tracking user interactions with the bubble that appears for all
175 // users in the new avatar menu after upgrading.
176 enum ProfileNewAvatarMenuUpgrade {
177 // User views the upgrade bubble.
178 PROFILE_AVATAR_MENU_UPGRADE_VIEW = 0,
179 // User dismissed the upgrade bubble.
180 PROFILE_AVATAR_MENU_UPGRADE_DISMISS,
181 // User selects 'What's New' in the upgrade bubble.
182 PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW,
183 // User selects 'Not You?' in the upgrade bubble.
184 PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU,
185 NUM_PROFILE_AVATAR_MENU_UPGRADE_METRICS,
188 static void UpdateReportedProfilesStatistics(ProfileManager* manager);
189 // Count and return summary information about the profiles currently in the
190 // |manager|. This information is returned in the output variable |counts|.
191 static bool CountProfileInformation(ProfileManager* manager,
192 ProfileCounts* counts);
194 static void LogNumberOfProfiles(ProfileManager* manager);
195 static void LogProfileAddNewUser(ProfileAdd metric);
196 static void LogProfileAvatarSelection(size_t icon_index);
197 static void LogProfileDeleteUser(ProfileDelete metric);
198 static void LogProfileOpenMethod(ProfileOpen metric);
199 static void LogProfileSwitchGaia(ProfileGaia metric);
200 static void LogProfileSwitchUser(ProfileOpen metric);
201 static void LogProfileSyncInfo(ProfileSync metric);
202 static void LogProfileAuthResult(ProfileAuth metric);
203 static void LogProfileDesktopMenu(ProfileDesktopMenu metric,
204 signin::GAIAServiceType gaia_service);
205 static void LogProfileDelete(bool profile_was_signed_in);
206 static void LogProfileNewAvatarMenuNotYou(ProfileNewAvatarMenuNotYou metric);
207 static void LogProfileNewAvatarMenuSignin(ProfileNewAvatarMenuSignin metric);
208 static void LogProfileNewAvatarMenuUpgrade(
209 ProfileNewAvatarMenuUpgrade metric);
211 #if defined(OS_ANDROID)
212 static void LogProfileAndroidAccountManagementMenu(
213 ProfileAndroidAccountManagementMenu metric,
214 signin::GAIAServiceType gaia_service);
215 #endif // defined(OS_ANDROID)
217 // These functions should only be called on the UI thread because they hook
218 // into g_browser_process through a helper function.
219 static void LogProfileLaunch(Profile* profile);
220 static void LogProfileSyncSignIn(const base::FilePath& profile_path);
221 static void LogProfileUpdate(const base::FilePath& profile_path);
225 #endif // CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_