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 || proxyBidderRequest.timeout;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After testing this I realized there's a few more steps to take. proxyBidderRequest.timeout here is undefined as it's filtered out here. However, it turns out that timeout is not the one we want:

timeout: s2sConfig.timeout,

my suggestion is to add requestBidsTimeout here:

let s2sBidRequest = {'ad_units': adUnitsS2SCopy, s2sConfig, ortb2Fragments};

and then pick it up from here (should be available under context.s2sBidRequest)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. I've made the suggested changes - or what I understand the suggested changes to be - with 4bb1b47. Happy to answer any questions or follow up as needed!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dgirardi actually, I just tried running my test where I just do this

// request.ext.tmaxmax = request.ext.tmaxmax || context.s2sBidRequest.requestBidsTimeout; --> commenting out temporarily to see what happens if request.ext.tmaxmax is not available for assignment

request.ext.tmaxmax = context.s2sBidRequest.requestBidsTimeout;  

And my test (line 791 of prebidServerBidAdapter_spec.js) fails because the actual value is undefined. Which I guess means requestBidsTimeout is undefined.

I think this means that I need to do additional test-data setup to mimic requestBidsTimeout being available in a real-world scenario.

I'll dig more into this and let you know if further logic changes are required in ortbConverter.js, adapterManager.js or elsewhere.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this means that I need to do additional test-data setup to mimic requestBidsTimeout being available in a real-world scenario.

Only if you add a test case that covers the fallback - which I won't object to. Currently it should pass as it only checks that the input tmaxmax has precedence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. I can verify that it does pass in its current iteration. I'll try adding a fallback test too in a little bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, fallback test added.


[request.app, request.dooh, request.site].forEach(section => {
if (section && !section.publisher?.id) {
Expand Down
20 changes: 20 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,26 @@ describe('S2S Adapter', function () {
expect(req.tmax).to.eql(123);
});

it('should set tmaxmax correctly', () => {
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.ext.tmaxmax).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' };
Expand Down