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_SERVER = PREF_BRANCH + "server";
const PREF_ENABLED = PREF_BRANCH + "enabled"; const PREF_ENABLED = PREF_BRANCH + "enabled";
const PREF_PREVIOUS_BUILDID = PREF_BRANCH + "previousBuildID"; const PREF_PREVIOUS_BUILDID = PREF_BRANCH + "previousBuildID";
const PREF_FHR_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
// Do not gather data more than once a minute // Do not gather data more than once a minute
const TELEMETRY_INTERVAL = 60000; const TELEMETRY_INTERVAL = 60000;
@ -703,7 +704,6 @@ let Impl = {
UIMeasurements: UITelemetry.getUIMeasurements(), UIMeasurements: UITelemetry.getUIMeasurements(),
log: TelemetryLog.entries(), log: TelemetryLog.entries(),
info: info, info: info,
clientID: this._clientID,
}; };
if (Object.keys(this._slowSQLStartup).length != 0 && if (Object.keys(this._slowSQLStartup).length != 0 &&
@ -712,6 +712,17 @@ let Impl = {
payloadObj.slowSQLStartup = this._slowSQLStartup; 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; return payloadObj;
}, },
@ -959,10 +970,12 @@ let Impl = {
this.attachObservers(); this.attachObservers();
this.gatherMemory(); this.gatherMemory();
let drs = Cc["@mozilla.org/datareporting/service;1"] if ("@mozilla.org/datareporting/service;1" in Cc) {
.getService(Ci.nsISupports) let drs = Cc["@mozilla.org/datareporting/service;1"]
.wrappedJSObject; .getService(Ci.nsISupports)
this._clientID = yield drs.getClientID(); .wrappedJSObject;
this._clientID = yield drs.getClientID();
}
Telemetry.asyncFetchTelemetryData(function () {}); Telemetry.asyncFetchTelemetryData(function () {});
delete this._timer; delete this._timer;

View File

@ -43,6 +43,7 @@ let gNumberOfThreadsLaunched = 0;
const PREF_BRANCH = "toolkit.telemetry."; const PREF_BRANCH = "toolkit.telemetry.";
const PREF_ENABLED = PREF_BRANCH + "enabled"; 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); 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(payload.info.revision.startsWith("http"));
} }
do_check_true("clientID" in payload); if ("@mozilla.org/datareporting/service;1" in Cc &&
do_check_neq(payload.clientID, null); Services.prefs.getBoolPref(PREF_FHR_UPLOAD_ENABLED)) {
do_check_eq(payload.clientID, gDataReportingClientID); do_check_true("clientID" in payload);
do_check_neq(payload.clientID, null);
do_check_eq(payload.clientID, gDataReportingClientID);
}
try { try {
// If we've not got nsIGfxInfoDebug, then this will throw and stop us doing // 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"); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
Services.prefs.setBoolPref(PREF_ENABLED, true); Services.prefs.setBoolPref(PREF_ENABLED, true);
Services.prefs.setBoolPref(PREF_FHR_UPLOAD_ENABLED, true);
// Send the needed startup notifications to the datareporting service // Send the needed startup notifications to the datareporting service
// to ensure that it has been initialized. // to ensure that it has been initialized.
gDatareportingService.observe(null, "app-startup", null); if ("@mozilla.org/datareporting/service;1" in Cc) {
gDatareportingService.observe(null, "profile-after-change", null); 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. // Make it look like we've previously failed to lock a profile a couple times.
write_fake_failedprofilelocks_file(); write_fake_failedprofilelocks_file();
@ -448,7 +455,9 @@ function actualTest() {
add_task(function* asyncSetup() { add_task(function* asyncSetup() {
yield TelemetryPing.setup(); 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 // 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 // Send the needed startup notifications to the datareporting service
// to ensure that it has been initialized. // to ensure that it has been initialized.
gDatareportingService.observe(null, "app-startup", null); if ("@mozilla.org/datareporting/service;1" in Cc) {
gDatareportingService.observe(null, "profile-after-change", null); gDatareportingService.observe(null, "app-startup", null);
gDatareportingService.observe(null, "profile-after-change", null);
}
run_next_test(); run_next_test();
} }