Skip to content

Commit

Permalink
MWPW-158122
Browse files Browse the repository at this point in the history
  • Loading branch information
Blainegunn committed Sep 18, 2024
1 parent 8bce0c7 commit 5abd28f
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 7 deletions.
24 changes: 19 additions & 5 deletions acrobat/blocks/verb-widget/verb-widget.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import LIMITS from './limits.js';
import { setLibs, isOldBrowser } from '../../scripts/utils.js';
import verbAnalytics from '../../scripts/alloy/verb-widget.js';
Expand All @@ -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');
Expand All @@ -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;
// }
Expand All @@ -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');
Expand Down Expand Up @@ -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);
});
Expand All @@ -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);
Expand All @@ -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();
}
});
}
65 changes: 63 additions & 2 deletions acrobat/scripts/alloy/verb-widget.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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'}`,
],
},
},
},
},
},
Expand Down

0 comments on commit 5abd28f

Please sign in to comment.