Skip to content

Commit

Permalink
support setting coopSync in s2sConfig (prebid#6330)
Browse files Browse the repository at this point in the history
  • Loading branch information
msm0504 authored and stsepelin committed May 28, 2021
1 parent d83169a commit 64dd09a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ function queueSync(bidderCodes, gdprConsent, uspConsent, s2sConfig) {
payload.us_privacy = uspConsent;
}

if (typeof s2sConfig.coopSync === 'boolean') {
payload.coopSync = s2sConfig.coopSync;
}

const jsonPayload = JSON.stringify(payload);
ajax(s2sConfig.syncEndpoint,
(response) => {
Expand Down
31 changes: 31 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2529,5 +2529,36 @@ describe('S2S Adapter', function () {
const requestBid = JSON.parse(server.requests[0].requestBody);
expect(requestBid.bidders).to.deep.equal(['appnexus', 'rubicon']);
});

it('should add cooperative sync flag to cookie_sync request if property is present', function () {
let s2sConfig = utils.deepClone(CONFIG);
s2sConfig.coopSync = false;
s2sConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync';

const s2sBidRequest = utils.deepClone(REQUEST);
s2sBidRequest.s2sConfig = s2sConfig;

let bidRequest = utils.deepClone(BID_REQUESTS);

adapter.callBids(s2sBidRequest, bidRequest, addBidResponse, done, ajax);
let requestBid = JSON.parse(server.requests[0].requestBody);

expect(requestBid.coopSync).to.equal(false);
});

it('should not add cooperative sync flag to cookie_sync request if property is not present', function () {
let s2sConfig = utils.deepClone(CONFIG);
s2sConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync';

const s2sBidRequest = utils.deepClone(REQUEST);
s2sBidRequest.s2sConfig = s2sConfig;

let bidRequest = utils.deepClone(BID_REQUESTS);

adapter.callBids(s2sBidRequest, bidRequest, addBidResponse, done, ajax);
let requestBid = JSON.parse(server.requests[0].requestBody);

expect(requestBid.coopSync).to.be.undefined;
});
});
});

0 comments on commit 64dd09a

Please sign in to comment.