Skip to content

Commit

Permalink
Add new 371x660 prebid size (#1597)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakeii authored Sep 27, 2024
1 parent 70a4cb8 commit c9dd980
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-bats-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@guardian/commercial': minor
---

Add new 371x660 size to prebid
2 changes: 1 addition & 1 deletion playwright/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ const waitForSlot = async (page: Page, slot: string, waitForIframe = true) => {

if (waitForIframe) {
// iframe locator
const iframe = page.locator(`${slotId} iframe`);
const iframe = page.locator(`${slotId} iframe:first-child`);
// wait for the iframe
await iframe.waitFor({ state: 'visible', timeout: 120000 });
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/ad-sizes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ type SizeKeys =
| 'outstreamMobile'
| 'portrait'
| 'portraitInterstitial'
| 'pubmaticInterscroller'
| 'skyscraper'
| 'sponsorLogo';

Expand Down Expand Up @@ -158,6 +159,7 @@ const proprietaryAdSizes = {
fluid: createAdSize(0, 0),
googleCard: createAdSize(300, 274),
outOfPage: createAdSize(1, 1),
pubmaticInterscroller: createAdSize(371, 660), // pubmatic only mobile size
};

/**
Expand Down
5 changes: 5 additions & 0 deletions src/events/render-advert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ sizeCallbacks[adSizes.outstreamMobile.toString()] = (advert: Advert) =>
sizeCallbacks[adSizes.googleCard.toString()] = (advert: Advert) =>
advert.updateExtraSlotClasses('ad-slot--gc');

sizeCallbacks[adSizes.pubmaticInterscroller.toString()] = (advert: Advert) => {
advert.shouldRefresh = false;
return Promise.resolve();
};

/**
* Out of page adverts - creatives that aren't directly shown on the page - need to be hidden,
* and their containers closed up.
Expand Down
23 changes: 17 additions & 6 deletions src/insert/spacefinder/article.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,22 @@ const addDesktopRightRailAds = (
);
};

const additionalMobileAndTabletInlineSizes = (index: number) => {
if (index === 1) {
return {
mobile: [adSizes.portraitInterstitial],
};
} else if (index === 2) {
return {
mobile: [
adSizes.portraitInterstitial,
adSizes.pubmaticInterscroller,
],
};
}
return undefined;
};

const addMobileAndTabletInlineAds = (
fillSlot: FillAdSlot,
currentBreakpoint: ReturnType<typeof getCurrentBreakpoint>,
Expand All @@ -209,12 +225,7 @@ const addMobileAndTabletInlineAds = (
return fillSlot(
name,
slot,
// Add the mobile portrait interstitial size to inline1 and inline2
i == 1 || i == 2
? {
mobile: [adSizes.portraitInterstitial],
}
: undefined,
additionalMobileAndTabletInlineSizes(i),
);
});
await Promise.all(slots);
Expand Down
7 changes: 7 additions & 0 deletions src/lib/header-bidding/prebid/bid-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,13 @@ const pubmaticBidder = (slotSizes: HeaderBiddingSize[]): PrebidBidder => {
bidParams: (slotId: string): PrebidPubmaticParams => ({
publisherId: getPubmaticPublisherId(),
adSlot: stripDfpAdPrefixFrom(slotId),
placementId:
slotId === 'dfp-ad--inline2' &&
slotSizes.find(
(size) => size.width === 371 && size.height === 660,
)
? 'seenthis_guardian_371x660'
: undefined,
}),
};

Expand Down
1 change: 1 addition & 0 deletions src/lib/header-bidding/slot-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ describe('getPrebidAdSlots', () => {
expect(hbSlots[0]?.sizes).toEqual([
createAdSize(300, 250),
createAdSize(320, 480),
createAdSize(371, 660),
]);
});

Expand Down
6 changes: 5 additions & 1 deletion src/lib/header-bidding/slot-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ const getSlots = (): HeaderBiddingSizeMapping => {
: [adSizes.mpu],
tablet: [adSizes.mpu],
mobile: isArticle
? [adSizes.mpu, adSizes.portraitInterstitial]
? [
adSizes.mpu,
adSizes.portraitInterstitial,
adSizes.pubmaticInterscroller,
]
: [adSizes.mpu],
},
mostpop: {
Expand Down

0 comments on commit c9dd980

Please sign in to comment.