Skip to content

Commit

Permalink
Merge branch 'stage' into MWPW-160929
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinrivero authored Oct 28, 2024
2 parents ae2938a + 6003c0e commit eba66ae
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions acrobat/blocks/verb-widget/verb-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,19 @@ function redDir(verb) {
window.location.href = newLocation;
}

let exitFlag;
function handleExit(event) {
if (exitFlag) { return; }
event.preventDefault();
event.returnValue = true;
}

export default async function init(element) {
if (isOldBrowser()) {
window.location.href = EOLBrowserPage;
return;
}

const ENV = getEnv();
const { locale } = getConfig();
const ppURL = window.mph['verb-widget-privacy-policy-url'] || `https://www.adobe.com${locale.prefix}/privacy/policy.html`;
const touURL = window.mph['verb-widget-terms-of-use-url'] || `https://www.adobe.com${locale.prefix}/legal/terms.html`;
Expand Down Expand Up @@ -250,24 +256,26 @@ export default async function init(element) {
verbAnalytics('job:uploading', VERB, e.detail?.data);
setUser();
document.cookie = `UTS_Uploading=${Date.now()};domain=.adobe.com;path=/;expires=${cookieExp}`;
window.addEventListener('beforeunload', (w) => {
handleExit(w);
});
}

if (e.detail?.event === 'uploaded') {
exitFlag = true;
verbAnalytics('job:uploaded', VERB, e.detail?.data);
setUser();
document.cookie = `UTS_Uploaded=${Date.now()};domain=.adobe.com;path=/;expires=${cookieExp}`;
}
});

if (e.detail?.event === 'redirect to product') {
verbAnalytics('transition', VERB);
setUser();
window.addEventListener('beforeunload', () => {
const date = new Date();
date.setTime(date.getTime() + 1 * 60 * 1000);
const cookieExp = `expires=${date.toUTCString()}`;
if (exitFlag) {
document.cookie = `UTS_Redirect=${Date.now()};domain=.adobe.com;path=/;expires=${cookieExp}`;
}

if (e.detail?.event === 'redirect to product') {
verbAnalytics('transition', VERB);
setUser();
}
});

// Errors, Analytics & Logging
Expand Down

0 comments on commit eba66ae

Please sign in to comment.