Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PBS adapter: add tmaxmax #11540

Merged
merged 10 commits into from
Jun 3, 2024
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