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

Improve Digital adapter: add support for adomain and floors module #6943

Merged
merged 1 commit into from
Jun 4, 2021
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
32 changes: 29 additions & 3 deletions modules/improvedigitalBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js
const VIDEO_TARGETING = ['skip', 'skipmin', 'skipafter'];

export const spec = {
version: '7.3.0',
version: '7.4.0',
code: BIDDER_CODE,
gvlid: 253,
aliases: ['id'],
Expand Down Expand Up @@ -158,6 +158,12 @@ export const spec = {
bid.height = 1;
}

if (bidObject.adomain) {
bid.meta = {
advertiserDomains: bidObject.adomain
};
}

bids.push(bid);
});
return bids;
Expand Down Expand Up @@ -218,6 +224,21 @@ function getVideoTargetingParams(bid) {
return result;
}

function getBidFloor(bid) {
if (!utils.isFn(bid.getFloor)) {
return null;
}
const floor = bid.getFloor({
currency: 'USD',
mediaType: '*',
size: '*'
});
if (utils.isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'USD') {
return floor.floor;
}
return null;
}

function outstreamRender(bid) {
bid.renderer.push(() => {
window.ANOutstreamVideo.renderAd({
Expand Down Expand Up @@ -264,8 +285,6 @@ function getNormalizedBidRequest(bid) {
const bidId = utils.getBidIdParameter('bidId', bid);
const transactionId = utils.getBidIdParameter('transactionId', bid);
const currency = config.getConfig('currency.adServerCurrency');
const bidFloor = utils.getBidIdParameter('bidFloor', bid.params);
const bidFloorCur = utils.getBidIdParameter('bidFloorCur', bid.params);

let normalizedBidRequest = {};
if (isInstreamVideo(bid)) {
Expand Down Expand Up @@ -309,6 +328,13 @@ function getNormalizedBidRequest(bid) {
if (currency) {
normalizedBidRequest.currency = currency;
}
// Floor
let bidFloor = getBidFloor(bid);
let bidFloorCur = null;
if (!bidFloor) {
bidFloor = utils.getBidIdParameter('bidFloor', bid.params);
bidFloorCur = utils.getBidIdParameter('bidFloorCur', bid.params);
}
if (bidFloor) {
normalizedBidRequest.bidFloor = bidFloor;
normalizedBidRequest.bidFloorCur = bidFloorCur ? bidFloorCur.toUpperCase() : 'USD';
Expand Down
16 changes: 16 additions & 0 deletions test/spec/modules/improvedigitalBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,14 @@ describe('Improve Digital Adapter Tests', function () {
params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length)));
expect(params.bid_request.imp[0].bidfloor).to.equal(0.05);
expect(params.bid_request.imp[0].bidfloorcur).to.equal('EUR');

// getFloor defined -> use it over bidFloor
let getFloorResponse = { currency: 'USD', floor: 3 };
bidRequest.getFloor = () => getFloorResponse;
request = spec.buildRequests([bidRequest])[0];
params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length)));
expect(params.bid_request.imp[0].bidfloor).to.equal(3);
expect(params.bid_request.imp[0].bidfloorcur).to.equal('USD');
});

it('should add GDPR consent string', function () {
Expand Down Expand Up @@ -953,6 +961,14 @@ describe('Improve Digital Adapter Tests', function () {
expect(bids[0].netRevenue).to.equal(true);
});

it('should set advertiserDomains', function () {
const adomain = ['domain.com'];
const response = JSON.parse(JSON.stringify(serverResponse));
response.body.bid[0].adomain = adomain;
const bids = spec.interpretResponse(response, {bidderRequest});
expect(bids[0].meta.advertiserDomains).to.equal(adomain);
});

// Native ads
it('should return a well-formed native ad bid', function () {
let bids = spec.interpretResponse(serverResponseNative, {bidderRequest});
Expand Down