From 977a792e78d053be0dbaba8522be37eb68dd72b3 Mon Sep 17 00:00:00 2001 From: Megan Thomas Date: Thu, 16 Nov 2023 13:32:27 -0800 Subject: [PATCH] MWPW-135908 Add lana (#29) * MWPW-135908 Add lana * tags --- blog/scripts/scripts.js | 3 ++- blog/scripts/utils.js | 3 +-- test/scripts/utils.test.js | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/blog/scripts/scripts.js b/blog/scripts/scripts.js index 5e491ea..51f2d53 100644 --- a/blog/scripts/scripts.js +++ b/blog/scripts/scripts.js @@ -140,9 +140,10 @@ const miloLibs = setLibs(LIBS); }()); (async function loadPage() { - const { loadArea, setConfig } = await import(`${miloLibs}/utils/utils.js`); + const { loadArea, setConfig, loadLana } = await import(`${miloLibs}/utils/utils.js`); setConfig({ ...CONFIG, miloLibs }); + loadLana({ clientId: 'bacom-blog', tags: 'default' }); await buildAutoBlocks(); await loadArea(); }()); diff --git a/blog/scripts/utils.js b/blog/scripts/utils.js index a25fa5d..2f59ccf 100644 --- a/blog/scripts/utils.js +++ b/blog/scripts/utils.js @@ -139,7 +139,6 @@ export async function buildAutoBlocks() { await buildArticleHeader(mainEl); } } catch (error) { - // eslint-disable-next-line no-console - console.error('Auto Blocking failed', error); + window.lana?.log(`Auto Blocking failed: ${error}`, { tags: 'autoBlock' }); } } diff --git a/test/scripts/utils.test.js b/test/scripts/utils.test.js index 6b32872..88dc878 100644 --- a/test/scripts/utils.test.js +++ b/test/scripts/utils.test.js @@ -48,24 +48,26 @@ describe('Libs', () => { const metadata = await readFile({ path: './mocks/tagsHead.html' }); +window.lana = { log: () => {} }; + describe('Auto Blocks', () => { before(() => { setLibs('/libs'); }); beforeEach(() => { - sinon.stub(console, 'error'); + sinon.stub(window.lana, 'log'); }); afterEach(() => { - console.error.restore(); + window.lana.log.restore(); }); it('catches errors', async () => { document.head.innerHTML = metadata; document.body.innerHTML = ''; await buildAutoBlocks(); - expect(console.error.calledWith('Auto Blocking failed')).to.be.true; + expect(window.lana.log.called).to.be.true; }); it('builds the tags block', async () => {