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

Unified Diff: chrome/browser/resources/hotword/state_manager.js

Issue 667873002: Add UMA to hotword trigger extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add to histograms.xml Created 6 years, 2 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: chrome/browser/resources/hotword/state_manager.js
diff --git a/chrome/browser/resources/hotword/state_manager.js b/chrome/browser/resources/hotword/state_manager.js
index f71755d3cb4f7d28fd375b35afc46a88b3c75654..74c9292f8fb0286b2ae74580efe0ff0ff37cc116 100644
--- a/chrome/browser/resources/hotword/state_manager.js
+++ b/chrome/browser/resources/hotword/state_manager.js
@@ -102,6 +102,33 @@ cr.define('hotword', function() {
};
var State_ = StateManager.State_;
+ var UmaMediaStreamErrors_ = {
+ // These first error are defined by the MediaStream spec:
+ // http://w3c.github.io/mediacapture-main/getusermedia.html#idl-def-MediaStreamError
+ 'NotSupportedError': hotword.constants.UmaMediaStreamError.NOT_SUPPORTED,
+ 'PermissionDeniedError':
+ hotword.constants.UmaMediaStreamError.PERMISSION_DENIED,
+ 'ConstraintNotSatisfiedError':
+ hotword.constants.UmaMediaStreamError.CONSTRAINT_NOT_SATISFIED,
+ 'OverconstrainedError':
+ hotword.constants.UmaMediaStreamError.OVERCONSTRAINED,
+ 'NotFoundError': hotword.constants.UmaMediaStreamError.NOT_FOUND,
+ 'AbortError': hotword.constants.UmaMediaStreamError.ABORT,
+ 'SourceUnavailableError':
+ hotword.constants.UmaMediaStreamError.SOURCE_UNAVAILABLE,
+ // The next few errors are chrome-specific. See:
+ // content/renderer/media/user_media_client_impl.cc
+ // (UserMediaClientImpl::GetUserMediaRequestFailed)
+ 'PermissionDismissedError':
+ hotword.constants.UmaMediaStreamError.PERMISSION_DISMISSED,
+ 'InvalidStateError':
+ hotword.constants.UmaMediaStreamError.INVALID_STATE,
+ 'DevicesNotFoundError':
+ hotword.constants.UmaMediaStreamError.DEVICES_NOT_FOUND,
+ 'InvalidSecurityOriginError':
+ hotword.constants.UmaMediaStreamError.INVALID_SECURITY_ORIGIN
+ };
+
StateManager.prototype = {
/**
* Request status details update. Intended to be called from the
@@ -205,6 +232,16 @@ cr.define('hotword', function() {
}
}.bind(this),
function(error) {
+ if (error.name in UmaMediaStreamErrors_) {
+ var metricValue = UmaMediaStreamErrors_[error.name];
+ } else {
+ var metricValue =
+ hotword.constants.UmaMediaStreamError.UNKNOWN;
+ }
+ hotword.metrics.recordEnum(
+ hotword.constants.UmaMetrics.MEDIA_STREAM_ERROR,
+ metricValue,
+ hotword.constants.UmaMediaStreamError.MAX);
this.state_ = State_.ERROR;
this.pluginManager_ = null;
}.bind(this));
@@ -285,6 +322,8 @@ cr.define('hotword', function() {
*/
onTrigger_: function() {
hotword.debug('Hotword triggered!');
+ chrome.metricsPrivate.recordUserAction(
+ hotword.constants.UmaMetrics.TRIGGER);
assert(this.pluginManager_, 'No NaCl plugin loaded on trigger');
// Detector implicitly stops when the hotword is detected.
this.state_ = State_.STOPPED;

Powered by Google App Engine
This is Rietveld 408576698