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 menu from NTP
53 ICON_AVATAR_BUBBLE, // User opens the avatar menu from button
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 AUTH_FAILED_OFFLINE, // Profile failed authentication and was offline
100 NUM_PROFILE_AUTH_METRICS
103 // Enum for tracking user interactions with the user menu and user manager.
104 // Interactions initiated from the content area are logged into a different
105 // histogram from those that were initiated from the avatar button.
106 // An example of the interaction beginning in the content area is
107 // clicking "Manage Accounts" within account selection on a Google property.
108 enum ProfileDesktopMenu {
109 // User opened the user menu, and clicked lock.
110 PROFILE_DESKTOP_MENU_LOCK = 0,
111 // User opened the user menu, and removed an account.
112 PROFILE_DESKTOP_MENU_REMOVE_ACCT,
113 // User opened the user menu, and started adding an account.
114 PROFILE_DESKTOP_MENU_ADD_ACCT,
115 // User opened the user menu, and changed the profile name.
116 PROFILE_DESKTOP_MENU_EDIT_NAME,
117 // User opened the user menu, and started selecting a new profile image.
118 PROFILE_DESKTOP_MENU_EDIT_IMAGE,
119 // User opened the user menu, and opened the user manager.
120 PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER,
121 // User opened the user menu, and selected Go Incognito.
122 PROFILE_DESKTOP_MENU_GO_INCOGNITO,
123 NUM_PROFILE_DESKTOP_MENU_METRICS,
126 #if defined(OS_ANDROID)
127 // Enum for tracking user interactions with the account management menu
130 // A Java counterpart will be generated for this enum.
131 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.profiles
132 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: ProfileAccountManagementMetrics
133 // GENERATED_JAVA_PREFIX_TO_STRIP: PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_
134 enum ProfileAndroidAccountManagementMenu {
135 // User arrived at the Account management screen.
136 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_VIEW = 0,
137 // User arrived at the Account management screen, and clicked Add account.
138 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_ADD_ACCOUNT = 1,
139 // User arrived at the Account management screen, and clicked Go incognito.
140 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_GO_INCOGNITO = 2,
141 // User arrived at the Account management screen, and clicked on primary.
142 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_CLICK_PRIMARY_ACCOUNT = 3,
143 // User arrived at the Account management screen, and clicked on secondary.
144 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_CLICK_SECONDARY_ACCOUNT = 4,
145 // User arrived at the Account management screen, toggled Chrome signout.
146 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_TOGGLE_SIGNOUT = 5,
147 // User toggled Chrome signout, and clicked Signout.
148 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_SIGNOUT_SIGNOUT = 6,
149 // User toggled Chrome signout, and clicked Cancel.
150 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_SIGNOUT_CANCEL = 7,
151 // User arrived at the android Account management screen directly from some
153 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_DIRECT_ADD_ACCOUNT = 8,
154 NUM_PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_METRICS,
156 #endif // defined(OS_ANDROID)
158 // Enum for tracking user interactions with the 'Not You?' bubble that users
159 // can navigate to from the Upgrade bubble after upgrade.
160 enum ProfileNewAvatarMenuNotYou {
161 // User views the 'Not You?' bubble.
162 PROFILE_AVATAR_MENU_NOT_YOU_VIEW = 0,
163 // User selects back from within the 'Not You?' bubble.
164 PROFILE_AVATAR_MENU_NOT_YOU_BACK,
165 // User adds a person from within the 'Not You?' bubble.
166 PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON,
167 // User chooses to disconnect (sign out) from within the 'Not You?' bubble.
168 PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT,
169 NUM_PROFILE_AVATAR_MENU_NOT_YOU_METRICS,
172 // Enum for tracking user interactions with the signin bubble that appears
173 // in the New Avatar Menu after using the Inline Signin flow.
174 enum ProfileNewAvatarMenuSignin {
175 // User viewed the signin bubble after successfully using the inline signin.
176 PROFILE_AVATAR_MENU_SIGNIN_VIEW = 0,
177 // User selected ok to dismiss the signin bubble.
178 PROFILE_AVATAR_MENU_SIGNIN_OK,
179 // User opened the settings from the signin bubble.
180 PROFILE_AVATAR_MENU_SIGNIN_SETTINGS,
181 NUM_PROFILE_AVATAR_MENU_SIGNIN_METRICS,
184 // Enum for tracking user interactions with the bubble that appears for all
185 // users in the new avatar menu after upgrading.
186 enum ProfileNewAvatarMenuUpgrade {
187 // User views the upgrade bubble.
188 PROFILE_AVATAR_MENU_UPGRADE_VIEW = 0,
189 // User dismissed the upgrade bubble.
190 PROFILE_AVATAR_MENU_UPGRADE_DISMISS,
191 // User selects 'What's New' in the upgrade bubble.
192 PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW,
193 // User selects 'Not You?' in the upgrade bubble.
194 PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU,
195 NUM_PROFILE_AVATAR_MENU_UPGRADE_METRICS,
198 static void UpdateReportedProfilesStatistics(ProfileManager* manager);
199 // Count and return summary information about the profiles currently in the
200 // |manager|. This information is returned in the output variable |counts|.
201 static bool CountProfileInformation(ProfileManager* manager,
202 ProfileCounts* counts);
204 static void LogNumberOfProfiles(ProfileManager* manager);
205 static void LogProfileAddNewUser(ProfileAdd metric);
206 static void LogProfileAvatarSelection(size_t icon_index);
207 static void LogProfileDeleteUser(ProfileDelete metric);
208 static void LogProfileOpenMethod(ProfileOpen metric);
209 static void LogProfileSwitchGaia(ProfileGaia metric);
210 static void LogProfileSwitchUser(ProfileOpen metric);
211 static void LogProfileSyncInfo(ProfileSync metric);
212 static void LogProfileAuthResult(ProfileAuth metric);
213 static void LogProfileDesktopMenu(ProfileDesktopMenu metric,
214 signin::GAIAServiceType gaia_service);
215 static void LogProfileDelete(bool profile_was_signed_in);
216 static void LogProfileNewAvatarMenuNotYou(ProfileNewAvatarMenuNotYou metric);
217 static void LogProfileNewAvatarMenuSignin(ProfileNewAvatarMenuSignin metric);
218 static void LogProfileNewAvatarMenuUpgrade(
219 ProfileNewAvatarMenuUpgrade metric);
221 #if defined(OS_ANDROID)
222 static void LogProfileAndroidAccountManagementMenu(
223 ProfileAndroidAccountManagementMenu metric,
224 signin::GAIAServiceType gaia_service);
225 #endif // defined(OS_ANDROID)
227 // These functions should only be called on the UI thread because they hook
228 // into g_browser_process through a helper function.
229 static void LogProfileLaunch(Profile* profile);
230 static void LogProfileSyncSignIn(const base::FilePath& profile_path);
231 static void LogProfileUpdate(const base::FilePath& profile_path);
235 #endif // CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_