Skip to content

Commit

Permalink
PBS adapter: add tmaxmax (#11540)
Browse files Browse the repository at this point in the history
* 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.

* 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.

* Use requestBidsTimeout for tmaxmax alternative

* Update ortbConverter logic so that `requestBidsTimeout` is the alternative value when `tmaxmax` is not available.

* Update prebidServerBidAdapter_spec.js

* Add a test to verify that fallback for `tmaxmax` is `requestBidsTimeout`.
  • Loading branch information
jefftmahoney committed Jun 3, 2024
1 parent fca4691 commit 524c2ad
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
1 change: 1 addition & 0 deletions modules/prebidServerBidAdapter/ortbConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const PBS_CONVERTER = ortbConverter({
const request = buildRequest(imps, proxyBidderRequest, context);

request.tmax = s2sBidRequest.s2sConfig.timeout;
request.ext.tmaxmax = request.ext.tmaxmax || context.s2sBidRequest.requestBidsTimeout;

[request.app, request.dooh, request.site].forEach(section => {
if (section && !section.publisher?.id) {
Expand Down
2 changes: 1 addition & 1 deletion src/adapterManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
38 changes: 33 additions & 5 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -763,12 +763,40 @@ 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);
it('should set tmaxmax correctly when publisher has specified it', () => {
const cfg = {...CONFIG};

// publisher has specified a tmaxmax in their setup
const ortb2Fragments = {
global: {
ext: {
tmaxmax: 4242
}
}
};
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(123);

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 () {
Expand Down

0 comments on commit 524c2ad

Please sign in to comment.