diff --git a/acrobat/blocks/acom-widget/acom-widget.js b/acrobat/blocks/acom-widget/acom-widget.js index 1d507284..aacae344 100644 --- a/acrobat/blocks/acom-widget/acom-widget.js +++ b/acrobat/blocks/acom-widget/acom-widget.js @@ -1,5 +1,6 @@ import LIMITS from './limits.js'; import { setLibs } from '../../scripts/utils.js'; +import acomAnalytics from '../../scripts/alloy/acom-widget.js'; const miloLibs = setLibs('/libs'); const { createTag } = await import(`${miloLibs}/utils/utils.js`); @@ -23,17 +24,20 @@ const sendToUnity = async (file, verb, err, errTxt) => { // Error Check: File Empty if (file.size < 1) { + acomAnalytics('error:step01:empty-file', verb); handleError(err, errTxt, 'acom-widget-error-empty'); } // Error Check: Supported File Type if (LIMITS[verb].acceptedFiles.indexOf(file.type) < 0) { + acomAnalytics('error:step01:unsupported-file-type', verb); handleError(err, errTxt, 'acom-widget-error-unsupported'); return; } // Error Check: File Too Large if (file.size > LIMITS[verb].maxFileSize) { + acomAnalytics('error:step01:file-too-large', verb); handleError(err, errTxt, 'acom-widget-error-large', LIMITS[verb].maxFileSizeFriendly); } @@ -177,7 +181,14 @@ export default async function init(element) { element.append(widget, footer); + acomAnalytics('landing:shown', VERB); + + button.addEventListener('click', () => { + acomAnalytics('dropzone:choose-file-clicked', VERB); + }); + button.addEventListener('change', (e) => { + acomAnalytics('choose-file:open', VERB); const file = e.target.files[0]; if (file) { sendToUnity(file, VERB, errorState, errorStateText); @@ -186,6 +197,10 @@ export default async function init(element) { e.target.value = ''; }); + button.addEventListener('cancel', () => { + acomAnalytics('choose-file:close', VERB); + }); + widget.addEventListener('dragover', (e) => { e.preventDefault(); setDraggingClass(widget, true); @@ -196,6 +211,7 @@ export default async function init(element) { }); widget.addEventListener('drop', (e) => { + acomAnalytics('files-dropped', VERB); dropFiles(e, VERB, errorState, errorStateText); setDraggingClass(widget, false); }); diff --git a/acrobat/scripts/alloy/acom-widget.js b/acrobat/scripts/alloy/acom-widget.js new file mode 100644 index 00000000..b36f889b --- /dev/null +++ b/acrobat/scripts/alloy/acom-widget.js @@ -0,0 +1,31 @@ +export default function init(eventName, verb) { + const event = { + documentUnloading: true, + data: { + eventType: 'web.webinteraction.linkClicks', + web: { + webInteraction: { + linkClicks: { value: 1 }, + type: 'other', + name: `acrobat:verb-${verb}:${eventName}`, + }, + }, + _adobe_corpnew: { + digitalData: { + dcweb: { event: { pagename: `acrobat:verb-${verb}:${eventName}` } }, + dcweb2: { event: { pagename: `acrobat:verb-${verb}:${eventName}` } }, + }, + }, + }, + }; + // 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 +}