Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove a9 block bidder add for fronts #1692

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hip-lemons-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@guardian/commercial': patch
---

serve gumgum interscroller for Fronts
53 changes: 45 additions & 8 deletions src/lib/header-bidding/a9/a9.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class A9AdUnit implements A9AdUnitInterface {

constructor(advert: Advert, slot: HeaderBiddingSlot) {
this.slotID = advert.id;
this.slotName = window.guardian.config.page.adUnit;
this.slotName = `${window.guardian.config.page.adUnit}/${this.slotID}`;
this.sizes = slot.sizes.map((size) => Array.from(size));
}
}
Expand All @@ -30,16 +30,10 @@ const bidderTimeout = 1500;
const initialise = (): void => {
if (!initialised && window.apstag) {
initialised = true;
const blockedBidders = window.guardian.config.page.isFront
? [
'1lsxjb4', // GumGum, as they have been showing wonky formats on fronts
]
: [];
window.apstag.init({
pubID: window.guardian.config.page.a9PublisherId,
adServer: 'googletag',
bidTimeout: bidderTimeout,
blockedBidders,
});
}
};
Expand Down Expand Up @@ -70,11 +64,54 @@ const requestBids = async (
return requestQueue;
}

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

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.
* - There is a cross over in logic where the page is both an article as well as a network front/section front,
* - in this case we want to identify the page as a non-front page (arrticle) and include all ad units.
*
* @param adUnits - The array of ad units to be filtered.
* @returns The filtered array of ad units based on the page context.
*/
const updatedAdUnits = adUnits.map((adUnit) => {
let blockedBidders: string[] = [];

if (isNetworkFront && adUnit.slotID === 'dfp-ad--inline1--mobile') {
blockedBidders = ['1lsxjb4']; // Block GumGum for network front condition
} else if (
isSectionFront &&
adUnit.slotID === 'dfp-ad--top-above-nav'
) {
blockedBidders = ['1lsxjb4']; // Block GumGum for section front condition
}

return { ...adUnit, params: { blockedBidders } };
});

requestQueue = requestQueue
.then(
() =>
new Promise<void>((resolve) => {
window.apstag?.fetchBids({ slots: adUnits }, () => {
window.apstag?.fetchBids({ slots: updatedAdUnits }, () => {
window.googletag.cmd.push(() => {
window.apstag?.setDisplayBids();
resolve();
Expand Down
1 change: 0 additions & 1 deletion src/types/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ type ApstagInitConfig = {
pubID: string;
adServer?: string;
bidTimeout?: number;
blockedBidders?: string[];
};

type FetchBidsBidConfig = {
Expand Down
Loading