From 4ca9a4840b51f29d137291332b308b17bc0e0cb8 Mon Sep 17 00:00:00 2001 From: bosco-ensemble Date: Wed, 17 Apr 2024 09:49:25 -0700 Subject: [PATCH 1/4] TDW-2409 added ability to fetch ad_test value from url params --- blocks/marketing/marketing.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/blocks/marketing/marketing.js b/blocks/marketing/marketing.js index 1bb173e4..9484c18b 100644 --- a/blocks/marketing/marketing.js +++ b/blocks/marketing/marketing.js @@ -82,10 +82,21 @@ export default async function decorate(block) { } } else { window.tude.setFeatureFlags({ injectAds: false }); - window.tude.refreshAdsViaDivMappings([{ - divId: slot, - baseDivId: slot, - }]); + const ad_test = new URLSearchParams(window.location.search).get('ad_test'); + if(ad_test) { + window.tude.refreshAdsViaDivMappings([{ + divId: slot, + baseDivId: slot, + targeting: { + ad_test: ad_test + } + }]); + } else { + window.tude.refreshAdsViaDivMappings([{ + divId: slot, + baseDivId: slot, + }]); + } } }); }); From ab7758b1d463d460e268a1679a4c76bf3363a428 Mon Sep 17 00:00:00 2001 From: bosco-ensemble Date: Wed, 17 Apr 2024 09:54:48 -0700 Subject: [PATCH 2/4] TDW-2409 lint fix --- blocks/marketing/marketing.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/blocks/marketing/marketing.js b/blocks/marketing/marketing.js index 9484c18b..ca5116fc 100644 --- a/blocks/marketing/marketing.js +++ b/blocks/marketing/marketing.js @@ -82,14 +82,14 @@ export default async function decorate(block) { } } else { window.tude.setFeatureFlags({ injectAds: false }); - const ad_test = new URLSearchParams(window.location.search).get('ad_test'); - if(ad_test) { + const adTest = new URLSearchParams(window.location.search).get('ad_test'); + if (adTest) { window.tude.refreshAdsViaDivMappings([{ divId: slot, baseDivId: slot, targeting: { - ad_test: ad_test - } + ad_test: adTest, + }, }]); } else { window.tude.refreshAdsViaDivMappings([{ From ffd29c1576d5ef244f31f042c5c486bdd02c8d0f Mon Sep 17 00:00:00 2001 From: bosco-ensemble Date: Wed, 17 Apr 2024 12:35:07 -0700 Subject: [PATCH 3/4] TDW-2409 changed conditional statement --- blocks/marketing/marketing.js | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/blocks/marketing/marketing.js b/blocks/marketing/marketing.js index ca5116fc..1ecd2f27 100644 --- a/blocks/marketing/marketing.js +++ b/blocks/marketing/marketing.js @@ -81,22 +81,18 @@ export default async function decorate(block) { document.addEventListener('scroll', checkBottomAdDisplay); } } else { - window.tude.setFeatureFlags({ injectAds: false }); + window.tude.setFeatureFlags({injectAds: false}); const adTest = new URLSearchParams(window.location.search).get('ad_test'); - if (adTest) { - window.tude.refreshAdsViaDivMappings([{ - divId: slot, - baseDivId: slot, - targeting: { - ad_test: adTest, - }, - }]); - } else { - window.tude.refreshAdsViaDivMappings([{ - divId: slot, - baseDivId: slot, - }]); + const adMapping = { + divId: slot, + baseDivId: slot, } + if (adTest) adMapping.targeting = { + ad_test: adTest, + } + window.tude.refreshAdsViaDivMappings([ + adMapping + ]); } }); }); From 5fc797f862f98480e5936366cc7e45307de0ee92 Mon Sep 17 00:00:00 2001 From: bosco-ensemble Date: Wed, 17 Apr 2024 12:43:53 -0700 Subject: [PATCH 4/4] TDW-2409 lint fix --- blocks/marketing/marketing.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/blocks/marketing/marketing.js b/blocks/marketing/marketing.js index 1ecd2f27..737922fb 100644 --- a/blocks/marketing/marketing.js +++ b/blocks/marketing/marketing.js @@ -81,17 +81,19 @@ export default async function decorate(block) { document.addEventListener('scroll', checkBottomAdDisplay); } } else { - window.tude.setFeatureFlags({injectAds: false}); + window.tude.setFeatureFlags({ injectAds: false }); const adTest = new URLSearchParams(window.location.search).get('ad_test'); const adMapping = { divId: slot, baseDivId: slot, - } - if (adTest) adMapping.targeting = { - ad_test: adTest, + }; + if (adTest) { + adMapping.targeting = { + ad_test: adTest, + }; } window.tude.refreshAdsViaDivMappings([ - adMapping + adMapping, ]); } });