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

Adhese Bid Adapter: Configurable vast as url #7659

Merged
merged 11 commits into from
Nov 9, 2021
9 changes: 7 additions & 2 deletions modules/adheseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { config } from '../src/config.js';

const BIDDER_CODE = 'adhese';
const GVLID = 553;
Expand All @@ -20,11 +21,15 @@ export const spec = {
if (validBidRequests.length === 0) {
return null;
}

const { gdprConsent, refererInfo } = bidderRequest;

const adheseConfig = config.getConfig('adhese');
const gdprParams = (gdprConsent && gdprConsent.consentString) ? { xt: [gdprConsent.consentString] } : {};
const refererParams = (refererInfo && refererInfo.referer) ? { xf: [base64urlEncode(refererInfo.referer)] } : {};
const commonParams = { ...gdprParams, ...refererParams };
const globalCustomParams = (adheseConfig && adheseConfig.globalTargets) ? cleanTargets(adheseConfig.globalTargets) : {};
const commonParams = { ...globalCustomParams, ...gdprParams, ...refererParams };
const vastContentAsUrl = !(adheseConfig && adheseConfig.vastContentAsUrl == false);

const slots = validBidRequests.map(bid => ({
slotname: bidToSlotName(bid),
Expand All @@ -34,7 +39,7 @@ export const spec = {
const payload = {
slots: slots,
parameters: commonParams,
vastContentAsUrl: true,
vastContentAsUrl: vastContentAsUrl,
user: {
ext: {
eids: getEids(validBidRequests),
Expand Down
28 changes: 27 additions & 1 deletion test/spec/modules/adheseBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {expect} from 'chai';
import {spec} from 'modules/adheseBidAdapter.js';
import {config} from 'src/config.js';

const BID_ID = 456;
const TTL = 360;
Expand Down Expand Up @@ -131,12 +132,21 @@ describe('AdheseAdapter', function () {
expect(JSON.parse(req.data)).to.not.have.key('eids');
});

it('should request vast content as url', function () {
it('should request vast content as url by default', function () {
let req = spec.buildRequests([ minimalBid() ], bidderRequest);

expect(JSON.parse(req.data).vastContentAsUrl).to.equal(true);
});

it('should request vast content as markup when configured', function () {
sinon.stub(config, 'getConfig').withArgs('adhese').returns({ vastContentAsUrl: false });

let req = spec.buildRequests([ minimalBid() ], bidderRequest);

expect(JSON.parse(req.data).vastContentAsUrl).to.equal(false);
config.getConfig.restore();
});

it('should include bids', function () {
let bid = minimalBid();
let req = spec.buildRequests([ bid ], bidderRequest);
Expand All @@ -155,6 +165,22 @@ describe('AdheseAdapter', function () {

expect(req.url).to.equal('https://ads-demo.adhese.com/json');
});

it('should include params specified in the config', function () {
sinon.stub(config, 'getConfig').withArgs('adhese').returns({ globalTargets: { 'tl': [ 'all' ] } });
let req = spec.buildRequests([ minimalBid() ], bidderRequest);

expect(JSON.parse(req.data).parameters).to.deep.include({ 'tl': [ 'all' ] });
config.getConfig.restore();
});

it('should give priority to bid params over config params', function () {
sinon.stub(config, 'getConfig').withArgs('adhese').returns({ globalTargets: { 'xt': ['CONFIG_CONSENT_STRING'] } });
let req = spec.buildRequests([ minimalBid() ], bidderRequest);

expect(JSON.parse(req.data).parameters).to.deep.include({ 'xt': [ 'CONSENT_STRING' ] });
config.getConfig.restore();
});
});

describe('interpretResponse', () => {
Expand Down