From 112d360ab840fbcef8aa85c664de01b98a5ca733 Mon Sep 17 00:00:00 2001 From: ahubertcriteo <31441781+ahubertcriteo@users.noreply.github.com> Date: Fri, 25 May 2018 22:00:45 +0200 Subject: [PATCH] Update Criteo bid adapter to send undefined GDPR consent fields instead of default false value when values are not defined (#2630) * Convert Criteo adapter to bidderFactory * Add documentation for Prebid 1.0 Criteo adapter * Add support for zone-matching bids on Prebid 1.0 Criteo adapter * Add unit tests to the Prebid 1.0 Criteo adapter * Explicit the fact that Criteo bids are net revenue * Pass currency in Criteo 1.0 adapter * Update Criteo adapter to use PublisherTag if present * Implement fastbid in prebid 1.0 criteo adapter * Pass the bid requests to the Criteo interpret method * Add missing ttl and creativeId fields to Criteo bids * Add 'native' support to the Criteo adapter * Check that the Criteo adapter returned by PublisherTag is not empty * Update criteo prebid adapter to reload publisher tag once auction is finished * Fix 'assign to const' IE errors in Criteo native adapter * Disable the PublisherTag event queue * Fix Criteo adapter on older Prebid versions not using response.body * Fix TypeError if FastBid is outdated * Remove the success variable in tryGetCriteoFastBid * Fix events being overwritten with FastBid * Update PublisherTag loading comment * Use adUnitCode as impid * Add events handlers in Criteo adapter to fix timeouts not treated as such * Add handler for setTargeting event * Move the registeredEvents set higher up to reduce the chances of race conditions * Fix UTests following recent Criteo adapter changes * Add comment linking to the PublisherTag unminified source * Do not return a request in buildRequests on error In some cases, the buildCdbRequest function might return a falsy value, in case of error in creating the request or if we know in advance that this request will return a no-bid. In this case, the buildRequests() method should not return a request, causing a no-bid. * Use loadExternalScript instead of loadScript * Use spec.onTimeout instead of registering an event handler * GDPR support in Criteo adapter (#4) GDPR support in Criteo adapter * Remove BID_WON and SET_TARGETING events from Criteo adapter * Update adapter version * Add support for multi-size in Criteo adapter * Fix support for multi size in Criteo adapter * Update adapterVersion to 7 * GDPR support criteo: send undefined gdpr consent fields instead of false when not defined * Update adapterVersion to 8 --- modules/criteoBidAdapter.js | 19 ++++++++++------ test/spec/modules/criteoBidAdapter_spec.js | 25 +++++++++++++++++++++- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/modules/criteoBidAdapter.js b/modules/criteoBidAdapter.js index 320d8526244..81da55ebf67 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 ccf683dc4ca..e855c828b1f 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', () => {