Bug 1236580 - Remove the IS_UNIFIED_TELEMETRY constant and the related preferences. r=gfritzsche
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Wed, 27 Jan 2016 01:03:00 +0100
changeset 281864 fa59fd64e745b3af37b36c813f1b2e2e779a9fa6
parent 281863 1686b901daa4eb42e6bbae2e9ba23c9754c584da
child 281865 d359f149bf63826eefba0276ddb6050141af158c
push id17271
push useralessio.placitelli@gmail.com
push dateThu, 28 Jan 2016 07:46:18 +0000
treeherderfx-team@d359f149bf63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1236580
milestone47.0a1
Bug 1236580 - Remove the IS_UNIFIED_TELEMETRY constant and the related preferences. r=gfritzsche
browser/app/profile/firefox.js
browser/base/content/abouthealthreport/abouthealth.js
testing/mozbase/mozprofile/mozprofile/profile.py
testing/profiles/prefs_general.js
toolkit/components/telemetry/TelemetryController.jsm
toolkit/components/telemetry/TelemetryEnvironment.jsm
toolkit/components/telemetry/healthreport-prefs.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1532,18 +1532,16 @@ pref("browser.translation.neverForLangua
 // Show the translation UI bits, like the info bar, notification icon and preferences.
 pref("browser.translation.ui.show", false);
 // Allows to define the translation engine. Bing is default, Yandex may optionally switched on.
 pref("browser.translation.engine", "bing");
 
 // Telemetry settings.
 // Determines if Telemetry pings can be archived locally.
 pref("toolkit.telemetry.archive.enabled", true);
-// Whether we enable opt-out Telemetry for a sample of the release population.
-pref("toolkit.telemetry.optoutSample", true);
 
 // Telemetry experiments settings.
 pref("experiments.enabled", true);
 pref("experiments.manifest.fetchIntervalSeconds", 86400);
 pref("experiments.manifest.uri", "https://telemetry-experiment.cdn.mozilla.net/manifest/v1/firefox/%VERSION%/%CHANNEL%");
 // Whether experiments are supported by the current application profile.
 pref("experiments.supported", true);
 
--- a/browser/base/content/abouthealthreport/abouthealth.js
+++ b/browser/base/content/abouthealthreport/abouthealth.js
@@ -7,38 +7,32 @@
 var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/Preferences.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 const prefs = new Preferences("datareporting.healthreport.");
 
 const PREF_UNIFIED = "toolkit.telemetry.unified";
-const PREF_UNIFIED_OPTIN = "toolkit.telemetry.unifiedIsOptIn";
-
-// Whether v4 behavior is enabled, i.e. unified Telemetry features are on by default.
-const IS_V4 = Preferences.get(PREF_UNIFIED, false) &&
-              !Preferences.get(PREF_UNIFIED_OPTIN, false);
+const PREF_REPORTING_URL = "datareporting.healthreport.about.reportUrl";
 
 var healthReportWrapper = {
   init: function () {
     let iframe = document.getElementById("remote-report");
     iframe.addEventListener("load", healthReportWrapper.initRemotePage, false);
     iframe.src = this._getReportURI().spec;
     prefs.observe("uploadEnabled", this.updatePrefState, healthReportWrapper);
   },
 
   uninit: function () {
     prefs.ignore("uploadEnabled", this.updatePrefState, healthReportWrapper);
   },
 
   _getReportURI: function () {
-    const pref = IS_V4 ? "datareporting.healthreport.about.reportUrl"
-                       : "datareporting.healthreport.about.reportUrlUnified";
-    let url = Services.urlFormatter.formatURLPref(pref);
+    let url = Services.urlFormatter.formatURLPref(PREF_REPORTING_URL);
     return Services.io.newURI(url, null, null);
   },
 
   setDataSubmission: function (enabled) {
     MozSelfSupport.healthReportDataSubmissionEnabled = enabled;
     this.updatePrefState();
   },
 
--- a/testing/mozbase/mozprofile/mozprofile/profile.py
+++ b/testing/mozbase/mozprofile/mozprofile/profile.py
@@ -380,19 +380,16 @@ class FirefoxProfile(Profile):
                    'security.notification_enable_delay' : 0,
                    # Suppress automatic safe mode after crashes
                    'toolkit.startup.max_resumed_crashes' : -1,
                    # Don't report telemetry information
                    'toolkit.telemetry.enabled' : False,
                    # Don't send Telemetry reports to the production server. This is
                    # needed as Telemetry sends pings also if FHR upload is enabled.
                    'toolkit.telemetry.server' : 'http://%(server)s/telemetry-dummy/',
-                   # Our current tests expect the unified Telemetry feature to be opt-out,
-                   # which is not true while we hold back shipping it.
-                   'toolkit.telemetry.unifiedIsOptIn': True,
                    }
 
 class MetroFirefoxProfile(Profile):
     """Specialized Profile subclass for Firefox Metro"""
 
     preferences = {# Don't automatically update the application for desktop and metro build
                    'app.update.enabled' : False,
                    'app.update.metro.enabled' : False,
--- a/testing/profiles/prefs_general.js
+++ b/testing/profiles/prefs_general.js
@@ -140,18 +140,17 @@ user_pref("network.activity.blipInterval
 // We do not wish to display datareporting policy notifications as it might
 // cause other tests to fail. Tests that wish to test the notification functionality
 // should explicitly disable this pref.
 user_pref("datareporting.policy.dataSubmissionPolicyBypassNotification", true);
 
 // Point Firefox Health Report at a local server. We don't care if it actually
 // works. It just can't hit the default production endpoint.
 user_pref("datareporting.healthreport.documentServerURI", "http://%(server)s/healthreport/");
-user_pref("datareporting.healthreport.about.reportUrl", "http://%(server)s/abouthealthreport/");
-user_pref("datareporting.healthreport.about.reportUrlUnified", "http://%(server)s/abouthealthreport/v4/");
+user_pref("datareporting.healthreport.about.reportUrl", "http://%(server)s/abouthealthreport/v4/");
 
 // Make sure CSS error reporting is enabled for tests
 user_pref("layout.css.report_errors", true);
 
 // Enable CSS Grid for testing
 user_pref("layout.css.grid.enabled", true);
 
 // Enable CSS 'contain' for testing
@@ -228,19 +227,16 @@ user_pref('browser.contentHandlers.types
 user_pref('browser.contentHandlers.types.1.uri', 'http://test1.example.org/rss?url=%%s')
 user_pref('browser.contentHandlers.types.2.uri', 'http://test1.example.org/rss?url=%%s')
 user_pref('browser.contentHandlers.types.3.uri', 'http://test1.example.org/rss?url=%%s')
 user_pref('browser.contentHandlers.types.4.uri', 'http://test1.example.org/rss?url=%%s')
 user_pref('browser.contentHandlers.types.5.uri', 'http://test1.example.org/rss?url=%%s')
 
 // We want to collect telemetry, but we don't want to send in the results.
 user_pref('toolkit.telemetry.server', 'https://%(server)s/telemetry-dummy/');
-// Our current tests expect the unified Telemetry feature to be opt-out,
-// which is not true while we hold back shipping it.
-user_pref('toolkit.telemetry.unifiedIsOptIn', false);
 
 // A couple of preferences with default values to test that telemetry preference
 // watching is working.
 user_pref('toolkit.telemetry.test.pref1', true);
 user_pref('toolkit.telemetry.test.pref2', false);
 
 // We don't want to hit the real Firefox Accounts server for tests.  We don't
 // actually need a functioning FxA server, so just set it to something that
--- a/toolkit/components/telemetry/TelemetryController.jsm
+++ b/toolkit/components/telemetry/TelemetryController.jsm
@@ -34,25 +34,20 @@ const PREF_BRANCH = "toolkit.telemetry."
 const PREF_BRANCH_LOG = PREF_BRANCH + "log.";
 const PREF_SERVER = PREF_BRANCH + "server";
 const PREF_LOG_LEVEL = PREF_BRANCH_LOG + "level";
 const PREF_LOG_DUMP = PREF_BRANCH_LOG + "dump";
 const PREF_CACHED_CLIENTID = PREF_BRANCH + "cachedClientID";
 const PREF_FHR_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
 const PREF_SESSIONS_BRANCH = "datareporting.sessions.";
 const PREF_UNIFIED = PREF_BRANCH + "unified";
-const PREF_UNIFIED_OPTIN = PREF_BRANCH + "unifiedIsOptIn";
-const PREF_OPTOUT_SAMPLE = PREF_BRANCH + "optoutSample";
 
 // Whether the FHR/Telemetry unification features are enabled.
 // Changing this pref requires a restart.
 const IS_UNIFIED_TELEMETRY = Preferences.get(PREF_UNIFIED, false);
-// This preference allows to leave unified Telemetry behavior on only for people that
-// opted into Telemetry. Changing this pref requires a restart.
-const IS_UNIFIED_OPTIN = Preferences.get(PREF_UNIFIED_OPTIN, false);
 
 const PING_FORMAT_VERSION = 4;
 
 // Delay before intializing telemetry (ms)
 const TELEMETRY_DELAY = Preferences.get("toolkit.telemetry.initDelay", 60) * 1000;
 // Delay before initializing telemetry if we're testing (ms)
 const TELEMETRY_TEST_DELAY = 100;
 
@@ -85,39 +80,16 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource://gre/modules/TelemetryArchive.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "TelemetrySession",
                                   "resource://gre/modules/TelemetrySession.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "TelemetrySend",
                                   "resource://gre/modules/TelemetrySend.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "TelemetryReportingPolicy",
                                   "resource://gre/modules/TelemetryReportingPolicy.jsm");
 
-XPCOMUtils.defineLazyGetter(this, "gCrcTable", function() {
-  let c;
-  let table = [];
-  for (let n = 0; n < 256; n++) {
-      c = n;
-      for (let k =0; k < 8; k++) {
-          c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
-      }
-      table[n] = c;
-  }
-  return table;
-});
-
-function crc32(str) {
-    let crc = 0 ^ (-1);
-
-    for (let i = 0; i < str.length; i++ ) {
-        crc = (crc >>> 8) ^ gCrcTable[(crc ^ str.charCodeAt(i)) & 0xFF];
-    }
-
-    return (crc ^ (-1)) >>> 0;
-}
-
 /**
  * Setup Telemetry logging. This function also gets called when loggin related
  * preferences change.
  */
 var gLogger = null;
 var gLogAppenderDump = null;
 function configureLogging() {
   if (!gLogger) {
@@ -148,17 +120,16 @@ function configureLogging() {
 
 /**
  * This is a policy object used to override behavior for testing.
  */
 var Policy = {
   now: () => new Date(),
   generatePingId: () => Utils.generateUUID(),
   getCachedClientID: () => ClientID.getCachedClientID(),
-  isUnifiedOptin: () => IS_UNIFIED_OPTIN,
 }
 
 this.EXPORTED_SYMBOLS = ["TelemetryController"];
 
 this.TelemetryController = Object.freeze({
   Constants: Object.freeze({
     PREF_LOG_LEVEL: PREF_LOG_LEVEL,
     PREF_LOG_DUMP: PREF_LOG_DUMP,
@@ -323,25 +294,16 @@ this.TelemetryController = Object.freeze
    *
    * @return The client id as string, or null.
    */
   get clientID() {
     return Impl.clientID;
   },
 
   /**
-   * Whether this client is part of a sample that gets opt-out Telemetry.
-   *
-   * @return {Boolean} Whether the client is part of the opt-out sample.
-   */
-  get isInOptoutSample() {
-    return Impl.isInOptoutSample;
-  },
-
-  /**
    * The AsyncShutdown.Barrier to synchronize with TelemetryController shutdown.
    */
   get shutdown() {
     return Impl._shutdownBarrier.client;
   },
 
   /**
    * The session recorder instance managed by Telemetry.
@@ -615,66 +577,36 @@ var Impl = {
     return TelemetryStorage.saveAbortedSessionPing(pingData);
   },
 
   removeAbortedSessionPing: function() {
     return TelemetryStorage.removeAbortedSessionPing();
   },
 
   /**
-   *
-   */
-  _isInOptoutSample: function() {
-    if (!Preferences.get(PREF_OPTOUT_SAMPLE, false)) {
-      this._log.config("_sampleForOptoutTelemetry - optout sampling is disabled");
-      return false;
-    }
-
-    const clientId = Policy.getCachedClientID();
-    if (!clientId) {
-      this._log.config("_sampleForOptoutTelemetry - no cached client id available")
-      return false;
-    }
-
-    // This mimics the server-side 1% sampling, so that we can get matching populations.
-    // The server samples on ((crc32(clientId) % 100) == 42), we match 42+X here to get
-    // a bigger sample.
-    const sample = crc32(clientId) % 100;
-    const offset = 42;
-    const range = 5; // sampling from 5%
-
-    const optout = (sample >= offset && sample < (offset + range));
-    this._log.config("_sampleForOptoutTelemetry - sampling for optout Telemetry - " +
-                     "offset: " + offset + ", range: " + range + ", sample: " + sample);
-    return optout;
-  },
-
-  /**
    * Perform telemetry initialization for either chrome or content process.
    * @return {Boolean} True if Telemetry is allowed to record at least base (FHR) data,
    *                   false otherwise.
    */
   enableTelemetryRecording: function enableTelemetryRecording() {
     // The thumbnail service also runs in a content process, even with e10s off.
     // We need to check if e10s is on so we don't submit child payloads for it.
     // We still need xpcshell child tests to work, so we skip this if test mode is enabled.
     if (Utils.isContentProcess && !this._testMode && !Services.appinfo.browserTabsRemoteAutostart) {
       this._log.config("enableTelemetryRecording - not enabling Telemetry for non-e10s child process");
       Telemetry.canRecordBase = false;
       Telemetry.canRecordExtended = false;
       return false;
     }
 
     // Configure base Telemetry recording.
-    // Unified Telemetry makes it opt-out unless the unifedOptin pref is set.
-    // Additionally, we make Telemetry opt-out for a 5% sample.
-    // If extended Telemetry is enabled, base recording is always on as well.
+    // Unified Telemetry makes it opt-out. If extended Telemetry is enabled, base recording
+    // is always on as well.
     const enabled = Utils.isTelemetryEnabled;
-    const isOptout = IS_UNIFIED_TELEMETRY && (!Policy.isUnifiedOptin() || this._isInOptoutSample());
-    Telemetry.canRecordBase = enabled || isOptout;
+    Telemetry.canRecordBase = enabled || IS_UNIFIED_TELEMETRY;
     Telemetry.canRecordExtended = enabled;
 
     this._log.config("enableTelemetryRecording - canRecordBase:" + Telemetry.canRecordBase +
                      ", canRecordExtended: " + Telemetry.canRecordExtended);
 
     return Telemetry.canRecordBase;
   },
 
@@ -863,20 +795,16 @@ var Impl = {
       break;
     }
   },
 
   get clientID() {
     return this._clientID;
   },
 
-  get isInOptoutSample() {
-    return this._isInOptoutSample();
-  },
-
   /**
    * Get an object describing the current state of this module for AsyncShutdown diagnostics.
    */
   _getState: function() {
     return {
       initialized: this._initialized,
       initStarted: this._initStarted,
       haveDelayedInitTask: !!this._delayedInitTask,
--- a/toolkit/components/telemetry/TelemetryEnvironment.jsm
+++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm
@@ -1092,17 +1092,16 @@ EnvironmentCache.prototype = {
     try {
       updateChannel = UpdateUtils.getUpdateChannel(false);
     } catch (e) {}
 
     this._currentEnvironment.settings = {
       blocklistEnabled: Preferences.get(PREF_BLOCKLIST_ENABLED, true),
       e10sEnabled: Services.appinfo.browserTabsRemoteAutostart,
       telemetryEnabled: Utils.isTelemetryEnabled,
-      isInOptoutSample: TelemetryController.isInOptoutSample,
       locale: getBrowserLocale(),
       update: {
         channel: updateChannel,
         enabled: Preferences.get(PREF_UPDATE_ENABLED, true),
         autoDownload: Preferences.get(PREF_UPDATE_AUTODOWNLOAD, true),
       },
       userPrefs: this._getPrefData(),
     };
--- a/toolkit/components/telemetry/healthreport-prefs.js
+++ b/toolkit/components/telemetry/healthreport-prefs.js
@@ -3,9 +3,8 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 pref("datareporting.healthreport.infoURL", "https://www.mozilla.org/legal/privacy/firefox.html#health-report");
 
 // Health Report is enabled by default on all channels.
 pref("datareporting.healthreport.uploadEnabled", true);
 
 pref("datareporting.healthreport.about.reportUrl", "https://fhr.cdn.mozilla.net/%LOCALE%/v4/");
-pref("datareporting.healthreport.about.reportUrlUnified", "https://fhr.cdn.mozilla.net/%LOCALE%/v4/");