Bug 1064333 - Only add the stable user id to the ping when FHR upload is enabled. r=froydnj
☠☠ backed out by 9951cc945fcb ☠ ☠
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Thu, 16 Oct 2014 20:11:34 +0200
changeset 235113 ccb8a2ac9746a87026389ded473ab18195013043
parent 235112 3466ed3b9b614ffab56045528ebefa87fa9d43ab
child 235114 378314f2892cc06034c54ae77f2385172201c4f0
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1064333
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1064333 - Only add the stable user id to the ping when FHR upload is enabled. r=froydnj
toolkit/components/telemetry/TelemetryPing.jsm
toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
toolkit/components/telemetry/tests/unit/test_TelemetryPingBuildID.js
--- a/toolkit/components/telemetry/TelemetryPing.jsm
+++ b/toolkit/components/telemetry/TelemetryPing.jsm
@@ -27,16 +27,17 @@ const PAYLOAD_VERSION = 1;
 // This is the HG changeset of the Histogram.json file, used to associate
 // submitted ping data with its histogram definition (bug 832007)
 #expand const HISTOGRAMS_FILE_VERSION = "__HISTOGRAMS_FILE_VERSION__";
 
 const PREF_BRANCH = "toolkit.telemetry.";
 const PREF_SERVER = PREF_BRANCH + "server";
 const PREF_ENABLED = PREF_BRANCH + "enabled";
 const PREF_PREVIOUS_BUILDID = PREF_BRANCH + "previousBuildID";
+const PREF_FHR_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
 
 // Do not gather data more than once a minute
 const TELEMETRY_INTERVAL = 60000;
 // Delay before intializing telemetry (ms)
 const TELEMETRY_DELAY = 60000;
 // Delay before initializing telemetry if we're testing (ms)
 const TELEMETRY_TEST_DELAY = 100;
 
@@ -698,25 +699,35 @@ let Impl = {
       chromeHangs: Telemetry.chromeHangs,
       threadHangStats: this.getThreadHangStats(Telemetry.threadHangStats),
       lateWrites: Telemetry.lateWrites,
       addonHistograms: this.getAddonHistograms(),
       addonDetails: AddonManagerPrivate.getTelemetryDetails(),
       UIMeasurements: UITelemetry.getUIMeasurements(),
       log: TelemetryLog.entries(),
       info: info,
-      clientID: this._clientID,
     };
 
     if (Object.keys(this._slowSQLStartup).length != 0 &&
         (Object.keys(this._slowSQLStartup.mainThread).length ||
          Object.keys(this._slowSQLStartup.otherThreads).length)) {
       payloadObj.slowSQLStartup = this._slowSQLStartup;
     }
 
+    let fhrUploadEnabled = false;
+    try {
+      fhrUploadEnabled = Services.prefs.getBoolPref(PREF_FHR_UPLOAD_ENABLED);
+    } catch (e) {
+      // Pref not set.
+    }
+
+    if (this._clientID && fhrUploadEnabled) {
+      payloadObj.clientID = this._clientID;
+    }
+
     return payloadObj;
   },
 
   getSessionPayload: function getSessionPayload(reason) {
     let measurements = this.getSimpleMeasurements(reason == "saved-session");
     let info = this.getMetadata(reason);
     return this.assemblePayloadWithMeasurements(measurements, info);
   },
@@ -954,20 +965,22 @@ let Impl = {
           // since it's never sent to the server. All that this.send does with
           // the reason is check to make sure it's not a test-ping.
           yield this.send("overdue-flush", this._server);
         }
 
         this.attachObservers();
         this.gatherMemory();
 
-        let drs = Cc["@mozilla.org/datareporting/service;1"]
-                    .getService(Ci.nsISupports)
-                    .wrappedJSObject;
-        this._clientID = yield drs.getClientID();
+        if ("@mozilla.org/datareporting/service;1" in Cc) {
+          let drs = Cc["@mozilla.org/datareporting/service;1"]
+                      .getService(Ci.nsISupports)
+                      .wrappedJSObject;
+          this._clientID = yield drs.getClientID();
+        }
 
         Telemetry.asyncFetchTelemetryData(function () {});
         delete this._timer;
         deferred.resolve();
       }.bind(this));
     }
 
     this._timer.initWithCallback(timerCallback.bind(this),
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
@@ -38,16 +38,17 @@ const PR_CREATE_FILE = 0x8;
 const PR_TRUNCATE = 0x20;
 const RW_OWNER = 0600;
 
 const NUMBER_OF_THREADS_TO_LAUNCH = 30;
 let gNumberOfThreadsLaunched = 0;
 
 const PREF_BRANCH = "toolkit.telemetry.";
 const PREF_ENABLED = PREF_BRANCH + "enabled";
+const PREF_FHR_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
 
 const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
 
 let gHttpServer = new HttpServer();
 let gServerStarted = false;
 let gRequestIterator = null;
 let gDataReportingClientID = null;
 
@@ -166,19 +167,22 @@ function checkPayloadInfo(payload, reaso
   do_check_eq(payload.info.reason, reason);
   do_check_true("appUpdateChannel" in payload.info);
   do_check_true("locale" in payload.info);
   do_check_true("revision" in payload.info);
   if (Services.appinfo.isOfficial) {
     do_check_true(payload.info.revision.startsWith("http"));
   }
 
-  do_check_true("clientID" in payload);
-  do_check_neq(payload.clientID, null);
-  do_check_eq(payload.clientID, gDataReportingClientID);
+  if ("@mozilla.org/datareporting/service;1" in Cc &&
+      Services.prefs.getBoolPref(PREF_FHR_UPLOAD_ENABLED)) {
+    do_check_true("clientID" in payload);
+    do_check_neq(payload.clientID, null);
+    do_check_eq(payload.clientID, gDataReportingClientID);
+  }
 
   try {
     // If we've not got nsIGfxInfoDebug, then this will throw and stop us doing
     // this test.
     let gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfoDebug);
     let isWindows = ("@mozilla.org/windows-registry-key;1" in Components.classes);
     let isOSX = ("nsILocalFileMac" in Components.interfaces);
 
@@ -388,21 +392,24 @@ function run_test() {
     // If we can't test gfxInfo, that's fine, we'll note it later.
   }
 
   // Addon manager needs a profile directory
   do_get_profile();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
 
   Services.prefs.setBoolPref(PREF_ENABLED, true);
+  Services.prefs.setBoolPref(PREF_FHR_UPLOAD_ENABLED, true);
 
   // Send the needed startup notifications to the datareporting service
   // to ensure that it has been initialized.
-  gDatareportingService.observe(null, "app-startup", null);
-  gDatareportingService.observe(null, "profile-after-change", null);
+  if ("@mozilla.org/datareporting/service;1" in Cc) {
+    gDatareportingService.observe(null, "app-startup", null);
+    gDatareportingService.observe(null, "profile-after-change", null);
+  }
 
   // Make it look like we've previously failed to lock a profile a couple times.
   write_fake_failedprofilelocks_file();
 
   // Make it look like we've shutdown before.
   write_fake_shutdown_file();
 
   let currentMaxNumberOfThreads = Telemetry.maximalNumberOfConcurrentThreads;
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryPingBuildID.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryPingBuildID.js
@@ -69,13 +69,15 @@ add_task(function* test_newBuild() {
 
 
 function run_test() {
   // Make sure we have a profile directory.
   do_get_profile();
 
   // Send the needed startup notifications to the datareporting service
   // to ensure that it has been initialized.
-  gDatareportingService.observe(null, "app-startup", null);
-  gDatareportingService.observe(null, "profile-after-change", null);
+  if ("@mozilla.org/datareporting/service;1" in Cc) {
+    gDatareportingService.observe(null, "app-startup", null);
+    gDatareportingService.observe(null, "profile-after-change", null);
+  }
 
   run_next_test();
 }