Bug 1443609 - Remove legacy components from `UITelemetry` r=chutten
authorJan-Erik Rediger <janerik@fnordig.de>
Wed, 04 Apr 2018 07:39:00 +0300
changeset 777895 68ef8c8c50f6fff0d4ae1192edc6b208f755deba
parent 777894 4dfc990e1b9cd13dea1d3fdc03ccb0348836a9f2
child 777896 739f1e73cac0bec6df02cd62f9067c31b15851b9
push id105320
push userbmo:dharvey@mozilla.com
push dateThu, 05 Apr 2018 13:17:43 +0000
reviewerschutten
bugs1443609, 1443605
milestone61.0a1
Bug 1443609 - Remove legacy components from `UITelemetry` r=chutten Reporting was already disabled in Bug 1443605. This keeps the `enabled` getter as a way to detect if it is enabled, in use in BrowserUITelemetry only. This keeps `addEvent` and related methods, as they are still in use on Android.
browser/docs/UITelemetry.rst
browser/modules/BrowserUITelemetry.jsm
toolkit/components/telemetry/UITelemetry.jsm
--- a/browser/docs/UITelemetry.rst
+++ b/browser/docs/UITelemetry.rst
@@ -1,13 +1,17 @@
 .. _uitelemetry:
 
-=======================
-UITelemetry data format
-=======================
+==================================
+UITelemetry data format (obsolete)
+==================================
+
+.. note::
+
+    ``UITelemetry`` is deprecated. As of Firefox 61, ``UITelemetry`` is no longer reported.
 
 UI Telemetry sends its data as a JSON blob. This document describes the different parts
 of the JSON blob.
 
 ``toolbars``
 ============
 
 This tracks the state of the user's UI customizations. It has the following properties:
--- a/browser/modules/BrowserUITelemetry.jsm
+++ b/browser/modules/BrowserUITelemetry.jsm
@@ -6,18 +6,16 @@
 
 var EXPORTED_SYMBOLS = ["BrowserUITelemetry"];
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 ChromeUtils.defineModuleGetter(this, "AppConstants",
   "resource://gre/modules/AppConstants.jsm");
-ChromeUtils.defineModuleGetter(this, "UITelemetry",
-  "resource://gre/modules/UITelemetry.jsm");
 ChromeUtils.defineModuleGetter(this, "RecentWindow",
   "resource:///modules/RecentWindow.jsm");
 ChromeUtils.defineModuleGetter(this, "CustomizableUI",
   "resource:///modules/CustomizableUI.jsm");
 ChromeUtils.defineModuleGetter(this, "UITour",
   "resource:///modules/UITour.jsm");
 XPCOMUtils.defineLazyGetter(this, "Timer", function() {
   let timer = {};
@@ -161,28 +159,16 @@ const BUCKET_DEFAULT = "__DEFAULT__";
 // Bucket prefix, for named buckets.
 const BUCKET_PREFIX = "bucket_";
 // Standard separator to use between different parts of a bucket name, such
 // as primary name and the time step string.
 const BUCKET_SEPARATOR = "|";
 
 var BrowserUITelemetry = {
   init() {
-    UITelemetry.addSimpleMeasureFunction("toolbars",
-                                         this.getToolbarMeasures.bind(this));
-    UITelemetry.addSimpleMeasureFunction("contextmenu",
-                                         this.getContextMenuInfo.bind(this));
-    // Ensure that UITour.jsm remains lazy-loaded, yet always registers its
-    // simple measure function with UITelemetry.
-    UITelemetry.addSimpleMeasureFunction("UITour",
-                                         () => UITour.getTelemetry());
-
-    UITelemetry.addSimpleMeasureFunction("syncstate",
-                                         this.getSyncState.bind(this));
-
     Services.obs.addObserver(this, "autocomplete-did-enter-text");
     CustomizableUI.addListener(this);
 
     // Register existing windows
     let browserEnum = Services.wm.getEnumerator("navigator:browser");
     while (browserEnum.hasMoreElements()) {
       this._registerWindow(browserEnum.getNext());
     }
--- a/toolkit/components/telemetry/UITelemetry.jsm
+++ b/toolkit/components/telemetry/UITelemetry.jsm
@@ -65,23 +65,16 @@ var UITelemetry = {
    * This exists exclusively for testing -- our events are not intended to
    * be retrieved via an XPCOM interface.
    */
   get wrappedJSObject() {
     return this;
   },
 
   /**
-   * Holds the functions that provide UITelemetry's simple
-   * measurements. Those functions are mapped to unique names,
-   * and should be registered with addSimpleMeasureFunction.
-   */
-  _simpleMeasureFunctions: {},
-
-  /**
    * A hack to generate the relative timestamp from start when we don't have
    * access to the Java timer.
    * XXX: Bug 1007647 - Support realtime and/or uptime in JavaScript.
    */
   uptimeMillis() {
     return Date.now() - Services.startup.getStartupInfo().process;
   },
 
@@ -156,63 +149,16 @@ var UITelemetry = {
     this._recordEvent(aEvent);
   },
 
   _recordEvent(aEvent) {
     this._measurements.push(aEvent);
   },
 
   /**
-   * Called by TelemetrySession to populate the simple measurement
-   * blob. This function will iterate over all functions added
-   * via addSimpleMeasureFunction and return an object with the
-   * results of those functions.
-   */
-  getSimpleMeasures() {
-    if (!this.enabled) {
-      return {};
-    }
-
-    let result = {};
-    for (let name in this._simpleMeasureFunctions) {
-      result[name] = this._simpleMeasureFunctions[name]();
-    }
-    return result;
-  },
-
-  /**
-   * Allows the caller to register functions that will get called
-   * for simple measures during a Telemetry ping. aName is a unique
-   * identifier used as they key for the simple measurement in the
-   * object that getSimpleMeasures returns.
-   *
-   * This function throws an exception if aName already has a function
-   * registered for it.
-   */
-  addSimpleMeasureFunction(aName, aFunction) {
-    if (!this.enabled) {
-      return;
-    }
-
-    if (aName in this._simpleMeasureFunctions) {
-      throw new Error("A simple measurement function is already registered for " + aName);
-    }
-
-    if (!aFunction || typeof aFunction !== "function") {
-      throw new Error("addSimpleMeasureFunction called with non-function argument.");
-    }
-
-    this._simpleMeasureFunctions[aName] = aFunction;
-  },
-
-  removeSimpleMeasureFunction(aName) {
-    delete this._simpleMeasureFunctions[aName];
-  },
-
-  /**
    * Called by TelemetrySession to populate the UI measurement
    * blob.
    *
    * Optionally clears the set of measurements based on aClear.
    */
   getUIMeasurements(aClear) {
     if (!this.enabled) {
       return [];