From 5813c8a32eae66442fada7f5678c0b8896b6391f Mon Sep 17 00:00:00 2001 From: vgoodric Date: Thu, 6 Jun 2024 23:58:01 -0600 Subject: [PATCH 1/2] calculate preview in utils --- libs/utils/utils.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 8c2103ca49..6d3520885b 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -919,7 +919,7 @@ export const combineMepSources = async (persEnabled, promoEnabled, mepParam) => }; async function checkForPageMods() { - const { mep: mepParam } = Object.fromEntries(PAGE_URL.searchParams); + const { mep: mepParam, mepButton } = Object.fromEntries(PAGE_URL.searchParams); if (mepParam === 'off') return; const persEnabled = getMepEnablement('personalization'); const promoEnabled = getMepEnablement('manifestnames', 'promo'); @@ -928,7 +928,11 @@ async function checkForPageMods() { if (!mepEnabled) return; const config = getConfig(); - config.mep = { targetEnabled }; + config.mep = { + targetEnabled, + preview: (mepButton !== 'off' + && (config.env?.name !== 'prod' || mepParam || mepParam === '' || mepButton)), + }; loadLink( `${config.base}/features/personalization/personalization.js`, { as: 'script', rel: 'modulepreload' }, From 24eeb9aee29f1df6a5f047e34a77265d52963354 Mon Sep 17 00:00:00 2001 From: vgoodric Date: Thu, 6 Jun 2024 23:58:31 -0600 Subject: [PATCH 2/2] update personalization to not recalculate --- libs/features/personalization/personalization.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js index 1473eb2bf0..d64c3204a1 100644 --- a/libs/features/personalization/personalization.js +++ b/libs/features/personalization/personalization.js @@ -826,12 +826,10 @@ export async function applyPers(manifests, postLCP = false) { const { mep: mepParam, mepHighlight, - mepButton, } = Object.fromEntries(PAGE_URL.searchParams); config.mep = { handleFragmentCommand, - preview: (mepButton !== 'off' - && (config.env?.name !== 'prod' || mepParam || mepParam === '' || mepButton)), + preview: config.mep?.preview, override: mepParam ? decodeURIComponent(mepParam) : '', highlight: (mepHighlight !== undefined && mepHighlight !== 'false'), mepParam,