From c056f011ee5d643231213aa40dff4e064d7c376d Mon Sep 17 00:00:00 2001 From: Emma Imber Date: Wed, 8 Jan 2025 14:46:56 +0000 Subject: [PATCH 1/2] Add amiused calls to see if modules handling frontend ads are still being used --- src/insert/article-aside-adverts.ts | 11 +++++++++++ src/insert/high-merch.ts | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/insert/article-aside-adverts.ts b/src/insert/article-aside-adverts.ts index b4aaad9f9..f7bfeba3a 100644 --- a/src/insert/article-aside-adverts.ts +++ b/src/insert/article-aside-adverts.ts @@ -1,3 +1,4 @@ +import { amIUsed } from '../utils/am-i-used'; import fastdom from '../utils/fastdom-promise'; const minArticleHeight = 1300; @@ -59,6 +60,9 @@ export const init = (): Promise => { return Promise.resolve(false); } + // logging to see if this code gets used at all + amIUsed('article-aside-adverts.ts', 'init'); + return fastdom .measure(() => { const immersiveElementOffset = getTopOffset(immersiveEls[0]); @@ -80,6 +84,8 @@ export const init = (): Promise => { window.guardian.config.page.isImmersive && immersiveEls.length > 0 ) { + // logging to see if this conditional block is being fired + amIUsed('article-aside-adverts.ts', 'immersive adjustments'); return fastdom.mutate(() => { removeStickyClasses(adSlotsWithinRightCol); adSlotsWithinRightCol[0]?.setAttribute( @@ -92,6 +98,11 @@ export const init = (): Promise => { // most articles are long enough to fit a DMPU. However, the occasional shorter article // will need the slot sizes to be adjusted, and the sticky behaviour removed. if (mainColHeight < minArticleHeight) { + // logging to see if this conditional block is being fired + amIUsed( + 'article-aside-adverts.ts', + 'short article adjustments', + ); return fastdom.mutate(() => { removeStickyClasses(adSlotsWithinRightCol); adSlotsWithinRightCol[0]?.setAttribute( diff --git a/src/insert/high-merch.ts b/src/insert/high-merch.ts index 9912abb49..0030ec617 100644 --- a/src/insert/high-merch.ts +++ b/src/insert/high-merch.ts @@ -1,5 +1,6 @@ import { createAdSlot, wrapSlotInContainer } from '../core/create-ad-slot'; import { commercialFeatures } from '../lib/commercial-features'; +import { amIUsed } from '../utils/am-i-used'; import fastdom from '../utils/fastdom-promise'; /** @@ -23,6 +24,7 @@ export const init = (): Promise => { // \Remove this return fastdom.mutate(() => { if (anchor?.parentNode) { + amIUsed('high-merch.ts', 'valid anchor'); anchor.parentNode.insertBefore(container, anchor); } }); From e6d647a89ffc84920adedcdff271dd6639b96dfd Mon Sep 17 00:00:00 2001 From: Emma Imber Date: Wed, 8 Jan 2025 14:51:29 +0000 Subject: [PATCH 2/2] Changeset --- .changeset/pretty-feet-worry.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/pretty-feet-worry.md diff --git a/.changeset/pretty-feet-worry.md b/.changeset/pretty-feet-worry.md new file mode 100644 index 000000000..356e8c1ab --- /dev/null +++ b/.changeset/pretty-feet-worry.md @@ -0,0 +1,5 @@ +--- +'@guardian/commercial': patch +--- + +Add amIUsed logs for old frontend modules