Skip to content

Commit

Permalink
Sovrn ccpa support legacy (prebid#4623)
Browse files Browse the repository at this point in the history
* sovrn ccpa support

* use array map/join instead of object.entries
  • Loading branch information
aprakash-sovrn authored and Isaac A. Dettman committed Dec 17, 2019
1 parent 9ba8031 commit f799046
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 16 deletions.
32 changes: 17 additions & 15 deletions modules/sovrnBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,12 @@ export const spec = {
};
}

if (bidderRequest && bidderRequest.gdprConsent) {
sovrnBidReq.regs = {
ext: {
gdpr: +bidderRequest.gdprConsent.gdprApplies
}};
sovrnBidReq.user = {
ext: {
consent: bidderRequest.gdprConsent.consentString
}};
if (bidderRequest.gdprConsent) {
utils.deepSetValue(sovrnBidReq, 'regs.ext.gdpr', +bidderRequest.gdprConsent.gdprApplies);
utils.deepSetValue(sovrnBidReq, 'user.ext.consent', bidderRequest.gdprConsent.consentString)
}
if (bidderRequest.uspConsent) {
utils.deepSetValue(sovrnBidReq, 'regs.ext.us_privacy', bidderRequest.uspConsent);
}

if (digitrust) {
Expand Down Expand Up @@ -151,21 +148,26 @@ export const spec = {
}
},

getUserSyncs: function(syncOptions, serverResponses, gdprConsent) {
getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) {
try {
let tracks = []
const tracks = []
if (serverResponses && serverResponses.length !== 0) {
if (syncOptions.iframeEnabled) {
let iidArr = serverResponses.filter(resp => utils.deepAccess(resp, 'body.ext.iid'))
const iidArr = serverResponses.filter(resp => utils.deepAccess(resp, 'body.ext.iid'))
.map(resp => resp.body.ext.iid);
let consentString = '';
const params = [];
if (gdprConsent && gdprConsent.gdprApplies && typeof gdprConsent.consentString === 'string') {
consentString = gdprConsent.consentString
params.push(['gdpr_consent', gdprConsent.consentString]);
}
if (uspConsent) {
params.push(['us_privacy', uspConsent]);
}

if (iidArr[0]) {
params.push(['informer', iidArr[0]]);
tracks.push({
type: 'iframe',
url: 'https://ap.lijit.com/beacon?informer=' + iidArr[0] + '&gdpr_consent=' + consentString,
url: 'https://ap.lijit.com/beacon?' + params.map(p => p.join('=')).join('&')
});
}
}
Expand Down
64 changes: 63 additions & 1 deletion test/spec/modules/sovrnBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,25 @@ describe('sovrnBidAdapter', function() {
expect(data.user.ext.consent).to.equal(consentString);
});

it('should send us_privacy if bidderRequest has a value for uspConsent', function () {
let uspString = '1NYN';
let bidderRequest = {
'bidderCode': 'sovrn',
'auctionId': '1d1a030790a475',
'bidderRequestId': '22edbae2733bf6',
'timeout': 3000,
uspConsent: uspString,
refererInfo: {
referer: 'http://example.com/page.html',
}
};
bidderRequest.bids = bidRequests;

const data = JSON.parse(spec.buildRequests(bidRequests, bidderRequest).data);

expect(data.regs.ext['us_privacy']).to.equal(uspString);
});

it('converts tagid to string', function () {
const ivBidRequests = [{
'bidder': 'sovrn',
Expand Down Expand Up @@ -399,13 +418,56 @@ describe('sovrnBidAdapter', function() {
const expectedReturnStatement = [
{
'type': 'iframe',
'url': 'https://ap.lijit.com/beacon?informer=13487408&gdpr_consent=',
'url': 'https://ap.lijit.com/beacon?informer=13487408',
}
];
const returnStatement = spec.getUserSyncs(syncOptions, serverResponse);
expect(returnStatement[0]).to.deep.equal(expectedReturnStatement[0]);
});

it('should include gdpr consent string if present', function() {
const gdprConsent = {
gdprApplies: 1,
consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='
}
const expectedReturnStatement = [
{
'type': 'iframe',
'url': `https://ap.lijit.com/beacon?gdpr_consent=${gdprConsent.consentString}&informer=13487408`,
}
];
const returnStatement = spec.getUserSyncs(syncOptions, serverResponse, gdprConsent, '');
expect(returnStatement[0]).to.deep.equal(expectedReturnStatement[0]);
});

it('should include us privacy string if present', function() {
const uspString = '1NYN';
const expectedReturnStatement = [
{
'type': 'iframe',
'url': `https://ap.lijit.com/beacon?us_privacy=${uspString}&informer=13487408`,
}
];
const returnStatement = spec.getUserSyncs(syncOptions, serverResponse, null, uspString);
expect(returnStatement[0]).to.deep.equal(expectedReturnStatement[0]);
});

it('should include all privacy strings if present', function() {
const gdprConsent = {
gdprApplies: 1,
consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='
}
const uspString = '1NYN';
const expectedReturnStatement = [
{
'type': 'iframe',
'url': `https://ap.lijit.com/beacon?gdpr_consent=${gdprConsent.consentString}&us_privacy=${uspString}&informer=13487408`,
}
];
const returnStatement = spec.getUserSyncs(syncOptions, serverResponse, gdprConsent, uspString);
expect(returnStatement[0]).to.deep.equal(expectedReturnStatement[0]);
});

it('should not return if iid missing on server response', function() {
const returnStatement = spec.getUserSyncs(syncOptions, []);
expect(returnStatement).to.be.empty;
Expand Down

0 comments on commit f799046

Please sign in to comment.