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

Side by Side Diff: chrome/browser/resources/sync_promo.js

Issue 8528054: Sync Promo: Add more UMA metrics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more code review changes Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/sync_setup_overlay.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // TODO(sail): Refactor options_page and remove this include. 5 // TODO(sail): Refactor options_page and remove this include.
6 <include src="options/options_page.js"/> 6 <include src="options/options_page.js"/>
7 <include src="sync_setup_overlay.js"/> 7 <include src="sync_setup_overlay.js"/>
8 8
9 cr.define('sync_promo', function() { 9 cr.define('sync_promo', function() {
10 /** 10 /**
(...skipping 18 matching lines...) Expand all
29 CREATE_ACCOUNT_CLICKED: i++, 29 CREATE_ACCOUNT_CLICKED: i++,
30 SKIP_CLICKED: i++, 30 SKIP_CLICKED: i++,
31 SIGN_IN_ATTEMPTED: i++, 31 SIGN_IN_ATTEMPTED: i++,
32 SIGNED_IN_SUCCESSFULLY: i++, 32 SIGNED_IN_SUCCESSFULLY: i++,
33 ADVANCED_CLICKED: i++, 33 ADVANCED_CLICKED: i++,
34 ENCRYPTION_HELP_CLICKED: i++, 34 ENCRYPTION_HELP_CLICKED: i++,
35 CANCELLED_AFTER_SIGN_IN: i++, 35 CANCELLED_AFTER_SIGN_IN: i++,
36 CONFIRMED_AFTER_SIGN_IN: i++, 36 CONFIRMED_AFTER_SIGN_IN: i++,
37 CLOSED_TAB: i++, 37 CLOSED_TAB: i++,
38 CLOSED_WINDOW: i++, 38 CLOSED_WINDOW: i++,
39 LEFT_DURING_THROBBER: i++,
39 }; 40 };
40 }()); 41 }());
41 42
42 cr.addSingletonGetter(SyncPromo); 43 cr.addSingletonGetter(SyncPromo);
43 44
44 SyncPromo.prototype = { 45 SyncPromo.prototype = {
45 __proto__: options.SyncSetupOverlay.prototype, 46 __proto__: options.SyncSetupOverlay.prototype,
46 47
47 showOverlay_: function() { 48 showOverlay_: function() {
48 $('sync-setup-overlay').hidden = false; 49 $('sync-setup-overlay').hidden = false;
(...skipping 13 matching lines...) Expand all
62 this.hideOuterLoginUI_(); 63 this.hideOuterLoginUI_();
63 $('sync-setup-login-promo-column').hidden = false; 64 $('sync-setup-login-promo-column').hidden = false;
64 $('promo-skip').hidden = false; 65 $('promo-skip').hidden = false;
65 66
66 this.showSetupUI_(); 67 this.showSetupUI_();
67 chrome.send('SyncPromo:Initialize'); 68 chrome.send('SyncPromo:Initialize');
68 69
69 var self = this; 70 var self = this;
70 71
71 $('promo-skip-button').addEventListener('click', function() { 72 $('promo-skip-button').addEventListener('click', function() {
72 chrome.send('SyncPromo:UserFlowAction', [actions.SKIP_CLICKED]); 73 chrome.send('SyncPromo:UserSkipped');
73 self.closeOverlay_(); 74 self.closeOverlay_();
74 }); 75 });
75 76
76 var learnMoreClickedAlready = false; 77 var learnMoreClickedAlready = false;
77 $('promo-learn-more-show').addEventListener('click', function() { 78 $('promo-learn-more-show').addEventListener('click', function() {
78 self.showLearnMore_(true); 79 self.showLearnMore_(true);
79 if (!learnMoreClickedAlready) 80 if (!learnMoreClickedAlready)
80 chrome.send('SyncPromo:UserFlowAction', [actions.LEARN_MORE_CLICKED]); 81 chrome.send('SyncPromo:UserFlowAction', [actions.LEARN_MORE_CLICKED]);
81 learnMoreClickedAlready = true; 82 learnMoreClickedAlready = true;
82 }); 83 });
(...skipping 19 matching lines...) Expand all
102 if (!createAccountClickedAlready) 103 if (!createAccountClickedAlready)
103 chrome.send('SyncPromo:UserFlowAction', 104 chrome.send('SyncPromo:UserFlowAction',
104 [actions.CREATE_ACCOUNT_CLICKED]); 105 [actions.CREATE_ACCOUNT_CLICKED]);
105 createAccountClickedAlready = true; 106 createAccountClickedAlready = true;
106 }); 107 });
107 108
108 // We listen to the <form>'s submit vs. the <input type="submit"> click so 109 // We listen to the <form>'s submit vs. the <input type="submit"> click so
109 // we also track users that use the keyboard and press enter. 110 // we also track users that use the keyboard and press enter.
110 var signInAttemptedAlready = false; 111 var signInAttemptedAlready = false;
111 $('gaia-login-form').addEventListener('submit', function() { 112 $('gaia-login-form').addEventListener('submit', function() {
113 ++self.signInAttempts_;
112 if (!signInAttemptedAlready) 114 if (!signInAttemptedAlready)
113 chrome.send('SyncPromo:UserFlowAction', [actions.SIGN_IN_ATTEMPTED]); 115 chrome.send('SyncPromo:UserFlowAction', [actions.SIGN_IN_ATTEMPTED]);
114 signInAttemptedAlready = true; 116 signInAttemptedAlready = true;
115 }); 117 });
116 118
117 var encryptionHelpClickedAlready = false; 119 var encryptionHelpClickedAlready = false;
118 $('encryption-help-link').addEventListener('click', function() { 120 $('encryption-help-link').addEventListener('click', function() {
119 if (!encryptionHelpClickedAlready ) 121 if (!encryptionHelpClickedAlready )
120 chrome.send('SyncPromo:UserFlowAction', 122 chrome.send('SyncPromo:UserFlowAction',
121 [actions.ENCRYPTION_HELP_CLICKED]); 123 [actions.ENCRYPTION_HELP_CLICKED]);
(...skipping 18 matching lines...) Expand all
140 this.infographic_ = $('promo-infographic'); 142 this.infographic_ = $('promo-infographic');
141 this.learnMore_ = $('promo-information'); 143 this.learnMore_ = $('promo-information');
142 144
143 this.infographic_.addEventListener('webkitTransitionEnd', 145 this.infographic_.addEventListener('webkitTransitionEnd',
144 this.toggleHidden_.bind(this)); 146 this.toggleHidden_.bind(this));
145 this.learnMore_.addEventListener('webkitTransitionEnd', 147 this.learnMore_.addEventListener('webkitTransitionEnd',
146 this.toggleHidden_.bind(this)); 148 this.toggleHidden_.bind(this));
147 }, 149 },
148 150
149 /** 151 /**
152 * Called when the page is unloading to record number of times a user tried
153 * to sign in and if they left while a throbber was running.
154 * @private
155 */
156 recordPageViewActions_: function() {
157 chrome.send('SyncPromo:RecordSignInAttempts', [this.signInAttempts_]);
158 if (this.throbberStart_)
159 chrome.send('SyncPromo:UserFlowAction', [actions.LEFT_DURING_THROBBER]);
160 },
161
162 /**
150 * Remove the [hidden] attribute from the node that was not previously 163 * Remove the [hidden] attribute from the node that was not previously
151 * transitioning. 164 * transitioning.
152 * @param {Event} e A -webkit-transition end event. 165 * @param {Event} e A -webkit-transition end event.
153 * @private 166 * @private
154 */ 167 */
155 toggleHidden_: function(e) { 168 toggleHidden_: function(e) {
156 // Only show the other element if the target of this event was hidden 169 // Only show the other element if the target of this event was hidden
157 // (showing also triggers a transition end). 170 // (showing also triggers a transition end).
158 if (e.target.hidden) { 171 if (e.target.hidden) {
159 if (e.target === this.infographic_) 172 if (e.target === this.infographic_)
(...skipping 26 matching lines...) Expand all
186 }, 199 },
187 200
188 /** 201 /**
189 * Shows or hides the title of the promo page. 202 * Shows or hides the title of the promo page.
190 * @param {Boolean} visible true if the title should be visible, false 203 * @param {Boolean} visible true if the title should be visible, false
191 * otherwise. 204 * otherwise.
192 * @private 205 * @private
193 */ 206 */
194 setPromoTitleVisible_: function(visible) { 207 setPromoTitleVisible_: function(visible) {
195 $('promo-title').hidden = !visible; 208 $('promo-title').hidden = !visible;
196 } 209 },
210
211 /** @inheritDoc */
212 setThrobbersVisible_: function(visible) {
213 if (visible) {
214 this.throbberStart_ = Date.now();
215 } else {
216 if (this.throbberStart_) {
217 chrome.send('SyncPromo:RecordThrobberTime',
218 [Date.now() - this.throbberStart_]);
219 }
220 this.throbberStart_ = 0;
221 }
222 // Pass through to SyncSetupOverlay to handle display logic.
223 options.SyncSetupOverlay.prototype.setThrobbersVisible_.apply(
224 this, arguments);
225 },
226
227 /**
228 * Number of times a user attempted to sign in to GAIA during this page
229 * view.
230 * @private
231 */
232 signInAttempts_: 0,
233
234 /**
235 * The start time of a throbber on the page.
236 * @private
237 */
238 throbberStart_: 0,
197 }; 239 };
198 240
199 SyncPromo.showErrorUI = function() { 241 SyncPromo.showErrorUI = function() {
200 SyncPromo.getInstance().showErrorUI_(); 242 SyncPromo.getInstance().showErrorUI_();
201 }; 243 };
202 244
203 SyncPromo.showSetupUI = function() { 245 SyncPromo.showSetupUI = function() {
204 SyncPromo.getInstance().showSetupUI_(); 246 SyncPromo.getInstance().showSetupUI_();
205 }; 247 };
206 248
(...skipping 13 matching lines...) Expand all
220 SyncPromo.showStopSyncingUI = function() { 262 SyncPromo.showStopSyncingUI = function() {
221 SyncPromo.getInstance().showStopSyncingUI_(); 263 SyncPromo.getInstance().showStopSyncingUI_();
222 }; 264 };
223 265
224 SyncPromo.initialize = function() { 266 SyncPromo.initialize = function() {
225 SyncPromo.getInstance().initializePage(); 267 SyncPromo.getInstance().initializePage();
226 }; 268 };
227 269
228 SyncPromo.setPromoTitleVisible = function(visible) { 270 SyncPromo.setPromoTitleVisible = function(visible) {
229 SyncPromo.getInstance().setPromoTitleVisible_(visible); 271 SyncPromo.getInstance().setPromoTitleVisible_(visible);
230 } 272 };
273
274 SyncPromo.recordPageViewActions = function() {
275 SyncPromo.getInstance().recordPageViewActions_();
276 };
231 277
232 // Export 278 // Export
233 return { 279 return {
234 SyncPromo : SyncPromo 280 SyncPromo: SyncPromo
235 }; 281 };
236 }); 282 });
237 283
238 var OptionsPage = options.OptionsPage; 284 var OptionsPage = options.OptionsPage;
239 var SyncSetupOverlay = sync_promo.SyncPromo; 285 var SyncSetupOverlay = sync_promo.SyncPromo;
240 window.addEventListener('DOMContentLoaded', sync_promo.SyncPromo.initialize); 286 window.addEventListener('DOMContentLoaded', sync_promo.SyncPromo.initialize);
287 window.addEventListener('beforeunload',
288 sync_promo.SyncPromo.recordPageViewActions.bind(sync_promo.SyncPromo));
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/sync_setup_overlay.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698