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
{
40 // Enum for counting the ways users were added.
42 ADD_NEW_USER_ICON
= 0, // User adds new user from icon menu
43 ADD_NEW_USER_MENU
, // User adds new user from menu bar
44 ADD_NEW_USER_DIALOG
, // User adds new user from create-profile dialog
45 ADD_NEW_USER_MANAGER
, // User adds new user from User Manager
46 ADD_NEW_USER_LAST_DELETED
, // Auto-created after deleting last user
47 NUM_PROFILE_ADD_METRICS
51 DELETE_PROFILE_SETTINGS
= 0, // Delete profile from settings page.
52 DELETE_PROFILE_USER_MANAGER
, // Delete profile from User Manager.
53 NUM_DELETE_PROFILE_METRICS
56 // Enum for counting the ways user profiles and menus were opened.
58 NTP_AVATAR_BUBBLE
= 0, // User opens avatar menu from NTP
59 ICON_AVATAR_BUBBLE
, // User opens the avatar menu from button
60 SWITCH_PROFILE_ICON
, // User switches profiles from icon menu
61 SWITCH_PROFILE_MENU
, // User switches profiles from menu bar
62 SWITCH_PROFILE_DOCK
, // User switches profiles from dock (Mac-only)
63 OPEN_USER_MANAGER
, // User opens the User Manager
64 SWITCH_PROFILE_MANAGER
, // User switches profiles from the User Manager
65 SWITCH_PROFILE_UNLOCK
, // User switches to lockd profile via User Manager
66 SWITCH_PROFILE_GUEST
, // User switches to guest profile
67 NUM_PROFILE_OPEN_METRICS
70 // Enum for getting net counts for adding and deleting users.
71 enum ProfileNetUserCounts
{
72 ADD_NEW_USER
= 0, // Total count of add new user
73 PROFILE_DELETED
, // User deleted a profile
74 NUM_PROFILE_NET_METRICS
77 // Sign in is logged once the user has entered their GAIA information.
78 // The options for sync are logged after the user has submitted the options
79 // form. See sync_setup_handler.h.
81 SYNC_CUSTOMIZE
= 0, // User decided to customize sync
82 SYNC_CHOOSE
, // User chose what to sync
83 SYNC_ENCRYPT
, // User has chosen to encrypt all data
84 SYNC_PASSPHRASE
, // User is using a passphrase
85 NUM_PROFILE_SYNC_METRICS
89 ORIGINAL
= 0, // Refers to the original/default profile
90 SECONDARY
, // Refers to a user-created profile
91 NUM_PROFILE_TYPE_METRICS
95 GAIA_OPT_IN
= 0, // User changed to GAIA photo as avatar
96 GAIA_OPT_OUT
, // User changed to not use GAIA photo as avatar
97 NUM_PROFILE_GAIA_METRICS
101 AUTH_UNNECESSARY
, // Profile was not locked
102 AUTH_LOCAL
, // Profile was authenticated locally
103 AUTH_ONLINE
, // Profile was authenticated on-line
104 AUTH_FAILED
, // Profile failed authentication
105 AUTH_FAILED_OFFLINE
, // Profile failed authentication and was offline
106 NUM_PROFILE_AUTH_METRICS
109 // Enum for tracking user interactions with the user menu and user manager.
110 // Interactions initiated from the content area are logged into a different
111 // histogram from those that were initiated from the avatar button.
112 // An example of the interaction beginning in the content area is
113 // clicking "Manage Accounts" within account selection on a Google property.
114 enum ProfileDesktopMenu
{
115 // User opened the user menu, and clicked lock.
116 PROFILE_DESKTOP_MENU_LOCK
= 0,
117 // User opened the user menu, and removed an account.
118 PROFILE_DESKTOP_MENU_REMOVE_ACCT
,
119 // User opened the user menu, and started adding an account.
120 PROFILE_DESKTOP_MENU_ADD_ACCT
,
121 // User opened the user menu, and changed the profile name.
122 PROFILE_DESKTOP_MENU_EDIT_NAME
,
123 // User opened the user menu, and started selecting a new profile image.
124 PROFILE_DESKTOP_MENU_EDIT_IMAGE
,
125 // User opened the user menu, and opened the user manager.
126 PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER
,
127 // User opened the user menu, and selected Go Incognito.
128 PROFILE_DESKTOP_MENU_GO_INCOGNITO
,
129 NUM_PROFILE_DESKTOP_MENU_METRICS
,
132 #if defined(OS_ANDROID)
133 // Enum for tracking user interactions with the account management menu
136 // A Java counterpart will be generated for this enum.
137 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.profiles
138 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: ProfileAccountManagementMetrics
139 // GENERATED_JAVA_PREFIX_TO_STRIP: PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_
140 enum ProfileAndroidAccountManagementMenu
{
141 // User arrived at the Account management screen.
142 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_VIEW
= 0,
143 // User arrived at the Account management screen, and clicked Add account.
144 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_ADD_ACCOUNT
= 1,
145 // User arrived at the Account management screen, and clicked Go incognito.
146 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_GO_INCOGNITO
= 2,
147 // User arrived at the Account management screen, and clicked on primary.
148 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_CLICK_PRIMARY_ACCOUNT
= 3,
149 // User arrived at the Account management screen, and clicked on secondary.
150 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_CLICK_SECONDARY_ACCOUNT
= 4,
151 // User arrived at the Account management screen, toggled Chrome signout.
152 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_TOGGLE_SIGNOUT
= 5,
153 // User toggled Chrome signout, and clicked Signout.
154 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_SIGNOUT_SIGNOUT
= 6,
155 // User toggled Chrome signout, and clicked Cancel.
156 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_SIGNOUT_CANCEL
= 7,
157 // User arrived at the android Account management screen directly from some
159 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_DIRECT_ADD_ACCOUNT
= 8,
160 NUM_PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_METRICS
,
162 #endif // defined(OS_ANDROID)
164 // Enum for tracking user interactions with the 'Not You?' bubble that users
165 // can navigate to from the Upgrade bubble after upgrade.
166 enum ProfileNewAvatarMenuNotYou
{
167 // User views the 'Not You?' bubble.
168 PROFILE_AVATAR_MENU_NOT_YOU_VIEW
= 0,
169 // User selects back from within the 'Not You?' bubble.
170 PROFILE_AVATAR_MENU_NOT_YOU_BACK
,
171 // User adds a person from within the 'Not You?' bubble.
172 PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON
,
173 // User chooses to disconnect (sign out) from within the 'Not You?' bubble.
174 PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT
,
175 NUM_PROFILE_AVATAR_MENU_NOT_YOU_METRICS
,
178 // Enum for tracking user interactions with the signin bubble that appears
179 // in the New Avatar Menu after using the Inline Signin flow.
180 enum ProfileNewAvatarMenuSignin
{
181 // User viewed the signin bubble after successfully using the inline signin.
182 PROFILE_AVATAR_MENU_SIGNIN_VIEW
= 0,
183 // User selected ok to dismiss the signin bubble.
184 PROFILE_AVATAR_MENU_SIGNIN_OK
,
185 // User opened the settings from the signin bubble.
186 PROFILE_AVATAR_MENU_SIGNIN_SETTINGS
,
187 NUM_PROFILE_AVATAR_MENU_SIGNIN_METRICS
,
190 // Enum for tracking user interactions with the bubble that appears for all
191 // users in the new avatar menu after upgrading.
192 enum ProfileNewAvatarMenuUpgrade
{
193 // User views the upgrade bubble.
194 PROFILE_AVATAR_MENU_UPGRADE_VIEW
= 0,
195 // User dismissed the upgrade bubble.
196 PROFILE_AVATAR_MENU_UPGRADE_DISMISS
,
197 // User selects 'What's New' in the upgrade bubble.
198 PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW
,
199 // User selects 'Not You?' in the upgrade bubble.
200 PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU
,
201 NUM_PROFILE_AVATAR_MENU_UPGRADE_METRICS
,
204 static void UpdateReportedProfilesStatistics(ProfileManager
* manager
);
205 // Count and return summary information about the profiles currently in the
206 // |manager|. This information is returned in the output variable |counts|.
207 static bool CountProfileInformation(ProfileManager
* manager
,
208 ProfileCounts
* counts
);
210 static void LogNumberOfProfileSwitches();
211 #if defined(OS_WIN) || defined(OS_MACOSX)
212 // Update OS level tracking of profile counts.
213 static void UpdateReportedOSProfileStatistics(size_t active
, size_t signedin
);
216 static void LogNumberOfProfiles(ProfileManager
* manager
);
217 static void LogProfileAddNewUser(ProfileAdd metric
);
218 static void LogProfileAvatarSelection(size_t icon_index
);
219 static void LogProfileDeleteUser(ProfileDelete metric
);
220 static void LogProfileOpenMethod(ProfileOpen metric
);
221 static void LogProfileSwitch(ProfileOpen metric
,
222 ProfileManager
* manager
,
223 const base::FilePath
& profile_path
);
224 static void LogProfileSwitchGaia(ProfileGaia metric
);
225 static void LogProfileSyncInfo(ProfileSync metric
);
226 static void LogProfileAuthResult(ProfileAuth metric
);
227 static void LogProfileDesktopMenu(ProfileDesktopMenu metric
,
228 signin::GAIAServiceType gaia_service
);
229 static void LogProfileDelete(bool profile_was_signed_in
);
230 static void LogProfileNewAvatarMenuNotYou(ProfileNewAvatarMenuNotYou metric
);
231 static void LogProfileNewAvatarMenuSignin(ProfileNewAvatarMenuSignin metric
);
232 static void LogProfileNewAvatarMenuUpgrade(
233 ProfileNewAvatarMenuUpgrade metric
);
235 #if defined(OS_ANDROID)
236 static void LogProfileAndroidAccountManagementMenu(
237 ProfileAndroidAccountManagementMenu metric
,
238 signin::GAIAServiceType gaia_service
);
239 #endif // defined(OS_ANDROID)
241 // These functions should only be called on the UI thread because they hook
242 // into g_browser_process through a helper function.
243 static void LogProfileLaunch(Profile
* profile
);
244 static void LogProfileSyncSignIn(const base::FilePath
& profile_path
);
245 static void LogProfileUpdate(const base::FilePath
& profile_path
);
249 #endif // CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_