Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vrtcal Bid Adapter: added GDPR, CCPA, COPPA, and timeout passing support #8612

Merged
merged 1 commit into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be bidderRequest.timeout. it's equivalent except when the publisher specifies the timeout manually with pbjs.requestBids({timeout: ...}), in which case this would miss it.

I don't know how much it matters since the correct timeout is enforced by core anyway - it depends on what the backend does with it.

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