Skip to content

Commit

Permalink
Proxistore Bid Adapter: add support for tcf v2 consent (#6543)
Browse files Browse the repository at this point in the history
* use tcf v2 consent

* set cosentGiven to false and test Gdpr api v2
  • Loading branch information
vincentproxistore authored Apr 12, 2021
1 parent 80de594 commit 75f5bdf
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 39 deletions.
32 changes: 14 additions & 18 deletions modules/proxistoreBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';

const BIDDER_CODE = 'proxistore';
const PROXISTORE_VENDOR_ID = 418;

Expand Down Expand Up @@ -27,38 +26,35 @@ function _createServerRequest(bidRequests, bidderRequest) {
language: bidRequests[0].params.language,
gdpr: {
applies: false,
consentGiven: false
},
};

if (bidderRequest && bidderRequest.gdprConsent) {
if (
typeof bidderRequest.gdprConsent.gdprApplies === 'boolean' &&
bidderRequest.gdprConsent.gdprApplies
) {
const { gdprConsent } = bidderRequest;
if (typeof gdprConsent.gdprApplies === 'boolean' && gdprConsent.gdprApplies) {
payload.gdpr.applies = true;
}

if (
typeof bidderRequest.gdprConsent.consentString === 'string' &&
bidderRequest.gdprConsent.consentString
) {
if (typeof gdprConsent.consentString === 'string' && gdprConsent.consentString) {
payload.gdpr.consentString = bidderRequest.gdprConsent.consentString;
}

if (
bidderRequest.gdprConsent.vendorData &&
bidderRequest.gdprConsent.vendorData.vendorConsents &&
typeof bidderRequest.gdprConsent.vendorData.vendorConsents[PROXISTORE_VENDOR_ID.toString(10)] !== 'undefined'
) {
payload.gdpr.consentGiven = !!bidderRequest.gdprConsent.vendorData
.vendorConsents[PROXISTORE_VENDOR_ID.toString(10)];
if (gdprConsent.vendorData) {
const {vendorData} = gdprConsent;
const {apiVersion} = gdprConsent;
if (apiVersion === 2 && vendorData.vendor && vendorData.vendor.consents && typeof vendorData.vendor.consents[PROXISTORE_VENDOR_ID.toString(10)] !== 'undefined') {
payload.gdpr.consentGiven = !!vendorData.vendor.consents[PROXISTORE_VENDOR_ID.toString(10)];
} else if (apiVersion === 1 && vendorData.vendorConsents && typeof vendorData.vendorConsents[PROXISTORE_VENDOR_ID.toString(10)] !== 'undefined') {
payload.gdpr.consentGiven = !!vendorData.vendorConsents[PROXISTORE_VENDOR_ID.toString(10)];
}
}
}

const options = {
contentType: 'application/json',
withCredentials: !!payload.gdpr.consentGiven,
withCredentials: payload.gdpr.consentGiven,
};

const endPointUri = payload.gdpr.consentGiven || !payload.gdpr.applies
? `https://abs.proxistore.com/${payload.language}/v3/rtb/prebid/multi`
: `https://abs.proxistore.com/${payload.language}/v3/rtb/prebid/multi/cookieless`;
Expand Down
72 changes: 51 additions & 21 deletions test/spec/modules/proxistoreBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ import { expect } from 'chai';
let { spec } = require('modules/proxistoreBidAdapter');
const BIDDER_CODE = 'proxistore';
describe('ProxistoreBidAdapter', function () {
const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==';
const bidderRequest = {
bidderCode: BIDDER_CODE,
auctionId: '1025ba77-5463-4877-b0eb-14b205cb9304',
bidderRequestId: '10edf38ec1a719',
gdprConsent: {
apiVersion: 2,
gdprApplies: true,
consentString: 'CONSENT_STRING',
consentString: consentString,
vendorData: {
vendorConsents: {
418: true,
vendor: {
consents: {
418: true,
},
},
},
},
Expand Down Expand Up @@ -75,6 +79,29 @@ describe('ProxistoreBidAdapter', function () {
expect(request.url).equal(url.cookieBase);
// doens't have gpdr consent
bidderRequest.gdprConsent.vendorData = null;

request = spec.buildRequests([bid], bidderRequest);
expect(request.url).equal(url.cookieLess);

// api v2
bidderRequest.gdprConsent = {
gdprApplies: true,
allowAuctionWithoutConsent: true,
consentString: consentString,
vendorData: {
vendor: {
consents: {
'418': true
}
},
},
apiVersion: 2
};
// has gdpr consent
request = spec.buildRequests([bid], bidderRequest);
expect(request.url).equal(url.cookieBase);

bidderRequest.gdprConsent.vendorData.vendor = {};
request = spec.buildRequests([bid], bidderRequest);
expect(request.url).equal(url.cookieLess);
});
Expand Down Expand Up @@ -105,26 +132,29 @@ describe('ProxistoreBidAdapter', function () {
expect(data.bids[0].floor).to.be.null;
});
});
describe('interpretResponse', function() {
const emptyResponseParam = {body: []};
const fakeResponseParam = {body: [
{ ad: '',
cpm: 6.25,
creativeId: '22c3290b-8cd5-4cd6-8e8c-28a2de180ccd',
currency: 'EUR',
dealId: '2021-03_a63ec55e-b9bb-4ca4-b2c9-f456be67e656',
height: 600,
netRevenue: true,
requestId: '3543724f2a033c9',
segments: [],
ttl: 10,
vastUrl: null,
vastXml: null,
width: 300}
]
describe('interpretResponse', function () {
const emptyResponseParam = { body: [] };
const fakeResponseParam = {
body: [
{
ad: '',
cpm: 6.25,
creativeId: '22c3290b-8cd5-4cd6-8e8c-28a2de180ccd',
currency: 'EUR',
dealId: '2021-03_a63ec55e-b9bb-4ca4-b2c9-f456be67e656',
height: 600,
netRevenue: true,
requestId: '3543724f2a033c9',
segments: [],
ttl: 10,
vastUrl: null,
vastXml: null,
width: 300,
},
],
};

it('should always return an array', function() {
it('should always return an array', function () {
let response = spec.interpretResponse(emptyResponseParam, bid);
expect(response).to.be.an('array');
expect(response.length).equal(0);
Expand Down

0 comments on commit 75f5bdf

Please sign in to comment.