From 1b231bfcd17115d64f6db3ab106f719bbf9fda52 Mon Sep 17 00:00:00 2001 From: Blaine Gunn Date: Mon, 23 Sep 2024 13:42:17 -0600 Subject: [PATCH 1/2] MWPW-158944 --- acrobat/blocks/verb-widget/limits.js | 4 +-- acrobat/blocks/verb-widget/verb-widget.js | 34 +++++++++++------------ acrobat/scripts/alloy/verb-widget.js | 10 +++---- acrobat/scripts/scripts.js | 3 +- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/acrobat/blocks/verb-widget/limits.js b/acrobat/blocks/verb-widget/limits.js index 76e6d950..298a1073 100644 --- a/acrobat/blocks/verb-widget/limits.js +++ b/acrobat/blocks/verb-widget/limits.js @@ -1,7 +1,7 @@ const LIMITS = { fillsign: { - maxFileSize: 100000000, // 1 MB - maxFileSizeFriendly: '100 MB', // 1 MB + maxFileSize: 100000000, // 100 MB + maxFileSizeFriendly: '100 MB', // 100 MB acceptedFiles: ['application/pdf'], maxNumFiles: 1, mobileApp: true, diff --git a/acrobat/blocks/verb-widget/verb-widget.js b/acrobat/blocks/verb-widget/verb-widget.js index a01ae945..04c40add 100644 --- a/acrobat/blocks/verb-widget/verb-widget.js +++ b/acrobat/blocks/verb-widget/verb-widget.js @@ -11,17 +11,6 @@ const setUser = () => { localStorage.setItem('unity.user', 'true'); }; -const handleError = (err, errTxt, str, strTwo) => { - err.classList.add('verb-error'); - err.classList.remove('hide'); - errTxt.textContent = `${window.mph[str]} ${strTwo || ''}`; - - setTimeout(() => { - err.classList.remove('verb-error'); - err.classList.add('hide'); - }, 5000); -}; - const setDraggingClass = (widget, shouldToggle) => { // eslint-disable-next-line chai-friendly/no-unused-expressions shouldToggle ? widget.classList.add('dragging') : widget.classList.remove('dragging'); @@ -147,32 +136,43 @@ export default async function init(element) { }); // Errors, Analytics & Logging + const handleError = (str) => { + errorState.classList.add('verb-error'); + errorState.classList.remove('hide'); + errorStateText.textContent = str; + + setTimeout(() => { + errorState.classList.remove('verb-error'); + errorState.classList.add('hide'); + }, 5000); + }; + window.addEventListener('unity:show-error-toast', (e) => { console.log(`⛔️ Error Code - ${e.detail?.code}`); if (e.detail?.code === 'only_accept_one_file') { - handleError(errorState, errorStateText, 'verb-widget-error-multi'); + handleError(e.detail?.message); verbAnalytics('error', VERB); } if (e.detail?.code === 'unsupported_type') { - handleError(errorState, errorStateText, 'verb-widget-error-unsupported'); + handleError(e.detail?.message); verbAnalytics('error:unsupported_type', VERB); } if (e.detail?.code === 'empty_file') { - handleError(errorState, errorStateText, 'verb-widget-error-empty'); + handleError(e.detail?.message); verbAnalytics('error:empty_file', VERB); } // Code may be wrong. should be 'file_too_large' if (e.detail?.code === 'file_too_largempty_file') { - handleError(errorState, errorStateText, 'verb-widget-error-large', LIMITS[VERB].maxFileSizeFriendly); + handleError(e.detail?.message); verbAnalytics('error', VERB); } if (e.detail?.code === 'max_page_count') { - handleError(errorState, errorStateText, 'verb-widget-error-max', LIMITS[VERB].maxNumFiles); + handleError(e.detail?.message); verbAnalytics('error:max_page_count', VERB); } @@ -183,5 +183,5 @@ export default async function init(element) { }); } -// const ce = (new CustomEvent('unity:show-error-toast', { detail: { code: 'only_accept_one_file', message: 'Error message' } })); +// const ce = (new CustomEvent('unity:show-error-toast', { detail: { event: 'choose-file-clicked', data: {size: 33, type: 'df'}, code: 'only_accept_one_file', message: 'Error message' } })); // dispatchEvent(ce) diff --git a/acrobat/scripts/alloy/verb-widget.js b/acrobat/scripts/alloy/verb-widget.js index c5829ac9..f3b5cff5 100644 --- a/acrobat/scripts/alloy/verb-widget.js +++ b/acrobat/scripts/alloy/verb-widget.js @@ -23,8 +23,8 @@ if (params.dropzone2) { appTags.push('dropzone2'); } -export default function init(eventName, verb) { - console.log(`📡 Event Name - acrobat:verb-${verb}:${eventName}`); +export default function init(eventName, verb, metaData) { + console.log(`📡 Event Name - acrobat:verb-${verb}:${eventName} - metaData: ${metaData?.type} / ${metaData?.size} `); const event = { documentUnloading: true, data: { @@ -66,10 +66,10 @@ export default function init(eventName, verb) { dcweb2: { event: { pagename: `acrobat:verb-${verb}:${eventName}` }, content: { - type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - size: '2-5MB', + type: metaData?.type, + size: metaData?.size, count: 1, - extension: 'docx', + // extension: 'docx', may not be needed }, source: { user_agent: navigator.userAgent, diff --git a/acrobat/scripts/scripts.js b/acrobat/scripts/scripts.js index 2fcecfa8..8809a0a0 100644 --- a/acrobat/scripts/scripts.js +++ b/acrobat/scripts/scripts.js @@ -28,8 +28,7 @@ const setLibs = (prodLibs, location) => { if (branch === 'main' && hostname === 'www.stage.adobe.com') return 'https://www.stage.adobe.com/libs'; if (!(hostname.includes('.hlx.') || hostname.includes('local') || hostname.includes('stage'))) return prodLibs; if (branch === 'local') return 'http://localhost:6456/libs'; - const tld = hostname.includes('live') ? 'live' : 'page'; - return branch.includes('--') ? `https://${branch}.hlx.${tld}/libs` : `https://${branch}--milo--adobecom.hlx.${tld}/libs`; + return branch.includes('--') ? `https://${branch}.hlx.live/libs` : `https://${branch}--milo--adobecom.hlx.live/libs`; }; const getLocale = (locales, pathname = window.location.pathname) => { From 957ebd83f6c5c42c1f017a0c70442f1a76628bbb Mon Sep 17 00:00:00 2001 From: Blaine Gunn Date: Wed, 25 Sep 2024 14:40:17 -0600 Subject: [PATCH 2/2] more errors and new pattern --- acrobat/blocks/verb-widget/verb-widget.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/acrobat/blocks/verb-widget/verb-widget.js b/acrobat/blocks/verb-widget/verb-widget.js index 04c40add..ff8b477e 100644 --- a/acrobat/blocks/verb-widget/verb-widget.js +++ b/acrobat/blocks/verb-widget/verb-widget.js @@ -150,35 +150,41 @@ export default async function init(element) { window.addEventListener('unity:show-error-toast', (e) => { console.log(`⛔️ Error Code - ${e.detail?.code}`); - if (e.detail?.code === 'only_accept_one_file') { + if (e.detail?.code.includes('error_only_accept_one_file')) { handleError(e.detail?.message); verbAnalytics('error', VERB); } - if (e.detail?.code === 'unsupported_type') { + if (e.detail?.code.includes('error_unsupported_type')) { handleError(e.detail?.message); verbAnalytics('error:unsupported_type', VERB); } - if (e.detail?.code === 'empty_file') { + if (e.detail?.code.includes('error_empty_file')) { handleError(e.detail?.message); verbAnalytics('error:empty_file', VERB); } - // Code may be wrong. should be 'file_too_large' - if (e.detail?.code === 'file_too_largempty_file') { + if (e.detail?.code.includes('error_file_too_large')) { handleError(e.detail?.message); verbAnalytics('error', VERB); } - if (e.detail?.code === 'max_page_count') { + if (e.detail?.code.includes('error_max_page_count')) { handleError(e.detail?.message); verbAnalytics('error:max_page_count', VERB); } + if (e.detail?.code.includes('error_generic') + || e.detail?.code.includes('error_max_quota_exceeded') + || e.detail?.code.includes('error_no_storage_provision') + || e.detail?.code.includes('error_duplicate_asset')) { + handleError(e.detail?.message); + verbAnalytics('error', VERB); + } + // acrobat:verb-fillsign:error:page_count_missing_from_metadata_api // acrobat:verb-fillsign:error:403 - // acrobat:verb-fillsign:error // LANA for 403 }); }