diff --git a/acrobat/scripts/alloy/susi-auth-handler.js b/acrobat/scripts/alloy/susi-auth-handler.js new file mode 100644 index 00000000..7f11740d --- /dev/null +++ b/acrobat/scripts/alloy/susi-auth-handler.js @@ -0,0 +1,18 @@ +export default function init(ctaName, action, device) { + const event = { + // always trigger the event using navigator.sendBeacon + documentUnloading: true, + data: { + eventType: 'web.webinteraction.linkClicks', + web: { + webInteraction: { + linkClicks: { value: 1 }, + type: 'other', + name: `${ctaName}|marquee-${action}|overview|${device}`, + }, + }, + }, + }; + // eslint-disable-next-line no-underscore-dangle + window?._satellite?.track('event', event); +} diff --git a/acrobat/scripts/scripts.js b/acrobat/scripts/scripts.js index 8809a0a0..14a7e01f 100644 --- a/acrobat/scripts/scripts.js +++ b/acrobat/scripts/scripts.js @@ -459,6 +459,14 @@ const { ietf } = getLocale(locales); setConfig({ ...CONFIG, miloLibs }); + window.addEventListener('IMS:Ready', async () => { + const susiElems = document.querySelectorAll('a[href*="susi"]'); + if (susiElems.length > 0) { + const { default: handleImsSusi } = await import('./susiAuthHandler.js'); + handleImsSusi(susiElems); + } + }); + loadIms().then(() => { const imsIsReady = new CustomEvent('IMS:Ready'); window.dispatchEvent(imsIsReady); diff --git a/acrobat/scripts/susiAuthHandler.js b/acrobat/scripts/susiAuthHandler.js new file mode 100644 index 00000000..1416d79b --- /dev/null +++ b/acrobat/scripts/susiAuthHandler.js @@ -0,0 +1,21 @@ +import susiAnalytics from './alloy/susi-auth-handler.js'; + +export default function handleImsSusi(susiElems) { + susiElems.forEach((link) => { + if (link.href.includes('-sign-up')) { + link.addEventListener('click', (e) => { + e.preventDefault(); + susiAnalytics(link.text, 'sign-up', window.browser.isMobile ? 'mobile' : 'desktop'); + window.adobeIMS.signUp(); + }); + } else if (link.href.includes('-sign-in')) { + link.addEventListener('click', (e) => { + e.preventDefault(); + susiAnalytics(link.text, 'sign-in', window.browser.isMobile ? 'mobile' : 'desktop'); + window.adobeIMS.signIn(); + }); + } + link.style.pointerEvents = 'auto'; + link.style.cursor = 'pointer'; + }); +} diff --git a/acrobat/styles/styles.css b/acrobat/styles/styles.css index 31ede7aa..8da955dd 100644 --- a/acrobat/styles/styles.css +++ b/acrobat/styles/styles.css @@ -878,3 +878,8 @@ main { display: none; } } + +a[href*="susi"] { + pointer-events: none; + cursor: default; +}