Skip to content

Commit

Permalink
Adf adapter: add coppa signal support (#8375)
Browse files Browse the repository at this point in the history
* Coppa signal support in adf adapter

* Update

Co-authored-by: Justas Pupelis <justas.pupelis@adform.com>
  • Loading branch information
Pupis and Pupis authored May 5, 2022
1 parent 97ae929 commit 645abee
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/adfBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ export const spec = {
request.is_debug = !!test;
request.test = 1;
}

if (config.getConfig('coppa')) {
deepSetValue(request, 'regs.coppa', 1);
}

if (deepAccess(bidderRequest, 'gdprConsent.gdprApplies') !== undefined) {
deepSetValue(request, 'user.ext.consent', bidderRequest.gdprConsent.consentString);
deepSetValue(request, 'regs.ext.gdpr', bidderRequest.gdprConsent.gdprApplies & 1);
Expand Down
27 changes: 27 additions & 0 deletions test/spec/modules/adfBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,33 @@ describe('Adf adapter', function () {
assert.equal(request.source.fd, 1);
});

it('should not set coppa when coppa is not provided or is set to false', function () {
config.setConfig({
});
let validBidRequests = [{ bidId: 'bidId', params: { test: 1 } }];
let bidderRequest = { gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, refererInfo: { referer: 'page' } };
let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data);

assert.equal(request.regs.coppa, undefined);

config.setConfig({
coppa: false
});
request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data);

assert.equal(request.regs.coppa, undefined);
});

it('should set coppa to 1 when coppa is provided with value true', function () {
config.setConfig({
coppa: true
});
let validBidRequests = [{ bidId: 'bidId', params: { test: 1 } }];
let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data);

assert.equal(request.regs.coppa, 1);
});

it('should send info about device', function () {
config.setConfig({
device: { w: 100, h: 100 }
Expand Down

0 comments on commit 645abee

Please sign in to comment.