Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / components / signin / core / browser / signin_metrics.cc
blobad78b6404977631793d0f7c46392db94c5041577
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"
11 namespace signin_metrics {
13 // Helper method to determine which |DifferentPrimaryAccounts| applies.
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;
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);
54 void LogSigninProfile(bool is_first_run, base::Time install_date) {
55 // Track whether or not the user signed in during the first run of Chrome.
56 UMA_HISTOGRAM_BOOLEAN("Signin.DuringFirstRun", is_first_run);
58 // Determine how much time passed since install when this profile was signed
59 // in.
60 base::TimeDelta elapsed_time = base::Time::Now() - install_date;
61 UMA_HISTOGRAM_COUNTS("Signin.ElapsedTimeFromInstallToSignin",
62 elapsed_time.InMinutes());
65 void LogSigninAddAccount() {
66 // Account signin may fail for a wide variety of reasons. There is no
67 // explicit false, but one can compare this value with the various UI
68 // flows that lead to account sign-in, and deduce that the difference
69 // counts the failures.
70 UMA_HISTOGRAM_BOOLEAN("Signin.AddAccount", true);
73 void LogSignout(ProfileSignout metric) {
74 UMA_HISTOGRAM_ENUMERATION("Signin.SignoutProfile", metric,
75 NUM_PROFILE_SIGNOUT_METRICS);
78 void LogExternalCcResultFetches(bool fetches_completed) {
79 UMA_HISTOGRAM_BOOLEAN("Signin.Reconciler.AllExternalCcResultCompleted",
80 fetches_completed);
83 } // namespace signin_metrics