Bug 1734146 - Reach groups should include all features that are part of the messaging-experiments provider r=pdahiya

Differential Revision: https://phabricator.services.mozilla.com/D127664
This commit is contained in:
Andrei Oprea 2021-10-14 09:26:09 +00:00
Родитель d3871de00b
Коммит b5e3b22572
4 изменённых файлов: 58 добавлений и 6 удалений

Просмотреть файл

@ -1456,7 +1456,7 @@ pref("browser.newtabpage.activity-stream.asrouter.providers.message-groups", "{\
// this page over http opens us up to a man-in-the-middle attack that we'd rather not face. If you are a downstream
// repackager of this code using an alternate snippet url, please keep your users safe
pref("browser.newtabpage.activity-stream.asrouter.providers.snippets", "{\"id\":\"snippets\",\"enabled\":false,\"type\":\"remote\",\"url\":\"https://snippets.cdn.mozilla.net/%STARTPAGE_VERSION%/%NAME%/%VERSION%/%APPBUILDID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/\",\"updateCycleInMs\":14400000}");
pref("browser.newtabpage.activity-stream.asrouter.providers.messaging-experiments", "{\"id\":\"messaging-experiments\",\"enabled\":true,\"type\":\"remote-experiments\",\"messageGroups\":[\"cfr\",\"whats-new-panel\",\"moments-page\",\"aboutwelcome\",\"infobar\",\"spotlight\"],\"updateCycleInMs\":3600000}");
pref("browser.newtabpage.activity-stream.asrouter.providers.messaging-experiments", "{\"id\":\"messaging-experiments\",\"enabled\":true,\"type\":\"remote-experiments\",\"messageGroups\":[\"cfr\",\"moments-page\",\"aboutwelcome\",\"infobar\",\"spotlight\"],\"updateCycleInMs\":3600000}");
// ASRouter user prefs
pref("browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons", true);

Просмотреть файл

@ -79,7 +79,7 @@ const STARTPAGE_VERSION = "6";
const RS_SERVER_PREF = "services.settings.server";
const RS_MAIN_BUCKET = "main";
const RS_COLLECTION_L10N = "ms-language-packs"; // "ms" stands for Messaging System
const RS_PROVIDERS_WITH_L10N = ["cfr", "whats-new-panel"];
const RS_PROVIDERS_WITH_L10N = ["cfr"];
const RS_FLUENT_VERSION = "v1";
const RS_FLUENT_RECORD_PREFIX = `cfr-${RS_FLUENT_VERSION}`;
const RS_DOWNLOAD_MAX_RETRIES = 2;
@ -97,7 +97,7 @@ const USE_REMOTE_L10N_PREF =
// Experiment groups that need to report the reach event in Messaging-Experiments.
// If you're adding new groups to it, make sure they're also added in the
// `messaging_experiments.reach.objects` defined in "toolkit/components/telemetry/Events.yaml"
const REACH_EVENT_GROUPS = ["cfr", "moments-page"];
const REACH_EVENT_GROUPS = ["cfr", "moments-page", "infobar", "spotlight"];
const REACH_EVENT_CATEGORY = "messaging_experiments";
const REACH_EVENT_METHOD = "reach";

Просмотреть файл

@ -1727,6 +1727,59 @@ describe("ASRouter", () => {
});
});
describe("#reachEvent", () => {
let experimentAPIStub;
let messageGroups = ["cfr", "moments-page", "infobar", "spotlight"];
beforeEach(() => {
let getExperimentStub = sandbox.stub();
let getAllBranchesStub = sandbox.stub();
messageGroups.forEach(feature => {
getExperimentStub.withArgs({ featureId: feature }).returns({
slug: `slug-${feature}`,
branch: {
slug: `branch-${feature}`,
feature: { value: null, enabled: true },
},
});
getAllBranchesStub.withArgs(`slug-${feature}`).resolves([
{
slug: `other-branch-${feature}`,
feature: { value: { trigger: "unit-test" }, enabled: true },
},
]);
});
experimentAPIStub = {
ready: sandbox.stub().resolves(),
getExperiment: getExperimentStub,
getAllBranches: getAllBranchesStub,
};
globals.set("ExperimentAPI", experimentAPIStub);
});
afterEach(() => {
sandbox.restore();
});
it("should tag `forReachEvent`/`forExposureEvent` for all the expected message types", async () => {
// This should match the `providers.messaging-experiments`
let response = await MessageLoaderUtils.loadMessagesForProvider({
type: "remote-experiments",
messageGroups,
});
assert.calledOnce(experimentAPIStub.ready);
// 1 message for reach 1 for expose
assert.property(response, "messages");
assert.lengthOf(response.messages, messageGroups.length * 2);
assert.lengthOf(
response.messages.filter(m => m.forReachEvent),
messageGroups.length
);
assert.lengthOf(
response.messages.filter(m => m.forExposureEvent),
messageGroups.length
);
});
});
describe("#sendTriggerMessage", () => {
it("should pass the trigger to ASRouterTargeting when sending trigger message", async () => {
await Router.setState({

Просмотреть файл

@ -1188,10 +1188,9 @@ messaging_experiments:
reach:
objects: [
"cfr",
"whats_new_panel",
"moments_page",
"snippets",
"cfr_fxa"
"infobar",
"spotlight"
]
methods: ["reach"]
release_channel_collection: opt-out