From 93f9fe48746189c0ca37e7cfd408ec1d35d89e6b Mon Sep 17 00:00:00 2001 From: Jozef Bartek <31618107+jbartek25@users.noreply.github.com> Date: Thu, 2 Dec 2021 22:58:46 +0100 Subject: [PATCH] Improve Digital adapter: support for Google's additional consent (#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 * Update improvedigitalBidAdapter.js Updated version Co-authored-by: Samiul Amin Shanto <93644987+samiul-shanto@users.noreply.github.com> Co-authored-by: Faisal Islam --- modules/improvedigitalBidAdapter.js | 22 ++++++++++++++++--- .../modules/improvedigitalBidAdapter_spec.js | 4 +++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/modules/improvedigitalBidAdapter.js b/modules/improvedigitalBidAdapter.js index 688a8815e93..2c96d0540ee 100644 --- a/modules/improvedigitalBidAdapter.js +++ b/modules/improvedigitalBidAdapter.js @@ -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'], @@ -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) { diff --git a/test/spec/modules/improvedigitalBidAdapter_spec.js b/test/spec/modules/improvedigitalBidAdapter_spec.js index 095e50f0c66..3aa2ab8e873 100644 --- a/test/spec/modules/improvedigitalBidAdapter_spec.js +++ b/test/spec/modules/improvedigitalBidAdapter_spec.js @@ -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', }, }; @@ -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 () {