From bfd87ac71e35b6dbd6e1987acd1633ed014cc484 Mon Sep 17 00:00:00 2001 From: Sam Foster Date: Fri, 3 Jan 2014 11:47:45 -0800 Subject: [PATCH] Bug 948139 - Use UITelemetry to capture clicks on the 'switch to desktop' appbar item. r=mbrubeck --- browser/metro/base/content/appbar.js | 26 +++++++++++++++++++ browser/metro/base/content/browser-scripts.js | 2 ++ 2 files changed, 28 insertions(+) diff --git a/browser/metro/base/content/appbar.js b/browser/metro/base/content/appbar.js index e4629ed4196..d0b89160d1e 100644 --- a/browser/metro/base/content/appbar.js +++ b/browser/metro/base/content/appbar.js @@ -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)); }, + }; diff --git a/browser/metro/base/content/browser-scripts.js b/browser/metro/base/content/browser-scripts.js index bbbdc3f42c9..0e1290326ad 100644 --- a/browser/metro/base/content/browser-scripts.js +++ b/browser/metro/base/content/browser-scripts.js @@ -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 */