Index: components/chrome_apps/webstore_widget/app/main.js |
diff --git a/components/chrome_apps/webstore_widget/app/main.js b/components/chrome_apps/webstore_widget/app/main.js |
index 1151da84a367588a199a5f6da0440fa529f86c89..f0ca4676ec4f5ea5420921b248ecb6dc6cf4ac8c 100644 |
--- a/components/chrome_apps/webstore_widget/app/main.js |
+++ b/components/chrome_apps/webstore_widget/app/main.js |
@@ -68,20 +68,50 @@ function createPlatformDelegate(strings) { |
metricsImpl: { |
/** |
+ * Map from interval name to interval start timestamp. |
+ * @type {Object<string, Date>} |
+ */ |
+ intervals: {}, |
+ |
+ /** |
* @param {string} enumName |
* @param {number} value |
* @param {number} enumSize |
*/ |
- recordEnum: function(enumName, value, enumSize) {}, |
+ recordEnum: function(enumName, value, enumSize) { |
+ var index = (value >= 0 && value < enumSize) ? value : enumSize; |
+ chrome.metricsPrivate.recordValue({ |
+ 'metricName': 'WebstoreWidgetApp.' + enumName, |
+ 'type': 'histogram-linear', |
+ 'min': 1, |
+ 'max': enumSize, |
+ 'buckets': enumSize + 1 |
+ }, index); |
+ }, |
/** @param {string} actionName */ |
- recordUserAction: function(actionName) {}, |
+ recordUserAction: function(actionName) { |
+ chrome.metricsPrivate.recordUserAction( |
+ 'WebstoreWidgetApp.' + actionName); |
+ }, |
/** @param {string} intervalName */ |
- startInterval: function(intervalName) {}, |
+ startInterval: function(intervalName) { |
+ this.intervals[intervalName] = Date.now(); |
+ }, |
/** @param {string} intervalName */ |
- recordInterval: function(intervalName) {} |
+ recordInterval: function(intervalName) { |
+ if (!intervalName in this.intervals) { |
+ console.error('Interval \'' + intervalName + '\' not started'); |
+ return; |
+ } |
+ |
+ chrome.metricsPrivate.recordTime( |
+ 'WebstoreWidgetApp.' + intervalName, |
+ Date.now() - this.intervals[intervalName]); |
+ delete this.intervals[intervalName]; |
+ } |
}, |
/** |