Skip to content

Commit

Permalink
Improve Digital COPPA support (#7948)
Browse files Browse the repository at this point in the history
Co-authored-by: Samiul Amin Shanto <93644987+samiul-shanto@users.noreply.github.com>
  • Loading branch information
jbartek25 and samiul-shanto authored Jan 21, 2022
1 parent e8a7ebc commit b3ee5da
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/improvedigitalBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const spec = {
// End of adding first party data

requestParameters.schain = bidRequests[0].schain;
requestParameters.coppa = config.getConfig('coppa') === true;

if (bidRequests[0].userId) {
const eids = createEidsArray(bidRequests[0].userId);
Expand Down Expand Up @@ -652,6 +653,10 @@ export function ImproveDigitalAdServerJSClient(endPoint) {
}
}

if (requestParameters.coppa) {
impressionBidRequestObject.coppa = 1;
}

return impressionBidRequestObject;
};

Expand Down
19 changes: 19 additions & 0 deletions test/spec/modules/improvedigitalBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,25 @@ describe('Improve Digital Adapter Tests', function () {
]
);
});

it('should set coppa', function() {
sinon.stub(config, 'getConfig')
.withArgs('coppa')
.returns(true);
const bidRequest = Object.assign({}, simpleBidRequest);
const request = spec.buildRequests([bidRequest], bidderRequestReferrer)[0];
const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length)));
expect(params.bid_request.coppa).to.equal(1);

config.getConfig.restore();
});

it('should undefined coppa', function() {
const bidRequest = Object.assign({}, simpleBidRequest);
const request = spec.buildRequests([bidRequest], bidderRequestReferrer)[0];
const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length)));
expect(params.bid_request.coppa).to.equal(undefined);
});
});

const serverResponse = {
Expand Down

0 comments on commit b3ee5da

Please sign in to comment.