Skip to content

Commit

Permalink
ZetaSspBidAdapter: provide gdpr and sspa values in bidRequest (#7311)
Browse files Browse the repository at this point in the history
Co-authored-by: Surovenko Alexey <surovenko.alexey@gmail.com>
  • Loading branch information
asurovenko-zeta and surovenko authored Aug 17, 2021
1 parent a4207df commit 718e164
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
23 changes: 11 additions & 12 deletions modules/zetaSspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,18 @@ export const spec = {
if (params.test) {
payload.test = params.test;
}
if (request.gdprConsent) {
payload.regs = {
ext: {
gdpr: request.gdprConsent.gdprApplies === true ? 1 : 0
}
};
if (request.gdprConsent.gdprApplies && request.gdprConsent.consentString) {
payload.user.ext = {
...payload.user.ext,
consent: request.gdprConsent.consentString
}
}

// Attaching GDPR Consent Params
if (bidderRequest && bidderRequest.gdprConsent) {
utils.deepSetValue(payload, 'user.ext.consent', bidderRequest.gdprConsent.consentString);
utils.deepSetValue(payload, 'regs.ext.gdpr', (bidderRequest.gdprConsent.gdprApplies ? 1 : 0));
}

// CCPA
if (bidderRequest && bidderRequest.uspConsent) {
utils.deepSetValue(payload, 'regs.ext.us_privacy', bidderRequest.uspConsent);
}

provideEids(request, payload);
return {
method: 'POST',
Expand Down
10 changes: 10 additions & 0 deletions test/spec/modules/zetaSspBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe('Zeta Ssp Bid Adapter', function () {
gdprApplies: 1,
consentString: 'consentString'
},
uspConsent: 'someCCPAString',
params: {
placement: 111,
user: {
Expand Down Expand Up @@ -169,6 +170,15 @@ describe('Zeta Ssp Bid Adapter', function () {
expect(sync4.url).to.include('&us_privacy=');
});

it('Test provide gdpr and ccpa values in payload', function () {
const request = spec.buildRequests(bannerRequest, bannerRequest[0]);
const payload = JSON.parse(request.data);

expect(payload.user.ext.consent).to.eql('consentString');
expect(payload.regs.ext.gdpr).to.eql(1);
expect(payload.regs.ext.us_privacy).to.eql('someCCPAString');
});

it('Test do not override user object', function () {
const request = spec.buildRequests(bannerRequest, bannerRequest[0]);
const payload = JSON.parse(request.data);
Expand Down

0 comments on commit 718e164

Please sign in to comment.