Chromium Code Reviews| Index: ui/file_manager/file_manager/foreground/js/metrics.js |
| diff --git a/ui/file_manager/file_manager/foreground/js/metrics.js b/ui/file_manager/file_manager/foreground/js/metrics.js |
| index a59491d7b489192dd1661efd77c3f6a03f933091..f8bb675282e02b88bacb14462c6e9b18df40655b 100644 |
| --- a/ui/file_manager/file_manager/foreground/js/metrics.js |
| +++ b/ui/file_manager/file_manager/foreground/js/metrics.js |
| @@ -54,26 +54,51 @@ metrics.call_ = function(name, args) { |
| }; |
| /** |
| - * Create a decorator function that calls a chrome.metricsPrivate function |
| - * with the same name and correct parameters. |
| - * |
| - * @param {string} name Method name. |
| + * Records a value than can range from 1 to 10,000. |
| + * @param {string} name Short metric name. |
| + * @param {number} value Value to be recorded. |
| */ |
| -metrics.decorate = function(name) { |
| - metrics[name] = function() { |
| - var args = Array.apply(null, arguments); |
| - args[0] = metrics.convertName_(args[0]); |
| - metrics.call_(name, args); |
| - if (metrics.log) { |
| - console.log('chrome.metricsPrivate.' + name, args); |
| - } |
| - }; |
| +metrics.recordMediumCount = function(name, value) { |
| + var args = [metrics.convertName_(name), value]; |
| + metrics.call_('recordMediumCount', args); |
| + if (metrics.log) |
| + console.log('chrome.metricsPrivate.recordMediumCount', args); |
| +}; |
| + |
| +/** |
| + * Records a value than can range from 1 to 100. |
| + * @param {string} name Short metric name. |
| + * @param {number} value Value to be recorded. |
| + */ |
| +metrics.recordSmallCount = function(name, value) { |
| + var args = [metrics.convertName_(name), value]; |
| + metrics.call_('recordSmallCount', args); |
| + if (metrics.log) |
|
hirono
2014/10/24 06:45:56
How about moving all the common part to metrics.ca
fukino
2014/10/27 09:11:24
metrics.recordEnum() also calls metrics.call_(), b
hirono
2014/10/27 09:28:45
How about logging part? You also would like to hav
fukino
2014/10/27 09:41:29
Nice suggestion! Thanks!
I moved the logging part
|
| + console.log('chrome.metricsPrivate.recordSmallCount', args); |
| }; |
| -metrics.decorate('recordMediumCount'); |
| -metrics.decorate('recordSmallCount'); |
| -metrics.decorate('recordTime'); |
| -metrics.decorate('recordUserAction'); |
| +/** |
| + * Records an elapsed time of no more than 10 seconds. |
| + * @param {string} name Short metric name. |
| + * @param {number} time Time to be recorded in milliseconds. |
| + */ |
| +metrics.recordTime = function(name, time) { |
| + var args = [metrics.convertName_(name), time]; |
| + metrics.call_('recordTime', args); |
| + if (metrics.log) |
| + console.log('chrome.metricsPrivate.recordTime', args); |
| +}; |
| + |
| +/** |
| + * Records an action performed by the user. |
| + * @param {string} name Short metric name. |
| + */ |
| +metrics.recordUserAction = function(name) { |
| + var args = [metrics.convertName_(name)]; |
| + metrics.call_('recordUserAction', args); |
| + if (metrics.log) |
| + console.log('chrome.metricsPrivate.recordUserAction', args); |
| +}; |
| /** |
| * Complete the time interval recording. |