Skip to content

Commit

Permalink
Configure Adhese gvlid, filter out empty params to reduce the Adhese …
Browse files Browse the repository at this point in the history
…request size (#5602)
  • Loading branch information
mefjush authored Aug 18, 2020
1 parent 0e182b7 commit 6c61de8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
17 changes: 11 additions & 6 deletions modules/adheseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';

const BIDDER_CODE = 'adhese';
const GVLID = 553;
const USER_SYNC_BASE_URL = 'https://user-sync.adhese.com/iframe/user_sync.html';

export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
supportedMediaTypes: [BANNER, VIDEO],

isBidRequestValid: function(bid) {
Expand Down Expand Up @@ -112,12 +114,15 @@ function mergeTargets(targets, target) {
if (target) {
Object.keys(target).forEach(function (key) {
const val = target[key];
const values = Array.isArray(val) ? val : [val];
if (targets[key]) {
const distinctValues = values.filter(v => targets[key].indexOf(v) < 0);
targets[key].push.apply(targets[key], distinctValues);
} else {
targets[key] = values;
const dirtyValues = Array.isArray(val) ? val : [val];
const values = dirtyValues.filter(v => v === 0 || v);
if (values.length > 0) {
if (targets[key]) {
const distinctValues = values.filter(v => targets[key].indexOf(v) < 0);
targets[key].push.apply(targets[key], distinctValues);
} else {
targets[key] = values;
}
}
});
}
Expand Down
8 changes: 8 additions & 0 deletions test/spec/modules/adheseBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ describe('AdheseAdapter', function () {
expect(JSON.parse(req.data).parameters).to.deep.include({ 'ci': [ 'london', 'gent' ] });
});

it('should filter out empty params', function () {
let req = spec.buildRequests([ bidWithParams({ 'aa': [], 'bb': null, 'cc': '', 'dd': [ '', '' ], 'ee': [ 0, 1, null ], 'ff': 0, 'gg': [ 'x', 'y', '' ] }) ], bidderRequest);

let params = JSON.parse(req.data).parameters;
expect(params).to.not.have.any.keys('aa', 'bb', 'cc', 'dd');
expect(params).to.deep.include({ 'ee': [ 0, 1 ], 'ff': [ 0 ], 'gg': [ 'x', 'y' ] });
});

it('should include gdpr consent param', function () {
let req = spec.buildRequests([ minimalBid() ], bidderRequest);

Expand Down

0 comments on commit 6c61de8

Please sign in to comment.