1 // Copyright 2014 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 #include "components/signin/core/browser/signin_metrics.h"
7 #include "base/logging.h"
8 #include "base/metrics/histogram.h"
9 #include "base/metrics/user_metrics.h"
10 #include "base/time/time.h"
12 namespace signin_metrics
{
14 // Helper method to determine which |DifferentPrimaryAccounts| applies.
15 DifferentPrimaryAccounts
ComparePrimaryAccounts(bool primary_accounts_same
,
16 int pre_count_gaia_cookies
) {
17 if (primary_accounts_same
)
19 if (pre_count_gaia_cookies
== 0)
20 return NO_COOKIE_PRESENT
;
21 return COOKIE_AND_TOKEN_PRIMARIES_DIFFERENT
;
24 void LogSigninAccountReconciliation(int total_number_accounts
,
25 int count_added_to_cookie_jar
,
26 int count_removed_from_cookie_jar
,
27 bool primary_accounts_same
,
28 bool is_first_reconcile
,
29 int pre_count_gaia_cookies
) {
30 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfAccountsPerProfile",
31 total_number_accounts
);
32 // We want to include zeroes in the counts of added or removed accounts to
33 // easily capture _relatively_ how often we merge accounts.
34 if (is_first_reconcile
) {
35 UMA_HISTOGRAM_COUNTS_100("Signin.Reconciler.AddedToCookieJar.FirstRun",
36 count_added_to_cookie_jar
);
37 UMA_HISTOGRAM_COUNTS_100("Signin.Reconciler.RemovedFromCookieJar.FirstRun",
38 count_removed_from_cookie_jar
);
39 UMA_HISTOGRAM_ENUMERATION(
40 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun",
41 ComparePrimaryAccounts(primary_accounts_same
, pre_count_gaia_cookies
),
42 NUM_DIFFERENT_PRIMARY_ACCOUNT_METRICS
);
44 UMA_HISTOGRAM_COUNTS_100("Signin.Reconciler.AddedToCookieJar.SubsequentRun",
45 count_added_to_cookie_jar
);
46 UMA_HISTOGRAM_COUNTS_100(
47 "Signin.Reconciler.RemovedFromCookieJar.SubsequentRun",
48 count_removed_from_cookie_jar
);
49 UMA_HISTOGRAM_ENUMERATION(
50 "Signin.Reconciler.DifferentPrimaryAccounts.SubsequentRun",
51 ComparePrimaryAccounts(primary_accounts_same
, pre_count_gaia_cookies
),
52 NUM_DIFFERENT_PRIMARY_ACCOUNT_METRICS
);
56 void LogSigninProfile(bool is_first_run
, base::Time install_date
) {
57 // Track whether or not the user signed in during the first run of Chrome.
58 UMA_HISTOGRAM_BOOLEAN("Signin.DuringFirstRun", is_first_run
);
60 // Determine how much time passed since install when this profile was signed
62 base::TimeDelta elapsed_time
= base::Time::Now() - install_date
;
63 UMA_HISTOGRAM_COUNTS("Signin.ElapsedTimeFromInstallToSignin",
64 elapsed_time
.InMinutes());
67 void LogSigninSource(Source source
) {
68 UMA_HISTOGRAM_ENUMERATION("Signin.SigninSource", source
, HISTOGRAM_MAX
);
71 void LogSigninAddAccount() {
72 // Account signin may fail for a wide variety of reasons. There is no
73 // explicit false, but one can compare this value with the various UI
74 // flows that lead to account sign-in, and deduce that the difference
75 // counts the failures.
76 UMA_HISTOGRAM_BOOLEAN("Signin.AddAccount", true);
79 void LogSignout(ProfileSignout metric
) {
80 UMA_HISTOGRAM_ENUMERATION("Signin.SignoutProfile", metric
,
81 NUM_PROFILE_SIGNOUT_METRICS
);
84 void LogExternalCcResultFetches(
85 bool fetches_completed
,
86 const base::TimeDelta
& time_to_check_connections
) {
87 UMA_HISTOGRAM_BOOLEAN("Signin.Reconciler.AllExternalCcResultCompleted",
89 if (fetches_completed
) {
91 "Signin.Reconciler.ExternalCcResultTime.Completed",
92 time_to_check_connections
);
95 "Signin.Reconciler.ExternalCcResultTime.NotCompleted",
96 time_to_check_connections
);
100 void LogAuthError(GoogleServiceAuthError::State auth_error
) {
101 UMA_HISTOGRAM_ENUMERATION("Signin.AuthError", auth_error
,
102 GoogleServiceAuthError::State::NUM_STATES
);
105 void LogSigninConfirmHistogramValue(int action
) {
106 UMA_HISTOGRAM_ENUMERATION("Signin.OneClickConfirmation", action
,
107 signin_metrics::HISTOGRAM_CONFIRM_MAX
);
110 } // namespace signin_metrics