Skip to content

Commit

Permalink
Improve Digital: adapter improvements (#5399)
Browse files Browse the repository at this point in the history
* Improve Digital: CCPA support

* Outstream video support

* Lint fixes

* Improve Digital: outstream and deal improvements
  • Loading branch information
jbartek25 committed Jun 25, 2020
1 parent 4e0df1a commit d14b991
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
30 changes: 12 additions & 18 deletions modules/improvedigitalBidAdapter.js
Expand Up @@ -8,7 +8,7 @@ const BIDDER_CODE = 'improvedigital';
const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js';

export const spec = {
version: '7.0.0',
version: '7.1.0',
code: BIDDER_CODE,
gvlid: 253,
aliases: ['id'],
Expand Down Expand Up @@ -123,15 +123,15 @@ export const spec = {

// Deal ID. Composite ads can have multiple line items and the ID of the first
// dealID line item will be used.
if (utils.isNumber(bidObject.lid) && bidObject.buying_type === 'deal_id') {
if (utils.isNumber(bidObject.lid) && bidObject.buying_type && bidObject.buying_type !== 'rtb') {
bid.dealId = bidObject.lid;
} else if (Array.isArray(bidObject.lid) &&
Array.isArray(bidObject.buying_type) &&
bidObject.lid.length === bidObject.buying_type.length) {
let isDeal = false;
bidObject.buying_type.forEach((bt, i) => {
if (isDeal) return;
if (bt === 'deal_id') {
if (bt && bt !== 'rtb') {
isDeal = true;
bid.dealId = bidObject.lid[i];
}
Expand Down Expand Up @@ -182,9 +182,10 @@ export const spec = {
};

function isInstreamVideo(bid) {
const mediaTypes = Object.keys(utils.deepAccess(bid, 'mediaTypes', {}));
const videoMediaType = utils.deepAccess(bid, 'mediaTypes.video');
const context = utils.deepAccess(bid, 'mediaTypes.video.context');
return bid.mediaType === 'video' || (videoMediaType && context !== 'outstream');
return bid.mediaType === 'video' || (mediaTypes.length === 1 && videoMediaType && context !== 'outstream');
}

function isOutstreamVideo(bid) {
Expand All @@ -197,30 +198,23 @@ function outstreamRender(bid) {
bid.renderer.push(() => {
window.ANOutstreamVideo.renderAd({
sizes: [bid.width, bid.height],
width: bid.width,
height: bid.height,
targetId: bid.adUnitCode,
adResponse: bid.adResponse,
rendererOptions: {
showBigPlayButton: false,
showProgressBar: 'bar',
showVolume: false,
allowFullscreen: true,
skippable: false,
}
});
rendererOptions: bid.renderer.getConfig()
}, handleOutstreamRendererEvents.bind(null, bid));
});
}

function handleOutstreamRendererEvents(bid, id, eventName) {
bid.renderer.handleVideoEvent({ id, eventName });
}

function createRenderer(bidRequest) {
const renderer = Renderer.install({
id: bidRequest.adUnitCode,
url: RENDERER_URL,
loaded: false,
config: {
player_width: bidRequest.mediaTypes.video.playerSize[0][0],
player_height: bidRequest.mediaTypes.video.playerSize[0][1]
},
config: utils.deepAccess(bidRequest, 'renderer.options'),
adUnitCode: bidRequest.adUnitCode
});
try {
Expand Down
9 changes: 7 additions & 2 deletions test/spec/modules/improvedigitalBidAdapter_spec.js
Expand Up @@ -778,10 +778,15 @@ describe('Improve Digital Adapter Tests', function () {
expect(bids[0].dealId).to.not.exist;

response.body.bid[0].lid = 268515;
response.body.bid[0].buying_type = 'classic';
response.body.bid[0].buying_type = 'rtb';
bids = spec.interpretResponse(response, {bidderRequest});
expect(bids[0].dealId).to.not.exist;

response.body.bid[0].lid = 268515;
response.body.bid[0].buying_type = 'classic';
bids = spec.interpretResponse(response, {bidderRequest});
expect(bids[0].dealId).to.equal(268515);

response.body.bid[0].lid = 268515;
response.body.bid[0].buying_type = 'deal_id';
bids = spec.interpretResponse(response, {bidderRequest});
Expand All @@ -798,7 +803,7 @@ describe('Improve Digital Adapter Tests', function () {
expect(bids[0].dealId).to.not.exist;

response.body.bid[0].lid = [ 268515, 12456, 34567 ];
response.body.bid[0].buying_type = [ 'classic', 'deal_id', 'deal_id' ];
response.body.bid[0].buying_type = [ 'rtb', 'deal_id', 'deal_id' ];
bids = spec.interpretResponse(response, {bidderRequest});
expect(bids[0].dealId).to.equal(12456);
});
Expand Down

0 comments on commit d14b991

Please sign in to comment.