From c9dd9803ec834b0f5baa9da8dd42a0fed3dd36e6 Mon Sep 17 00:00:00 2001 From: Jake Date: Fri, 27 Sep 2024 12:54:21 +0100 Subject: [PATCH] Add new 371x660 prebid size (#1597) --- .changeset/red-bats-grow.md | 5 +++++ playwright/lib/util.ts | 2 +- src/core/ad-sizes.ts | 2 ++ src/events/render-advert.ts | 5 +++++ src/insert/spacefinder/article.ts | 23 +++++++++++++++------ src/lib/header-bidding/prebid/bid-config.ts | 7 +++++++ src/lib/header-bidding/slot-config.spec.ts | 1 + src/lib/header-bidding/slot-config.ts | 6 +++++- 8 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 .changeset/red-bats-grow.md diff --git a/.changeset/red-bats-grow.md b/.changeset/red-bats-grow.md new file mode 100644 index 000000000..11fc36c9a --- /dev/null +++ b/.changeset/red-bats-grow.md @@ -0,0 +1,5 @@ +--- +'@guardian/commercial': minor +--- + +Add new 371x660 size to prebid diff --git a/playwright/lib/util.ts b/playwright/lib/util.ts index a99fa54d7..2a0586e81 100644 --- a/playwright/lib/util.ts +++ b/playwright/lib/util.ts @@ -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 }); } diff --git a/src/core/ad-sizes.ts b/src/core/ad-sizes.ts index 09cfd7d0a..1ed90b818 100644 --- a/src/core/ad-sizes.ts +++ b/src/core/ad-sizes.ts @@ -90,6 +90,7 @@ type SizeKeys = | 'outstreamMobile' | 'portrait' | 'portraitInterstitial' + | 'pubmaticInterscroller' | 'skyscraper' | 'sponsorLogo'; @@ -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 }; /** diff --git a/src/events/render-advert.ts b/src/events/render-advert.ts index 87692a47d..8db7d7ca8 100644 --- a/src/events/render-advert.ts +++ b/src/events/render-advert.ts @@ -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. diff --git a/src/insert/spacefinder/article.ts b/src/insert/spacefinder/article.ts index e85c57547..ce9f53446 100644 --- a/src/insert/spacefinder/article.ts +++ b/src/insert/spacefinder/article.ts @@ -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, @@ -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); diff --git a/src/lib/header-bidding/prebid/bid-config.ts b/src/lib/header-bidding/prebid/bid-config.ts index e04730035..ceb84b503 100644 --- a/src/lib/header-bidding/prebid/bid-config.ts +++ b/src/lib/header-bidding/prebid/bid-config.ts @@ -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, }), }; diff --git a/src/lib/header-bidding/slot-config.spec.ts b/src/lib/header-bidding/slot-config.spec.ts index 4cbea46e9..bd9a6a051 100644 --- a/src/lib/header-bidding/slot-config.spec.ts +++ b/src/lib/header-bidding/slot-config.spec.ts @@ -171,6 +171,7 @@ describe('getPrebidAdSlots', () => { expect(hbSlots[0]?.sizes).toEqual([ createAdSize(300, 250), createAdSize(320, 480), + createAdSize(371, 660), ]); }); diff --git a/src/lib/header-bidding/slot-config.ts b/src/lib/header-bidding/slot-config.ts index bf1717bed..30cf8cb95 100644 --- a/src/lib/header-bidding/slot-config.ts +++ b/src/lib/header-bidding/slot-config.ts @@ -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: {