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

added CCPA support, gvlid to adform and adformOpenRTB adapters #5214

Merged
merged 1 commit into from
Jun 11, 2020
Merged
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
18 changes: 13 additions & 5 deletions modules/adformBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import * as utils from '../src/utils.js';
const OUTSTREAM_RENDERER_URL = 'https://s2.adform.net/banners/scripts/video/outstream/render.js';

const BIDDER_CODE = 'adform';
const GVLID = 50;
export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
supportedMediaTypes: [ BANNER, VIDEO ],
isBidRequestValid: function (bid) {
return !!(bid.params.mid);
Expand Down Expand Up @@ -47,13 +49,19 @@ export const spec = {
request.push('pt=' + netRevenue);
request.push('stid=' + validBidRequests[0].auctionId);

if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) {
const gdprApplies = utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies');
const consentString = utils.deepAccess(bidderRequest, 'gdprConsent.consentString');
if (gdprApplies !== undefined) {
gdprObject = {
gdpr: bidderRequest.gdprConsent.gdprApplies,
gdpr_consent: bidderRequest.gdprConsent.consentString
gdpr: gdprApplies,
gdpr_consent: consentString
};
request.push('gdpr=' + gdprObject.gdpr);
request.push('gdpr_consent=' + gdprObject.gdpr_consent);
request.push('gdpr=' + (gdprApplies & 1));
request.push('gdpr_consent=' + consentString);
}

if (bidderRequest && bidderRequest.uspConsent) {
request.push('us_privacy=' + bidderRequest.uspConsent);
}

for (i = 1, l = globalParams.length; i < l; i++) {
Expand Down
8 changes: 7 additions & 1 deletion modules/adformOpenRTBBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as utils from '../src/utils.js';
import { config } from '../src/config.js';

const BIDDER_CODE = 'adformOpenRTB';
const GVLID = 50;
const NATIVE_ASSET_IDS = { 0: 'title', 2: 'icon', 3: 'image', 5: 'sponsoredBy', 4: 'body', 1: 'cta' };
const NATIVE_PARAMS = {
title: {
Expand Down Expand Up @@ -46,6 +47,7 @@ const NATIVE_PARAMS = {

export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
supportedMediaTypes: [ NATIVE ],
isBidRequestValid: bid => !!bid.params.mid,
buildRequests: (validBidRequests, bidderRequest) => {
Expand Down Expand Up @@ -122,11 +124,15 @@ export const spec = {
request.is_debug = !!test;
request.test = 1;
}
if (utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies')) {
if (utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies') !== undefined) {
request.user = { ext: { consent: bidderRequest.gdprConsent.consentString } };
request.regs = { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies & 1 } };
}

if (bidderRequest.uspConsent) {
utils.deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent);
}

return {
method: 'POST',
url: 'https://' + adxDomain + '/adx/openrtb',
Expand Down
28 changes: 17 additions & 11 deletions test/spec/modules/adformBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,25 +129,24 @@ describe('Adform adapter', function () {
assert.equal(parsedUrl.query.pt, 'gross');
});

describe('gdpr', function () {
describe('user privacy', function () {
it('should send GDPR Consent data to adform if gdprApplies', function () {
let resultBids = JSON.parse(JSON.stringify(bids[0]));
let request = spec.buildRequests([bids[0]], {gdprConsent: {gdprApplies: true, consentString: 'concentDataString'}});
let parsedUrl = parseUrl(request.url).query;

assert.equal(parsedUrl.gdpr, 'true');
assert.equal(parsedUrl.gdpr, '1');
assert.equal(parsedUrl.gdpr_consent, 'concentDataString');
});

it('should not send GDPR Consent data to adform if gdprApplies is false or undefined', function () {
let resultBids = JSON.parse(JSON.stringify(bids[0]));
it('should not send GDPR Consent data to adform if gdprApplies is undefined', function () {
let request = spec.buildRequests([bids[0]], {gdprConsent: {gdprApplies: false, consentString: 'concentDataString'}});
let parsedUrl = parseUrl(request.url).query;

assert.ok(!parsedUrl.gdpr);
assert.ok(!parsedUrl.gdpr_consent);
assert.equal(parsedUrl.gdpr, '0');
assert.equal(parsedUrl.gdpr_consent, 'concentDataString');

request = spec.buildRequests([bids[0]], {gdprConsent: {gdprApplies: undefined, consentString: 'concentDataString'}});
parsedUrl = parseUrl(request.url).query;
assert.ok(!parsedUrl.gdpr);
assert.ok(!parsedUrl.gdpr_consent);
});
Expand All @@ -163,6 +162,13 @@ describe('Adform adapter', function () {
request = spec.buildRequests([bids[0]]);
assert.ok(!request.gdpr);
});

it('should send CCPA Consent data to adform', function () {
const request = spec.buildRequests([bids[0]], {uspConsent: '1YA-'});
const parsedUrl = parseUrl(request.url).query;

assert.equal(parsedUrl.us_privacy, '1YA-');
});
});
});

Expand Down Expand Up @@ -247,14 +253,14 @@ describe('Adform adapter', function () {
for (let i = 0; i < result.length; i++) {
assert.equal(result[i].gdpr, true);
assert.equal(result[i].gdpr_consent, 'ERW342EIOWT34234KMGds');
};
}

bidRequest.gdpr = undefined;
result = spec.interpretResponse(serverResponse, bidRequest);
for (let i = 0; i < result.length; i++) {
assert.ok(!result[i].gdpr);
assert.ok(!result[i].gdpr_consent);
};
}
});

it('should set a renderer only for an outstream context', function () {
Expand Down Expand Up @@ -302,13 +308,13 @@ describe('Adform adapter', function () {
serverResponse.body = [serverResponse.body[0]];
bidRequest.bids = [bidRequest.bids[0]];

bidRequest.bids[0].sizes = [['300', '250'], ['250', '300'], ['300', '600'], ['600', '300']]
bidRequest.bids[0].sizes = [['300', '250'], ['250', '300'], ['300', '600'], ['600', '300']];
let result = spec.interpretResponse(serverResponse, bidRequest);

assert.equal(result[0].width, 300);
assert.equal(result[0].height, 600);
});
})
});
});

beforeEach(function () {
Expand Down
26 changes: 24 additions & 2 deletions test/spec/modules/adformOpenRTBBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('AdformOpenRTB adapter', function () {
assert.ok(request.data);
});

describe('gdpr', function () {
describe('user privacy', function () {
it('should send GDPR Consent data to adform if gdprApplies', function () {
let validBidRequests = [{ bidId: 'bidId', params: { siteId: 'siteId', test: 1 } }];
let bidderRequest = { gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, refererInfo: { referer: 'page' } };
Expand All @@ -60,16 +60,38 @@ describe('AdformOpenRTB adapter', function () {
let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data);

assert.equal(typeof request.regs.ext.gdpr, 'number');
assert.equal(request.regs.ext.gdpr, 1);
});

it('should not send GDPR Consent data to adform if gdprApplies is false or undefined', function () {
it('should send CCPA Consent data to adform', function () {
let validBidRequests = [{ bidId: 'bidId', params: { siteId: 'siteId', test: 1 } }];
let bidderRequest = { uspConsent: '1YA-', refererInfo: { referer: 'page' } };
let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data);

assert.equal(request.regs.ext.us_privacy, '1YA-');

bidderRequest = { uspConsent: '1YA-', gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, refererInfo: { referer: 'page' } };
request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data);

assert.equal(request.regs.ext.us_privacy, '1YA-');
assert.equal(request.user.ext.consent, 'consentDataString');
assert.equal(request.regs.ext.gdpr, 1);
});

it('should not send GDPR Consent data to adform if gdprApplies is undefined', function () {
let validBidRequests = [{
bidId: 'bidId',
params: { siteId: 'siteId' }
}];
let bidderRequest = {gdprConsent: {gdprApplies: false, consentString: 'consentDataString'}, refererInfo: { referer: 'page' }};
let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data);

assert.equal(request.user.ext.consent, 'consentDataString');
assert.equal(request.regs.ext.gdpr, 0);

bidderRequest = {gdprConsent: {consentString: 'consentDataString'}, refererInfo: { referer: 'page' }};
request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data);

assert.equal(request.user, undefined);
assert.equal(request.regs, undefined);
});
Expand Down