Skip to content

Commit

Permalink
Update for Media.net adapter (#2232)
Browse files Browse the repository at this point in the history
* Log client-side timeouts

* prebid version added in timeout log

* removing events.on from adapter

* storing cid in global
  • Loading branch information
vedantseta authored and matthewlane committed Mar 19, 2018
1 parent 6aa8c18 commit b9906c3
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 8 deletions.
14 changes: 11 additions & 3 deletions modules/medianetBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { registerBidder } from 'src/adapters/bidderFactory';
import * as utils from 'src/utils';
import { config } from 'src/config';

const BIDDER_CODE = 'medianet';
const BID_URL = 'https://prebid.media.net/rtb/prebid';

$$PREBID_GLOBAL$$.medianetGlobals = {};

function siteDetails(site) {
site = site || {};

Expand Down Expand Up @@ -35,7 +38,8 @@ function getSize(size) {

function configuredParams(params) {
return {
customer_id: params.cid
customer_id: params.cid,
prebid_version: $$PREBID_GLOBAL$$.version
}
}

Expand All @@ -46,7 +50,8 @@ function slotParams(bidRequest) {
ext: {
dfp_id: bidRequest.adUnitCode
},
banner: transformSizes(bidRequest.sizes)
banner: transformSizes(bidRequest.sizes),
all: bidRequest.params
};

if (bidRequest.params.crid) {
Expand All @@ -65,7 +70,8 @@ function generatePayload(bidRequests) {
site: siteDetails(bidRequests[0].params.site),
ext: configuredParams(bidRequests[0].params),
id: bidRequests[0].auctionId,
imp: bidRequests.map(request => slotParams(request))
imp: bidRequests.map(request => slotParams(request)),
tmax: config.getConfig('bidderTimeout')
}
}

Expand Down Expand Up @@ -103,6 +109,8 @@ export const spec = {
return false;
}

Object.assign($$PREBID_GLOBAL$$.medianetGlobals, !$$PREBID_GLOBAL$$.medianetGlobals.cid && {cid: bid.params.cid});

return true;
},

Expand Down
78 changes: 73 additions & 5 deletions test/spec/modules/medianetBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {expect} from 'chai';
import {spec} from 'modules/medianetBidAdapter';
import { config } from 'src/config';

let VALID_BID_REQUEST = [{
'bidder': 'medianet',
Expand Down Expand Up @@ -68,14 +69,64 @@ let VALID_BID_REQUEST = [{
'bidderRequestId': '1e9b1f07797c1c',
'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d'
}],
VALID_PAYLOAD_INVALID_BIDFLOOR = {
'site': {
'page': 'http://media.net/prebidtest',
'domain': 'media.net',
'ref': 'http://media.net/prebidtest'
},
'ext': {
'customer_id': 'customer_id',
'prebid_version': $$PREBID_GLOBAL$$.version
},
'id': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d',
'imp': [{
'id': '28f8f8130a583e',
'ext': {
'dfp_id': 'div-gpt-ad-1460505748561-0'
},
'banner': [{
'w': 300,
'h': 250
}],
'all': {
'cid': 'customer_id',
'bidfloor': 'abcdef',
'site': {
'page': 'http://media.net/prebidtest',
'domain': 'media.net',
'ref': 'http://media.net/prebidtest'
}
}
}, {
'id': '3f97ca71b1e5c2',
'ext': {
'dfp_id': 'div-gpt-ad-1460505748561-123'
},
'banner': [{
'w': 300,
'h': 251
}],
'all': {
'cid': 'customer_id',
'site': {
'page': 'http://media.net/prebidtest',
'domain': 'media.net',
'ref': 'http://media.net/prebidtest'
}
}
}],
'tmax': config.getConfig('bidderTimeout')
},
VALID_PAYLOAD = {
'site': {
'page': 'http://media.net/prebidtest',
'domain': 'media.net',
'ref': 'http://media.net/prebidtest'
},
'ext': {
'customer_id': 'customer_id'
'customer_id': 'customer_id',
'prebid_version': $$PREBID_GLOBAL$$.version
},
'id': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d',
'imp': [{
Expand All @@ -86,7 +137,15 @@ let VALID_BID_REQUEST = [{
'banner': [{
'w': 300,
'h': 250
}]
}],
'all': {
'cid': 'customer_id',
'site': {
'page': 'http://media.net/prebidtest',
'domain': 'media.net',
'ref': 'http://media.net/prebidtest'
}
}
}, {
'id': '3f97ca71b1e5c2',
'ext': {
Expand All @@ -95,8 +154,17 @@ let VALID_BID_REQUEST = [{
'banner': [{
'w': 300,
'h': 251
}]
}]
}],
'all': {
'cid': 'customer_id',
'site': {
'page': 'http://media.net/prebidtest',
'domain': 'media.net',
'ref': 'http://media.net/prebidtest'
}
}
}],
'tmax': config.getConfig('bidderTimeout')
},
VALID_PARAMS = {
bidder: 'medianet',
Expand Down Expand Up @@ -286,7 +354,7 @@ describe('Media.net bid adapter', () => {

it('should ignore bidfloor if not a valid number', () => {
let bidReq = spec.buildRequests(VALID_BID_REQUEST_INVALID_BIDFLOOR);
expect(JSON.parse(bidReq.data)).to.deep.equal(VALID_PAYLOAD);
expect(JSON.parse(bidReq.data)).to.deep.equal(VALID_PAYLOAD_INVALID_BIDFLOOR);
});
});

Expand Down

0 comments on commit b9906c3

Please sign in to comment.