Skip to content

Commit

Permalink
Passing epoch and tmax to translator request
Browse files Browse the repository at this point in the history
  • Loading branch information
Kapil Tuptewar authored and pm-azhar-mulla committed Aug 30, 2022
1 parent d464c5f commit 8316884
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,18 @@ export const spec = {
mergeDeep(payload, {user: commonFpd.user});
}

// Check if bidderRequest has timeout property if present send timeout as tmax value to translator request
// bidderRequest has timeout property if publisher sets during calling requestBids function from page
// if not bidderRequest contains global value set by Prebid
if (bidderRequest?.timeout) {
payload.tmax = bidderRequest.timeout || config.getConfig('bidderTimeout');
} else {
payload.tmax = window?.PWT?.versionDetails?.timeout;
}

// Sending epoch timestamp in request.ext object
payload.ext.epoch = new Date().getTime();

// Note: Do not move this block up
// if site object is set in Prebid config then we need to copy required fields from site into app and unset the site object
if (typeof config.getConfig('app') === 'object') {
Expand Down
16 changes: 16 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,22 @@ describe('PubMatic adapter', function () {
expect(data.source.ext.schain).to.deep.equal(bidRequests[0].schain);
});

it('Set tmax from global config if not set by requestBids method', function() {
let sandbox = sinon.sandbox.create();
sandbox.stub(config, 'getConfig').callsFake((key) => {
var config = {
bidderTimeout: 3000
};
return config[key];
});
let request = spec.buildRequests(bidRequests, {
auctionId: 'new-auction-id', timeout: 3000
});
let data = JSON.parse(request.data);
expect(data.tmax).to.deep.equal(3000);
sandbox.restore();
});

it('Set content from config, set site.content', function() {
let sandbox = sinon.sandbox.create();
const content = {
Expand Down

0 comments on commit 8316884

Please sign in to comment.