Bug 1064333 - Only add the stable user id to the ping when FHR upload is enabled. r=froydnj
--- 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,21 @@ 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 (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,16 +391,17 @@ 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);
// Make it look like we've previously failed to lock a profile a couple times.
write_fake_failedprofilelocks_file();