diff --git a/acrobat/blocks/verb-widget/verb-widget.js b/acrobat/blocks/verb-widget/verb-widget.js index cc54d9e0..73a766dd 100644 --- a/acrobat/blocks/verb-widget/verb-widget.js +++ b/acrobat/blocks/verb-widget/verb-widget.js @@ -1,4 +1,3 @@ - import LIMITS from './limits.js'; import { setLibs, isOldBrowser } from '../../scripts/utils.js'; import verbAnalytics from '../../scripts/alloy/verb-widget.js'; @@ -8,6 +7,10 @@ const { createTag } = await import(`${miloLibs}/utils/utils.js`); const EOLBrowserPage = 'https://acrobat.adobe.com/home/index-browser-eol.html'; +const setUser = () => { + localStorage.setItem('unity.user', 'true'); +}; + // const handleError = (err, errTxt, str, strTwo) => { // err.classList.add('verb-error'); // err.classList.remove('hide'); @@ -27,13 +30,13 @@ const EOLBrowserPage = 'https://acrobat.adobe.com/home/index-browser-eol.html'; // const sendToUnity = async (file, verb, err, errTxt) => { // // Error Check: File Empty // if (file.size < 1) { -// verbAnalytics('error:step01:empty-file', verb); +// verbAnalytics('error:empty_file', verb); // handleError(err, errTxt, 'verb-widget-error-empty'); // } // // Error Check: Supported File Type // if (LIMITS[verb].acceptedFiles.indexOf(file.type) < 0) { -// verbAnalytics('error:step01:unsupported-file-type', verb); +// verbAnalytics('error:unsupported_type', verb); // handleError(err, errTxt, 'verb-widget-error-unsupported'); // return; // } @@ -44,6 +47,8 @@ const EOLBrowserPage = 'https://acrobat.adobe.com/home/index-browser-eol.html'; // handleError(err, errTxt, 'verb-widget-error-large', LIMITS[verb].maxFileSizeFriendly); // } // }; +// Page: Upload Error acrobat:verb-fillsign:error +// Page: Upload Error acrobat:verb-fillsign:error:max_page_count const setDraggingClass = (widget, shouldToggle) => { shouldToggle ? widget.classList.add('dragging') : widget.classList.remove('dragging'); @@ -108,6 +113,10 @@ export default async function init(element) { verbAnalytics('landing:shown', VERB); + widgetMobileButton.addEventListener('click', () => { + verbAnalytics('goto-app:clicked', VERB); + }); + button.addEventListener('click', () => { verbAnalytics('dropzone:choose-file-clicked', VERB); }); @@ -116,6 +125,9 @@ export default async function init(element) { verbAnalytics('choose-file:close', VERB); }); + // Page : File upload events acrobat:verb-fillsign:job:uploaded + // Page : File upload events acrobat:verb-fillsign:job:uploading + widget.addEventListener('dragover', (e) => { e.preventDefault(); setDraggingClass(widget, true); @@ -131,12 +143,14 @@ export default async function init(element) { }); window.addEventListener('unity:track-analytics', (e) => { - if (e.detail.event === 'change') { + if (e.detail?.event === 'change') { verbAnalytics('choose-file:open', VERB); + setUser(); } - if (e.detail.event === 'drop') { + if (e.detail?.event === 'drop') { verbAnalytics('files-dropped', VERB); setDraggingClass(widget, false); + setUser(); } }); } diff --git a/acrobat/scripts/alloy/verb-widget.js b/acrobat/scripts/alloy/verb-widget.js index b36f889b..73624ed8 100644 --- a/acrobat/scripts/alloy/verb-widget.js +++ b/acrobat/scripts/alloy/verb-widget.js @@ -1,3 +1,28 @@ +const params = new Proxy( + // eslint-disable-next-line compat/compat + new URLSearchParams(window.location.search), + { get: (searchParams, prop) => searchParams.get(prop) }, +); + +let appReferrer = params.x_api_client_id || params['x-product'] || ''; +if (params.x_api_client_location || params['x-product-location']) { + appReferrer = `${appReferrer}:${params.x_api_client_location || params['x-product-location']}`; +} +let trackingId = params.trackingid || ''; +if (params.mv) { + trackingId = `${trackingId}:${params.mv}`; +} +if (params.mv2) { + trackingId = `${trackingId}:${params.mv2}`; +} +const appTags = []; +if (params.workflow) { + appTags.push(params.workflow); +} +if (params.dropzone2) { + appTags.push('dropzone2'); +} + export default function init(eventName, verb) { const event = { documentUnloading: true, @@ -12,8 +37,44 @@ export default function init(eventName, verb) { }, _adobe_corpnew: { digitalData: { - dcweb: { event: { pagename: `acrobat:verb-${verb}:${eventName}` } }, - dcweb2: { event: { pagename: `acrobat:verb-${verb}:${eventName}` } }, + dcweb: { + event: { pagename: `acrobat:verb-${verb}:${eventName}` }, + source: { + user_agent: navigator.userAgent, + lang: document.documentElement.lang, + app_name: 'unity:adobe_com', + url: window.location.href, + app_referrer: appReferrer, + tracking_id: trackingId, + }, + user: { + locale: document.documentElement.lang.toLocaleLowerCase(), + id: 'DO WE NEED THIS?', + is_authenticated: false, + user_tags: [ + `${localStorage['unity.user'] ? 'frictionless_return_user' : 'frictionless_new_user'}`, + ], + }, + }, + dcweb2: { + event: { pagename: `acrobat:verb-${verb}:${eventName}` }, + source: { + user_agent: navigator.userAgent, + lang: document.documentElement.lang, + app_name: 'unity:adobe_com', + url: window.location.href, + app_referrer: appReferrer, + tracking_id: trackingId, + }, + user: { + locale: document.documentElement.lang.toLocaleLowerCase(), + id: 'DO WE NEED THIS?', + is_authenticated: false, + user_tags: [ + `${localStorage['unity.user'] ? 'frictionless_return_user' : 'frictionless_new_user'}`, + ], + }, + }, }, }, },