From 4bda3a52b0724744d50ef57399d4f129788ddb0a Mon Sep 17 00:00:00 2001 From: Vivian A Goodrich <101133187+vgoodric@users.noreply.github.com> Date: Wed, 19 Jun 2024 08:24:15 -0600 Subject: [PATCH] MWPW-152659 [MILO][MODAL][ANALYTICS] Analytic on modal load is missing (#2478) * add check before overriding digitalData * fix object creation to avoid erro --- libs/blocks/modal/modal.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libs/blocks/modal/modal.js b/libs/blocks/modal/modal.js index 586861c4df..d8cef368fb 100644 --- a/libs/blocks/modal/modal.js +++ b/libs/blocks/modal/modal.js @@ -1,3 +1,4 @@ +/* eslint-disable no-underscore-dangle */ /* eslint-disable import/no-cycle */ import { createTag, getMetadata, localizeLink, loadStyle, getConfig } from '../../utils/utils.js'; @@ -20,18 +21,15 @@ export function findDetails(hash, el) { } function fireAnalyticsEvent(event) { - // eslint-disable-next-line no-underscore-dangle - window._satellite?.track('event', { + const data = { xdm: {}, - data: { - web: { webInteraction: { name: event?.type } }, - _adobe_corpnew: { digitalData: event?.data }, - }, - }); + data: { web: { webInteraction: { name: event?.type } } }, + }; + if (event?.data) data.data._adobe_corpnew = { digitalData: event.data }; + window._satellite?.track('event', data); } export function sendAnalytics(event) { - // eslint-disable-next-line no-underscore-dangle if (window._satellite?.track) { fireAnalyticsEvent(event); } else {