Skip to content

Commit f799046

Browse files
aprakash-sovrnIsaac A. Dettman
authored and
Isaac A. Dettman
committed
Sovrn ccpa support legacy (#4623)
* sovrn ccpa support * use array map/join instead of object.entries
1 parent 9ba8031 commit f799046

File tree

2 files changed

+80
-16
lines changed

2 files changed

+80
-16
lines changed

modules/sovrnBidAdapter.js

+17-15
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,12 @@ export const spec = {
8181
};
8282
}
8383

84-
if (bidderRequest && bidderRequest.gdprConsent) {
85-
sovrnBidReq.regs = {
86-
ext: {
87-
gdpr: +bidderRequest.gdprConsent.gdprApplies
88-
}};
89-
sovrnBidReq.user = {
90-
ext: {
91-
consent: bidderRequest.gdprConsent.consentString
92-
}};
84+
if (bidderRequest.gdprConsent) {
85+
utils.deepSetValue(sovrnBidReq, 'regs.ext.gdpr', +bidderRequest.gdprConsent.gdprApplies);
86+
utils.deepSetValue(sovrnBidReq, 'user.ext.consent', bidderRequest.gdprConsent.consentString)
87+
}
88+
if (bidderRequest.uspConsent) {
89+
utils.deepSetValue(sovrnBidReq, 'regs.ext.us_privacy', bidderRequest.uspConsent);
9390
}
9491

9592
if (digitrust) {
@@ -151,21 +148,26 @@ export const spec = {
151148
}
152149
},
153150

154-
getUserSyncs: function(syncOptions, serverResponses, gdprConsent) {
151+
getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) {
155152
try {
156-
let tracks = []
153+
const tracks = []
157154
if (serverResponses && serverResponses.length !== 0) {
158155
if (syncOptions.iframeEnabled) {
159-
let iidArr = serverResponses.filter(resp => utils.deepAccess(resp, 'body.ext.iid'))
156+
const iidArr = serverResponses.filter(resp => utils.deepAccess(resp, 'body.ext.iid'))
160157
.map(resp => resp.body.ext.iid);
161-
let consentString = '';
158+
const params = [];
162159
if (gdprConsent && gdprConsent.gdprApplies && typeof gdprConsent.consentString === 'string') {
163-
consentString = gdprConsent.consentString
160+
params.push(['gdpr_consent', gdprConsent.consentString]);
164161
}
162+
if (uspConsent) {
163+
params.push(['us_privacy', uspConsent]);
164+
}
165+
165166
if (iidArr[0]) {
167+
params.push(['informer', iidArr[0]]);
166168
tracks.push({
167169
type: 'iframe',
168-
url: 'https://ap.lijit.com/beacon?informer=' + iidArr[0] + '&gdpr_consent=' + consentString,
170+
url: 'https://ap.lijit.com/beacon?' + params.map(p => p.join('=')).join('&')
169171
});
170172
}
171173
}

test/spec/modules/sovrnBidAdapter_spec.js

+63-1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,25 @@ describe('sovrnBidAdapter', function() {
152152
expect(data.user.ext.consent).to.equal(consentString);
153153
});
154154

155+
it('should send us_privacy if bidderRequest has a value for uspConsent', function () {
156+
let uspString = '1NYN';
157+
let bidderRequest = {
158+
'bidderCode': 'sovrn',
159+
'auctionId': '1d1a030790a475',
160+
'bidderRequestId': '22edbae2733bf6',
161+
'timeout': 3000,
162+
uspConsent: uspString,
163+
refererInfo: {
164+
referer: 'http://example.com/page.html',
165+
}
166+
};
167+
bidderRequest.bids = bidRequests;
168+
169+
const data = JSON.parse(spec.buildRequests(bidRequests, bidderRequest).data);
170+
171+
expect(data.regs.ext['us_privacy']).to.equal(uspString);
172+
});
173+
155174
it('converts tagid to string', function () {
156175
const ivBidRequests = [{
157176
'bidder': 'sovrn',
@@ -399,13 +418,56 @@ describe('sovrnBidAdapter', function() {
399418
const expectedReturnStatement = [
400419
{
401420
'type': 'iframe',
402-
'url': 'https://ap.lijit.com/beacon?informer=13487408&gdpr_consent=',
421+
'url': 'https://ap.lijit.com/beacon?informer=13487408',
403422
}
404423
];
405424
const returnStatement = spec.getUserSyncs(syncOptions, serverResponse);
406425
expect(returnStatement[0]).to.deep.equal(expectedReturnStatement[0]);
407426
});
408427

428+
it('should include gdpr consent string if present', function() {
429+
const gdprConsent = {
430+
gdprApplies: 1,
431+
consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='
432+
}
433+
const expectedReturnStatement = [
434+
{
435+
'type': 'iframe',
436+
'url': `https://ap.lijit.com/beacon?gdpr_consent=${gdprConsent.consentString}&informer=13487408`,
437+
}
438+
];
439+
const returnStatement = spec.getUserSyncs(syncOptions, serverResponse, gdprConsent, '');
440+
expect(returnStatement[0]).to.deep.equal(expectedReturnStatement[0]);
441+
});
442+
443+
it('should include us privacy string if present', function() {
444+
const uspString = '1NYN';
445+
const expectedReturnStatement = [
446+
{
447+
'type': 'iframe',
448+
'url': `https://ap.lijit.com/beacon?us_privacy=${uspString}&informer=13487408`,
449+
}
450+
];
451+
const returnStatement = spec.getUserSyncs(syncOptions, serverResponse, null, uspString);
452+
expect(returnStatement[0]).to.deep.equal(expectedReturnStatement[0]);
453+
});
454+
455+
it('should include all privacy strings if present', function() {
456+
const gdprConsent = {
457+
gdprApplies: 1,
458+
consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='
459+
}
460+
const uspString = '1NYN';
461+
const expectedReturnStatement = [
462+
{
463+
'type': 'iframe',
464+
'url': `https://ap.lijit.com/beacon?gdpr_consent=${gdprConsent.consentString}&us_privacy=${uspString}&informer=13487408`,
465+
}
466+
];
467+
const returnStatement = spec.getUserSyncs(syncOptions, serverResponse, gdprConsent, uspString);
468+
expect(returnStatement[0]).to.deep.equal(expectedReturnStatement[0]);
469+
});
470+
409471
it('should not return if iid missing on server response', function() {
410472
const returnStatement = spec.getUserSyncs(syncOptions, []);
411473
expect(returnStatement).to.be.empty;

0 commit comments

Comments
 (0)