Commit a1483f21 authored by aruslan@chromium.org's avatar aruslan@chromium.org

[Android][Mirror] UMA stats for Account management screen.

BUG=376860

Review URL: https://codereview.chromium.org/304983005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274519 0039d316-1c4b-4281-b951-d872f2087c98
parent 97313d5f
......@@ -16,6 +16,29 @@ import org.chromium.chrome.browser.profiles.Profile;
public class AccountManagementScreenHelper {
private static AccountManagementScreenManager sManager;
/*
* TODO(aruslan): http://crbug.com/379987 Move to a generator.
* Enum for tracking user interactions with the account management menu
* on Android.
* This must match enum ProfileAndroidAccountManagementMenu in profile_metrics.h.
*/
// User arrived at the Account management screen.
public static final int ACCOUNT_MANAGEMENT_MENU_VIEW = 0;
// User arrived at the Account management screen, and clicked Add account.
public static final int ACCOUNT_MANAGEMENT_MENU_ADD_ACCOUNT = 1;
// User arrived at the Account management screen, and clicked Go incognito.
public static final int ACCOUNT_MANAGEMENT_MENU_GO_INCOGNITO = 2;
// User arrived at the Account management screen, and clicked on primary.
public static final int ACCOUNT_MANAGEMENT_MENU_CLICK_PRIMARY_ACCOUNT = 3;
// User arrived at the Account management screen, and clicked on secondary.
public static final int ACCOUNT_MANAGEMENT_MENU_CLICK_SECONDARY_ACCOUNT = 4;
// User arrived at the Account management screen, toggled Chrome signout.
public static final int ACCOUNT_MANAGEMENT_MENU_TOGGLE_SIGNOUT = 5;
// User toggled Chrome signout, and clicked Signout.
public static final int ACCOUNT_MANAGEMENT_MENU_SIGNOUT_SIGNOUT = 6;
// User toggled Chrome signout, and clicked Cancel.
public static final int ACCOUNT_MANAGEMENT_MENU_SIGNOUT_CANCEL = 7;
/**
* The screen manager interface.
*/
......@@ -24,8 +47,10 @@ public class AccountManagementScreenHelper {
* Opens the account management UI screen.
* @param applicationContext The application context.
* @param profile The user profile.
* @param gaiaServiceType A signin::GAIAServiceType value that triggered the dialog.
*/
void openAccountManagementScreen(Context applicationContext, Profile profile);
void openAccountManagementScreen(
Context applicationContext, Profile profile, int gaiaServiceType);
}
/**
......@@ -38,10 +63,23 @@ public class AccountManagementScreenHelper {
}
@CalledByNative
private static void openAccountManagementScreen(Context applicationContext, Profile profile) {
private static void openAccountManagementScreen(
Context applicationContext, Profile profile, int gaiaServiceType) {
ThreadUtils.assertOnUiThread();
if (sManager == null) return;
sManager.openAccountManagementScreen(applicationContext, profile);
sManager.openAccountManagementScreen(applicationContext, profile, gaiaServiceType);
}
/**
* Log a UMA event for a given metric and a signin type.
* @param metric A PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU metric.
* @param gaiaServiceType A signin::GAIAServiceType.
*/
public static void logEvent(int metric, int gaiaServiceType) {
nativeLogEvent(metric, gaiaServiceType);
}
// Native methods.
private static native void nativeLogEvent(int metric, int gaiaServiceType);
}
......@@ -8,18 +8,30 @@
#include "base/android/jni_string.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_android.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "jni/AccountManagementScreenHelper_jni.h"
// static
void AccountManagementScreenHelper::OpenAccountManagementScreen(
Profile* profile) {
Profile* profile,
signin::GAIAServiceType service_type) {
DCHECK(profile);
DCHECK(ProfileAndroid::FromProfile(profile));
Java_AccountManagementScreenHelper_openAccountManagementScreen(
base::android::AttachCurrentThread(),
base::android::GetApplicationContext(),
ProfileAndroid::FromProfile(profile)->GetJavaObject().obj());
ProfileAndroid::FromProfile(profile)->GetJavaObject().obj(),
static_cast<int>(service_type));
}
static void LogEvent(JNIEnv* env,
jclass clazz,
jint metric,
jint gaiaServiceType) {
ProfileMetrics::LogProfileAndroidAccountManagementMenu(
static_cast<ProfileMetrics::ProfileAndroidAccountManagementMenu>(metric),
static_cast<signin::GAIAServiceType>(gaiaServiceType));
}
// static
......
......@@ -8,6 +8,7 @@
#include <jni.h>
#include "base/basictypes.h"
#include "chrome/browser/signin/signin_header_helper.h"
class Profile;
......@@ -18,7 +19,8 @@ class AccountManagementScreenHelper {
static bool Register(JNIEnv* env);
// Opens the account management screen.
static void OpenAccountManagementScreen(Profile* profile);
static void OpenAccountManagementScreen(Profile* profile,
signin::GAIAServiceType service_type);
private:
DISALLOW_COPY_AND_ASSIGN(AccountManagementScreenHelper);
......
......@@ -330,6 +330,54 @@ void ProfileMetrics::LogProfileDesktopMenu(
}
}
#if defined(OS_ANDROID)
void ProfileMetrics::LogProfileAndroidAccountManagementMenu(
ProfileAndroidAccountManagementMenu metric,
signin::GAIAServiceType gaia_service) {
// The first parameter to the histogram needs to be literal, because of the
// optimized implementation of |UMA_HISTOGRAM_ENUMERATION|. Do not attempt
// to refactor.
switch (gaia_service) {
case signin::GAIA_SERVICE_TYPE_NONE:
UMA_HISTOGRAM_ENUMERATION(
"Profile.AndroidAccountManagementMenu.NonGAIA",
metric,
NUM_PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_METRICS);
break;
case signin::GAIA_SERVICE_TYPE_SIGNOUT:
UMA_HISTOGRAM_ENUMERATION(
"Profile.AndroidAccountManagementMenu.GAIASignout",
metric,
NUM_PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_METRICS);
break;
case signin::GAIA_SERVICE_TYPE_INCOGNITO:
UMA_HISTOGRAM_ENUMERATION(
"Profile.AndroidAccountManagementMenu.GAIASignoutIncognito",
metric,
NUM_PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_METRICS);
break;
case signin::GAIA_SERVICE_TYPE_ADDSESSION:
UMA_HISTOGRAM_ENUMERATION(
"Profile.AndroidAccountManagementMenu.GAIAAddSession",
metric,
NUM_PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_METRICS);
break;
case signin::GAIA_SERVICE_TYPE_REAUTH:
UMA_HISTOGRAM_ENUMERATION(
"Profile.AndroidAccountManagementMenu.GAIAReAuth",
metric,
NUM_PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_METRICS);
break;
case signin::GAIA_SERVICE_TYPE_DEFAULT:
UMA_HISTOGRAM_ENUMERATION(
"Profile.AndroidAccountManagementMenu.GAIADefault",
metric,
NUM_PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_METRICS);
break;
}
}
#endif // defined(OS_ANDROID)
void ProfileMetrics::LogProfileLaunch(Profile* profile) {
base::FilePath profile_path = profile->GetPath();
UMA_HISTOGRAM_ENUMERATION("Profile.LaunchBrowser",
......
......@@ -118,6 +118,32 @@ class ProfileMetrics {
NUM_PROFILE_DESKTOP_MENU_METRICS,
};
#if defined(OS_ANDROID)
// TODO(aruslan): http://crbug.com/379987 Move to a generator.
// Enum for tracking user interactions with the account management menu
// on Android.
// This should match its counterpart in AccountManagementScreenHelper.java.
enum ProfileAndroidAccountManagementMenu {
// User arrived at the Account management screen.
PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_VIEW = 0,
// User arrived at the Account management screen, and clicked Add account.
PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_ADD_ACCOUNT,
// User arrived at the Account management screen, and clicked Go incognito.
PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_GO_INCOGNITO,
// User arrived at the Account management screen, and clicked on primary.
PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_CLICK_PRIMARY_ACCOUNT,
// User arrived at the Account management screen, and clicked on secondary.
PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_CLICK_SECONDARY_ACCOUNT,
// User arrived at the Account management screen, toggled Chrome signout.
PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_TOGGLE_SIGNOUT,
// User toggled Chrome signout, and clicked Signout.
PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_SIGNOUT_SIGNOUT,
// User toggled Chrome signout, and clicked Cancel.
PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_SIGNOUT_CANCEL,
NUM_PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_METRICS,
};
#endif // defined(OS_ANDROID)
static void UpdateReportedProfilesStatistics(ProfileManager* manager);
static void LogNumberOfProfiles(ProfileManager* manager);
......@@ -133,6 +159,12 @@ class ProfileMetrics {
static void LogProfileDesktopMenu(ProfileDesktopMenu metric,
signin::GAIAServiceType gaia_service);
#if defined(OS_ANDROID)
static void LogProfileAndroidAccountManagementMenu(
ProfileAndroidAccountManagementMenu metric,
signin::GAIAServiceType gaia_service);
#endif // defined(OS_ANDROID)
// These functions should only be called on the UI thread because they hook
// into g_browser_process through a helper function.
static void LogProfileLaunch(Profile* profile);
......
......@@ -83,10 +83,9 @@ void ProcessMirrorHeaderUIThread(
GURL(chrome::kChromeUINativeNewTabURL), content::Referrer(),
OFF_THE_RECORD, content::PAGE_TRANSITION_AUTO_TOPLEVEL, false));
} else {
// TODO(mlerman): pass service_type to android logic for UMA metrics
// that will eventually be installed there.
AccountManagementScreenHelper::OpenAccountManagementScreen(
Profile::FromBrowserContext(web_contents->GetBrowserContext()));
Profile::FromBrowserContext(web_contents->GetBrowserContext()),
service_type);
}
#endif // OS_ANDROID
}
......
......@@ -21325,6 +21325,15 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<summary>The frequency of ways that new user profiles are added.</summary>
</histogram>
<histogram name="Profile.AndroidAccountManagementMenu"
enum="ProfileAndroidAccountManagementMenu">
<owner>aruslan@chromium.org</owner>
<summary>
Track user interactions that can be performed in the Android account
management menu.
</summary>
</histogram>
<histogram name="Profile.AppCount">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<summary>The number of installed apps when a profile is opened.</summary>
......@@ -41247,6 +41256,33 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="3" label="Add new user from the User Manager"/>
</enum>
<enum name="ProfileAndroidAccountManagementMenu" type="int">
<int value="0" label="Opened Menu">
User arrived at the Account management screen.
</int>
<int value="1" label="Add Account">
User arrived at the Account management screen, and clicked Add account.
</int>
<int value="2" label="Go Incognito">
User arrived at the Account management screen, and clicked Go incognito.
</int>
<int value="3" label="Primary Account">
User arrived at the Account management screen, and clicked on primary.
</int>
<int value="4" label="Secondary Account">
User arrived at the Account management screen, and clicked on secondary.
</int>
<int value="5" label="Toggled Signout">
User arrived at the Account management screen, toggled Chrome signout.
</int>
<int value="6" label="Confirm Signout">
User toggled Chrome signout, and clicked Signout.
</int>
<int value="7" label="Cancel Signout">
User toggled Chrome signout, and clicked Cancel.
</int>
</enum>
<enum name="ProfileAuth" type="int">
<int value="0" label="Authentication was unnecessary (profile not locked)"/>
<int value="1" label="Authentication performed using local credentials"/>
......@@ -46820,6 +46856,24 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<affected-histogram name="Prerender.TimeUntilUsed2"/>
</histogram_suffixes>
<histogram_suffixes name="Profile.AndroidAccountManagementMenu" separator=".">
<suffix name="NonGAIA" label="Interaction was not initiated from GAIA"/>
<suffix name="GAIASignout"
label="GAIA-initiated interaction indicating a service type of Signout"/>
<suffix name="GAIASignoutIncognito"
label="GAIA-initiated interaction indicating a service type of Signout
and go Incogntio"/>
<suffix name="GAIAAddSession"
label="GAIA-initiated interaction indicating a service type of Add a
Session"/>
<suffix name="GAIAReAuth"
label="GAIA-initiated interaction indicating a service type of
Reauthenticate this user"/>
<suffix name="GAIADefault"
label="GAIA-initiated interaction indicating the default service type"/>
<affected-histogram name="Profile.AndroidAccountManagementMenu"/>
</histogram_suffixes>
<histogram_suffixes name="Profile.DesktopMenu" separator=".">
<suffix name="NonGAIA" label="Interaction was not initiated from GAIA"/>
<suffix name="GAIASignout"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment