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

PubMatic to support coppa #4336

Merged
merged 12 commits into from
Oct 21, 2019
10 changes: 10 additions & 0 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,11 @@ export const spec = {
};
}

// coppa compliance
if (config.getConfig('coppa') === true) {
utils.deepSetValue(payload, 'regs.coppa', 1);
}

_handleDealCustomTargetings(payload, dctrArr, validBidRequests);
_handleEids(payload, validBidRequests);
_blockedIabCategoriesValidation(payload, blockedIabCategories);
Expand Down Expand Up @@ -1018,6 +1023,11 @@ export const spec = {
syncurl += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || '');
}

// coppa compliance
if (config.getConfig('coppa') === true) {
syncurl += '&coppa=1';
}

if (syncOptions.iframeEnabled) {
return [{
type: 'iframe',
Expand Down
40 changes: 40 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,46 @@ describe('PubMatic adapter', function () {
// should have called DigiTrust.getUser() once
expect(window.DigiTrust.getUser.calledOnce).to.equal(true);
});

it('should NOT include coppa flag in bid request if coppa config is not present', () => {
const request = spec.buildRequests(bidRequests, {});
let data = JSON.parse(request.data);
if (data.regs) {
// in case GDPR is set then data.regs will exist
expect(data.regs.coppa).to.equal(undefined);
} else {
expect(data.regs).to.equal(undefined);
}
});

it('should include coppa flag in bid request if coppa is set to true', () => {
sandbox.stub(config, 'getConfig').callsFake(key => {
const config = {
'coppa': true
};
return config[key];
});
const request = spec.buildRequests(bidRequests, {});
let data = JSON.parse(request.data);
expect(data.regs.coppa).to.equal(1);
});

it('should NOT include coppa flag in bid request if coppa is set to false', () => {
sandbox.stub(config, 'getConfig').callsFake(key => {
const config = {
'coppa': false
};
return config[key];
});
const request = spec.buildRequests(bidRequests, {});
let data = JSON.parse(request.data);
if (data.regs) {
// in case GDPR is set then data.regs will exist
expect(data.regs.coppa).to.equal(undefined);
} else {
expect(data.regs).to.equal(undefined);
}
});
});

describe('AdsrvrOrgId from config', function() {
Expand Down