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

Unified Diff: chrome/browser/resources/google_now/background.js

Issue 199793024: Report Metrics on No Card Polling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR Feedback Created 6 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/resources/google_now/background_unittest.gtestjs » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/google_now/background.js
diff --git a/chrome/browser/resources/google_now/background.js b/chrome/browser/resources/google_now/background.js
index acc2aca1aa0d2fa8fc4bbc1cab4e567429d2f20e..8be55592d81acab781bf4b24305191f2c1ca7b2b 100644
--- a/chrome/browser/resources/google_now/background.js
+++ b/chrome/browser/resources/google_now/background.js
@@ -227,7 +227,10 @@ var GoogleNowEvent = {
DELETED_SHOW_WELCOME_TOAST: 8,
STOPPED: 9,
DELETED_USER_SUPPRESSED: 10,
- EVENTS_TOTAL: 11 // EVENTS_TOTAL is not an event; all new events need to be
+ SIGNED_OUT: 11,
+ NOTIFICATION_DISABLED: 12,
+ GOOGLE_NOW_DISABLED: 13,
+ EVENTS_TOTAL: 14 // EVENTS_TOTAL is not an event; all new events need to be
// added before it.
};
@@ -953,6 +956,24 @@ function setBackgroundEnable(backgroundEnable) {
}
/**
+ * Record why this extension would not poll for cards.
+ * @param {boolean} signedIn true if the user is signed in.
+ * @param {boolean} notificationEnabled true if
+ * Google Now for Chrome is allowed to show notifications.
+ * @param {boolean} googleNowEnabled true if
+ * the Google Now is enabled for the user.
+ */
+function recordEventIfNoCards(signedIn, notificationEnabled, googleNowEnabled) {
+ if (!signedIn) {
+ recordEvent(GoogleNowEvent.SIGNED_OUT);
+ } else if (!notificationEnabled) {
+ recordEvent(GoogleNowEvent.NOTIFICATION_DISABLED);
+ } else if (!googleNowEnabled) {
+ recordEvent(GoogleNowEvent.GOOGLE_NOW_DISABLED);
+ }
+}
+
+/**
* Does the actual work of deciding what Google Now should do
* based off of the current state of Chrome.
* @param {boolean} signedIn true if the user is signed in.
@@ -986,6 +1007,8 @@ function updateRunningState(
recordEvent(GoogleNowEvent.STOPPED);
}
+ recordEventIfNoCards(signedIn, notificationEnabled, googleNowEnabled);
+
console.log(
'Requested Actions shouldSetBackground=' + shouldSetBackground + ' ' +
'setShouldPollCards=' + shouldPollCards);
« no previous file with comments | « no previous file | chrome/browser/resources/google_now/background_unittest.gtestjs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698