Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(617)

Unified Diff: components/signin/core/browser/signin_manager.cc

Issue 459853002: UMA track signed in duration at signout (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: track minutes a profile was signed in before signing out Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/signin/core/browser/signin_manager.cc
diff --git a/components/signin/core/browser/signin_manager.cc b/components/signin/core/browser/signin_manager.cc
index 9c68eb98915ca9b5c5c0d78a990e7c1bd2ac50b0..851bcb40c40a951190cbbb2b3b15908c71ce4c60 100644
--- a/components/signin/core/browser/signin_manager.cc
+++ b/components/signin/core/browser/signin_manager.cc
@@ -7,6 +7,7 @@
#include <string>
#include <vector>
+#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@@ -201,13 +202,24 @@ void SigninManager::SignOut(
ClearTransientSigninData();
const std::string username = GetAuthenticatedUsername();
+ const base::Time signin_time =
+ base::Time::FromInternalValue(
+ client_->GetPrefs()->GetInt64(prefs::kSignedInTime));
clear_authenticated_username();
client_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername);
+ client_->GetPrefs()->ClearPref(prefs::kSignedInTime);
client_->ClearSigninScopedDeviceId();
// Erase (now) stale information from AboutSigninInternals.
NotifyDiagnosticsObservers(USERNAME, "");
+ // Determine the duration the user was logged in and log that to UMA.
+ if (!signin_time.is_null()) {
+ base::TimeDelta signed_in_duration = base::Time::Now() - signin_time;
Alexei Svitkine (slow) 2014/08/12 14:41:49 Note: Be aware that if the user's machine time cha
Mike Lerman 2014/08/12 18:07:10 I assume this will indeed be a very small proporti
+ UMA_HISTOGRAM_COUNTS("Signin.SignedInDurationBeforeSignout",
+ signed_in_duration.InMinutes()));
Roger Tawa OOO till Jul 10th 2014/08/12 14:14:52 Should we be paranoid and check that delta > 0?
Alexei Svitkine (slow) 2014/08/12 14:41:49 I believe it should automatically go in the underf
Mike Lerman 2014/08/12 18:07:10 Acknowledged.
+ }
+
// Revoke all tokens before sending signed_out notification, because there
// may be components that don't listen for token service events when the
// profile is not connected to an account.

Powered by Google App Engine
This is Rietveld 408576698