• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "components/signin/core/browser/signin_metrics.h"
6 
7 #include "base/logging.h"
8 #include "base/metrics/histogram.h"
9 #include "base/metrics/user_metrics.h"
10 
11 namespace signin_metrics {
12 
13 // Helper method to determine which |DifferentPrimaryAccounts| applies.
ComparePrimaryAccounts(bool primary_accounts_same,int pre_count_gaia_cookies)14 DifferentPrimaryAccounts ComparePrimaryAccounts(bool primary_accounts_same,
15                                                 int pre_count_gaia_cookies) {
16   if (primary_accounts_same)
17     return ACCOUNTS_SAME;
18   if (pre_count_gaia_cookies == 0)
19     return NO_COOKIE_PRESENT;
20   return COOKIE_AND_TOKEN_PRIMARIES_DIFFERENT;
21 }
22 
LogSigninAccountReconciliation(int total_number_accounts,int count_added_to_cookie_jar,int count_added_to_token,bool primary_accounts_same,bool is_first_reconcile,int pre_count_gaia_cookies)23 void LogSigninAccountReconciliation(int total_number_accounts,
24                                     int count_added_to_cookie_jar,
25                                     int count_added_to_token,
26                                     bool primary_accounts_same,
27                                     bool is_first_reconcile,
28                                     int pre_count_gaia_cookies) {
29   UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfAccountsPerProfile",
30                            total_number_accounts);
31   // We want to include zeroes in the counts of added accounts to easily
32   // capture _relatively_ how often we merge accounts.
33   if (is_first_reconcile) {
34     UMA_HISTOGRAM_COUNTS_100("Signin.Reconciler.AddedToCookieJar.FirstRun",
35                              count_added_to_cookie_jar);
36     UMA_HISTOGRAM_COUNTS_100("Signin.Reconciler.AddedToChrome.FirstRun",
37                              count_added_to_token);
38     UMA_HISTOGRAM_ENUMERATION(
39         "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun",
40         ComparePrimaryAccounts(primary_accounts_same, pre_count_gaia_cookies),
41         NUM_DIFFERENT_PRIMARY_ACCOUNT_METRICS);
42   } else {
43     UMA_HISTOGRAM_COUNTS_100("Signin.Reconciler.AddedToCookieJar.SubsequentRun",
44                              count_added_to_cookie_jar);
45     UMA_HISTOGRAM_COUNTS_100("Signin.Reconciler.AddedToChrome.SubsequentRun",
46                              count_added_to_token);
47     UMA_HISTOGRAM_ENUMERATION(
48         "Signin.Reconciler.DifferentPrimaryAccounts.SubsequentRun",
49         ComparePrimaryAccounts(primary_accounts_same, pre_count_gaia_cookies),
50         NUM_DIFFERENT_PRIMARY_ACCOUNT_METRICS);
51   }
52 }
53 
LogSigninAddAccount()54 void LogSigninAddAccount() {
55   // Account signin may fail for a wide variety of reasons. There is no
56   // explicit false, but one can compare this value with the various UI
57   // flows that lead to account sign-in, and deduce that the difference
58   // counts the failures.
59   UMA_HISTOGRAM_BOOLEAN("Signin.AddAccount", true);
60 }
61 
LogSignout(ProfileSignout metric)62 void LogSignout(ProfileSignout metric) {
63   UMA_HISTOGRAM_ENUMERATION("Signin.SignoutProfile", metric,
64                             NUM_PROFILE_SIGNOUT_METRICS);
65 }
66 
67 }  // namespace signin_metrics
68