From 6a2a7cdbdb21abe14a57fdc924336ae19252bdd7 Mon Sep 17 00:00:00 2001 From: Jeff Mahoney Date: Wed, 22 May 2024 10:19:30 -0400 Subject: [PATCH 1/4] Update logic to determine tmax * Update the logic in `ortbConverter.js` so that if a publisher specifies `tmaxmax` as a part of their setup (i.e. specifies it in their `setConfig()` call), `tmaxmax` is what is used to determine `tmax` for a request. --- modules/prebidServerBidAdapter/ortbConverter.js | 2 +- test/spec/modules/prebidServerBidAdapter_spec.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/prebidServerBidAdapter/ortbConverter.js b/modules/prebidServerBidAdapter/ortbConverter.js index e0f038767c2..ef195576da9 100644 --- a/modules/prebidServerBidAdapter/ortbConverter.js +++ b/modules/prebidServerBidAdapter/ortbConverter.js @@ -57,7 +57,7 @@ const PBS_CONVERTER = ortbConverter({ let {s2sBidRequest, requestedBidders, eidPermissions} = context; const request = buildRequest(imps, proxyBidderRequest, context); - request.tmax = s2sBidRequest.s2sConfig.timeout; + request.tmax = s2sBidRequest.s2sConfig.ortb2?.ext?.tmaxmax || s2sBidRequest.s2sConfig.timeout; [request.app, request.dooh, request.site].forEach(section => { if (section && !section.publisher?.id) { diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index 9c2ac8a23a9..003287e391b 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -771,6 +771,19 @@ describe('S2S Adapter', function () { expect(req.tmax).to.eql(123); }); + it('should set tmax correctly if tmaxmax present in configuration', () => { + const tmaxCfg = { + ext: { + tmaxmax: 4242 + } + } + const cfg = { ...CONFIG, ortb2: tmaxCfg }; + config.setConfig({ s2sConfig: cfg }); + adapter.callBids({ ...REQUEST, s2sConfig: cfg }, BID_REQUESTS, addBidResponse, done, ajax); + const req = JSON.parse(server.requests[0].requestBody); + expect(req.tmax).to.eql(4242); + }); + it('should block request if config did not define p1Consent URL in endpoint object config', function () { let badConfig = utils.deepClone(CONFIG); badConfig.endpoint = { noP1Consent: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' }; From b3b3ca4ebc5eee8362aa0737956ae3f2b44760a4 Mon Sep 17 00:00:00 2001 From: Jeff Mahoney Date: Thu, 23 May 2024 18:40:51 -0400 Subject: [PATCH 2/4] Update tmaxmax logic and test * Update `request()` method in ortbConverter.js to properly account for fact that tmaxmax is actually now a new available property off of the ext property. * Update unit test to verify that when a publisher specifies a tmaxmax value in the config setup, it will be honored. --- .../prebidServerBidAdapter/ortbConverter.js | 3 ++- .../modules/prebidServerBidAdapter_spec.js | 25 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/modules/prebidServerBidAdapter/ortbConverter.js b/modules/prebidServerBidAdapter/ortbConverter.js index ef195576da9..b4a45f7e5e6 100644 --- a/modules/prebidServerBidAdapter/ortbConverter.js +++ b/modules/prebidServerBidAdapter/ortbConverter.js @@ -57,7 +57,8 @@ const PBS_CONVERTER = ortbConverter({ let {s2sBidRequest, requestedBidders, eidPermissions} = context; const request = buildRequest(imps, proxyBidderRequest, context); - request.tmax = s2sBidRequest.s2sConfig.ortb2?.ext?.tmaxmax || s2sBidRequest.s2sConfig.timeout; + request.tmax = s2sBidRequest.s2sConfig.timeout; + request.ext.tmaxmax = request.ext.tmaxmax || proxyBidderRequest.timeout; [request.app, request.dooh, request.site].forEach(section => { if (section && !section.publisher?.id) { diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index 003287e391b..8e91bdbf015 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -771,17 +771,24 @@ describe('S2S Adapter', function () { expect(req.tmax).to.eql(123); }); - it('should set tmax correctly if tmaxmax present in configuration', () => { - const tmaxCfg = { - ext: { - tmaxmax: 4242 + it('should set tmaxmax correctly', () => { + const cfg = {...CONFIG}; + + // publisher has specified a tmaxmax in their setup + const ortb2Fragments = { + global: { + ext: { + tmaxmax: 4242 + } } - } - const cfg = { ...CONFIG, ortb2: tmaxCfg }; - config.setConfig({ s2sConfig: cfg }); - adapter.callBids({ ...REQUEST, s2sConfig: cfg }, BID_REQUESTS, addBidResponse, done, ajax); + }; + const s2sCfg = {...REQUEST, cfg} + const payloadWithFragments = { ...s2sCfg, ortb2Fragments }; + + adapter.callBids(payloadWithFragments, BID_REQUESTS, addBidResponse, done, ajax); const req = JSON.parse(server.requests[0].requestBody); - expect(req.tmax).to.eql(4242); + + expect(req.ext.tmaxmax).to.eql(4242); }); it('should block request if config did not define p1Consent URL in endpoint object config', function () { From 4bb1b47a9afe39a601e7fef798f7c74a480e8188 Mon Sep 17 00:00:00 2001 From: Jeff Mahoney Date: Tue, 28 May 2024 23:16:42 -0400 Subject: [PATCH 3/4] Use requestBidsTimeout for tmaxmax alternative * Update ortbConverter logic so that `requestBidsTimeout` is the alternative value when `tmaxmax` is not available. --- modules/prebidServerBidAdapter/ortbConverter.js | 2 +- src/adapterManager.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/prebidServerBidAdapter/ortbConverter.js b/modules/prebidServerBidAdapter/ortbConverter.js index b4a45f7e5e6..34803e1d2fe 100644 --- a/modules/prebidServerBidAdapter/ortbConverter.js +++ b/modules/prebidServerBidAdapter/ortbConverter.js @@ -58,7 +58,7 @@ const PBS_CONVERTER = ortbConverter({ const request = buildRequest(imps, proxyBidderRequest, context); request.tmax = s2sBidRequest.s2sConfig.timeout; - request.ext.tmaxmax = request.ext.tmaxmax || proxyBidderRequest.timeout; + request.ext.tmaxmax = request.ext.tmaxmax || context.s2sBidRequest.requestBidsTimeout; [request.app, request.dooh, request.site].forEach(section => { if (section && !section.publisher?.id) { diff --git a/src/adapterManager.js b/src/adapterManager.js index 557f4c1eee4..8228001892d 100644 --- a/src/adapterManager.js +++ b/src/adapterManager.js @@ -420,7 +420,7 @@ adapterManager.callBids = (adUnits, bidRequests, addBidResponse, doneCb, request let uniqueServerRequests = serverBidderRequests.filter(serverBidRequest => serverBidRequest.uniquePbsTid === uniquePbsTid); if (s2sAdapter) { - let s2sBidRequest = {'ad_units': adUnitsS2SCopy, s2sConfig, ortb2Fragments}; + let s2sBidRequest = {'ad_units': adUnitsS2SCopy, s2sConfig, ortb2Fragments, requestBidsTimeout}; if (s2sBidRequest.ad_units.length) { let doneCbs = uniqueServerRequests.map(bidRequest => { bidRequest.start = timestamp(); From f20d82192c29597d4c00c57b3fb007f50da55a4c Mon Sep 17 00:00:00 2001 From: Jeff Mahoney Date: Wed, 29 May 2024 18:04:38 -0400 Subject: [PATCH 4/4] Update prebidServerBidAdapter_spec.js * Add a test to verify that fallback for `tmaxmax` is `requestBidsTimeout`. --- .../modules/prebidServerBidAdapter_spec.js | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index 8e91bdbf015..d2446b1ca0d 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -763,15 +763,7 @@ describe('S2S Adapter', function () { }); }) - it('should set tmax to s2sConfig.timeout', () => { - const cfg = {...CONFIG, timeout: 123}; - config.setConfig({s2sConfig: cfg}); - adapter.callBids({...REQUEST, s2sConfig: cfg}, BID_REQUESTS, addBidResponse, done, ajax); - const req = JSON.parse(server.requests[0].requestBody); - expect(req.tmax).to.eql(123); - }); - - it('should set tmaxmax correctly', () => { + it('should set tmaxmax correctly when publisher has specified it', () => { const cfg = {...CONFIG}; // publisher has specified a tmaxmax in their setup @@ -791,6 +783,22 @@ describe('S2S Adapter', function () { expect(req.ext.tmaxmax).to.eql(4242); }); + it('should set tmaxmax correctly when publisher has not specified it', () => { + const cfg = {...CONFIG}; + + // publisher has not specified a tmaxmax in their setup - so we should be + // falling back to requestBidsTimeout + const ortb2Fragments = {}; + const s2sCfg = {...REQUEST, cfg}; + const requestBidsTimeout = 808; + const payloadWithFragments = { ...s2sCfg, ortb2Fragments, requestBidsTimeout }; + + adapter.callBids(payloadWithFragments, BID_REQUESTS, addBidResponse, done, ajax); + const req = JSON.parse(server.requests[0].requestBody); + + expect(req.ext.tmaxmax).to.eql(808); + }); + it('should block request if config did not define p1Consent URL in endpoint object config', function () { let badConfig = utils.deepClone(CONFIG); badConfig.endpoint = { noP1Consent: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' };