Skip to content

Commit

Permalink
add support for userSyncLimit field in s2sConfig (#3375)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnellbaker authored and mike-chowla committed Dec 18, 2018
1 parent 691dcf6 commit f2e5f17
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ function queueSync(bidderCodes, gdprConsent) {
account: _s2sConfig.accountId
};

let userSyncLimit = _s2sConfig.userSyncLimit;
if (utils.isNumber(userSyncLimit) && userSyncLimit > 0) {
payload['limit'] = userSyncLimit;
}

if (gdprConsent) {
// only populate gdpr field if we know CMP returned consent information (ie didn't timeout or have an error)
if (typeof gdprConsent.consentString !== 'undefined') {
Expand Down
42 changes: 42 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,48 @@ describe('S2S Adapter', function () {
value: ['buzz']
}]);
});

it('adds limit to the cookie_sync request if userSyncLimit is greater than 0', function () {
let cookieSyncConfig = utils.deepClone(CONFIG);
cookieSyncConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync';
cookieSyncConfig.userSyncLimit = 1;

config.setConfig({ s2sConfig: cookieSyncConfig });

let bidRequest = utils.deepClone(BID_REQUESTS);
adapter.callBids(REQUEST, bidRequest, addBidResponse, done, ajax);
let requestBid = JSON.parse(requests[0].requestBody);

expect(requestBid.bidders).to.contain('appnexus').and.to.have.lengthOf(1);
expect(requestBid.account).is.equal('1');
expect(requestBid.limit).is.equal(1);
});

it('does not add limit to cooke_sync request if userSyncLimit is missing or 0', function () {
let cookieSyncConfig = utils.deepClone(CONFIG);
cookieSyncConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync';
config.setConfig({ s2sConfig: cookieSyncConfig });

let bidRequest = utils.deepClone(BID_REQUESTS);
adapter.callBids(REQUEST, bidRequest, addBidResponse, done, ajax);
let requestBid = JSON.parse(requests[0].requestBody);

expect(requestBid.bidders).to.contain('appnexus').and.to.have.lengthOf(1);
expect(requestBid.account).is.equal('1');
expect(requestBid.limit).is.undefined;

cookieSyncConfig.userSyncLimit = 0;
config.resetConfig();
config.setConfig({ s2sConfig: cookieSyncConfig });

bidRequest = utils.deepClone(BID_REQUESTS);
adapter.callBids(REQUEST, bidRequest, addBidResponse, done, ajax);
requestBid = JSON.parse(requests[0].requestBody);

expect(requestBid.bidders).to.contain('appnexus').and.to.have.lengthOf(1);
expect(requestBid.account).is.equal('1');
expect(requestBid.limit).is.undefined;
});
});

describe('response handler', function () {
Expand Down

0 comments on commit f2e5f17

Please sign in to comment.