Skip to content

Commit

Permalink
Added GDPR, CCPA, COPPA, and timeout passing support (#8612)
Browse files Browse the repository at this point in the history
Co-authored-by: Ubuntu <ubuntu@ip-172-31-25-92.us-west-1.compute.internal>
  • Loading branch information
2 people authored and ahmadlob committed Jul 27, 2022
1 parent 23d933a commit 9b18c73
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
35 changes: 35 additions & 0 deletions modules/vrtcalBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js';
import { BANNER } from '../src/mediaTypes.js';
import {ajax} from '../src/ajax.js';
import {isFn, isPlainObject} from '../src/utils.js';
import { config } from '../src/config.js';

export const spec = {
code: 'vrtcal',
Expand All @@ -21,10 +22,32 @@ export const spec = {
}
}

let gdprApplies = 0;
let gdprConsent = '';
let ccpa = '';
let coppa = 0;
let tmax = 0;

if (bid && bid.gdprConsent) {
gdprApplies = bid.gdprConsent.gdprApplies ? 1 : 0;
gdprConsent = bid.gdprConsent.consentString;
}

if (bid && bid.uspConsent) {
ccpa = bid.uspConsent;
}

if (config.getConfig('coppa') === true) {
coppa = 1;
}

tmax = config.getConfig('bidderTimeout');

const params = {
prebidJS: 1,
prebidAdUnitCode: bid.adUnitCode,
id: bid.bidId,
tmax: tmax,
imp: [{
id: '1',
banner: {
Expand All @@ -41,6 +64,18 @@ export const spec = {
device: {
ua: 'VRTCAL_FILLED',
ip: 'VRTCAL_FILLED'
},
regs: {
coppa: coppa,
ext: {
gdpr: gdprApplies,
us_privacy: ccpa
}
},
user: {
ext: {
consent: gdprConsent
}
}
};

Expand Down
17 changes: 17 additions & 0 deletions test/spec/modules/vrtcalBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect } from 'chai'
import { spec } from 'modules/vrtcalBidAdapter'
import { newBidder } from 'src/adapters/bidderFactory'
import { config } from 'src/config.js';

describe('vrtcalBidAdapter', function () {
const adapter = newBidder(spec)
Expand Down Expand Up @@ -50,6 +51,22 @@ describe('vrtcalBidAdapter', function () {
request = spec.buildRequests(bidRequests);
expect(request[0].data).to.match(/"bidfloor":0.55/);
});

it('pass GDPR,CCPA, and COPPA indicators/consent strings with the request when present', function () {
bidRequests[0].gdprConsent = {consentString: 'gdpr-consent-string', gdprApplies: true};
bidRequests[0].uspConsent = 'ccpa-consent-string';
config.setConfig({ coppa: false });

request = spec.buildRequests(bidRequests);
expect(request[0].data).to.match(/"user":{"ext":{"consent":"gdpr-consent-string"}}/);
expect(request[0].data).to.match(/"regs":{"coppa":0,"ext":{"gdpr":1,"us_privacy":"ccpa-consent-string"}}/);
});

it('pass bidder timeout/tmax with the request', function () {
config.setConfig({ bidderTimeout: 435 });
request = spec.buildRequests(bidRequests);
expect(request[0].data).to.match(/"tmax":435/);
});
});

describe('interpretResponse', function () {
Expand Down

0 comments on commit 9b18c73

Please sign in to comment.