From a1d29479013ac1685b742be23a37a290fec114d0 Mon Sep 17 00:00:00 2001 From: Lyubomir Shishkov <61063794+lyubomirshishkov@users.noreply.github.com> Date: Wed, 12 Feb 2025 20:52:11 +0200 Subject: [PATCH 1/2] ## FMSC-1894 - Add support for MultiBid in Improve Digital's Prebid Bid Adapter * **Type:** Feature * **Scope:** improvedigitalBidAdapter.js, improvedigitalBidAdapter_spec.js * **Subject:** Adds multi-bid support in Improve Digital's Bid Adapter * **Breaks:** N/A --- modules/improvedigitalBidAdapter.js | 8 +++ .../modules/improvedigitalBidAdapter_spec.js | 65 +++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/modules/improvedigitalBidAdapter.js b/modules/improvedigitalBidAdapter.js index 33ba08e8fd2..82d969cf4c8 100644 --- a/modules/improvedigitalBidAdapter.js +++ b/modules/improvedigitalBidAdapter.js @@ -172,6 +172,14 @@ export const CONVERTER = ortbConverter({ } deepSetValue(imp, `${bidderParamsPath}.keyValues`, getBidIdParameter('keyValues', bidRequest.params) || undefined); + const maxBids = config.getConfig('multibid') + ?.find(multiBidSetting => multiBidSetting?.bidder === BIDDER_CODE || multiBidSetting.bidders?.includes(BIDDER_CODE)) + ?.maxBids; + + if (maxBids) { + deepSetValue(imp, 'ext.max_bids', maxBids); + } + return imp; }, request(buildRequest, imps, bidderRequest, context) { diff --git a/test/spec/modules/improvedigitalBidAdapter_spec.js b/test/spec/modules/improvedigitalBidAdapter_spec.js index 46e07bacbe4..2ad9bece301 100644 --- a/test/spec/modules/improvedigitalBidAdapter_spec.js +++ b/test/spec/modules/improvedigitalBidAdapter_spec.js @@ -708,6 +708,71 @@ describe('Improve Digital Adapter Tests', function () { expect(payload.imp[0].ext.prebid.storedrequest.id).to.equal('123456'); }); + it('should add max_bids param in imp.ext objects when multibid is enabled for improve digital individually', function () { + getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub.withArgs('multibid').returns([ + {bidder: 'improvedigital', maxBids: 3}, + {bidder: 'otherBidder', maxBids: 2}, + ]); + + const requests = spec.buildRequests([simpleBidRequest, instreamBidRequest], bidderRequest); + + // banner + let payload = JSON.parse(requests[0].data); + expect(payload.imp[0].ext.max_bids).to.equal(3); + // video + payload = JSON.parse(requests[1].data); + expect(payload.imp[0].ext.max_bids).to.equal(3); + }); + + it('should add max_bids param in imp.ext objects when multibid is enabled for improve digital and others', function () { + getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub.withArgs('multibid').returns([ + {bidders: ['improvedigital', 'otherBidderWithMultiBid'], maxBids: 3}, + {bidder: 'otherBidder', maxBids: 2}, + ]); + + const requests = spec.buildRequests([simpleBidRequest, instreamBidRequest], bidderRequest); + + // banner + let payload = JSON.parse(requests[0].data); + expect(payload.imp[0].ext.max_bids).to.equal(3); + // video + payload = JSON.parse(requests[1].data); + expect(payload.imp[0].ext.max_bids).to.equal(3); + }); + + it('should not add max_bids param in imp.ext objects when multibid is not enabled at all', function () { + getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub.withArgs('multibid').returns(undefined); + + const requests = spec.buildRequests([simpleBidRequest, instreamBidRequest], bidderRequest); + + // banner + let payload = JSON.parse(requests[0].data); + expect(payload.imp[0].ext.max_bids).to.not.exist; + // video + payload = JSON.parse(requests[1].data); + expect(payload.imp[0].ext.max_bids).to.not.exist; + }); + + it('should not add max_bids param in imp.ext objects when multibid is not enabled for improve digital', function () { + getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub.withArgs('multibid').returns([ + {bidders: ['otherBidderWithMultiBid'], maxBids: 3}, + {bidder: 'otherBidder', maxBids: 2}, + ]); + + const requests = spec.buildRequests([simpleBidRequest, instreamBidRequest], bidderRequest); + + // banner + let payload = JSON.parse(requests[0].data); + expect(payload.imp[0].ext.max_bids).to.not.exist; + // video + payload = JSON.parse(requests[1].data); + expect(payload.imp[0].ext.max_bids).to.not.exist; + }); + it('should set extend url when extend mode enabled in adunit params', function () { const bidRequest = deepClone(extendBidRequest); let request = spec.buildRequests([bidRequest], { bids: [bidRequest] })[0]; From 44c225098958849ee653b6e4b6533e8e015f24eb Mon Sep 17 00:00:00 2001 From: Lyubomir Shishkov <61063794+lyubomirshishkov@users.noreply.github.com> Date: Fri, 14 Feb 2025 11:26:52 +0200 Subject: [PATCH 2/2] * modified `CONVERTER.imp method` to use `bidderRequest.bidLimit`, instead of getting the multibid config. --- modules/improvedigitalBidAdapter.js | 8 +-- .../modules/improvedigitalBidAdapter_spec.js | 53 ++----------------- 2 files changed, 6 insertions(+), 55 deletions(-) diff --git a/modules/improvedigitalBidAdapter.js b/modules/improvedigitalBidAdapter.js index 82d969cf4c8..a1eb685b6a0 100644 --- a/modules/improvedigitalBidAdapter.js +++ b/modules/improvedigitalBidAdapter.js @@ -172,13 +172,7 @@ export const CONVERTER = ortbConverter({ } deepSetValue(imp, `${bidderParamsPath}.keyValues`, getBidIdParameter('keyValues', bidRequest.params) || undefined); - const maxBids = config.getConfig('multibid') - ?.find(multiBidSetting => multiBidSetting?.bidder === BIDDER_CODE || multiBidSetting.bidders?.includes(BIDDER_CODE)) - ?.maxBids; - - if (maxBids) { - deepSetValue(imp, 'ext.max_bids', maxBids); - } + context.bidderRequest.bidLimit && deepSetValue(imp, 'ext.max_bids', context.bidderRequest.bidLimit); return imp; }, diff --git a/test/spec/modules/improvedigitalBidAdapter_spec.js b/test/spec/modules/improvedigitalBidAdapter_spec.js index 2ad9bece301..24362d7861a 100644 --- a/test/spec/modules/improvedigitalBidAdapter_spec.js +++ b/test/spec/modules/improvedigitalBidAdapter_spec.js @@ -708,32 +708,10 @@ describe('Improve Digital Adapter Tests', function () { expect(payload.imp[0].ext.prebid.storedrequest.id).to.equal('123456'); }); - it('should add max_bids param in imp.ext objects when multibid is enabled for improve digital individually', function () { - getConfigStub = sinon.stub(config, 'getConfig'); - getConfigStub.withArgs('multibid').returns([ - {bidder: 'improvedigital', maxBids: 3}, - {bidder: 'otherBidder', maxBids: 2}, - ]); - - const requests = spec.buildRequests([simpleBidRequest, instreamBidRequest], bidderRequest); - - // banner - let payload = JSON.parse(requests[0].data); - expect(payload.imp[0].ext.max_bids).to.equal(3); - // video - payload = JSON.parse(requests[1].data); - expect(payload.imp[0].ext.max_bids).to.equal(3); - }); - - it('should add max_bids param in imp.ext objects when multibid is enabled for improve digital and others', function () { - getConfigStub = sinon.stub(config, 'getConfig'); - getConfigStub.withArgs('multibid').returns([ - {bidders: ['improvedigital', 'otherBidderWithMultiBid'], maxBids: 3}, - {bidder: 'otherBidder', maxBids: 2}, - ]); - - const requests = spec.buildRequests([simpleBidRequest, instreamBidRequest], bidderRequest); - + it('should add max_bids param in imp.ext objects when bidLimit is specified in the bidderRequest', function () { + const bidderRequestDeepClone = deepClone(bidderRequest); + bidderRequestDeepClone.bidLimit = 3; + const requests = spec.buildRequests([simpleBidRequest, instreamBidRequest], bidderRequestDeepClone); // banner let payload = JSON.parse(requests[0].data); expect(payload.imp[0].ext.max_bids).to.equal(3); @@ -742,29 +720,8 @@ describe('Improve Digital Adapter Tests', function () { expect(payload.imp[0].ext.max_bids).to.equal(3); }); - it('should not add max_bids param in imp.ext objects when multibid is not enabled at all', function () { - getConfigStub = sinon.stub(config, 'getConfig'); - getConfigStub.withArgs('multibid').returns(undefined); - + it('should not add max_bids param in imp.ext objects when bidLimit is not specified in the bidderRequest', function () { const requests = spec.buildRequests([simpleBidRequest, instreamBidRequest], bidderRequest); - - // banner - let payload = JSON.parse(requests[0].data); - expect(payload.imp[0].ext.max_bids).to.not.exist; - // video - payload = JSON.parse(requests[1].data); - expect(payload.imp[0].ext.max_bids).to.not.exist; - }); - - it('should not add max_bids param in imp.ext objects when multibid is not enabled for improve digital', function () { - getConfigStub = sinon.stub(config, 'getConfig'); - getConfigStub.withArgs('multibid').returns([ - {bidders: ['otherBidderWithMultiBid'], maxBids: 3}, - {bidder: 'otherBidder', maxBids: 2}, - ]); - - const requests = spec.buildRequests([simpleBidRequest, instreamBidRequest], bidderRequest); - // banner let payload = JSON.parse(requests[0].data); expect(payload.imp[0].ext.max_bids).to.not.exist;