Home | History | Annotate | Download | only in profiles
      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.
      4 
      5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_
      6 #define CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_
      7 
      8 #include <stddef.h>
      9 #include <string>
     10 
     11 #include "base/basictypes.h"
     12 #include "chrome/browser/signin/signin_header_helper.h"
     13 
     14 class Profile;
     15 class ProfileManager;
     16 
     17 namespace base {
     18 class FilePath;
     19 }
     20 
     21 class ProfileMetrics {
     22  public:
     23   struct ProfileCounts {
     24     size_t total;
     25     size_t signedin;
     26     size_t supervised;
     27     size_t unused;
     28     size_t gaia_icon;
     29 
     30     ProfileCounts()
     31         : total(0), signedin(0), supervised(0), unused(0), gaia_icon(0) {}
     32   };
     33 
     34   // Enum for counting the ways users were added.
     35   enum ProfileAdd {
     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
     42   };
     43 
     44   enum ProfileDelete {
     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
     48   };
     49 
     50   // Enum for counting the ways user profiles and menus were opened.
     51   enum ProfileOpen {
     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
     62   };
     63 
     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
     69   };
     70 
     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.
     74   enum ProfileSync {
     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
     80   };
     81 
     82   enum ProfileType {
     83     ORIGINAL = 0,             // Refers to the original/default profile
     84     SECONDARY,                // Refers to a user-created profile
     85     NUM_PROFILE_TYPE_METRICS
     86   };
     87 
     88   enum ProfileGaia {
     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
     92   };
     93 
     94   enum ProfileAuth {
     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
    101   };
    102 
    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     NUM_PROFILE_DESKTOP_MENU_METRICS,
    122   };
    123 
    124 #if defined(OS_ANDROID)
    125   // TODO(aruslan): http://crbug.com/379987 Move to a generator.
    126   // Enum for tracking user interactions with the account management menu
    127   // on Android.
    128   // This should match its counterpart in AccountManagementScreenHelper.java.
    129   enum ProfileAndroidAccountManagementMenu {
    130     // User arrived at the Account management screen.
    131     PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_VIEW = 0,
    132     // User arrived at the Account management screen, and clicked Add account.
    133     PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_ADD_ACCOUNT,
    134     // User arrived at the Account management screen, and clicked Go incognito.
    135     PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_GO_INCOGNITO,
    136     // User arrived at the Account management screen, and clicked on primary.
    137     PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_CLICK_PRIMARY_ACCOUNT,
    138     // User arrived at the Account management screen, and clicked on secondary.
    139     PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_CLICK_SECONDARY_ACCOUNT,
    140     // User arrived at the Account management screen, toggled Chrome signout.
    141     PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_TOGGLE_SIGNOUT,
    142     // User toggled Chrome signout, and clicked Signout.
    143     PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_SIGNOUT_SIGNOUT,
    144     // User toggled Chrome signout, and clicked Cancel.
    145     PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_SIGNOUT_CANCEL,
    146     NUM_PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_METRICS,
    147   };
    148 #endif  // defined(OS_ANDROID)
    149 
    150   // Enum for tracking user interactions with the 'Not You?' bubble that users
    151   // can navigate to from the Upgrade bubble after upgrade.
    152   enum ProfileNewAvatarMenuNotYou {
    153     // User views the 'Not You?' bubble.
    154     PROFILE_AVATAR_MENU_NOT_YOU_VIEW = 0,
    155     // User selects back from within the 'Not You?' bubble.
    156     PROFILE_AVATAR_MENU_NOT_YOU_BACK,
    157     // User adds a person from within the 'Not You?' bubble.
    158     PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON,
    159     // User chooses to disconnect (sign out) from within the 'Not You?' bubble.
    160     PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT,
    161     NUM_PROFILE_AVATAR_MENU_NOT_YOU_METRICS,
    162   };
    163 
    164   // Enum for tracking user interactions with the signin bubble that appears
    165   // in the New Avatar Menu after using the Inline Signin flow.
    166   enum ProfileNewAvatarMenuSignin {
    167     // User viewed the signin bubble after successfully using the inline signin.
    168     PROFILE_AVATAR_MENU_SIGNIN_VIEW = 0,
    169     // User selected ok to dismiss the signin bubble.
    170     PROFILE_AVATAR_MENU_SIGNIN_OK,
    171     // User opened the settings from the signin bubble.
    172     PROFILE_AVATAR_MENU_SIGNIN_SETTINGS,
    173     NUM_PROFILE_AVATAR_MENU_SIGNIN_METRICS,
    174   };
    175 
    176   // Enum for tracking user interactions with the bubble that appears for all
    177   // users in the new avatar menu after upgrading.
    178   enum ProfileNewAvatarMenuUpgrade {
    179     // User views the upgrade bubble.
    180     PROFILE_AVATAR_MENU_UPGRADE_VIEW = 0,
    181     // User dismissed the upgrade bubble.
    182     PROFILE_AVATAR_MENU_UPGRADE_DISMISS,
    183     // User selects 'What's New' in the upgrade bubble.
    184     PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW,
    185     // User selects 'Not You?' in the upgrade bubble.
    186     PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU,
    187     NUM_PROFILE_AVATAR_MENU_UPGRADE_METRICS,
    188   };
    189 
    190   static void UpdateReportedProfilesStatistics(ProfileManager* manager);
    191   // Count and return summary information about the profiles currently in the
    192   // |manager|. This information is returned in the output variable |counts|.
    193   static bool CountProfileInformation(ProfileManager* manager,
    194                                       ProfileCounts* counts);
    195 
    196   static void LogNumberOfProfiles(ProfileManager* manager);
    197   static void LogProfileAddNewUser(ProfileAdd metric);
    198   static void LogProfileAvatarSelection(size_t icon_index);
    199   static void LogProfileDeleteUser(ProfileDelete metric);
    200   static void LogProfileOpenMethod(ProfileOpen metric);
    201   static void LogProfileSwitchGaia(ProfileGaia metric);
    202   static void LogProfileSwitchUser(ProfileOpen metric);
    203   static void LogProfileSyncInfo(ProfileSync metric);
    204   static void LogProfileAuthResult(ProfileAuth metric);
    205   static void LogProfileDesktopMenu(ProfileDesktopMenu metric,
    206                                     signin::GAIAServiceType gaia_service);
    207   static void LogProfileDelete(bool profile_was_signed_in);
    208   static void LogProfileNewAvatarMenuNotYou(ProfileNewAvatarMenuNotYou metric);
    209   static void LogProfileNewAvatarMenuSignin(ProfileNewAvatarMenuSignin metric);
    210   static void LogProfileNewAvatarMenuUpgrade(
    211       ProfileNewAvatarMenuUpgrade metric);
    212 
    213 #if defined(OS_ANDROID)
    214   static void LogProfileAndroidAccountManagementMenu(
    215       ProfileAndroidAccountManagementMenu metric,
    216       signin::GAIAServiceType gaia_service);
    217 #endif  // defined(OS_ANDROID)
    218 
    219   // These functions should only be called on the UI thread because they hook
    220   // into g_browser_process through a helper function.
    221   static void LogProfileLaunch(Profile* profile);
    222   static void LogProfileSyncSignIn(const base::FilePath& profile_path);
    223   static void LogProfileUpdate(const base::FilePath& profile_path);
    224 };
    225 
    226 
    227 #endif  // CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_
    228