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

Synacormedia bid adapter: add tmax to requests based upon provided timeouts #8526

Merged
merged 1 commit into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions modules/synacormediaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ export const spec = {
imp: []
};

const callbackTimeout = bidderRequest.timeout;
const globalTimeout = config.getConfig('bidderTimeout');
const tmax = globalTimeout ? Math.min(globalTimeout, callbackTimeout) : callbackTimeout;
if (tmax) {
openRtbBidRequest.tmax = tmax;
patmmccann marked this conversation as resolved.
Show resolved Hide resolved
}

const schain = validBidReqs[0].schain;
if (schain) {
openRtbBidRequest.source = { ext: { schain } };
Expand Down
44 changes: 44 additions & 0 deletions test/spec/modules/synacormediaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ describe('synacormediaBidAdapter ', function () {
}
};

let bidderRequestWithTimeout = {
auctionId: 'xyz123',
refererInfo: {
referer: 'https://test.com/foo/bar'
},
timeout: 3000
};

let bidderRequestWithCCPA = {
auctionId: 'xyz123',
refererInfo: {
Expand Down Expand Up @@ -295,6 +303,42 @@ describe('synacormediaBidAdapter ', function () {
expect(reqVideo.data.imp).to.eql([expectedDataVideo1]);
});

it('should return no tmax', function () {
let req = spec.buildRequests([validBidRequest], bidderRequest);
expect(req.data).to.not.have.property('tmax');
});

it('should return tmax equal to callback timeout', function () {
let req = spec.buildRequests([validBidRequest], bidderRequestWithTimeout);
expect(req.data.tmax).to.eql(bidderRequestWithTimeout.timeout);
});

it('should return tmax equal to smaller global timeout', function () {
let sandbox = sinon.sandbox.create();
sandbox.stub(config, 'getConfig').callsFake(key => {
const config = {
'bidderTimeout': bidderRequestWithTimeout.timeout - 100
};
return config[key];
});
let req = spec.buildRequests([validBidRequest], bidderRequestWithTimeout);
sandbox.restore();
expect(req.data.tmax).to.eql(bidderRequestWithTimeout.timeout - 100);
});

it('should return tmax equal to smaller callback timeout', function () {
let sandbox = sinon.sandbox.create();
sandbox.stub(config, 'getConfig').callsFake(key => {
const config = {
'bidderTimeout': bidderRequestWithTimeout.timeout + 100
};
return config[key];
});
let req = spec.buildRequests([validBidRequest], bidderRequestWithTimeout);
sandbox.restore();
expect(req.data.tmax).to.eql(bidderRequestWithTimeout.timeout);
});

it('should return multiple bids when multiple valid requests with the same seatId are used', function () {
let secondBidRequest = {
bidId: 'foobar',
Expand Down