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