From 9bf82f07a74a48e1ce1395164b98342c7958f33f Mon Sep 17 00:00:00 2001 From: Megan Thomas Date: Tue, 14 Nov 2023 15:56:13 -0800 Subject: [PATCH 1/2] MWPW-135908 Add lana --- 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..18057ab 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' }); await buildAutoBlocks(); await loadArea(); }()); diff --git a/blog/scripts/utils.js b/blog/scripts/utils.js index a25fa5d..26e298e 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); } } diff --git a/test/scripts/utils.test.js b/test/scripts/utils.test.js index 6b32872..c9dcbea 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.calledWith('Auto Blocking failed')).to.be.true; }); it('builds the tags block', async () => { From eae7691bcd800d28dcda1ca943be62f2c650a0d8 Mon Sep 17 00:00:00 2001 From: Megan Thomas Date: Wed, 15 Nov 2023 15:49:39 -0800 Subject: [PATCH 2/2] tags --- blog/scripts/scripts.js | 2 +- blog/scripts/utils.js | 2 +- test/scripts/utils.test.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/blog/scripts/scripts.js b/blog/scripts/scripts.js index 18057ab..51f2d53 100644 --- a/blog/scripts/scripts.js +++ b/blog/scripts/scripts.js @@ -143,7 +143,7 @@ const miloLibs = setLibs(LIBS); const { loadArea, setConfig, loadLana } = await import(`${miloLibs}/utils/utils.js`); setConfig({ ...CONFIG, miloLibs }); - loadLana({ clientId: 'bacom-blog' }); + loadLana({ clientId: 'bacom-blog', tags: 'default' }); await buildAutoBlocks(); await loadArea(); }()); diff --git a/blog/scripts/utils.js b/blog/scripts/utils.js index 26e298e..2f59ccf 100644 --- a/blog/scripts/utils.js +++ b/blog/scripts/utils.js @@ -139,6 +139,6 @@ export async function buildAutoBlocks() { await buildArticleHeader(mainEl); } } catch (error) { - window.lana?.log('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 c9dcbea..88dc878 100644 --- a/test/scripts/utils.test.js +++ b/test/scripts/utils.test.js @@ -67,7 +67,7 @@ describe('Auto Blocks', () => { document.head.innerHTML = metadata; document.body.innerHTML = ''; await buildAutoBlocks(); - expect(window.lana.log.calledWith('Auto Blocking failed')).to.be.true; + expect(window.lana.log.called).to.be.true; }); it('builds the tags block', async () => {