Bug 1765907 - PBM experiment message should override default promo message r=mviar

Differential Revision: https://phabricator.services.mozilla.com/D144871
This commit is contained in:
Punam Dahiya
2022-05-12 18:24:06 +00:00
parent 4c67b09182
commit 74fd8b3a3e
9 changed files with 173 additions and 94 deletions

View File

@@ -119,7 +119,14 @@ async function renderPromo({
} else if (promoButton?.action?.type === "SHOW_SPOTLIGHT") {
linkEl.addEventListener("click", async event => {
event.preventDefault();
window.PrivateBrowsingRecordClick("promo_link");
// Record promo click telemetry and set metrics as allow for spotlight
// modal opened on promo click if user is enrolled in an experiment
let isExperiment = window.PrivateBrowsingRecordClick("promo_link");
const promoButtonData = promoButton?.action?.data;
if (promoButtonData?.content) {
promoButtonData.content.metrics = isExperiment ? "allow" : "block";
}
await RPMSendQuery("SpecialMessageActionDispatch", promoButton.action);
});
} else {
@@ -238,14 +245,17 @@ async function handlePromoOnPreload(message) {
async function setupFeatureConfig() {
let config = null;
let message = null;
try {
config = window.PrivateBrowsingFeatureConfig();
} catch (e) {}
if (!Object.keys(config).length) {
let hideDefault = window.PrivateBrowsingShouldHideDefault();
try {
let response = await window.ASRouterMessage({
type: "PBNEWTAB_MESSAGE_REQUEST",
data: {},
data: { hideDefault: !!hideDefault },
});
message = response?.message;
config = message?.content;