Skip to content
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
5 changes: 4 additions & 1 deletion libs/blocks/adobetv/adobetv.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { createTag, getConfig, getFederatedContentRoot } from '../../utils/utils

let captionsLangMapPromise = null;

const logError = (msg, error) => window.lana.log(`${msg}: ${error}`);
const logError = (msg, error) => window.lana.log(`${msg}: ${error}`, {
tags: 'adobetv',
severity: 'error',
});

const updateCaptionsLang = (url, geo, captionsLangMap) => {
if (geo && captionsLangMap) {
Expand Down
5 changes: 4 additions & 1 deletion libs/blocks/article-feed/article-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ export async function loadTaxonomy() {
a.href = tax.link;
} else {
// eslint-disable-next-line no-console
window.lana.log(`Trying to get a link for an unknown topic: ${topic} (current page)`, { tags: 'article-feed' });
window.lana.log(
`Trying to get a link for an unknown topic: ${topic} (current page)`,
{ tags: 'article-feed', severity: 'warning' },
);
a.href = '#';
}
delete a.dataset.topicLink;
Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/article-header/article-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async function validateAuthorUrl(url) {
const resp = await fetch(`${url.toLowerCase()}.plain.html`);
if (!resp?.ok) {
/* c8 ignore next 3 */
window.lana?.log(`Could not retrieve metadata for ${url}`, { tags: 'article-header' });
window.lana?.log(`Could not retrieve metadata for ${url}`, { tags: 'article-header', severity: 'critical' });
return null;
}

Expand Down
5 changes: 4 additions & 1 deletion libs/blocks/caas/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,10 @@ async function getLingoSiteLocale(origin, path, fqdn = 'www.adobe.com') {
});
return lingoSiteMapping;
} catch (e) {
window.lana?.log('Failed to load lingo-site-mapping.json:', e);
window.lana?.log(`Failed to load lingo-site-mapping.json: ${e}`, {
tags: 'caas',
severity: 'error',
});
}
return lingoSiteMapping;
}
Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/event-rich-results/event-rich-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function logNullValues(obj) {
Object.keys(obj).forEach((key) => {
const value = obj[key];
if (!value || value === '') {
window.lana.log(`Event property ${key} is not defined`, { tags: 'event-rich-results' });
window.lana.log(`Event property ${key} is not defined`, { tags: 'event-rich-results', severity: 'warning' });
}
logNullValues(value);
});
Expand Down
5 changes: 4 additions & 1 deletion libs/blocks/faas/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@ const beforeSubmitCallback = () => {
}),
})
.catch((error) => {
window.lana.log(`AA Sandbox Error: ${error.reason || error.error || error.message || error}`, { tags: 'faas', errorType: 'i' });
window.lana.log(
`AA Sandbox Error: ${error.reason || error.error || error.message || error}`,
{ tags: 'faas', errorType: 'i', severity: 'error' },
);
});
}
};
Expand Down
15 changes: 12 additions & 3 deletions libs/blocks/fragment/fragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ export default async function init(a) {
}

if (isCircularRef(relHref)) {
window.lana?.log(`ERROR: Fragment Circular Reference loading ${a.href}`);
window.lana?.log(`Fragment Circular Reference loading ${a.href}`, {
tags: 'fragment',
severity: 'error',
});
return;
}

Expand Down Expand Up @@ -264,7 +267,10 @@ export default async function init(a) {
return;
}
const message = `Could not get ${shouldFetchMepLingo ? 'mep-lingo ' : ''}fragment: ${resourcePath}.plain.html`;
window.lana?.log(message);
window.lana?.log(message, {
tags: 'fragment',
severity: 'error',
});
return;
}

Expand All @@ -275,7 +281,10 @@ export default async function init(a) {

const sections = doc.querySelectorAll('body > div');
if (!sections.length) {
window.lana?.log(`Could not make fragment: ${resourcePath}.plain.html`);
window.lana?.log(`Could not make fragment: ${resourcePath}.plain.html`, {
tags: 'fragment',
severity: 'error',
});
return;
}

Expand Down
15 changes: 13 additions & 2 deletions libs/blocks/global-footer/global-footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class Footer {
error.tags = 'global-footer';
error.url = url;
error.errorType = 'e';
error.severity = 'error';
lanaLog({ message: error.message, ...error });
const { onFooterError } = getConfig();
onFooterError?.(error);
Expand Down Expand Up @@ -272,6 +273,7 @@ class Footer {
e: `${file.statusText} url: ${file.url}`,
tags: 'global-footer',
errorType: 'i',
severity: 'error',
});
}
const content = await file.text();
Expand Down Expand Up @@ -320,7 +322,11 @@ class Footer {
try {
url = new URL(regionSelector.href);
} catch (e) {
lanaLog({ message: `Could not create URL for region picker; href: ${regionSelector.href}`, tags: 'global-footer', errorType: 'e' });
lanaLog({
message: `Could not create URL for region picker; href: ${regionSelector.href}`,
tags: 'global-footer',
severity: 'critical',
});
return this.elements.regionPicker;
}

Expand Down Expand Up @@ -565,7 +571,12 @@ export default function init(block) {
if (isDarkMode()) block.classList.add('feds--dark');
return footer;
} catch (e) {
lanaLog({ message: 'Could not create footer', e });
lanaLog({
message: 'Could not create footer',
e,
tags: 'global-footer',
severity: 'critical',
});
return null;
}
}
6 changes: 5 additions & 1 deletion libs/blocks/global-navigation/features/aside/aside.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ export default async function decorateAside({ headerElem, fedsPromoWrapper, prom
const onError = () => {
fedsPromoWrapper?.remove();
headerElem?.classList.remove('has-promo');
lanaLog({ message: 'Gnav Promo fragment not replaced, potential CLS' });
lanaLog({
message: 'Gnav Promo fragment not replaced, potential CLS',
tags: 'aside',
severity: 'warning',
});
return '';
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ const createWithBase = async (el) => {
element.querySelector('ul')?.prepend(...base.querySelectorAll('li'));
return createBreadcrumbs(element);
} catch (e) {
lanaLog({ e, message: 'Breadcrumbs failed fetching base', tags: 'gnav-breadcrumbs', errorType: 'i' });
lanaLog({
e,
message: 'Breadcrumbs failed fetching base',
tags: 'gnav-breadcrumbs',
errorType: 'i',
severity: 'error',
});
return null;
}
};
Expand Down Expand Up @@ -115,7 +121,12 @@ export default async function init(el) {
setBreadcrumbSEO(breadcrumbsEl);
return breadcrumbsEl;
} catch (e) {
lanaLog({ e, message: 'Breadcrumbs failed rendering', tags: 'gnav-breadcrumbs', errorType: 'e' });
lanaLog({
e,
message: 'Breadcrumbs failed rendering',
tags: 'gnav-breadcrumbs',
severity: 'error',
});
return null;
}
}
24 changes: 14 additions & 10 deletions libs/blocks/global-navigation/global-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const cssPromise = (async () => {
clientId: 'feds-milo',
sampleRate: 1,
tags: 'utilities',
errorType: 'info',
severity: 'error',
});
}
})();
Expand Down Expand Up @@ -207,8 +207,8 @@ export const CONFIG = {
trace: () => {},
debug: () => {},
info: () => {},
warn: (e) => lanaLog({ message: 'Profile Menu warning', e, tags: 'universalnav,warn' }),
error: (e) => lanaLog({ message: 'Profile Menu error', e, tags: 'universalnav', errorType: 'e' }),
warn: (e) => lanaLog({ message: 'Profile Menu warning', e, tags: 'universalnav', severity: 'warning' }),
error: (e) => lanaLog({ message: 'Profile Menu error', e, tags: 'universalnav', severity: 'error' }),
},
},
complexConfig: getConfig().unav?.profile?.complexConfig || null,
Expand Down Expand Up @@ -284,7 +284,7 @@ export const LANGMAP = {
// signIn, decorateSignIn and decorateProfileTrigger can be removed if IMS takes over the profile
const signIn = (options = {}) => {
if (typeof window.adobeIMS?.signIn !== 'function') {
lanaLog({ message: 'IMS signIn method not available', tags: 'gnav,warn' });
lanaLog({ message: 'IMS signIn method not available', tags: 'gnav', severity: 'warning' });
return;
}
window.adobeIMS.signIn(options);
Expand Down Expand Up @@ -320,7 +320,7 @@ const decorateSignIn = async ({ rawElem, decoratedElem }) => {
signIn(SIGNIN_CONTEXT);
});
} else {
lanaLog({ message: 'Sign in link not found in dropdown.', tags: 'gnav,warn' });
lanaLog({ message: 'Sign in link not found in dropdown.', tags: 'gnav', severity: 'warning' });
}

decoratedElem.append(dropdownElem);
Expand Down Expand Up @@ -527,7 +527,7 @@ class Gnav {
window.addEventListener('onImsLibInstance', () => this.imsReady());
return;
}
lanaLog({ message: 'GNAV: Error with IMS', e, tags: 'gnav', errorType: 'i' });
lanaLog({ message: 'GNAV: Error with IMS', e, tags: 'gnav', errorType: 'i', severity: 'error' });
}));

decorateProductEntryCTA = () => {
Expand Down Expand Up @@ -567,15 +567,15 @@ class Gnav {
if (!this.isLocalNav()) {
const localNavWrapper = document.querySelector('.feds-localnav');
if (localNavWrapper) {
lanaLog({ message: 'Gnav Localnav was removed, potential CLS', tags: 'gnav-localnav,warn' });
lanaLog({ message: 'Gnav Localnav was removed, potential CLS', tags: 'gnav-localnav', severity: 'warning' });
localNavWrapper.remove();
}
return;
}
const localNavItems = this.elements.navWrapper.querySelector('.feds-nav').querySelectorAll('.feds-navItem:not(.feds-navItem--section, .feds-navItem--mobile-only)');
const firstElem = localNavItems?.[0]?.querySelector('a, button') || localNavItems?.[0];
if (!firstElem) {
lanaLog({ message: 'GNAV: Incorrect authoring of localnav found.', tags: 'gnav', errorType: 'i' });
lanaLog({ message: 'GNAV: Incorrect authoring of localnav found.', tags: 'gnav', errorType: 'i', severity: 'error' });
return;
}
const [title, navTitle = ''] = this.getOriginalTitle(firstElem);
Expand All @@ -585,6 +585,7 @@ class Gnav {
message: 'GNAV: Localnav does not include \'localnav\' in its name.',
tags: 'gnav',
errorType: 'i',
severity: 'warning',
});
localNav = toFragment`<div class="feds-localnav"/>`;
this.block.after(localNav);
Expand Down Expand Up @@ -762,7 +763,7 @@ class Gnav {

resolve();
} catch (e) {
lanaLog({ message: 'GNAV: Error within loadDelayed', e, tags: 'gnav,warn' });
lanaLog({ message: 'GNAV: Error within loadDelayed', e, tags: 'gnav', severity: 'error' });
resolve();
}
});
Expand All @@ -788,6 +789,7 @@ class Gnav {
tags: 'gnav',
errorType: 'i',
message: `GNAV: issues within imsReady - ${this.useUniversalNav ? 'decorateUniversalNav' : 'decorateProfile'}`,
severity: 'error',
});
}
};
Expand Down Expand Up @@ -828,6 +830,7 @@ class Gnav {
e: `${profileData.statusText} url: ${profileData.url}`,
tags: 'gnav',
errorType: 'i',
severity: 'error',
});
return;
}
Expand Down Expand Up @@ -1186,7 +1189,7 @@ class Gnav {
fedsPromoWrapper.append(this.elements.aside);

if (this.elements.aside.clientHeight > fedsPromoWrapper.clientHeight) {
lanaLog({ message: 'Promo height is more than expected, potential CLS', tags: 'gnav-promo', errorType: 'i' });
lanaLog({ message: 'Promo height is more than expected, potential CLS', tags: 'gnav-promo', errorType: 'i', severity: 'warning' });
}
this.updateGnavTop();
this.promoResizeObserver?.disconnect();
Expand Down Expand Up @@ -1682,6 +1685,7 @@ export default async function init(block) {
error.tags = 'gnav';
error.url = url;
error.errorType = 'e';
error.severity = 'error';
lanaLog({ message: error.message, ...error });
throw error;
}
Expand Down
15 changes: 13 additions & 2 deletions libs/blocks/global-navigation/utilities/keyboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ class KeyboardNavigation {
}
this.desktop = window.matchMedia('(min-width: 900px)');
} catch (e) {
lanaLog({ message: 'Keyboard Navigation failed to load', e, tags: 'gnav-keyboard', errorType: 'e' });
lanaLog({
message: 'Keyboard Navigation failed to load',
e,
tags: 'gnav-keyboard',
severity: 'critical',
});
}
}

Expand All @@ -95,7 +100,13 @@ class KeyboardNavigation {
const { default: LnavNavigation } = await import('./localNav.js');
return new LnavNavigation();
} catch (e) {
lanaLog({ message: 'Keyboard Navigation failed to load for LNAV', e, tags: 'gnav-keyboard', errorType: 'i' });
lanaLog({
message: 'Keyboard Navigation failed to load for LNAV',
e,
tags: 'gnav-keyboard',
errorType: 'i',
severity: 'critical',
});
return null;
}
})();
Expand Down
13 changes: 10 additions & 3 deletions libs/blocks/global-navigation/utilities/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,21 @@ export const darkIcons = {
company: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="22" viewBox="0 0 24 22" fill="none"><path d="M14.2353 21.6209L12.4925 16.7699H8.11657L11.7945 7.51237L17.3741 21.6209H24L15.1548 0.379395H8.90929L0 21.6209H14.2353Z" fill="#FFFFFF"/></svg>',
};

export const lanaLog = ({ message, e = '', tags = 'default', errorType }) => {
export const lanaLog = ({
message,
e = '',
tags = 'default',
errorType,
severity,
} = {}) => {
const { locale = {} } = getConfig();
const url = getMetadata('gnav-source') || `${locale.contentRoot}/gnav`;
window.lana.log(`${message} | gnav-source: ${url} | href: ${window.location.href} | ${e.reason || e.error || e.message || e}`, {
clientId: LANA_CLIENT_ID,
sampleRate: 1,
tags,
errorType,
severity,
});
};

Expand Down Expand Up @@ -117,11 +124,11 @@ export const logPerformance = (
}
};

export const logErrorFor = async (fn, message, tags, errorType) => {
export const logErrorFor = async (fn, message, tags, errorType, severity = 'error') => {
try {
await fn();
} catch (e) {
lanaLog({ message, e, tags, errorType });
lanaLog({ message, e, tags, errorType, severity });
throw new Error(e);
}
};
Expand Down
5 changes: 4 additions & 1 deletion libs/blocks/iframe/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ export function handleIFrameEvents(message) {
const parsedMsg = JSON.parse(data);
if (parsedMsg.app === 'ManagePlan') handleManagePlanEvents(parsedMsg);
} catch (error) {
window.lana?.log(`Error while attempting to parse JSON from an iframe message: ${error}`);
window.lana?.log(`Error while attempting to parse JSON from an iframe message: ${error}`, {
tags: 'iframe',
severity: 'error',
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/library-config/lists/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function formatDom(aemDom, path) {

async function formatTemplate(path) {
const resp = await fetch(path);
if (!resp.ok) window.lana.log('Could not fetch template path', { tags: 'sidekick-templates', errorType: 'i' });
if (!resp.ok) window.lana.log('Could not fetch template path', { tags: 'sidekick-templates', errorType: 'i', severity: 'error' });

const html = await resp.text();
const dom = new DOMParser().parseFromString(html, 'text/html');
Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/m7/m7.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ export default async function init(el) {
});
}
} catch (e) {
window.lana.log(`Cannot generate M7 URL. ${e}`, { tags: 'm7', errorType: 'i' });
window.lana.log(`Cannot generate M7 URL. ${e}`, { tags: 'm7', errorType: 'i', severity: 'error' });
}
}
Loading
Loading