Skip to content

Commit ab2c050

Browse files
ankur-modijsnellbaker
authored andcommitted
support gdpr for one video adapter (#2981)
* support gdpr for one video adapter * gdpr support 1video
1 parent 3838a8f commit ab2c050

File tree

2 files changed

+59
-3
lines changed

2 files changed

+59
-3
lines changed

modules/oneVideoBidAdapter.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ export const spec = {
3636
* Make a server request from the list of BidRequests.
3737
*
3838
* @param {validBidRequests[]} - an array of bids
39+
* @param bidderRequest
3940
* @return ServerRequest Info describing the request to the server.
4041
*/
41-
buildRequests: function(bids) {
42+
buildRequests: function(bids, bidRequest) {
43+
let consentData = bidRequest ? bidRequest.gdprConsent : null;
44+
4245
return bids.map(bid => {
4346
return {
4447
method: 'POST',
4548
url: location.protocol + spec.ENDPOINT + bid.params.pubId,
46-
data: getRequestData(bid),
49+
data: getRequestData(bid, consentData),
4750
options: {contentType: 'application/json'},
4851
bidRequest: bid
4952
}
@@ -127,7 +130,11 @@ function getSize(sizes) {
127130
};
128131
}
129132

130-
function getRequestData(bid) {
133+
function isConsentRequired(consentData) {
134+
return !!(consentData && consentData.gdprApplies);
135+
}
136+
137+
function getRequestData(bid, consentData) {
131138
let loc = utils.getTopWindowLocation();
132139
let global = (window.top) ? window.top : window;
133140
let page = (bid.params.site && bid.params.site.page) ? (bid.params.site.page) : (loc.href);
@@ -179,6 +186,23 @@ function getRequestData(bid) {
179186
if (bid.params.site && bid.params.site.id) {
180187
bidData.site.id = bid.params.site.id
181188
}
189+
190+
if (isConsentRequired(consentData)) {
191+
bidData.regs = {
192+
ext: {
193+
gdpr: 1
194+
}
195+
};
196+
197+
if (consentData.consentString) {
198+
bidData.user = {
199+
ext: {
200+
consent: consentData.consentString
201+
}
202+
};
203+
}
204+
}
205+
182206
return bidData;
183207
}
184208

test/spec/modules/oneVideoBidAdapter_spec.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { expect } from 'chai';
22
import { spec } from 'modules/oneVideoBidAdapter';
33
import * as utils from 'src/utils';
4+
import {config} from 'src/config';
45

56
describe('OneVideoBidAdapter', () => {
67
let bidRequest;
8+
let bidderRequest;
9+
let mockConfig;
710

811
beforeEach(() => {
912
bidRequest = {
@@ -132,4 +135,33 @@ describe('OneVideoBidAdapter', () => {
132135
expect(bidResponse).to.deep.equal(o);
133136
});
134137
});
138+
139+
describe('when GDPR applies', function () {
140+
beforeEach(function () {
141+
bidderRequest = {
142+
gdprConsent: {
143+
consentString: 'test-gdpr-consent-string',
144+
gdprApplies: true
145+
}
146+
};
147+
148+
mockConfig = {
149+
consentManagement: {
150+
cmpApi: 'iab',
151+
timeout: 1111,
152+
allowAuctionWithoutConsent: 'cancel'
153+
}
154+
};
155+
});
156+
157+
it('should send a signal to specify that GDPR applies to this request', function () {
158+
const request = spec.buildRequests([ bidRequest ], bidderRequest);
159+
expect(request[0].data.regs.ext.gdpr).to.equal(1);
160+
});
161+
162+
it('should send the consent string', function () {
163+
const request = spec.buildRequests([ bidRequest ], bidderRequest);
164+
expect(request[0].data.user.ext.consent).to.equal(bidderRequest.gdprConsent.consentString);
165+
});
166+
});
135167
});

0 commit comments

Comments
 (0)