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

add support for userSyncLimit field in s2sConfig #3375

Merged
merged 1 commit into from
Dec 18, 2018
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
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