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

Update xeUtils/bidderUtils.js: pass full gdprConsent object to the bidder #12793

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 4 additions & 7 deletions libraries/xeUtils/bidderUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function buildRequests(validBidRequests, bidderRequest, endpoint) {
const {refererInfo = {}, gdprConsent = {}, uspConsent} = bidderRequest;
const requests = validBidRequests.map(req => {
const request = {};
request.tmax = bidderRequest.timeout || 0;
request.bidId = req.bidId;
request.banner = deepAccess(req, 'mediaTypes.banner');
request.auctionId = req.ortb2?.source?.tid;
Expand Down Expand Up @@ -77,13 +78,9 @@ export function buildRequests(validBidRequests, bidderRequest, endpoint) {
} else {
request.userEids = [];
}
if (gdprConsent.gdprApplies) {
request.gdprApplies = Number(gdprConsent.gdprApplies);
request.consentString = gdprConsent.consentString;
} else {
request.gdprApplies = 0;
request.consentString = '';
}

request.gdprConsent = gdprConsent;

if (uspConsent) {
request.usPrivacy = uspConsent;
} else {
Expand Down
19 changes: 4 additions & 15 deletions test/spec/modules/anyclipBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {getBidFloor} from '../../../libraries/xeUtils/bidderUtils.js';
const ENDPOINT = 'https://prebid.anyclip.com';

const defaultRequest = {
tmax: 0,
adUnitCode: 'test',
bidId: '1',
requestId: 'qwerty',
Expand Down Expand Up @@ -102,14 +103,14 @@ describe('anyclipBidAdapter', () => {

it('should build basic request structure', function () {
const request = JSON.parse(spec.buildRequests([defaultRequest], {}).data)[0];
expect(request).to.have.property('tmax').and.to.equal(defaultRequest.tmax);
expect(request).to.have.property('bidId').and.to.equal(defaultRequest.bidId);
expect(request).to.have.property('auctionId').and.to.equal(defaultRequest.ortb2.source.tid);
expect(request).to.have.property('transactionId').and.to.equal(defaultRequest.ortb2Imp.ext.tid);
expect(request).to.have.property('tz').and.to.equal(new Date().getTimezoneOffset());
expect(request).to.have.property('bc').and.to.equal(1);
expect(request).to.have.property('banner').and.to.deep.equal({sizes: [[300, 250], [300, 200]]});
expect(request).to.have.property('gdprApplies').and.to.equal(0);
expect(request).to.have.property('consentString').and.to.equal('');
expect(request).to.have.property('gdprConsent').and.to.deep.equal({});
expect(request).to.have.property('userEids').and.to.deep.equal([]);
expect(request).to.have.property('usPrivacy').and.to.equal('');
expect(request).to.have.property('sizes').and.to.deep.equal(['300x250', '300x200']);
Expand Down Expand Up @@ -205,18 +206,6 @@ describe('anyclipBidAdapter', () => {
expect(request).to.have.property('floor').and.to.equal(5);
});

it('should build request with gdpr consent data if applies', function () {
const bidderRequest = {
gdprConsent: {
gdprApplies: true,
consentString: 'qwerty'
}
};
const request = JSON.parse(spec.buildRequests([defaultRequest], bidderRequest).data)[0];
expect(request).to.have.property('gdprApplies').and.equals(1);
expect(request).to.have.property('consentString').and.equals('qwerty');
});

it('should build request with usp consent data if applies', function () {
const bidderRequest = {
uspConsent: '1YA-'
Expand Down Expand Up @@ -455,4 +444,4 @@ describe('anyclipBidAdapter', () => {
expect(result).to.equal(5);
});
});
})
});
19 changes: 4 additions & 15 deletions test/spec/modules/driftpixelBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {getBidFloor} from '../../../libraries/xeUtils/bidderUtils.js';
const ENDPOINT = 'https://pbjs.driftpixel.live';

const defaultRequest = {
tmax: 0,
adUnitCode: 'test',
bidId: '1',
requestId: 'qwerty',
Expand Down Expand Up @@ -102,15 +103,15 @@ describe('driftpixelBidAdapter', () => {

it('should build basic request structure', function () {
const request = JSON.parse(spec.buildRequests([defaultRequest], {}).data)[0];
expect(request).to.have.property('tmax').and.to.equal(defaultRequest.tmax);
expect(request).to.have.property('bidId').and.to.equal(defaultRequest.bidId);
expect(request).to.have.property('auctionId').and.to.equal(defaultRequest.ortb2.source.tid);
expect(request).to.have.property('transactionId').and.to.equal(defaultRequest.ortb2Imp.ext.tid);
expect(request).to.have.property('tz').and.to.equal(new Date().getTimezoneOffset());
expect(request).to.have.property('bc').and.to.equal(1);
expect(request).to.have.property('floor').and.to.equal(null);
expect(request).to.have.property('banner').and.to.deep.equal({sizes: [[300, 250], [300, 200]]});
expect(request).to.have.property('gdprApplies').and.to.equal(0);
expect(request).to.have.property('consentString').and.to.equal('');
expect(request).to.have.property('gdprConsent').and.to.deep.equal({});
expect(request).to.have.property('userEids').and.to.deep.equal([]);
expect(request).to.have.property('usPrivacy').and.to.equal('');
expect(request).to.have.property('sizes').and.to.deep.equal(['300x250', '300x200']);
Expand Down Expand Up @@ -205,18 +206,6 @@ describe('driftpixelBidAdapter', () => {
expect(request).to.have.property('floor').and.to.equal(5);
});

it('should build request with gdpr consent data if applies', function () {
const bidderRequest = {
gdprConsent: {
gdprApplies: true,
consentString: 'qwerty'
}
};
const request = JSON.parse(spec.buildRequests([defaultRequest], bidderRequest).data)[0];
expect(request).to.have.property('gdprApplies').and.equals(1);
expect(request).to.have.property('consentString').and.equals('qwerty');
});

it('should build request with usp consent data if applies', function () {
const bidderRequest = {
uspConsent: '1YA-'
Expand Down Expand Up @@ -455,4 +444,4 @@ describe('driftpixelBidAdapter', () => {
expect(result).to.equal(5);
});
});
})
});
19 changes: 4 additions & 15 deletions test/spec/modules/iqxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {getBidFloor} from '../../../libraries/xeUtils/bidderUtils.js';
const ENDPOINT = 'https://pbjs.iqzonertb.live';

const defaultRequest = {
tmax: 0,
adUnitCode: 'test',
bidId: '1',
requestId: 'qwerty',
Expand Down Expand Up @@ -91,15 +92,15 @@ describe('iqxBidAdapter', () => {

it('should build basic request structure', function () {
const request = JSON.parse(spec.buildRequests([defaultRequest], {}).data)[0];
expect(request).to.have.property('tmax').and.to.equal(defaultRequest.tmax);
expect(request).to.have.property('bidId').and.to.equal(defaultRequest.bidId);
expect(request).to.have.property('auctionId').and.to.equal(defaultRequest.ortb2.source.tid);
expect(request).to.have.property('transactionId').and.to.equal(defaultRequest.ortb2Imp.ext.tid);
expect(request).to.have.property('tz').and.to.equal(new Date().getTimezoneOffset());
expect(request).to.have.property('bc').and.to.equal(1);
expect(request).to.have.property('floor').and.to.equal(null);
expect(request).to.have.property('banner').and.to.deep.equal({sizes: [[300, 250], [300, 200]]});
expect(request).to.have.property('gdprApplies').and.to.equal(0);
expect(request).to.have.property('consentString').and.to.equal('');
expect(request).to.have.property('gdprConsent').and.to.deep.equal({});
expect(request).to.have.property('userEids').and.to.deep.equal([]);
expect(request).to.have.property('usPrivacy').and.to.equal('');
expect(request).to.have.property('sizes').and.to.deep.equal(['300x250', '300x200']);
Expand Down Expand Up @@ -194,18 +195,6 @@ describe('iqxBidAdapter', () => {
expect(request).to.have.property('floor').and.to.equal(5);
});

it('should build request with gdpr consent data if applies', function () {
const bidderRequest = {
gdprConsent: {
gdprApplies: true,
consentString: 'qwerty'
}
};
const request = JSON.parse(spec.buildRequests([defaultRequest], bidderRequest).data)[0];
expect(request).to.have.property('gdprApplies').and.equals(1);
expect(request).to.have.property('consentString').and.equals('qwerty');
});

it('should build request with usp consent data if applies', function () {
const bidderRequest = {
uspConsent: '1YA-'
Expand Down Expand Up @@ -444,4 +433,4 @@ describe('iqxBidAdapter', () => {
expect(result).to.equal(5);
});
});
})
});
19 changes: 4 additions & 15 deletions test/spec/modules/lm_kiviadsBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {getBidFloor} from '../../../libraries/xeUtils/bidderUtils.js';
const ENDPOINT = 'https://pbjs.kiviads.live';

const defaultRequest = {
tmax: 0,
adUnitCode: 'test',
bidId: '1',
requestId: 'qwerty',
Expand Down Expand Up @@ -91,15 +92,15 @@ describe('lm_kiviadsBidAdapter', () => {

it('should build basic request structure', function () {
const request = JSON.parse(spec.buildRequests([defaultRequest], {}).data)[0];
expect(request).to.have.property('tmax').and.to.equal(defaultRequest.tmax);
expect(request).to.have.property('bidId').and.to.equal(defaultRequest.bidId);
expect(request).to.have.property('auctionId').and.to.equal(defaultRequest.ortb2.source.tid);
expect(request).to.have.property('transactionId').and.to.equal(defaultRequest.ortb2Imp.ext.tid);
expect(request).to.have.property('tz').and.to.equal(new Date().getTimezoneOffset());
expect(request).to.have.property('bc').and.to.equal(1);
expect(request).to.have.property('floor').and.to.equal(null);
expect(request).to.have.property('banner').and.to.deep.equal({sizes: [[300, 250], [300, 200]]});
expect(request).to.have.property('gdprApplies').and.to.equal(0);
expect(request).to.have.property('consentString').and.to.equal('');
expect(request).to.have.property('gdprConsent').and.to.deep.equal({});
expect(request).to.have.property('userEids').and.to.deep.equal([]);
expect(request).to.have.property('usPrivacy').and.to.equal('');
expect(request).to.have.property('sizes').and.to.deep.equal(['300x250', '300x200']);
Expand Down Expand Up @@ -194,18 +195,6 @@ describe('lm_kiviadsBidAdapter', () => {
expect(request).to.have.property('floor').and.to.equal(5);
});

it('should build request with gdpr consent data if applies', function () {
const bidderRequest = {
gdprConsent: {
gdprApplies: true,
consentString: 'qwerty'
}
};
const request = JSON.parse(spec.buildRequests([defaultRequest], bidderRequest).data)[0];
expect(request).to.have.property('gdprApplies').and.equals(1);
expect(request).to.have.property('consentString').and.equals('qwerty');
});

it('should build request with usp consent data if applies', function () {
const bidderRequest = {
uspConsent: '1YA-'
Expand Down Expand Up @@ -444,4 +433,4 @@ describe('lm_kiviadsBidAdapter', () => {
expect(result).to.equal(5);
});
});
})
});
19 changes: 4 additions & 15 deletions test/spec/modules/xeBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {getBidFloor} from '../../../libraries/xeUtils/bidderUtils.js';
const ENDPOINT = 'https://pbjs.xe.works/bid';

const defaultRequest = {
tmax: 0,
adUnitCode: 'test',
bidId: '1',
requestId: 'qwerty',
Expand Down Expand Up @@ -102,15 +103,15 @@ describe('xeBidAdapter', () => {

it('should build basic request structure', function () {
const request = JSON.parse(spec.buildRequests([defaultRequest], {}).data)[0];
expect(request).to.have.property('tmax').and.to.equal(defaultRequest.tmax);
expect(request).to.have.property('bidId').and.to.equal(defaultRequest.bidId);
expect(request).to.have.property('auctionId').and.to.equal(defaultRequest.ortb2.source.tid);
expect(request).to.have.property('transactionId').and.to.equal(defaultRequest.ortb2Imp.ext.tid);
expect(request).to.have.property('tz').and.to.equal(new Date().getTimezoneOffset());
expect(request).to.have.property('bc').and.to.equal(1);
expect(request).to.have.property('floor').and.to.equal(null);
expect(request).to.have.property('banner').and.to.deep.equal({sizes: [[300, 250], [300, 200]]});
expect(request).to.have.property('gdprApplies').and.to.equal(0);
expect(request).to.have.property('consentString').and.to.equal('');
expect(request).to.have.property('gdprConsent').and.to.deep.equal({});
expect(request).to.have.property('userEids').and.to.deep.equal([]);
expect(request).to.have.property('usPrivacy').and.to.equal('');
expect(request).to.have.property('sizes').and.to.deep.equal(['300x250', '300x200']);
Expand Down Expand Up @@ -205,18 +206,6 @@ describe('xeBidAdapter', () => {
expect(request).to.have.property('floor').and.to.equal(5);
});

it('should build request with gdpr consent data if applies', function () {
const bidderRequest = {
gdprConsent: {
gdprApplies: true,
consentString: 'qwerty'
}
};
const request = JSON.parse(spec.buildRequests([defaultRequest], bidderRequest).data)[0];
expect(request).to.have.property('gdprApplies').and.equals(1);
expect(request).to.have.property('consentString').and.equals('qwerty');
});

it('should build request with usp consent data if applies', function () {
const bidderRequest = {
uspConsent: '1YA-'
Expand Down Expand Up @@ -455,4 +444,4 @@ describe('xeBidAdapter', () => {
expect(result).to.equal(5);
});
});
})
});