Skip to content

Commit

Permalink
Merge pull request #895 from adobecom/MWPW-162640
Browse files Browse the repository at this point in the history
MWPW-162640: Lana logging for additional error scenarios
  • Loading branch information
TsayAdobe authored Nov 18, 2024
2 parents 5f853a9 + ef5ecaf commit d1718ce
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions acrobat/blocks/verb-widget/verb-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,55 +279,60 @@ export default async function init(element) {

// Errors, Analytics & Logging
const lanaOptions = {
sampleRate: 1,
sampleRate: 100,
tags: 'DC_Milo,Project Unity (DC)',
};

const handleError = (str) => {
const handleError = (str, logToLana = false, logOptions = {}, e = null) => {
setDraggingClass(widget, false);
errorState.classList.add('verb-error');
errorState.classList.remove('hide');
errorStateText.textContent = str;

if (logToLana && e) {
const status = e.detail?.status || 'Unknown status';
const message = e.detail?.message || 'Unknown message';
window.lana?.log(`Error Status: ${status}, Error Message: ${message}`, logOptions);
}

setTimeout(() => {
errorState.classList.remove('verb-error');
errorState.classList.add('hide');
}, 5000);
};

element.addEventListener('unity:show-error-toast', (e) => {
// eslint-disable-next-line no-console
if (e.detail?.code.includes('error_only_accept_one_file')) {
handleError(e.detail?.message);
handleError(e.detail?.message, true, lanaOptions, e);
verbAnalytics('error', VERB);
}

if (e.detail?.code.includes('error_unsupported_type')) {
handleError(e.detail?.message);
handleError(e.detail?.message, true, lanaOptions, e);
verbAnalytics('error:unsupported_type', VERB);
}

if (e.detail?.code.includes('error_empty_file')) {
handleError(e.detail?.message);
handleError(e.detail?.message, true, lanaOptions, e);
verbAnalytics('error:empty_file', VERB);
}

if (e.detail?.code.includes('error_file_too_large')) {
handleError(e.detail?.message);
handleError(e.detail?.message, true, lanaOptions, e);
verbAnalytics('error', VERB);
}

if (e.detail?.code.includes('error_max_page_count')) {
handleError(e.detail?.message);
handleError(e.detail?.message, true, lanaOptions, e);
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);
handleError(e.detail?.message, true, lanaOptions, e);
verbAnalytics('error', VERB);
window.lana?.log(`Error Status: ${e.detail?.message}, Error Message: ${e.detail?.status}`, lanaOptions);
}

// acrobat:verb-fillsign:error:page_count_missing_from_metadata_api
Expand Down

0 comments on commit d1718ce

Please sign in to comment.