Bug 948139 - Use UITelemetry to capture clicks on the 'switch to desktop' appbar item. r=mbrubeck, a=lsblakk
authorSam Foster <sfoster@mozilla.com>
Fri, 03 Jan 2014 11:47:45 -0800
changeset 175606 bfc367d67c4a0f48297460d7634e2cc974e9b6fa
parent 175605 934b1761c773c24403cb7f2a832fe99a4930131b
child 175607 1c16411289e4bc4202c5786fc463ed7a978f8afc
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck, lsblakk
bugs948139
milestone28.0a2
Bug 948139 - Use UITelemetry to capture clicks on the 'switch to desktop' appbar item. r=mbrubeck, a=lsblakk
browser/metro/base/content/appbar.js
browser/metro/base/content/browser-scripts.js
--- a/browser/metro/base/content/appbar.js
+++ b/browser/metro/base/content/appbar.js
@@ -20,16 +20,24 @@ var Appbar = {
     window.addEventListener('MozContextActionsChange', this, false);
 
     // browser events we need to update button state on
     Elements.browsers.addEventListener('URLChanged', this, true);
     Elements.tabList.addEventListener('TabSelect', this, true);
 
     // 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) {
     switch (aEvent.type) {
       case 'URLChanged':
       case 'TabSelect':
         this.update();
         this.flushActiveTileset(aEvent.lastTab);
@@ -144,16 +152,17 @@ var Appbar = {
       });
   },
 
   onViewOnDesktop: function() {
     let appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"].
       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);
   },
 
   onAutocompleteCloseButton: function () {
     Elements.autocomplete.closePopup();
   },
 
@@ -268,18 +277,35 @@ var Appbar = {
 
     if (verbs.length) {
       Elements.contextappbar.show(); // should be no-op if we're already showing
     } else {
       Elements.contextappbar.dismiss();
     }
   },
 
+  // 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();
   },
 
   _updateStarButton: function() {
     Browser.isSiteStarredAsync(function (isStarred) {
       this.starButton.checked = isStarred;
     }.bind(this));
   },
+
 };
--- a/browser/metro/base/content/browser-scripts.js
+++ b/browser/metro/base/content/browser-scripts.js
@@ -41,16 +41,18 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource://gre/modules/commonjs/sdk/core/promise.js");
 
 XPCOMUtils.defineLazyModuleGetter(this, "Task",
                                   "resource://gre/modules/Task.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "OS",
                                   "resource://gre/modules/osfile.jsm");
 
+XPCOMUtils.defineLazyModuleGetter(this, "UITelemetry",
+                                  "resource://gre/modules/UITelemetry.jsm");
 /*
  * Services
  */
 
 XPCOMUtils.defineLazyServiceGetter(this, "StyleSheetSvc",
                                    "@mozilla.org/content/style-sheet-service;1",
                                    "nsIStyleSheetService");
 XPCOMUtils.defineLazyServiceGetter(window, "gHistSvc",