diff --git a/modules/criteoBidAdapter.js b/modules/criteoBidAdapter.js index 320d85262449..81da55ebf677 100755 --- a/modules/criteoBidAdapter.js +++ b/modules/criteoBidAdapter.js @@ -4,7 +4,7 @@ import { parse } from 'src/url'; import * as utils from 'src/utils'; import find from 'core-js/library/fn/array/find'; -const ADAPTER_VERSION = 7; +const ADAPTER_VERSION = 8; const BIDDER_CODE = 'criteo'; const CDB_ENDPOINT = '//bidder.criteo.com/cdb'; const CRITEO_VENDOR_ID = 91; @@ -208,12 +208,17 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { request.publisher.networkid = networkId; } if (bidderRequest && bidderRequest.gdprConsent) { - request.gdprConsent = { - gdprApplies: !!(bidderRequest.gdprConsent.gdprApplies), - consentData: bidderRequest.gdprConsent.consentString, - consentGiven: !!(bidderRequest.gdprConsent.vendorData && bidderRequest.gdprConsent.vendorData.vendorConsents && - bidderRequest.gdprConsent.vendorData.vendorConsents[ CRITEO_VENDOR_ID.toString(10) ]), - }; + request.gdprConsent = {}; + if (typeof bidderRequest.gdprConsent.gdprApplies !== 'undefined') { + request.gdprConsent.gdprApplies = !!(bidderRequest.gdprConsent.gdprApplies); + } + if (bidderRequest.gdprConsent.vendorData && bidderRequest.gdprConsent.vendorData.vendorConsents && + typeof bidderRequest.gdprConsent.vendorData.vendorConsents[ CRITEO_VENDOR_ID.toString(10) ] !== 'undefined') { + request.gdprConsent.consentGiven = !!(bidderRequest.gdprConsent.vendorData.vendorConsents[ CRITEO_VENDOR_ID.toString(10) ]); + } + if (typeof bidderRequest.gdprConsent.consentString !== 'undefined') { + request.gdprConsent.consentData = bidderRequest.gdprConsent.consentString; + } } return request; } diff --git a/test/spec/modules/criteoBidAdapter_spec.js b/test/spec/modules/criteoBidAdapter_spec.js index ccf683dc4cad..e855c828b1f2 100755 --- a/test/spec/modules/criteoBidAdapter_spec.js +++ b/test/spec/modules/criteoBidAdapter_spec.js @@ -126,7 +126,7 @@ describe('The Criteo bidding adapter', () => { expect(ortbRequest.slots[0].sizes[1]).to.equal('728x90'); expect(ortbRequest.gdprConsent.consentData).to.equal(undefined); expect(ortbRequest.gdprConsent.gdprApplies).to.equal(false); - expect(ortbRequest.gdprConsent.consentGiven).to.equal(false); + expect(ortbRequest.gdprConsent.consentGiven).to.equal(undefined); }); it('should properly build a mixed request', () => { @@ -169,6 +169,29 @@ describe('The Criteo bidding adapter', () => { expect(ortbRequest.slots[1].sizes[1]).to.equal('728x90'); expect(ortbRequest.gdprConsent).to.equal(undefined); }); + + it('should properly build request with undefined gdpr consent fields when they are not provided', () => { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + params: { + zoneId: 123, + }, + }, + ]; + const bidderRequest = { timeout: 3000, + gdprConsent: { + }, + }; + + const ortbRequest = spec.buildRequests(bidRequests, bidderRequest).data; + expect(ortbRequest.gdprConsent.consentData).to.equal(undefined); + expect(ortbRequest.gdprConsent.gdprApplies).to.equal(undefined); + expect(ortbRequest.gdprConsent.consentGiven).to.equal(undefined); + }); }); describe('interpretResponse', () => {