Skip to content

Commit

Permalink
Add vast xml support and other minor changes to Beachfront adapter (#…
Browse files Browse the repository at this point in the history
…4350)

* Add support for vast xml in the bid response

* add secure protocol to outstream player url

* add device connection type

* add player setting for poster color

* add new value for creative Id
  • Loading branch information
jsalis authored and jsnellbaker committed Oct 23, 2019
1 parent f2ee258 commit efc90a6
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 11 deletions.
19 changes: 14 additions & 5 deletions modules/beachfrontBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { VIDEO, BANNER } from '../src/mediaTypes';
import find from 'core-js/library/fn/array/find';
import includes from 'core-js/library/fn/array/includes';

const ADAPTER_VERSION = '1.7';
const ADAPTER_VERSION = '1.8';
const ADAPTER_NAME = 'BFIO_PREBID';
const OUTSTREAM = 'outstream';

export const VIDEO_ENDPOINT = 'https://reachms.bfmio.com/bid.json?exchange_id=';
export const BANNER_ENDPOINT = 'https://display.bfmio.com/prebid_display';
export const OUTSTREAM_SRC = '//player-cdn.beachfrontmedia.com/playerapi/loader/outstream.js';
export const OUTSTREAM_SRC = 'https://player-cdn.beachfrontmedia.com/playerapi/loader/outstream.js';

export const VIDEO_TARGETING = ['mimes', 'playbackmethod', 'maxduration', 'placement'];
export const DEFAULT_MIMES = ['video/mp4', 'application/javascript'];
Expand Down Expand Up @@ -68,10 +68,11 @@ export const spec = {
requestId: bidRequest.bidId,
bidderCode: spec.code,
vastUrl: response.url,
vastXml: response.vast,
cpm: response.bidPrice,
width: firstSize.w,
height: firstSize.h,
creativeId: response.cmpId,
creativeId: response.crid || response.cmpId,
renderer: context === OUTSTREAM ? createRenderer(bidRequest) : null,
mediaType: VIDEO,
currency: 'USD',
Expand Down Expand Up @@ -151,7 +152,8 @@ function createRenderer(bidRequest) {
height: bid.height,
expandInView: getPlayerBidParam(bidRequest, 'expandInView', false),
collapseOnComplete: getPlayerBidParam(bidRequest, 'collapseOnComplete', true),
progressColor: getPlayerBidParam(bidRequest, 'progressColor')
progressColor: getPlayerBidParam(bidRequest, 'progressColor'),
adPosterColor: getPlayerBidParam(bidRequest, 'adPosterColor')
});
});
});
Expand Down Expand Up @@ -284,7 +286,9 @@ function createVideoRequestData(bid, bidderRequest) {
mimes: DEFAULT_MIMES
}, video),
bidfloor: bidfloor,
secure: topLocation.protocol === 'https:' ? 1 : 0
secure: topLocation.protocol === 'https:' ? 1 : 0,
displaymanager: ADAPTER_NAME,
displaymanagerver: ADAPTER_VERSION
}],
site: {
page: topLocation.href,
Expand Down Expand Up @@ -325,6 +329,11 @@ function createVideoRequestData(bid, bidderRequest) {
}];
}

let connection = navigator.connection || navigator.webkitConnection;
if (connection && connection.effectiveType) {
payload.device.connectiontype = connection.effectiveType;
}

return payload;
}

Expand Down
1 change: 1 addition & 0 deletions modules/beachfrontBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Module that connects to Beachfront's demand sources
},
player: {
progressColor: '#50A8FA',
adPosterColor: '#FFF',
expandInView: false,
collapseOnComplete: true
}
Expand Down
55 changes: 49 additions & 6 deletions test/spec/modules/beachfrontBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,15 +496,16 @@ describe('BeachfrontAdapter', function () {
const serverResponse = {
bidPrice: 5.00,
url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
cmpId: '123abc'
crid: '123abc'
};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
expect(bidResponse).to.deep.equal({
requestId: bidRequest.bidId,
bidderCode: spec.code,
cpm: serverResponse.bidPrice,
creativeId: serverResponse.cmpId,
creativeId: serverResponse.crid,
vastUrl: serverResponse.url,
vastXml: undefined,
width: width,
height: height,
renderer: null,
Expand All @@ -515,6 +516,48 @@ describe('BeachfrontAdapter', function () {
});
});

it('should default to the legacy "cmpId" value for the creative ID', () => {
const width = 640;
const height = 480;
const bidRequest = bidRequests[0];
bidRequest.mediaTypes = {
video: {
playerSize: [ width, height ]
}
};
const serverResponse = {
bidPrice: 5.00,
url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
cmpId: '123abc'
};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
expect(bidResponse).to.deep.contain({
creativeId: serverResponse.cmpId
});
});

it('should return vast xml if found on the bid response', () => {
const width = 640;
const height = 480;
const bidRequest = bidRequests[0];
bidRequest.mediaTypes = {
video: {
playerSize: [ width, height ]
}
};
const serverResponse = {
bidPrice: 5.00,
url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
vast: '<VAST version="3.0"></VAST>',
crid: '123abc'
};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
expect(bidResponse).to.deep.contain({
vastUrl: serverResponse.url,
vastXml: serverResponse.vast
});
});

it('should return a renderer for outstream video bids', function () {
const bidRequest = bidRequests[0];
bidRequest.mediaTypes = {
Expand All @@ -525,7 +568,7 @@ describe('BeachfrontAdapter', function () {
const serverResponse = {
bidPrice: 5.00,
url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
cmpId: '123abc'
crid: '123abc'
};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
expect(bidResponse.renderer).to.deep.contain({
Expand All @@ -547,7 +590,7 @@ describe('BeachfrontAdapter', function () {
const serverResponse = {
bidPrice: 5.00,
url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
cmpId: '123abc'
crid: '123abc'
};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
window.Beachfront = { Player: sinon.spy() };
Expand Down Expand Up @@ -581,7 +624,7 @@ describe('BeachfrontAdapter', function () {
const serverResponse = {
bidPrice: 5.00,
url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
cmpId: '123abc'
crid: '123abc'
};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
window.Beachfront = { Player: sinon.spy() };
Expand Down Expand Up @@ -662,7 +705,7 @@ describe('BeachfrontAdapter', function () {
bidResponse = {
bidPrice: 5.00,
url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
cmpId: '123abc'
crid: '123abc'
};
});

Expand Down

0 comments on commit efc90a6

Please sign in to comment.