Skip to content

Commit

Permalink
add support for advertiser domains and other bid meta (#6842)
Browse files Browse the repository at this point in the history
Co-authored-by: John Salis <john@beachfront.com>
  • Loading branch information
jsalis and John Salis authored May 26, 2021
1 parent 36d0f72 commit 8cf4ad9
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 21 deletions.
6 changes: 5 additions & 1 deletion modules/beachfrontBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ export const spec = {
let firstSize = getFirstSize(sizes);
let context = utils.deepAccess(bidRequest, 'mediaTypes.video.context');
let responseType = getVideoBidParam(bidRequest, 'responseType') || 'both';
let responseMeta = Object.assign({ mediaType: VIDEO, advertiserDomains: [] }, response.meta);
let bidResponse = {
requestId: bidRequest.bidId,
bidderCode: spec.code,
cpm: response.bidPrice,
width: firstSize.w,
height: firstSize.h,
creativeId: response.crid || response.cmpId,
creativeId: response.crid,
meta: responseMeta,
renderer: context === OUTSTREAM ? createRenderer(bidRequest) : null,
mediaType: VIDEO,
currency: CURRENCY,
Expand All @@ -103,6 +105,7 @@ export const spec = {
.filter(bid => bid.adm)
.map((bid) => {
let request = find(bidRequest, req => req.adUnitCode === bid.slot);
let responseMeta = Object.assign({ mediaType: BANNER, advertiserDomains: [] }, bid.meta);
return {
requestId: request.bidId,
bidderCode: spec.code,
Expand All @@ -111,6 +114,7 @@ export const spec = {
cpm: bid.price,
width: bid.w,
height: bid.h,
meta: responseMeta,
mediaType: BANNER,
currency: CURRENCY,
netRevenue: true,
Expand Down
73 changes: 53 additions & 20 deletions test/spec/modules/beachfrontBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,33 +673,14 @@ describe('BeachfrontAdapter', function () {
width: width,
height: height,
renderer: null,
meta: { mediaType: 'video', advertiserDomains: [] },
mediaType: 'video',
currency: 'USD',
netRevenue: true,
ttl: 300
});
});

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 only vast url if the response type is "nurl"', () => {
const width = 640;
const height = 480;
Expand Down Expand Up @@ -761,6 +742,31 @@ describe('BeachfrontAdapter', function () {
});
expect(bidResponse.renderer.render).to.be.a('function');
});

it('should return meta data for 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',
meta: {
advertiserDomains: ['example.com'],
advertiserId: '123'
}
};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
expect(bidResponse.meta).to.deep.equal({
mediaType: 'video',
advertiserDomains: ['example.com'],
advertiserId: '123'
});
});
});

describe('for banner bids', function () {
Expand Down Expand Up @@ -815,13 +821,40 @@ describe('BeachfrontAdapter', function () {
cpm: serverResponse[ i ].price,
width: serverResponse[ i ].w,
height: serverResponse[ i ].h,
meta: { mediaType: 'banner', advertiserDomains: [] },
mediaType: 'banner',
currency: 'USD',
netRevenue: true,
ttl: 300
});
}
});

it('should return meta data for the bid response', () => {
bidRequests[0].mediaTypes = {
banner: {
sizes: [[ 300, 250 ], [ 728, 90 ]]
}
};
const serverResponse = [{
slot: bidRequests[0].adUnitCode,
adm: '<div id="44851937"></div>',
crid: 'crid_1',
price: 3.02,
w: 728,
h: 90,
meta: {
advertiserDomains: ['example.com'],
advertiserId: '123'
}
}];
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest: bidRequests });
expect(bidResponse[0].meta).to.deep.equal({
mediaType: 'banner',
advertiserDomains: ['example.com'],
advertiserId: '123'
});
});
});
});

Expand Down

0 comments on commit 8cf4ad9

Please sign in to comment.