Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-152627 [MILO][MARTECH] add Target propositionDisplay call #2477

Merged
merged 3 commits into from
Jun 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions libs/martech/martech.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-underscore-dangle */
import { getConfig, getMetadata, loadIms, loadLink, loadScript } from '../utils/utils.js';

const ALLOY_SEND_EVENT = 'alloy_sendEvent';
Expand Down Expand Up @@ -132,6 +133,7 @@ const getTargetPersonalization = async () => {
}, { once: true });

let manifests = [];
let propositions = [];
const response = await waitForEventOrTimeout(ALLOY_SEND_EVENT, timeout);
if (response.error) {
window.lana.log('target response time: ad blocker', { tags: 'errorType=info,module=martech' });
Expand All @@ -143,9 +145,13 @@ const getTargetPersonalization = async () => {
} else {
sendTargetResponseAnalytics(false, responseStart, timeout);
manifests = handleAlloyResponse(response.result);
propositions = response.result?.propositions || [];
}

return manifests;
return {
targetManifests: manifests,
targetPropositions: propositions,
};
};

const getDtmLib = (env) => ({
Expand Down Expand Up @@ -215,7 +221,6 @@ const loadMartechFiles = async (config, url, edgeConfigId) => {
const env = ['stage', 'local'].includes(config.env.name) ? '.qa' : '';
const martechPath = `martech.main.standard${env}.min.js`;
await loadScript(`${config.miloLibs || config.codeRoot}/deps/${martechPath}`);
// eslint-disable-next-line no-underscore-dangle
window._satellite.track('pageload');
};

Expand All @@ -241,11 +246,14 @@ export default async function init({
{ as: 'script', rel: 'modulepreload' },
);

const targetManifests = await getTargetPersonalization();
const { targetManifests, targetPropositions } = await getTargetPersonalization();
if (targetManifests?.length || persManifests?.length) {
const { preloadManifests, applyPers } = await import('../features/personalization/personalization.js');
const manifests = preloadManifests({ targetManifests, persManifests });
await applyPers(manifests, postLCP);
if (targetPropositions?.length && window._satellite) {
vgoodric marked this conversation as resolved.
Show resolved Hide resolved
window._satellite.track('propositionDisplay', targetPropositions);
}
}
}

Expand Down
Loading