Skip to content

Commit

Permalink
AdKernel Bid/Analytics Adapters: user privacy related changes (#6488)
Browse files Browse the repository at this point in the history
  • Loading branch information
ckbo3hrk committed Apr 5, 2021
1 parent 8b9f763 commit a01dc2b
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 16 deletions.
29 changes: 25 additions & 4 deletions modules/adkernelAdnAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import CONSTANTS from '../src/constants.json';
import adapterManager from '../src/adapterManager.js';
import * as utils from '../src/utils.js';
import {ajax} from '../src/ajax.js';
import { getStorageManager } from '../src/storageManager.js';
import {getStorageManager} from '../src/storageManager.js';
import {config} from '../src/config.js';

const ANALYTICS_VERSION = '1.0.1';
const GVLID = 14;
const ANALYTICS_VERSION = '1.0.2';
const DEFAULT_QUEUE_TIMEOUT = 4000;
const DEFAULT_HOST = 'tag.adkernel.com';
const storageObj = getStorageManager();
const storageObj = getStorageManager(GVLID);

const ADK_HB_EVENTS = {
AUCTION_INIT: 'auctionInit',
Expand All @@ -34,6 +36,7 @@ function buildRequestTemplate(pubId) {
},
lang: navigator.language
},
user: {},
src: getUmtSource(loc.href, ref)
}
}
Expand All @@ -50,6 +53,7 @@ let analyticsAdapter = Object.assign(adapter({analyticsType: 'endpoint'}),
if (analyticsAdapter.context.queue) {
analyticsAdapter.context.queue.init();
}
initPrivacy(analyticsAdapter.context.requestTemplate, args.bidderRequests);
handler = trackAuctionInit;
break;
case CONSTANTS.EVENTS.BID_REQUESTED:
Expand Down Expand Up @@ -100,7 +104,8 @@ analyticsAdapter.enableAnalytics = (config) => {

adapterManager.registerAnalyticsAdapter({
adapter: analyticsAdapter,
code: 'adkernelAdn'
code: 'adkernelAdn',
gvlid: GVLID
});

export default analyticsAdapter;
Expand Down Expand Up @@ -390,3 +395,19 @@ function getLocationAndReferrer(win) {
loc: win.location
};
}

function initPrivacy(template, requests) {
let consent = requests[0].gdprConsent;
if (consent && consent.gdprApplies) {
template.user.gdpr = ~~consent.gdprApplies;
}
if (consent && consent.consentString) {
template.user.gdpr_consent = consent.consentString;
}
if (requests[0].uspConsent) {
template.user.us_privacy = requests[0].uspConsent;
}
if (config.getConfig('coppa')) {
template.user.coppa = 1;
}
}
6 changes: 6 additions & 0 deletions modules/adkernelAdnBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import * as utils from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {config} from '../src/config.js';

const DEFAULT_ADKERNEL_DSP_DOMAIN = 'tag.adkernel.com';
const DEFAULT_MIMES = ['video/mp4', 'video/webm', 'application/x-shockwave-flash', 'application/javascript'];
const DEFAULT_PROTOCOLS = [2, 3, 5, 6];
const DEFAULT_APIS = [1, 2];
const GVLID = 14;

function isRtbDebugEnabled(refInfo) {
return refInfo.referer.indexOf('adk_debug=true') !== -1;
Expand Down Expand Up @@ -67,6 +69,9 @@ function buildRequestParams(tags, bidderRequest) {
if (uspConsent) {
utils.deepSetValue(req, 'user.us_privacy', uspConsent);
}
if (config.getConfig('coppa')) {
utils.deepSetValue(req, 'user.coppa', 1);
}
return req;
}

Expand Down Expand Up @@ -110,6 +115,7 @@ function buildBid(tag) {

export const spec = {
code: 'adkernelAdn',
gvlid: GVLID,
supportedMediaTypes: [BANNER, VIDEO],
aliases: ['engagesimply'],

Expand Down
8 changes: 6 additions & 2 deletions modules/adkernelBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const SYNC_TYPES = Object.freeze({
1: 'iframe',
2: 'image'
});
const GVLID = 14;

const NATIVE_MODEL = [
{name: 'title', assetType: 'title'},
Expand Down Expand Up @@ -50,8 +51,8 @@ const NATIVE_INDEX = NATIVE_MODEL.reduce((acc, val, idx) => {
* Adapter for requesting bids from AdKernel white-label display platform
*/
export const spec = {

code: 'adkernel',
gvlid: GVLID,
aliases: ['headbidding', 'adsolut', 'oftmediahb', 'audiencemedia', 'waardex_ak', 'roqoon', 'andbeyond', 'adbite', 'houseofpubs', 'torchad', 'stringads', 'bcm'],
supportedMediaTypes: [BANNER, VIDEO, NATIVE],

Expand Down Expand Up @@ -320,7 +321,7 @@ function getAllowedSyncMethod(bidderCode) {
*/
function buildRtbRequest(imps, bidderRequest, schain) {
let {bidderCode, gdprConsent, auctionId, refererInfo, timeout, uspConsent} = bidderRequest;

let coppa = config.getConfig('coppa');
let req = {
'id': auctionId,
'imp': imps,
Expand Down Expand Up @@ -349,6 +350,9 @@ function buildRtbRequest(imps, bidderRequest, schain) {
if (uspConsent) {
utils.deepSetValue(req, 'regs.ext.us_privacy', uspConsent);
}
if (coppa) {
utils.deepSetValue(req, 'regs.coppa', 1);
}
let syncMethod = getAllowedSyncMethod(bidderCode);
if (syncMethod) {
utils.deepSetValue(req, 'ext.adk_usersync', syncMethod);
Expand Down
21 changes: 15 additions & 6 deletions test/spec/modules/adkernelAdnAnalytics_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import analyticsAdapter, {ExpiringQueue, getUmtSource, storage} from 'modules/adkernelAdnAnalyticsAdapter.js';
import analyticsAdapter, {ExpiringQueue, getUmtSource, storage} from 'modules/adkernelAdnAnalyticsAdapter';
import {expect} from 'chai';
import adapterManager from 'src/adapterManager.js';
import adapterManager from 'src/adapterManager';
import CONSTANTS from 'src/constants.json';

const events = require('../../../src/events');
Expand Down Expand Up @@ -158,11 +158,16 @@ describe('', function () {
sizes: [[300, 250]],
bidId: '208750227436c1',
bidderRequestId: '1a6fc81528d0f6',
auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f'
auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f',
gdprConsent: {
consentString: 'CONSENT',
gdprApplies: true,
apiVersion: 2
},
uspConsent: '1---'
}],
auctionStart: 1509369418387,
timeout: 3000,
start: 1509369418389
timeout: 3000
};

const RESPONSE = {
Expand Down Expand Up @@ -202,6 +207,10 @@ describe('', function () {
events.getEvents.restore();
});

after(function() {
sandbox.restore();
});

it('should be configurable', function () {
adapterManager.registerAnalyticsAdapter({
code: 'adkernelAdn',
Expand All @@ -221,7 +230,7 @@ describe('', function () {
});

it('should handle auction init event', function () {
events.emit(CONSTANTS.EVENTS.AUCTION_INIT, {config: {}, timeout: 3000});
events.emit(CONSTANTS.EVENTS.AUCTION_INIT, {config: {}, bidderRequests: [REQUEST], timeout: 3000});
const ev = analyticsAdapter.context.queue.peekAll();
expect(ev).to.have.length(1);
expect(ev[0]).to.be.eql({event: 'auctionInit'});
Expand Down
11 changes: 10 additions & 1 deletion test/spec/modules/adkernelAdnBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {expect} from 'chai';
import {spec} from 'modules/adkernelAdnBidAdapter.js';
import {spec} from 'modules/adkernelAdnBidAdapter';
import {config} from 'src/config';

describe('AdkernelAdn adapter', function () {
const bid1_pub1 = {
Expand Down Expand Up @@ -263,6 +264,14 @@ describe('AdkernelAdn adapter', function () {
expect(bidRequests[0].user).to.have.property('gdpr', 0);
expect(bidRequests[0].user).to.not.have.property('consent');
});

it('should\'t contain consent string if gdpr isn\'t applied', function () {
config.setConfig({coppa: true});
let [_, bidRequests] = buildRequest([bid1_pub1]);
config.resetConfig();
expect(bidRequests[0]).to.have.property('user');
expect(bidRequests[0].user).to.have.property('coppa', 1);
});
});

describe('video request building', () => {
Expand Down
15 changes: 12 additions & 3 deletions test/spec/modules/adkernelBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {expect} from 'chai';
import {spec} from 'modules/adkernelBidAdapter.js';
import * as utils from 'src/utils.js';
import {spec} from 'modules/adkernelBidAdapter';
import * as utils from 'src/utils';
import {NATIVE, BANNER, VIDEO} from 'src/mediaTypes';
import {config} from 'src/config.js';
import {config} from 'src/config';

describe('Adkernel adapter', function () {
const bid1_zone1 = {
Expand Down Expand Up @@ -241,6 +241,7 @@ describe('Adkernel adapter', function () {

afterEach(function () {
sandbox.restore();
config.resetConfig();
});

function buildBidderRequest(url = 'https://example.com/index.html', params = {}) {
Expand Down Expand Up @@ -343,6 +344,14 @@ describe('Adkernel adapter', function () {
expect(bidRequest.user.ext).to.be.eql({'consent': 'test-consent-string'});
});

it('should contain coppa if configured', function () {
config.setConfig({coppa: true});
let [_, bidRequests] = buildRequest([bid1_zone1]);
let bidRequest = bidRequests[0];
expect(bidRequest).to.have.property('regs');
expect(bidRequest.regs).to.have.property('coppa', 1);
});

it('should\'t contain consent string if gdpr isn\'t applied', function () {
let [_, bidRequests] = buildRequest([bid1_zone1], buildBidderRequest('https://example.com/index.html', {gdprConsent: {gdprApplies: false}}));
let bidRequest = bidRequests[0];
Expand Down

0 comments on commit a01dc2b

Please sign in to comment.