Skip to content

Commit

Permalink
refactor bidRequest to include all ad slots if not a front
Browse files Browse the repository at this point in the history
  • Loading branch information
dskamiotis committed Dec 6, 2024
1 parent 945d288 commit 8ee4ce7
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions src/lib/header-bidding/a9/a9.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,40 @@ const requestBids = async (

const section = window.guardian.config.page.section;

const isNetworkFront =
section === 'uk' || section === 'us' || section === 'au';

const isNetworkFront = [
'uk',
'us',
'au',
'europe',
'international',
].includes(section);
const isSectionFront = [
'commentisfree',
'sport',
'culture',
'lifeandstyle',
].includes(section);

/**
* Filters the provided ad units based on the current page context.
*
* - If the page is a network front, only the ad unit with the slot ID 'dfp-ad--inline1--mobile' is included.
* - If the page is a section front, only the ad unit with the slot ID 'dfp-ad--top-above-nav' is included.
* - If the page is not a front, all ad units are included.
*
* @param adUnits - The array of ad units to be filtered.
* @returns The filtered array of ad units based on the page context.
*/
const filteredAdUnits = adUnits.filter((adUnit) => {
if (isNetworkFront) {
return adUnit.slotID === 'dfp-ad--inline1--mobile';
}
return adUnit.slotID === 'dfp-ad--top-above-nav';
if (isSectionFront) {
return adUnit.slotID === 'dfp-ad--top-above-nav';
}
if (!window.guardian.config.page.isFront) {
return true;
}
});

requestQueue = requestQueue
Expand Down

0 comments on commit 8ee4ce7

Please sign in to comment.