Skip to content

Commit

Permalink
MWPW-158777 returning proper response in case of error (#2916)
Browse files Browse the repository at this point in the history
  • Loading branch information
npeltier authored Sep 19, 2024
1 parent adf2a9c commit c3c9bcc
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions libs/martech/martech.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,23 @@ export const getTargetPersonalization = async () => {
window.lana.log(`target response time: ${responseTime}`, { tags: 'martech', errorType: 'i' });
}, { once: true });

let manifests = [];
let propositions = [];
let targetManifests = [];
let targetPropositions = [];
const response = await waitForEventOrTimeout(ALLOY_SEND_EVENT, timeout);
if (response.error) {
window.lana.log('target response time: ad blocker', { tags: 'martech', errorType: 'i' });
return [];
return { targetManifests, targetPropositions };
}
if (response.timeout) {
waitForEventOrTimeout(ALLOY_SEND_EVENT, 5100 - timeout)
.then(() => sendTargetResponseAnalytics(true, responseStart, timeout));
} else {
sendTargetResponseAnalytics(false, responseStart, timeout);
manifests = handleAlloyResponse(response.result);
propositions = response.result?.propositions || [];
targetManifests = handleAlloyResponse(response.result);
targetPropositions = response.result?.propositions || [];
}

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

const setupEntitlementCallback = () => {
Expand Down

0 comments on commit c3c9bcc

Please sign in to comment.