Bug 1400870 - Keep the attribution code on environment changes. r?chutten
This patch makes sure |_updateSettings| carries over the attribution code,
if present. Without this patch the whole "environment.settings" section
is replaced and the attribution code disppears after the first environment
change/subsession split.
MozReview-Commit-ID: 8bxjVOl2mUp
--- a/toolkit/components/telemetry/TelemetryEnvironment.jsm
+++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm
@@ -1358,17 +1358,23 @@ EnvironmentCache.prototype = {
* Update the cached settings data.
*/
_updateSettings() {
let updateChannel = null;
try {
updateChannel = UpdateUtils.getUpdateChannel(false);
} catch (e) {}
+ // Make sure to retain the attribution code across environment changes.
+ const attributionCode =
+ (this._currentEnvironment.settings &&
+ this._currentEnvironment.settings.attribution) || {};
+
this._currentEnvironment.settings = {
+ attribution: attributionCode,
blocklistEnabled: Services.prefs.getBoolPref(PREF_BLOCKLIST_ENABLED, true),
e10sEnabled: Services.appinfo.browserTabsRemoteAutostart,
e10sMultiProcesses: Services.appinfo.maxWebProcessCount,
e10sCohort: Services.prefs.getStringPref(PREF_E10S_COHORT, "unknown"),
telemetryEnabled: Utils.isTelemetryEnabled,
locale: getBrowserLocale(),
update: {
channel: updateChannel,
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
@@ -445,17 +445,17 @@ function checkSettingsSection(data) {
Assert.equal(typeof update.autoDownload, "boolean");
// Check "defaultSearchEngine" separately, as it can either be undefined or string.
if ("defaultSearchEngine" in data.settings) {
checkString(data.settings.defaultSearchEngine);
Assert.equal(typeof data.settings.defaultSearchEngineData, "object");
}
- if ("attribution" in data.settings) {
+ if (gIsWindows) {
Assert.equal(typeof data.settings.attribution, "object");
Assert.equal(data.settings.attribution.source, "google.com");
}
}
function checkProfileSection(data) {
Assert.ok("profile" in data, "There must be a profile section in Environment.");
Assert.equal(data.profile.creationDate, truncateToDays(PROFILE_CREATION_DATE_MS));