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   // Enum for counting the ways users were added.
     24   enum ProfileAdd {
     25     ADD_NEW_USER_ICON = 0,    // User adds new user from icon menu
     26     ADD_NEW_USER_MENU,        // User adds new user from menu bar
     27     ADD_NEW_USER_DIALOG,      // User adds new user from create-profile dialog
     28     ADD_NEW_USER_MANAGER,     // User adds new user from User Manager
     29     NUM_PROFILE_ADD_METRICS
     30   };
     31 
     32   // Enum for counting the ways user profiles and menus were opened.
     33   enum ProfileOpen {
     34     NTP_AVATAR_BUBBLE = 0,    // User opens avatar icon menu from NTP
     35     ICON_AVATAR_BUBBLE,       // User opens avatar icon menu from icon
     36     SWITCH_PROFILE_ICON,      // User switches profiles from icon menu
     37     SWITCH_PROFILE_MENU,      // User switches profiles from menu bar
     38     SWITCH_PROFILE_DOCK,      // User switches profiles from dock (Mac-only)
     39     OPEN_USER_MANAGER,        // User opens the User Manager
     40     SWITCH_PROFILE_MANAGER,   // User switches profiles from the User Manager
     41     SWITCH_PROFILE_UNLOCK,    // User switches to lockd profile via User Manager
     42     SWITCH_PROFILE_GUEST,     // User switches to guest profile
     43     NUM_PROFILE_OPEN_METRICS
     44   };
     45 
     46   // Enum for getting net counts for adding and deleting users.
     47   enum ProfileNetUserCounts {
     48     ADD_NEW_USER = 0,         // Total count of add new user
     49     PROFILE_DELETED,          // User deleted a profile
     50     NUM_PROFILE_NET_METRICS
     51   };
     52 
     53   // Sign in is logged once the user has entered their GAIA information.
     54   // The options for sync are logged after the user has submitted the options
     55   // form. See sync_setup_handler.h.
     56   enum ProfileSync {
     57     SYNC_CUSTOMIZE = 0,       // User decided to customize sync
     58     SYNC_CHOOSE,              // User chose what to sync
     59     SYNC_ENCRYPT,             // User has chosen to encrypt all data
     60     SYNC_PASSPHRASE,          // User is using a passphrase
     61     NUM_PROFILE_SYNC_METRICS
     62   };
     63 
     64   enum ProfileType {
     65     ORIGINAL = 0,             // Refers to the original/default profile
     66     SECONDARY,                // Refers to a user-created profile
     67     NUM_PROFILE_TYPE_METRICS
     68   };
     69 
     70   enum ProfileGaia {
     71     GAIA_OPT_IN = 0,          // User changed to GAIA photo as avatar
     72     GAIA_OPT_OUT,             // User changed to not use GAIA photo as avatar
     73     NUM_PROFILE_GAIA_METRICS
     74   };
     75 
     76   enum ProfileAuth {
     77     AUTH_UNNECESSARY,         // Profile was not locked
     78     AUTH_LOCAL,               // Profile was authenticated locally
     79     AUTH_ONLINE,              // Profile was authenticated on-line
     80     AUTH_FAILED,              // Profile failed authentication
     81     NUM_PROFILE_AUTH_METRICS
     82   };
     83 
     84   // Enum for tracking if new profile management is enabled and Promo views.
     85   // This is used in a histogram; the items should not be removed or re-ordered.
     86   enum ProfileUpgradeEnrollment {
     87     // User viewed the Upgrade promo card in the user menu.
     88     PROFILE_ENROLLMENT_SHOW_PREVIEW_PROMO,
     89     // User selected to view the intro tutorial.
     90     PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE,
     91     // User opted into New Profile Management via Promo card.
     92     PROFILE_ENROLLMENT_ACCEPT_NEW_PROFILE_MGMT,
     93     // User closed the Upgrade card.
     94     PROFILE_ENROLLMENT_CLOSE_WELCOME_CARD,
     95     // User disabled New Profile Management.
     96     PROFILE_ENROLLMENT_DISABLE_NEW_PROFILE_MGMT,
     97     // User elected to send feedback.
     98     PROFILE_ENROLLMENT_SEND_FEEDBACK,
     99     NUM_PROFILE_ENROLLMENT_METRICS,
    100   };
    101 
    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     NUM_PROFILE_DESKTOP_MENU_METRICS,
    119   };
    120 
    121 #if defined(OS_ANDROID)
    122   // TODO(aruslan): http://crbug.com/379987 Move to a generator.
    123   // Enum for tracking user interactions with the account management menu
    124   // on Android.
    125   // This should match its counterpart in AccountManagementScreenHelper.java.
    126   enum ProfileAndroidAccountManagementMenu {
    127     // User arrived at the Account management screen.
    128     PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_VIEW = 0,
    129     // User arrived at the Account management screen, and clicked Add account.
    130     PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_ADD_ACCOUNT,
    131     // User arrived at the Account management screen, and clicked Go incognito.
    132     PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_GO_INCOGNITO,
    133     // User arrived at the Account management screen, and clicked on primary.
    134     PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_CLICK_PRIMARY_ACCOUNT,
    135     // User arrived at the Account management screen, and clicked on secondary.
    136     PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_CLICK_SECONDARY_ACCOUNT,
    137     // User arrived at the Account management screen, toggled Chrome signout.
    138     PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_TOGGLE_SIGNOUT,
    139     // User toggled Chrome signout, and clicked Signout.
    140     PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_SIGNOUT_SIGNOUT,
    141     // User toggled Chrome signout, and clicked Cancel.
    142     PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_SIGNOUT_CANCEL,
    143     NUM_PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_METRICS,
    144   };
    145 #endif  // defined(OS_ANDROID)
    146 
    147   static void UpdateReportedProfilesStatistics(ProfileManager* manager);
    148 
    149   static void LogNumberOfProfiles(ProfileManager* manager);
    150   static void LogProfileAddNewUser(ProfileAdd metric);
    151   static void LogProfileAvatarSelection(size_t icon_index);
    152   static void LogProfileDeleteUser(ProfileNetUserCounts metric);
    153   static void LogProfileOpenMethod(ProfileOpen metric);
    154   static void LogProfileSwitchGaia(ProfileGaia metric);
    155   static void LogProfileSwitchUser(ProfileOpen metric);
    156   static void LogProfileSyncInfo(ProfileSync metric);
    157   static void LogProfileAuthResult(ProfileAuth metric);
    158   static void LogProfileUpgradeEnrollment(ProfileUpgradeEnrollment metric);
    159   static void LogProfileDesktopMenu(ProfileDesktopMenu metric,
    160                                     signin::GAIAServiceType gaia_service);
    161   static void LogProfileDelete(bool profile_was_signed_in);
    162 
    163 #if defined(OS_ANDROID)
    164   static void LogProfileAndroidAccountManagementMenu(
    165       ProfileAndroidAccountManagementMenu metric,
    166       signin::GAIAServiceType gaia_service);
    167 #endif  // defined(OS_ANDROID)
    168 
    169   // These functions should only be called on the UI thread because they hook
    170   // into g_browser_process through a helper function.
    171   static void LogProfileLaunch(Profile* profile);
    172   static void LogProfileSyncSignIn(const base::FilePath& profile_path);
    173   static void LogProfileUpdate(const base::FilePath& profile_path);
    174 };
    175 
    176 
    177 #endif  // CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_
    178