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

Unified 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, 6 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
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];
+ }
},
/**

Powered by Google App Engine
This is Rietveld 408576698