Bug 945499 - Switch BrowserUITelemetry from using UITelemetry's event logging to just counting events. r=Gijs, a=lsblakk.
authorMike Conley <mconley@mozilla.com>
Mon, 16 Dec 2013 11:45:53 -0500
changeset 167720 71be3d716c22d327da28e4035ce6965422ac52b9
parent 167719 c587a37ab70b218166cd0ecc1ad4f855070a038e
child 167721 bb07aea479a83a6bd0f72c43eca4567408ead55d
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, lsblakk
bugs945499
milestone27.0
Bug 945499 - Switch BrowserUITelemetry from using UITelemetry's event logging to just counting events. r=Gijs, a=lsblakk.
browser/modules/BrowserUITelemetry.jsm
--- a/browser/modules/BrowserUITelemetry.jsm
+++ b/browser/modules/BrowserUITelemetry.jsm
@@ -205,16 +205,30 @@ this.BrowserUITelemetry = {
   },
 
   observe: function(aSubject, aTopic, aData) {
     if (aTopic == "browser-delayed-startup-finished") {
       this._registerWindow(aSubject);
     }
   },
 
+  _countableEvents: {},
+  _countEvent: function(aCategory, aAction) {
+    if (!(aCategory in this._countableEvents)) {
+      this._countableEvents[aCategory] = {};
+    }
+
+    let categoryEvents = this._countableEvents[aCategory];
+
+    if (!(aAction in categoryEvents)) {
+      categoryEvents[aAction] = 0;
+    }
+    categoryEvents[aAction]++;
+  },
+
   _registerWindow: function(aWindow) {
     aWindow.addEventListener("unload", this);
     let document = aWindow.document;
 
     let appMenuButton = document.getElementById("appmenu-button");
     if (appMenuButton) {
       appMenuButton.addEventListener("mouseup", this);
     }
@@ -246,17 +260,17 @@ this.BrowserUITelemetry = {
 
     if (aEvent.originalTarget.id == "appmenu-button") {
       itemId = aEvent.originalTarget.id;
     } else {
       // We must have clicked on a child of the appmenu
       itemId = this._getAppmenuItemId(aEvent);
     }
 
-    UITelemetry.addEvent("appmenu:" + itemId, "mouseup");
+    this._countEvent("click-appmenu", itemId);
   },
 
   _getAppmenuItemId: function(aEvent) {
     let candidate =
       aEvent.originalTarget.id ? aEvent.originalTarget.id
                                : getIDBasedOnFirstIDedAncestor(aEvent.originalTarget);
 
     // We only accept items that are in our whitelist OR start with
@@ -266,17 +280,17 @@ this.BrowserUITelemetry = {
          APPMENU_PREFIX_WHITELIST.some( s => candidate.startsWith(s) ))) {
       return candidate;
     }
 
     return "unrecognized";
   },
 
   countCustomizationEvent: function(aCustomizationEvent) {
-    UITelemetry.addEvent("customize:" + aCustomizationEvent, null);
+    this._countEvent("customize", aCustomizationEvent);
   },
 
   getToolbarMeasures: function() {
     // Grab the most recent non-popup, non-private browser window for us to
     // analyze the toolbars in...
     let win = RecentWindow.getMostRecentBrowserWindow({
       private: false,
       allowPopups: false
@@ -337,16 +351,18 @@ this.BrowserUITelemetry = {
     let defaultRemoved = [node.id for (node of paletteChildren)
                           if (DEFAULT_ITEMS.indexOf(node.id) != -1)];
 
     result.defaultKept = defaultKept;
     result.defaultMoved = defaultMoved;
     result.nondefaultAdded = nondefaultAdded;
     result.defaultRemoved = defaultRemoved;
 
+    result.countableEvents = this._countableEvents;
+
     return result;
   },
 };
 
 /**
  * Returns the id of the first ancestor of aNode that has an id, with
  * ":child" appended to it. If aNode has no parent, or no ancestor has an
  * id, returns null.