Bug 1064333 - Only add the stable user id to the ping when FHR upload is enabled. r=froydnj

This commit is contained in:
Georg Fritzsche 2014-10-17 17:24:05 +02:00
parent 26c740bbf2
commit cbf225e6fb
3 changed files with 37 additions and 13 deletions

View File

@ -32,6 +32,7 @@ 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;
@ -703,7 +704,6 @@ let Impl = {
UIMeasurements: UITelemetry.getUIMeasurements(),
log: TelemetryLog.entries(),
info: info,
clientID: this._clientID,
};
if (Object.keys(this._slowSQLStartup).length != 0 &&
@ -712,6 +712,17 @@ let Impl = {
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;
},
@ -959,10 +970,12 @@ let Impl = {
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;

View File

@ -43,6 +43,7 @@ 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);
@ -171,9 +172,12 @@ function checkPayloadInfo(payload, reason) {
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
@ -393,11 +397,14 @@ function run_test() {
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();
@ -448,7 +455,9 @@ function actualTest() {
add_task(function* asyncSetup() {
yield TelemetryPing.setup();
gDataReportingClientID = yield gDatareportingService.getClientID();
if ("@mozilla.org/datareporting/service;1" in Cc) {
gDataReportingClientID = yield gDatareportingService.getClientID();
}
});
// Ensure that not overwriting an existing file fails silently

View File

@ -74,8 +74,10 @@ function run_test() {
// 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();
}