Skip to content

Commit

Permalink
Improve Digital adapter: support for video (prebid#4318)
Browse files Browse the repository at this point in the history
* Bid floor, https, native ad update

* Update the ad server protocol module

* Adding referrer

* Improve Digital support for video

* Improve Digital adapter: video

* adapter version -> 6.0.0
  • Loading branch information
jbartek25 authored and tadam75 committed Jan 9, 2020
1 parent 99be07e commit 8d21e77
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 3 deletions.
14 changes: 11 additions & 3 deletions modules/improvedigitalBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as utils from '../src/utils';
import { registerBidder } from '../src/adapters/bidderFactory';
import { config } from '../src/config';
import { BANNER, NATIVE } from '../src/mediaTypes';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes';

const BIDDER_CODE = 'improvedigital';

export const spec = {
version: '5.3.0',
version: '6.0.0',
code: BIDDER_CODE,
aliases: ['id'],
supportedMediaTypes: [BANNER, NATIVE],
supportedMediaTypes: [BANNER, NATIVE, VIDEO],

/**
* Determines whether or not the given bid request is valid.
Expand Down Expand Up @@ -87,6 +87,9 @@ export const spec = {
bid.native.impressionTrackers.unshift(bidObject.nurl);
}
bid.mediaType = NATIVE;
} else if (bidObject.ad_type && bidObject.ad_type === 'video') {
bid.vastXml = bidObject.adm;
bid.mediaType = VIDEO;
} else {
// Banner
let nurl = '';
Expand Down Expand Up @@ -186,6 +189,11 @@ function getNormalizedBidRequest(bid) {
const bidFloorCur = utils.getBidIdParameter('bidFloorCur', bid.params);

let normalizedBidRequest = {};
const videoMediaType = utils.deepAccess(bid, 'mediaTypes.video');
const context = utils.deepAccess(bid, 'mediaTypes.video.context');
if (bid.mediaType === 'video' || (videoMediaType && context !== 'outstream')) {
normalizedBidRequest.adTypes = [ VIDEO ];
}
if (placementId) {
normalizedBidRequest.placementId = placementId;
} else {
Expand Down
82 changes: 82 additions & 0 deletions test/spec/modules/improvedigitalBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,38 @@ describe('Improve Digital Adapter Tests', function () {
expect(params.bid_request.referrer).to.equal('https://blah.com/test.html');
});

it('should add ad type for instream video', function () {
let bidRequest = Object.assign({}, simpleBidRequest);
bidRequest.mediaType = 'video';
let request = spec.buildRequests([bidRequest])[0];
let params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length)));
expect(params.bid_request.imp[0].ad_types).to.deep.equal(['video']);

bidRequest = Object.assign({}, simpleBidRequest);
bidRequest.mediaTypes = {
video: {
context: 'instream',
playerSize: [640, 480]
}
};
request = spec.buildRequests([bidRequest])[0];
params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length)));
expect(params.bid_request.imp[0].ad_types).to.deep.equal(['video']);
});

it('should not set ad type for outstream video', function() {
const bidRequest = Object.assign({}, simpleBidRequest);
bidRequest.mediaTypes = {
video: {
context: 'outstream',
playerSize: [640, 480]
}
};
const request = spec.buildRequests([bidRequest])[0];
const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length)));
expect(params.bid_request.imp[0].ad_types).to.not.exist;
});

it('should add schain', function () {
const schain = '{"ver":"1.0","complete":1,"nodes":[{"asi":"headerlift.com","sid":"xyz","hp":1}]}';
const bidRequest = Object.assign({}, simpleBidRequest);
Expand Down Expand Up @@ -456,6 +488,34 @@ describe('Improve Digital Adapter Tests', function () {
}
};

const serverResponseVideo = {
'body': {
'id': '687a06c541d8d1',
'site_id': 191642,
'bid': [
{
'isNet': false,
'id': '33e9500b21129f',
'advid': '5279',
'price': 1.45888594164456,
'nurl': 'http://ice.360yield.com/imp_pixel?ic=wVmhKI07hCVyGC1sNdFp.6buOSiGYOw8jPyZLlcMY2RCwD4ek3Fy6.xUI7U002skGBs3objMBoNU-Frpvmb9js3NKIG0YZJgWaNdcpXY9gOXE9hY4-wxybCjVSNzhOQB-zic73hzcnJnKeoGgcfvt8fMy18-yD0aVdYWt4zbqdoITOkKNCPBEgbPFu1rcje-o7a64yZ7H3dKvtnIixXQYc1Ep86xGSBGXY6xW2KfUOMT6vnkemxO72divMkMdhR8cAuqIubbx-ZID8-xf5c9k7p6DseeBW0I8ionrlTHx.rGosgxhiFaMqtr7HiA7PBzKvPdeEYN0hQ8RYo8JzYL82hA91A3V2m9Ij6y0DfIJnnrKN8YORffhxmJ6DzwEl1zjrVFbD01bqB3Vdww8w8PQJSkKQkd313tr-atU8LS26fnBmOngEkVHwAr2WCKxuUvxHmuVBTA-Lgz7wKwMoOJCA3hFxMavVb0ZFB7CK0BUTVU6z0De92Q.FJKNCHLMbjX3vcAQ90=',
'h': 290,
'pid': 1053688,
'sync': [
'http://link1',
'http://link2'
],
'crid': '422031',
'w': 600,
'cid': '99006',
'adm': '<VAST></VAST>',
'ad_type': 'video'
}
],
'debug': ''
}
};

const nativeEventtrackers = [
{
event: 1,
Expand Down Expand Up @@ -552,6 +612,22 @@ describe('Improve Digital Adapter Tests', function () {
}
];

let expectedBidVideo = [
{
'vastXml': '<VAST></VAST>',
'adId': '33e9500b21129f',
'creativeId': '422031',
'cpm': 1.45888594164456,
'currency': 'USD',
'height': 290,
'mediaType': 'video',
'netRevenue': false,
'requestId': '33e9500b21129f',
'ttl': 300,
'width': 600
}
];

it('should return a well-formed bid', function () {
const bids = spec.interpretResponse(serverResponse);
expect(bids).to.deep.equal(expectedBid);
Expand Down Expand Up @@ -667,6 +743,12 @@ describe('Improve Digital Adapter Tests', function () {
delete bids[0].ortbNative;
expect(bids).to.deep.equal(expectedBids);
});

// Video
it('should return a well-formed video bid', function () {
const bids = spec.interpretResponse(serverResponseVideo);
expect(bids).to.deep.equal(expectedBidVideo);
});
});

describe('getUserSyncs', function () {
Expand Down

0 comments on commit 8d21e77

Please sign in to comment.