Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-135230 DC Widget Backup / Logging Improvements #331

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions acrobat/blocks/dc-converter-widget/dc-converter-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ const pageLang = localeMap[langFromPath] || 'en-us';
export default async function init(element) {
element.closest('main > div').dataset.section = 'widget';
const widget = element;
const DC_WIDGET_VERSION_FALLBACK = '2.40.0_1.172.1';
const DC_GENERATE_CACHE_VERSION_FALLBACK = '1.172.1';
const DC_WIDGET_VERSION_FALLBACK = '3.7.1_2.14.0';
const DC_GENERATE_CACHE_VERSION_FALLBACK = '2.14.0';
const STG_DC_WIDGET_VERSION = document.querySelector('meta[name="stg-dc-widget-version"]')?.getAttribute('content');
const STG_DC_GENERATE_CACHE_VERSION = document.querySelector('meta[name="stg-dc-generate-cache-version"]')?.getAttribute('content');

Expand All @@ -132,13 +132,17 @@ export default async function init(element) {
sampleRate: 1,
tags: 'Cat=DxDC_Frictionless,origin=milo',
};
// LANA
window.dcwErrors = [];
if (!DC_WIDGET_VERSION) {
DC_WIDGET_VERSION = DC_WIDGET_VERSION_FALLBACK;
window.lana?.log(`DC WIDGET VERSION IS NOT SET, USING FALLBACK VERSION: ${DC_WIDGET_VERSION_FALLBACK}`, lanaOptions);
dcwErrors.push(`DC WIDGET VERSION IS NOT SET, USING FALLBACK VERSION: ${DC_WIDGET_VERSION_FALLBACK}`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these reference window.dcwErrors ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to ask whether this line should be changed to include window.. Probably only a lint issue.

}
if (!DC_GENERATE_CACHE_VERSION) {
DC_GENERATE_CACHE_VERSION = DC_GENERATE_CACHE_VERSION_FALLBACK;
window.lana?.log(`DC GENERATE CACHE VERSION IS NOT SET, USING FALLBACK VERSION: ${DC_GENERATE_CACHE_VERSION_FALLBACK}`, lanaOptions);
dcwErrors.push(`DC GENERATE CACHE VERSION IS NOT SET, USING FALLBACK VERSION: ${DC_GENERATE_CACHE_VERSION_FALLBACK}`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

}
let WIDGET_ENV = `https://dev.acrobat.adobe.com/dc-hosted/${DC_WIDGET_VERSION}/dc-app-launcher.js`;
let ENV = 'dev';
Expand Down
9 changes: 7 additions & 2 deletions acrobat/scripts/dcLana.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,21 @@ export default function lanaLogging() {
}
}, 10000);

window.dcwErrors?.forEach((error) => {
lanaOptions.tags = 'Cat=DxDC_Frictionless,origin=milo';
window.lana.log(error, lanaOptions);
});

// Content Security Policy Logging
if (fricPage) {
window.cspErrors.forEach((error) => {
window.cspErrors?.forEach((error) => {
lanaCspOptions.tags = 'Cat=DxDC_Frictionless_CSP,origin=milo';
window.lana.log(error, lanaCspOptions);
})

document.addEventListener("securitypolicyviolation", (e) => {
lanaCspOptions.tags = 'Cat=DxDC_Frictionless_CSP,origin=milo';
window.lana.log(`${e.violatedDirective} violation ¶ Refused to load content from ${e.blockedURI}`, lanaCspOptions);
});
});
}
}
2 changes: 2 additions & 0 deletions acrobat/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,10 @@ const { ietf } = getLocale(locales);
loadArea, loadScript, setConfig, loadLana, getMetadata
} = await import(`${miloLibs}/utils/utils.js`);
addLocale(ietf);

setConfig({ ...CONFIG, miloLibs });
loadLana({ clientId: 'dxdc' });

// get event back form dc web and then load area
await loadArea(document, false);

Expand Down
Loading