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

sovrn ccpa support #22

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
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) {

Choose a reason for hiding this comment

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

how come you took out this additional check?... just curious.

Copy link
Author

Choose a reason for hiding this comment

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

it's already referred to, so if it didn't exist it's going to barf before we get here

utils.deepSetValue(sovrnBidReq, 'regs.ext.gdpr', +bidderRequest.gdprConsent.gdprApplies);

Choose a reason for hiding this comment

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

how did you come to use deepSetValue. just curious.

Copy link
Author

Choose a reason for hiding this comment

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

i think the prebid peeps mentioned it in a previous PR

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['gdpr_consent'] = gdprConsent.consentString
}
if (uspConsent) {
params['us_privacy'] = uspConsent;
}

if (iidArr[0]) {
params.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?' + Object.entries(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