diff --git a/modules/sharethroughBidAdapter.js b/modules/sharethroughBidAdapter.js index 53cb67c4e6d..ae1fb131966 100644 --- a/modules/sharethroughBidAdapter.js +++ b/modules/sharethroughBidAdapter.js @@ -1,7 +1,7 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; -import { deepAccess, generateUUID, inIframe } from '../src/utils.js'; +import { deepAccess, generateUUID, inIframe, mergeDeep } from '../src/utils.js'; const VERSION = '4.3.0'; const BIDDER_CODE = 'sharethrough'; @@ -104,6 +104,10 @@ export const sharethroughAdapterSpec = { const videoRequest = deepAccess(bidReq, 'mediaTypes.video'); + if (bidderRequest.fledgeEnabled && bidReq.mediaTypes.banner) { + mergeDeep(impression, { ext: { ae: 1 } }); // ae = auction environment; if this is 1, ad server knows we have a fledge auction + } + if (videoRequest) { // default playerSize, only change this if we know width and height are properly defined in the request let [w, h] = [640, 360]; @@ -116,6 +120,14 @@ export const sharethroughAdapterSpec = { [w, h] = videoRequest.playerSize[0]; } + const getVideoPlacementValue = (vidReq) => { + if (vidReq.plcmt) { + return vidReq.placement; + } else { + return vidReq.context === 'instream' ? 1 : +deepAccess(vidReq, 'placement', 4); + } + }; + impression.video = { pos: nullish(videoRequest.pos, 0), topframe: inIframe() ? 0 : 1, @@ -132,7 +144,8 @@ export const sharethroughAdapterSpec = { startdelay: nullish(videoRequest.startdelay, 0), skipmin: nullish(videoRequest.skipmin, 0), skipafter: nullish(videoRequest.skipafter, 0), - placement: videoRequest.context === 'instream' ? 1 : +deepAccess(videoRequest, 'placement', 4), + placement: getVideoPlacementValue(videoRequest), + plcmt: videoRequest.plcmt ? videoRequest.plcmt : null, }; if (videoRequest.delivery) impression.video.delivery = videoRequest.delivery; @@ -179,7 +192,9 @@ export const sharethroughAdapterSpec = { return []; } - return body.seatbid[0].bid.map((bid) => { + const fledgeAuctionEnabled = body.ext?.auctionConfigs; + + const bidsFromExchange = body.seatbid[0].bid.map((bid) => { // Spec: https://docs.prebid.org/dev-docs/bidder-adaptor.html#interpreting-the-response const response = { requestId: bid.impid, @@ -219,6 +234,15 @@ export const sharethroughAdapterSpec = { return response; }); + + if (fledgeAuctionEnabled) { + return { + bids: bidsFromExchange, + fledgeAuctionConfigs: body.ext?.auctionConfigs || {}, + }; + } else { + return bidsFromExchange; + } }, getUserSyncs: (syncOptions, serverResponses) => { diff --git a/test/spec/modules/sharethroughBidAdapter_spec.js b/test/spec/modules/sharethroughBidAdapter_spec.js index 6a63ae681e7..1bb6f898b81 100644 --- a/test/spec/modules/sharethroughBidAdapter_spec.js +++ b/test/spec/modules/sharethroughBidAdapter_spec.js @@ -585,6 +585,27 @@ describe('sharethrough adapter spec', function () { expect(videoImp.placement).to.equal(4); }); + + it('should not override "placement" value if "plcmt" prop is present', () => { + // ASSEMBLE + const ARBITRARY_PLACEMENT_VALUE = 99; + const ARBITRARY_PLCMT_VALUE = 100; + + bidRequests[1].mediaTypes.video.context = 'instream'; + bidRequests[1].mediaTypes.video.placement = ARBITRARY_PLACEMENT_VALUE; + + // adding "plcmt" property - this should prevent "placement" prop + // from getting overridden to 1 + bidRequests[1].mediaTypes.video['plcmt'] = ARBITRARY_PLCMT_VALUE; + + // ACT + const builtRequest = spec.buildRequests(bidRequests, bidderRequest)[1]; + const videoImp = builtRequest.data.imp[0].video; + + // ASSERT + expect(videoImp.placement).to.equal(ARBITRARY_PLACEMENT_VALUE); + expect(videoImp.plcmt).to.equal(ARBITRARY_PLCMT_VALUE); + }); }); }); @@ -692,6 +713,22 @@ describe('sharethrough adapter spec', function () { expect(openRtbReq.regs.ext.gpp_sid).to.equal(firstPartyData.regs.gpp_sid); }); }); + + describe('fledge', () => { + it('should attach "ae" as a property to the request if 1) fledge auctions are enabled, and 2) request is display (only supporting display for now)', () => { + // ASSEMBLE + const EXPECTED_AE_VALUE = 1; + + // ACT + bidderRequest['fledgeEnabled'] = true; + const builtRequests = spec.buildRequests(bidRequests, bidderRequest); + const ACTUAL_AE_VALUE = builtRequests[0].data.imp[0].ext.ae; + + // ASSERT + expect(ACTUAL_AE_VALUE).to.equal(EXPECTED_AE_VALUE); + expect(builtRequests[1].data.imp[0].ext.ae).to.be.undefined; + }); + }); }); describe('interpretResponse', function () {