Skip to content

Commit

Permalink
Improve Digital adapter: support for Google's additional consent (pre…
Browse files Browse the repository at this point in the history
…bid#7787)

* HBT-156: Added Google's additional consent (#1)

* HBT-156: Added Google's additional consent

* HBT-156: Code refactored

Co-authored-by: Faisal Islam <[email protected]>

* Update improvedigitalBidAdapter.js

Updated version

Co-authored-by: Samiul Amin Shanto <[email protected]>
Co-authored-by: Faisal Islam <[email protected]>
  • Loading branch information
3 people authored Dec 2, 2021
1 parent 713d923 commit 93f9fe4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
22 changes: 19 additions & 3 deletions modules/improvedigitalBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js
const VIDEO_TARGETING = ['skip', 'skipmin', 'skipafter'];

export const spec = {
version: '7.4.0',
version: '7.5.0',
code: BIDDER_CODE,
gvlid: 253,
aliases: ['id'],
Expand Down Expand Up @@ -45,8 +45,24 @@ export const spec = {
libVersion: this.version
};

if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.consentString) {
requestParameters.gdpr = bidderRequest.gdprConsent.consentString;
const gdprConsent = deepAccess(bidderRequest, 'gdprConsent')
if (gdprConsent) {
// GDPR Consent String
if (gdprConsent.consentString) {
requestParameters.gdpr = gdprConsent.consentString;
}

// Additional Consent String
const additionalConsent = deepAccess(gdprConsent, 'addtlConsent');
if (additionalConsent && additionalConsent.indexOf('~') !== -1) {
// Google Ad Tech Provider IDs
const atpIds = additionalConsent.substring(additionalConsent.indexOf('~') + 1);
deepSetValue(
requestParameters,
'user.ext.consented_providers_settings.consented_providers',
atpIds.split('.').map(id => parseInt(id, 10))
);
}
}

if (bidderRequest && bidderRequest.uspConsent) {
Expand Down
4 changes: 3 additions & 1 deletion test/spec/modules/improvedigitalBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ describe('Improve Digital Adapter Tests', function () {
gdprConsent: {
consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==',
vendorData: {},
gdprApplies: true
gdprApplies: true,
addtlConsent: '1~1.35.41.101',
},
};

Expand Down Expand Up @@ -278,6 +279,7 @@ describe('Improve Digital Adapter Tests', function () {
const request = spec.buildRequests([bidRequest], bidderRequestGdpr)[0];
const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length)));
expect(params.bid_request.gdpr).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==');
expect(params.bid_request.user.ext.consented_providers_settings.consented_providers).to.exist.and.to.deep.equal([1, 35, 41, 101]);
});

it('should add CCPA consent string', function () {
Expand Down

0 comments on commit 93f9fe4

Please sign in to comment.