Skip to content

Commit

Permalink
MWPW-138026 Add tags to lana logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon32 committed Dec 7, 2023
1 parent 3833c81 commit 32a71d6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
3 changes: 1 addition & 2 deletions blocks/faas-decode/faas-decode.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ export default async function init(el) {
const resp = await fetch(url);

if (!resp?.ok) {
// eslint-disable-next-line no-console
console.log(`Error fetching data from url: ${url}`);
window.lana?.log(`Error fetching data from url: ${url}`, { tags: 'info, faas-decode' });
return;
}

Expand Down
3 changes: 1 addition & 2 deletions blocks/tree-view/tree-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export const isCurrentPage = (link) => {

if (isBacomHost && url.pathname.replace('.html', '') === currentPath) return true;
} catch (e) {
// eslint-disable-next-line no-console
console.log('Tree View error:', e);
window.lana?.log(`Tree View error:${e.message}`, { tags: 'info, tree-view' });
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,6 @@ const miloLibs = setLibs(LIBS);
}
}
setConfig({ ...CONFIG, miloLibs });
loadLana({ clientId: 'bacom' });
loadLana({ clientId: 'bacom', tags: 'info' });
await loadArea();
}());
6 changes: 4 additions & 2 deletions test/blocks/faas-decode/faas-decode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import init from '../../../blocks/faas-decode/faas-decode.js';
import { setLibs } from '../../../scripts/utils.js';
import waitForElement from '../../helpers/waitForElement.js';

window.lana = { log: () => {} };

describe('FaaS Decode', () => {
before(() => {
sinon.spy(console, 'log');
sinon.stub(window.lana, 'log');
setLibs('/libs');
});

Expand All @@ -18,7 +20,7 @@ describe('FaaS Decode', () => {
document.body.innerHTML = '<div class="faas-decode"><div><div><a href="/404"></a></div></div></div>';
const el = document.querySelector('.faas-decode');
await init(el);
expect(console.log.args[0][0]).to.include('Error fetching data from url:');
expect(window.lana.log.args[0][0]).to.include('Error fetching data from url:');
});

it('creates a table', async () => {
Expand Down
7 changes: 4 additions & 3 deletions test/blocks/tree-view/tree-view.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { setLibs } from '../../../scripts/utils.js';

const { default: init, isCurrentPage } = await import('../../../blocks/tree-view/tree-view.js');

window.lana = { log: () => {} };
setLibs('libs');

describe('Tree View', () => {
Expand Down Expand Up @@ -38,10 +39,10 @@ describe('Tree View', () => {
});

it('isCurrentPage catches error', () => {
sinon.spy(console, 'log');
sinon.stub(window.lana, 'log');
isCurrentPage('/relative-link');
expect(console.log.args[0][0]).to.equal('Tree View error:');
console.log.restore();
expect(window.lana.log.args[0][0]).to.contain('Tree View error:');
window.lana.log.restore();
});

describe('accordion', () => {
Expand Down

0 comments on commit 32a71d6

Please sign in to comment.