From c204977832aa9adcd75e7431d8d4ad7eaa070ebd Mon Sep 17 00:00:00 2001 From: Joaquin Rivero Date: Thu, 19 Dec 2024 19:20:29 -0500 Subject: [PATCH] Removing waiting a second to send analytics and adding lana logs on done --- acrobat/blocks/verb-widget/verb-widget.js | 2 +- acrobat/scripts/alloy/verb-widget.js | 33 ++++++++++++++--------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/acrobat/blocks/verb-widget/verb-widget.js b/acrobat/blocks/verb-widget/verb-widget.js index 9a36104a..297bda92 100644 --- a/acrobat/blocks/verb-widget/verb-widget.js +++ b/acrobat/blocks/verb-widget/verb-widget.js @@ -270,7 +270,7 @@ export default async function init(element) { } if (e.detail?.event === 'uploaded') { - verbAnalytics('job:test-uploaded', VERB, e.detail?.data); + verbAnalytics('job:test-uploaded', VERB, e.detail?.data, false); exitFlag = true; setUser(); document.cookie = `UTS_Uploaded=${Date.now()};domain=.adobe.com;path=/;expires=${cookieExp}`; diff --git a/acrobat/scripts/alloy/verb-widget.js b/acrobat/scripts/alloy/verb-widget.js index a17720c7..435d9a7d 100644 --- a/acrobat/scripts/alloy/verb-widget.js +++ b/acrobat/scripts/alloy/verb-widget.js @@ -23,7 +23,7 @@ if (params.dropzone2) { appTags.push('dropzone2'); } -export default function init(eventName, verb, metaData) { +export default function init(eventName, verb, metaData, documentUnloading = true) { function getSessionID() { const aToken = window.adobeIMS.getAccessToken(); const arrayToken = aToken?.token.split('.'); @@ -33,7 +33,25 @@ export default function init(eventName, verb, metaData) { return tokenPayload.sub || tokenPayload.user_id; } const event = { - documentUnloading: true, + documentUnloading, + // eslint-disable-next-line + done: function (AJOPropositionResult, error) { + if (!documentUnloading) { + const accountType = window?.adobeIMS?.getAccountType(); + const verbEvent = `acrobat:verb-${verb}:${eventName}`; + if (error) { + window.lana?.log( + `Error Code: ${error}, Status: 'Unknown', Message: An error occurred while sending ${verbEvent}, Account Type: ${accountType}`, + { sampleRate: 100, tags: 'DC_Milo,Project Unity (DC)' }, + ); + } else { + window.lana?.log( + `Message: Event ${verbEvent} has been sent successfully, Account Type: ${accountType}`, + { sampleRate: 100, tags: 'DC_Milo,Project Unity (DC)' }, + ); + } + } + }, data: { eventType: 'web.webinteraction.linkClicks', web: { @@ -104,15 +122,6 @@ export default function init(eventName, verb, metaData) { }, }, }; - - // Alloy Ready... - const AlloyReady = setInterval(() => { - // eslint-disable-next-line no-underscore-dangle - if (window?._satellite?.track) { - clearInterval(AlloyReady); - // eslint-disable-next-line no-underscore-dangle - window._satellite?.track('event', event); - } - }, 1000); // eslint-disable-next-line no-underscore-dangle + window._satellite?.track?.('event', event); }