Skip to content

Commit

Permalink
Add the option to run with enablePersV2
Browse files Browse the repository at this point in the history
  • Loading branch information
markpadbe committed Feb 10, 2025
1 parent a811df4 commit 19b5520
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions libs/features/personalization/personalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -1189,13 +1189,13 @@ const handleAlloyResponse = (response) => ((response.propositions || response.de
?.filter(Boolean) ?? [];

async function handleMartechTargetInteraction(
{ config, targetInteractionPromise },
{ config, targetAjoInteractionPromise },
) {
const targetAjo = config.mep.ajoEnabled ? 'ajo' : 'target';
let targetAjoManifests = [];
let targetAjoPropositions = [];
if (config?.mep?.enablePersV2 && targetInteractionPromise) {
const { targetAjoInteractionData, respTime } = await targetInteractionPromise;
if (config?.mep?.enablePersV2 && targetAjoInteractionPromise) {
const { targetAjoInteractionData, respTime } = await targetAjoInteractionPromise;
if (targetAjoInteractionData.result) {
performance.clearMarks();
performance.clearMeasures();
Expand Down Expand Up @@ -1239,7 +1239,7 @@ export async function init(enablements = {}) {
let manifests = [];
const {
mepParam, mepHighlight, mepButton, pzn, promo, enablePersV2, hybridPersEnabled,
target, ajo, targetInteractionPromise, calculatedTimeout, postLCP,
target, ajo, targetAjoInteractionPromise, calculatedTimeout, postLCP,
} = enablements;
const config = getConfig();
if (postLCP) {
Expand Down Expand Up @@ -1267,9 +1267,9 @@ export async function init(enablements = {}) {
if (pzn) loadLink(getXLGListURL(config), { as: 'fetch', crossorigin: 'anonymous', rel: 'preload' });
}

if (enablePersV2 && target === true) {
if (enablePersV2 && (target === true || ajo === true)) {
manifests = manifests.concat(await handleMartechTargetInteraction(
{ config, targetInteractionPromise, calculatedTimeout },
{ config, targetAjoInteractionPromise, calculatedTimeout },
));
} else {
if (target === true || ajo === true) manifests = manifests.concat(await callMartech(config));
Expand Down
8 changes: 4 additions & 4 deletions libs/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ async function checkForPageMods() {
mepButton,
martech,
} = Object.fromEntries(PAGE_URL.searchParams);
let targetInteractionPromise = null;
let targetAjoInteractionPromise = null;
let calculatedTimeout = null;
if (mepParam === 'off') return;
const pzn = getMepEnablement('personalization');
Expand All @@ -1132,14 +1132,14 @@ async function checkForPageMods() {

const enablePersV2 = enablePersonalizationV2();
const hybridPersEnabled = getMepEnablement('hybrid-pers');
if ((target || xlg) && enablePersV2) {
if ((target || xlg || ajo) && enablePersV2) {
const params = new URL(window.location.href).searchParams;
calculatedTimeout = parseInt(params.get('target-timeout'), 10)
|| parseInt(getMetadata('target-timeout'), 10)
|| TARGET_TIMEOUT_MS;

const { locale } = getConfig();
targetInteractionPromise = (async () => {
targetAjoInteractionPromise = (async () => {
const { loadAnalyticsAndInteractionData } = await import('../martech/helpers.js');
const now = performance.now();
performance.mark('interaction-start');
Expand Down Expand Up @@ -1171,7 +1171,7 @@ async function checkForPageMods() {
promo,
target,
ajo,
targetInteractionPromise,
targetAjoInteractionPromise,
calculatedTimeout,
enablePersV2,
hybridPersEnabled,
Expand Down

0 comments on commit 19b5520

Please sign in to comment.