From c6723355530324984f21812b91a0a5c0dd8a0df2 Mon Sep 17 00:00:00 2001 From: "Timothy M. Ace" Date: Tue, 31 May 2022 16:24:28 -0400 Subject: [PATCH] CAPT-74: Pass ext section of each bid for prebid slot ID and GPID --- modules/synacormediaBidAdapter.js | 13 +++- .../modules/synacormediaBidAdapter_spec.js | 74 +++++++++++++++++++ 2 files changed, 85 insertions(+), 2 deletions(-) diff --git a/modules/synacormediaBidAdapter.js b/modules/synacormediaBidAdapter.js index 4cc648a2e04..76e33ffbf79 100644 --- a/modules/synacormediaBidAdapter.js +++ b/modules/synacormediaBidAdapter.js @@ -1,6 +1,6 @@ 'use strict'; -import {deepSetValue, getAdUnitSizes, isFn, isPlainObject, logWarn} from '../src/utils.js'; +import {deepAccess, deepSetValue, getAdUnitSizes, isFn, isPlainObject, logWarn} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {includes} from '../src/polyfill.js'; @@ -79,7 +79,16 @@ export const spec = { imps = this.buildVideoImpressions(adSizes, bid, tagIdOrPlacementId, pos, videoOrBannerKey); } if (imps.length > 0) { - imps.forEach(i => openRtbBidRequest.imp.push(i)); + imps.forEach(i => { + // Deeply add ext section to all imp[] for GPID, prebid slot id, and anything else down the line + const extSection = deepAccess(bid, 'ortb2Imp.ext'); + if (extSection) { + deepSetValue(i, 'ext', extSection); + } + + // Add imp[] to request object + openRtbBidRequest.imp.push(i); + }); } }); diff --git a/test/spec/modules/synacormediaBidAdapter_spec.js b/test/spec/modules/synacormediaBidAdapter_spec.js index b9a02799219..2779658ff6a 100644 --- a/test/spec/modules/synacormediaBidAdapter_spec.js +++ b/test/spec/modules/synacormediaBidAdapter_spec.js @@ -1362,4 +1362,78 @@ describe('synacormediaBidAdapter ', function () { expect(videoRequest.data.imp[0].bidfloor).to.equal(priceModuleFloor); }); }); + + describe('Bid Requests with gpid or anything in bid.ext should use if available', function () { + let validVideoBidRequest = { + bidder: 'synacormedia', + params: { + seatId: 'prebid', + placementId: 'demo1', + pos: 1, + video: {} + }, + renderer: { + url: '../syncOutstreamPlayer.js' + }, + ortb2Imp: { + ext: { + gpid: '/1111/homepage-video', + data: { + pbadslot: '/1111/homepage-video' + } + } + }, + mediaTypes: { + video: { + playerSize: [[300, 250]], + context: 'outstream' + } + }, + adUnitCode: 'div-1', + transactionId: '0869f34e-090b-4b20-84ee-46ff41405a39', + sizes: [[300, 250]], + bidId: '22b3a2268d9f0e', + bidderRequestId: '1d195910597e13', + auctionId: '3375d336-2aea-4ee7-804c-6d26b621ad20', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 + }; + + let validBannerBidRequest = { + bidId: '9876abcd', + sizes: [[300, 250]], + params: { + seatId: 'prebid', + placementId: '1234', + }, + ortb2Imp: { + ext: { + gpid: '/1111/homepage-banner', + data: { + pbadslot: '/1111/homepage-banner' + } + } + } + }; + + let bidderRequest = { + refererInfo: { + referer: 'http://localhost:9999/' + }, + bidderCode: 'synacormedia', + auctionId: 'f8a75621-d672-4cbb-9275-3db7d74fb110' + }; + + it('should return valid gpid and pbadslot', function () { + let videoRequest = spec.buildRequests([validVideoBidRequest], bidderRequest); + let bannerRequest = spec.buildRequests([validBannerBidRequest], bidderRequest); + + expect(videoRequest.data.imp[0].ext.gpid).to.equal('/1111/homepage-video'); + expect(videoRequest.data.imp[0].ext.data.pbadslot).to.equal('/1111/homepage-video'); + expect(bannerRequest.data.imp[0].ext.gpid).to.equal('/1111/homepage-banner'); + expect(bannerRequest.data.imp[0].ext.data.pbadslot).to.equal('/1111/homepage-banner'); + }); + }); });