Bug 948139 - Use UITelemetry to capture clicks on the 'switch to desktop' appbar item. r=mbrubeck

This commit is contained in:
Sam Foster 2014-01-03 11:47:45 -08:00
parent f265af2009
commit bfd87ac71e
2 changed files with 28 additions and 0 deletions

View File

@ -25,6 +25,14 @@ var Appbar = {
// tilegroup selection events for all modules get bubbled up
window.addEventListener("selectionchange", this, false);
// gather appbar telemetry data
try {
UITelemetry.addSimpleMeasureFunction("metro-appbar",
this.getAppbarMeasures.bind(this));
} catch (ex) {
// swallow exception that occurs if metro-appbar measure is already set up
}
},
handleEvent: function Appbar_handleEvent(aEvent) {
@ -149,6 +157,7 @@ var Appbar = {
getService(Components.interfaces.nsIAppStartup);
Services.prefs.setBoolPref('browser.sessionstore.resume_session_once', true);
this._incrementCountableEvent("switch-to-desktop-button");
appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit |
Components.interfaces.nsIAppStartup.eRestart);
},
@ -273,6 +282,22 @@ var Appbar = {
}
},
// track certain appbar events and interactions for the UITelemetry probe
_countableEvents: {},
_incrementCountableEvent: function(aName) {
if (!(aName in this._countableEvents)) {
this._countableEvents[aName] = 0;
}
this._countableEvents[aName]++;
},
getAppbarMeasures: function() {
return {
countableEvents: this._countableEvents
};
},
_updatePinButton: function() {
this.pinButton.checked = Browser.isSitePinned();
},
@ -282,4 +307,5 @@ var Appbar = {
this.starButton.checked = isStarred;
}.bind(this));
},
};

View File

@ -54,6 +54,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task",
XPCOMUtils.defineLazyModuleGetter(this, "OS",
"resource://gre/modules/osfile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "UITelemetry",
"resource://gre/modules/UITelemetry.jsm");
/*
* Services
*/