Index: chrome/browser/resources/sync_promo.js |
diff --git a/chrome/browser/resources/sync_promo.js b/chrome/browser/resources/sync_promo.js |
index e2366dbfd80612f9a7578b75d91cf1d933f54873..046413ec300d200b83132e3a7e17a46e130639e1 100644 |
--- a/chrome/browser/resources/sync_promo.js |
+++ b/chrome/browser/resources/sync_promo.js |
@@ -36,6 +36,7 @@ cr.define('sync_promo', function() { |
CONFIRMED_AFTER_SIGN_IN: i++, |
CLOSED_TAB: i++, |
CLOSED_WINDOW: i++, |
+ LEFT_DURING_THROBBER: i++, |
}; |
}()); |
@@ -109,6 +110,7 @@ cr.define('sync_promo', function() { |
// we also track users that use the keyboard and press enter. |
var signInAttemptedAlready = false; |
$('gaia-login-form').addEventListener('submit', function() { |
+ ++self.signInAttempts_; |
if (!signInAttemptedAlready) |
chrome.send('SyncPromo:UserFlowAction', [actions.SIGN_IN_ATTEMPTED]); |
signInAttemptedAlready = true; |
@@ -147,6 +149,18 @@ cr.define('sync_promo', function() { |
}, |
/** |
+ * Called when the page is unloading to record number of times a user tried |
+ * to sign in and if they left while a throbber was running. |
+ */ |
+ recordPageViewActions_: function() { |
+ chrome.send('SyncPromo:RecordSignInAttempts', [this.signInAttempts_]); |
+ if (typeof this.throbberStart_ == 'number' && |
+ window.isFinite(this.throbberStart_)) { |
+ chrome.send('SyncPromo:UserFlowAction', [actions.LEFT_DURING_THROBBER]); |
+ } |
+ }, |
+ |
+ /** |
* Remove the [hidden] attribute from the node that was not previously |
* transitioning. |
* @param {Event} e A -webkit-transition end event. |
@@ -193,7 +207,37 @@ cr.define('sync_promo', function() { |
*/ |
setPromoTitleVisible_: function(visible) { |
$('promo-title').hidden = !visible; |
- } |
+ }, |
+ |
+ /** @inheritDoc */ |
+ setThrobbersVisible_: function(visible) { |
+ if (visible) { |
+ this.throbberStart_ = Date.now(); |
+ } else { |
+ if (typeof this.throbberStart_ == 'number' && |
+ window.isFinite(this.throbberStart_)) { |
+ chrome.send('SyncPromo:RecordThrobberTime', |
+ [Date.now() - this.throbberStart_]); |
+ } |
+ this.throbberStart_ = null; |
+ } |
+ // Pass through to SyncSetupOverlay to handle display logic. |
+ options.SyncSetupOverlay.prototype.setThrobbersVisible_.apply( |
+ this, arguments); |
+ }, |
+ |
+ /** |
+ * Number of times a user attempted to sign in to GAIA during this page |
+ * view. |
+ * @private |
+ */ |
+ signInAttempts_: 0, |
+ |
+ /** |
+ * The start time of a throbber on the page. |
+ * @private |
+ */ |
+ throbberStart_: null, |
Evan Stade
2011/11/15 17:45:19
why are you complicating this by setting it to nul
Dan Beam
2011/11/15 18:37:13
Done.
|
}; |
SyncPromo.showErrorUI = function() { |
@@ -227,14 +271,20 @@ cr.define('sync_promo', function() { |
SyncPromo.setPromoTitleVisible = function(visible) { |
SyncPromo.getInstance().setPromoTitleVisible_(visible); |
- } |
+ }; |
+ |
+ SyncPromo.recordPageViewActions = function() { |
+ SyncPromo.getInstance().recordPageViewActions_(); |
+ }; |
// Export |
return { |
- SyncPromo : SyncPromo |
+ SyncPromo: SyncPromo |
}; |
}); |
var OptionsPage = options.OptionsPage; |
var SyncSetupOverlay = sync_promo.SyncPromo; |
window.addEventListener('DOMContentLoaded', sync_promo.SyncPromo.initialize); |
+window.addEventListener('beforeunload', |
+ sync_promo.SyncPromo.recordPageViewActions); |