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

Side by Side Diff: components/chrome_apps/webstore_widget/app/main.js

Issue 1204783007: Add metrics for Webstore Gallery Widget app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 //<include src="../../../../ui/webui/resources/js/cr.js"> 5 //<include src="../../../../ui/webui/resources/js/cr.js">
6 //<include src="../../../../ui/webui/resources/js/load_time_data.js"> 6 //<include src="../../../../ui/webui/resources/js/load_time_data.js">
7 //<include src="../../../../ui/webui/resources/js/i18n_template_no_process.js"> 7 //<include src="../../../../ui/webui/resources/js/i18n_template_no_process.js">
8 //<include src="../../../../ui/webui/resources/js/cr/event_target.js"> 8 //<include src="../../../../ui/webui/resources/js/cr/event_target.js">
9 //<include src="../../../../ui/webui/resources/js/cr/ui/dialogs.js"> 9 //<include src="../../../../ui/webui/resources/js/cr/ui/dialogs.js">
10 10
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 strings: { 61 strings: {
62 UI_LOCALE: getString('language'), 62 UI_LOCALE: getString('language'),
63 LINK_TO_WEBSTORE: getString('LINK_TO_WEBSTORE'), 63 LINK_TO_WEBSTORE: getString('LINK_TO_WEBSTORE'),
64 INSTALLATION_FAILED_MESSAGE: getString('INSTALLATION_FAILED_MESSAGE'), 64 INSTALLATION_FAILED_MESSAGE: getString('INSTALLATION_FAILED_MESSAGE'),
65 LOADING_SPINNER_ALT: getString('LOADING_SPINNER_ALT'), 65 LOADING_SPINNER_ALT: getString('LOADING_SPINNER_ALT'),
66 INSTALLING_SPINNER_ALT: getString('INSTALLING_SPINNER_ALT') 66 INSTALLING_SPINNER_ALT: getString('INSTALLING_SPINNER_ALT')
67 }, 67 },
68 68
69 metricsImpl: { 69 metricsImpl: {
70 /** 70 /**
71 * Map from interval name to interval start timestamp.
72 * @type {Object<string, Date>}
73 */
74 intervals: {},
75
76 /**
71 * @param {string} enumName 77 * @param {string} enumName
72 * @param {number} value 78 * @param {number} value
73 * @param {number} enumSize 79 * @param {number} enumSize
74 */ 80 */
75 recordEnum: function(enumName, value, enumSize) {}, 81 recordEnum: function(enumName, value, enumSize) {
82 var index = (value >= 0 && value < enumSize) ? value : enumSize - 1;
83 chrome.metricsPrivate.recordValue({
84 'metricName': 'WebstoreWidgetApp.' + enumName,
85 'type': 'histogram-linear',
86 'min': 1,
87 'max': enumSize,
88 'buckets': enumSize
Ilya Sherman 2015/06/25 21:40:29 Hmm, I think that either max should be "enumSize -
tbarzic 2015/06/25 22:31:09 This is how these values are recorded in File Mana
Ilya Sherman 2015/06/25 22:36:31 It's fine for the underflow bucket to be emitted t
tbarzic 2015/06/25 22:46:12 Done.
89 }, index);
90 },
76 91
77 /** @param {string} actionName */ 92 /** @param {string} actionName */
78 recordUserAction: function(actionName) {}, 93 recordUserAction: function(actionName) {
94 chrome.metricsPrivate.recordUserAction(
95 'WebstoreWidgetApp.' + actionName);
Ilya Sherman 2015/06/25 21:40:30 Please update actions.xml with any actions that yo
tbarzic 2015/06/25 22:31:09 Done.
96 },
79 97
80 /** @param {string} intervalName */ 98 /** @param {string} intervalName */
81 startInterval: function(intervalName) {}, 99 startInterval: function(intervalName) {
100 this.intervals[intervalName] = Date.now();
101 },
82 102
83 /** @param {string} intervalName */ 103 /** @param {string} intervalName */
84 recordInterval: function(intervalName) {} 104 recordInterval: function(intervalName) {
105 if (!intervalName in this.intervals) {
106 console.error('Interval \'' + intervalName + '\' not started');
107 return;
108 }
109
110 chrome.metricsPrivate.recordTime(
111 'WebstoreWidgetApp.' + intervalName,
112 Date.now() - this.intervals[intervalName]);
113 delete this.intervals[intervalName];
114 }
85 }, 115 },
86 116
87 /** 117 /**
88 * @param {string} itemId Item to be installed. 118 * @param {string} itemId Item to be installed.
89 * @param {function(?string)} callback Callback param is the error message, 119 * @param {function(?string)} callback Callback param is the error message,
90 * which is set to null on success. 120 * which is set to null on success.
91 */ 121 */
92 installWebstoreItem: function(itemId, callback) { 122 installWebstoreItem: function(itemId, callback) {
93 chrome.webstoreWidgetPrivate.installWebstoreItem( 123 chrome.webstoreWidgetPrivate.installWebstoreItem(
94 itemId, 124 itemId,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 var result = widgetContainer.finalizeAndGetResult(); 235 var result = widgetContainer.finalizeAndGetResult();
206 showWidgetResult(result.result); 236 showWidgetResult(result.result);
207 }) 237 })
208 /** @param {*} error */ 238 /** @param {*} error */
209 .catch(function(error) { 239 .catch(function(error) {
210 showWidgetResult(CWSWidgetContainer.Result.FAILED); 240 showWidgetResult(CWSWidgetContainer.Result.FAILED);
211 }); 241 });
212 }); 242 });
213 }); 243 });
214 })(); 244 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698