From a7ac5ad572d49f0031ee11c54bf59b10a1f8cbf6 Mon Sep 17 00:00:00 2001 From: vgoodric Date: Thu, 8 Aug 2024 18:20:51 -0600 Subject: [PATCH 1/4] initial fix --- libs/features/personalization/personalization.js | 5 +++-- libs/utils/utils.js | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js index 66d5936c15..6ec6487614 100644 --- a/libs/features/personalization/personalization.js +++ b/libs/features/personalization/personalization.js @@ -597,7 +597,7 @@ async function getPersonalizationVariant(manifestPath, variantNames = [], varian const hasEntitlementTag = entitlementKeys.some((tag) => variantInfo.allNames.includes(tag)); let userEntitlements = []; - if (hasEntitlementTag) { + if (hasEntitlementTag && config.mep.martech !== 'off') { userEntitlements = await config.entitlements(); } @@ -937,7 +937,7 @@ export const combineMepSources = async (persEnabled, promoEnabled, mepParam) => export async function init(enablements = {}) { let manifests = []; const { - mepParam, mepHighlight, mepButton, pzn, promo, target, postLCP, + mepParam, mepHighlight, mepButton, pzn, promo, target, postLCP, martech } = enablements; const config = getConfig(); if (!postLCP) { @@ -950,6 +950,7 @@ export async function init(enablements = {}) { highlight: (mepHighlight !== undefined && mepHighlight !== 'false'), targetEnabled: target, experiments: [], + martech, }; manifests = manifests.concat(await combineMepSources(pzn, promo, mepParam)); manifests?.forEach((manifest) => { diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 4402f394ae..de66c9418c 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -924,14 +924,19 @@ export const getMepEnablement = (mdKey, paramKey = false) => { }; async function checkForPageMods() { - const { mep: mepParam, mepHighlight, mepButton } = Object.fromEntries(PAGE_URL.searchParams); + const { + mep: mepParam, + mepHighlight, + mepButton, + martech, + } = Object.fromEntries(PAGE_URL.searchParams); if (mepParam === 'off') return; const pzn = getMepEnablement('personalization'); const promo = getMepEnablement('manifestnames', PROMO_PARAM); const target = getMepEnablement('target'); if (!(pzn || target || promo || mepParam || mepHighlight || mepButton || mepParam === '')) return; - if (target) { + if (target && martech !== 'off') { loadMartech(); } else if (pzn) { loadIms() @@ -944,7 +949,7 @@ async function checkForPageMods() { const { init } = await import('../features/personalization/personalization.js'); await init({ - mepParam, mepHighlight, mepButton, pzn, promo, target, + mepParam, mepHighlight, mepButton, pzn, promo, target, martech, }); } From 80ab4835d1594afa285e061580222247d2bf5b4e Mon Sep 17 00:00:00 2001 From: Vivian A Goodrich <101133187+vgoodric@users.noreply.github.com> Date: Fri, 9 Aug 2024 11:25:12 -0600 Subject: [PATCH 2/4] Update libs/features/personalization/personalization.js Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- libs/features/personalization/personalization.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js index 6ec6487614..97cd562b55 100644 --- a/libs/features/personalization/personalization.js +++ b/libs/features/personalization/personalization.js @@ -937,7 +937,7 @@ export const combineMepSources = async (persEnabled, promoEnabled, mepParam) => export async function init(enablements = {}) { let manifests = []; const { - mepParam, mepHighlight, mepButton, pzn, promo, target, postLCP, martech + mepParam, mepHighlight, mepButton, pzn, promo, target, postLCP, martech, } = enablements; const config = getConfig(); if (!postLCP) { From a95e5960ec41a8eee7e771a3bfd8da043a7aea34 Mon Sep 17 00:00:00 2001 From: vgoodric Date: Fri, 9 Aug 2024 13:07:07 -0600 Subject: [PATCH 3/4] move where martech=off is used --- libs/utils/utils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index de66c9418c..8c44639a2e 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -933,12 +933,12 @@ async function checkForPageMods() { if (mepParam === 'off') return; const pzn = getMepEnablement('personalization'); const promo = getMepEnablement('manifestnames', PROMO_PARAM); - const target = getMepEnablement('target'); + const target = martech === 'off' ? false : getMepEnablement('target'); if (!(pzn || target || promo || mepParam || mepHighlight || mepButton || mepParam === '')) return; - if (target && martech !== 'off') { + if (target) { loadMartech(); - } else if (pzn) { + } else if (pzn && martech !== 'off') { loadIms() .then(() => { /* c8 ignore next */ From 99b509628ae802f61a9795acd2bc21b1ff649299 Mon Sep 17 00:00:00 2001 From: vgoodric Date: Fri, 9 Aug 2024 13:21:16 -0600 Subject: [PATCH 4/4] move logic to handleEntitlements function --- libs/features/personalization/personalization.js | 5 ++--- libs/utils/utils.js | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js index 97cd562b55..66d5936c15 100644 --- a/libs/features/personalization/personalization.js +++ b/libs/features/personalization/personalization.js @@ -597,7 +597,7 @@ async function getPersonalizationVariant(manifestPath, variantNames = [], varian const hasEntitlementTag = entitlementKeys.some((tag) => variantInfo.allNames.includes(tag)); let userEntitlements = []; - if (hasEntitlementTag && config.mep.martech !== 'off') { + if (hasEntitlementTag) { userEntitlements = await config.entitlements(); } @@ -937,7 +937,7 @@ export const combineMepSources = async (persEnabled, promoEnabled, mepParam) => export async function init(enablements = {}) { let manifests = []; const { - mepParam, mepHighlight, mepButton, pzn, promo, target, postLCP, martech, + mepParam, mepHighlight, mepButton, pzn, promo, target, postLCP, } = enablements; const config = getConfig(); if (!postLCP) { @@ -950,7 +950,6 @@ export async function init(enablements = {}) { highlight: (mepHighlight !== undefined && mepHighlight !== 'false'), targetEnabled: target, experiments: [], - martech, }; manifests = manifests.concat(await combineMepSources(pzn, promo, mepParam)); manifests?.forEach((manifest) => { diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 8c44639a2e..f791165d38 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -191,6 +191,8 @@ export function getMetadata(name, doc = document) { } const handleEntitlements = (() => { + const { martech } = Object.fromEntries(PAGE_URL.searchParams); + if (martech === 'off') return () => {}; let entResolve; const entPromise = new Promise((resolve) => { entResolve = resolve; @@ -949,7 +951,7 @@ async function checkForPageMods() { const { init } = await import('../features/personalization/personalization.js'); await init({ - mepParam, mepHighlight, mepButton, pzn, promo, target, martech, + mepParam, mepHighlight, mepButton, pzn, promo, target, }); }