Files
tubestation/toolkit/components/normandy/content/ShieldFrameParent.sys.mjs
Beth Rennie 149d1a110f Bug 1955169 - Simplify recording of enrollment status telemetry r=omc-reviewers,nimbus-reviewers,aminomancer,chumphreys,application-update-reviewers,nalexander
Previously we were recording enrollment status telemetry everywhere we
were calling into `enroll` and `_unenroll` from onRecipe and
`updateEnrollment`. Now we record the enrollment status telemetry from
inside `NimbusTelemetry.recordEnrollment` and
`NimbusTelemetry.recordUnenrollment`, so that the enrollment status
telemetry is recorded from *every* enrollment event, not just during
`RemoteSettingsExperimentLoader.updateRecipes()`.

To help with this, a new helper has been added, `UnenrollmentCause`,
which carries all the metadata required to unenroll from an experiment
(similar how `CheckRecipeResult` carries all the metadata for enrollment
and updating enrollment) and to submit the corresponding telemetry. Now
instead of calling `unenroll()` with a reason string, you must call it
with an object returned from one of the `UenrollmentCause` utilities.
All tests that were calling `unenroll()` with a string like
"test" or "cleanup" have been updated to remove the reason string. When
it is not present, the `UnenrollmentCause` will default to an "unknown"
reason, which is good enough for test cleanup.

Differential Revision: https://phabricator.services.mozilla.com/D243212
2025-04-06 01:02:21 +00:00

51 lines
1.7 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
AboutPages: "resource://normandy-content/AboutPages.sys.mjs",
});
export class ShieldFrameParent extends JSWindowActorParent {
async receiveMessage(msg) {
let { aboutStudies } = lazy.AboutPages;
switch (msg.name) {
case "Shield:AddToWeakSet":
aboutStudies.addToWeakSet(this.browsingContext);
break;
case "Shield:RemoveFromWeakSet":
aboutStudies.removeFromWeakSet(this.browsingContext);
break;
case "Shield:GetAddonStudyList":
return aboutStudies.getAddonStudyList();
case "Shield:GetPreferenceStudyList":
return aboutStudies.getPreferenceStudyList();
case "Shield:GetMessagingSystemList":
return aboutStudies.getMessagingSystemList();
case "Shield:RemoveAddonStudy":
aboutStudies.removeAddonStudy(msg.data.recipeId, msg.data.reason);
break;
case "Shield:RemovePreferenceStudy":
aboutStudies.removePreferenceStudy(
msg.data.experimentName,
msg.data.reason
);
break;
case "Shield:RemoveMessagingSystemExperiment":
aboutStudies.removeMessagingSystemExperiment(msg.data.slug);
break;
case "Shield:OpenDataPreferences":
aboutStudies.openDataPreferences();
break;
case "Shield:GetStudiesEnabled":
return aboutStudies.getStudiesEnabled();
case "Shield:ExperimentOptIn":
return aboutStudies.optInToExperiment(msg.data);
}
return null;
}
}