forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/prebid/Prebid.js
* 'master' of https://github.com/prebid/Prebid.js: EngageBDR New Bid Adapter (prebid#2309) [FEAT] adunit sizes support (prebid#2320) Support aliases in prebidServer (prebid#2257) Changing default currency file to https (prebid#2306) Update stalebot labels (prebid#2319) Enhance location detection within utils (prebid#2167) if cache markup is not enabled, set it to the default value 0 (prebid#2302) Serverbid Bid Adapter: Added archon alias (prebid#2293) Smart Ad Server: Fix bug when multi bids (prebid#2170) NEW adapter AdtelligentBidAdapter (prebid#2137) add optional param to bridgewellBidAdapter (prebid#2289) Increment Pre Version Prebid 1.6.0 Release Unit test fixes (prebid#2301) PBS videoCacheKey and vastUrl (prebid#2101) Add Oneplanetonly Bid Adapter (prebid#2269) firing new adRenderFailed event when renderAd() fails (prebid#2210) Add Content Ignite adapter (prebid#2268) add hb_cache_id, hb_uuid should be deprecated and replaced by hb_cache_id (prebid#2273) Update Yieldlab adapter and add official maintainer (prebid#2231) Update for Media.net adapter (prebid#2232) Update to Rubicon Adapter for mediaTypes support (prebid#2272) message formatting (prebid#2285) Yieldbot impression image creation fix (prebid#2277) Updated Bid params (prebid#2275) Audience Network: Add 'pbv' and 'cb' query params (prebid#2252) Add e-planning analytics adapter (prebid#2211) Add vastUrl for Gamma Adapter Video (prebid#2261) update params for test bid (prebid#2267) Updated adUnitCode (prebid#2262)
- Loading branch information
Showing
56 changed files
with
2,815 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
import * as utils from 'src/utils'; | ||
import {registerBidder} from 'src/adapters/bidderFactory'; | ||
import {VIDEO, BANNER} from 'src/mediaTypes'; | ||
import {Renderer} from 'src/Renderer'; | ||
import findIndex from 'core-js/library/fn/array/find-index'; | ||
|
||
const URL = '//hb.adtelligent.com/auction/'; | ||
const OUTSTREAM_SRC = '//player.adtelligent.com/outstream-unit/2.01/outstream.min.js'; | ||
const BIDDER_CODE = 'adtelligent'; | ||
const OUTSTREAM = 'outstream'; | ||
const DISPLAY = 'display'; | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
supportedMediaTypes: [VIDEO, BANNER], | ||
isBidRequestValid: function (bid) { | ||
return bid && bid.params && bid.params.aid; | ||
}, | ||
|
||
/** | ||
* Make a server request from the list of BidRequests | ||
* @param bidRequests | ||
* @param bidderRequest | ||
*/ | ||
buildRequests: function (bidRequests, bidderRequest) { | ||
return { | ||
data: bidToTag(bidRequests), | ||
bidderRequest, | ||
method: 'GET', | ||
url: URL | ||
}; | ||
}, | ||
|
||
/** | ||
* Unpack the response from the server into a list of bids | ||
* @param serverResponse | ||
* @param bidderRequest | ||
* @return {Bid[]} An array of bids which were nested inside the server | ||
*/ | ||
interpretResponse: function (serverResponse, {bidderRequest}) { | ||
serverResponse = serverResponse.body; | ||
let bids = []; | ||
|
||
if (!utils.isArray(serverResponse)) { | ||
return parseRTBResponse(serverResponse, bidderRequest); | ||
} | ||
|
||
serverResponse.forEach(serverBidResponse => { | ||
bids = utils.flatten(bids, parseRTBResponse(serverBidResponse, bidderRequest)); | ||
}); | ||
|
||
return bids; | ||
} | ||
}; | ||
|
||
function parseRTBResponse(serverResponse, bidderRequest) { | ||
const isInvalidValidResp = !serverResponse || !serverResponse.bids || !serverResponse.bids.length; | ||
|
||
let bids = []; | ||
|
||
if (isInvalidValidResp) { | ||
let extMessage = serverResponse && serverResponse.ext && serverResponse.ext.message ? `: ${serverResponse.ext.message}` : ''; | ||
let errorMessage = `in response for ${bidderRequest.bidderCode} adapter ${extMessage}`; | ||
|
||
utils.logError(errorMessage); | ||
|
||
return bids; | ||
} | ||
|
||
serverResponse.bids.forEach(serverBid => { | ||
const requestId = findIndex(bidderRequest.bids, (bidRequest) => { | ||
return bidRequest.bidId === serverBid.requestId; | ||
}); | ||
|
||
if (serverBid.cpm !== 0 && requestId !== -1) { | ||
const bid = createBid(serverBid, getMediaType(bidderRequest.bids[requestId])); | ||
|
||
bids.push(bid); | ||
} | ||
}); | ||
|
||
return bids; | ||
} | ||
|
||
function bidToTag(bidRequests) { | ||
let tag = { | ||
domain: utils.getTopWindowLocation().hostname | ||
}; | ||
|
||
for (let i = 0, length = bidRequests.length; i < length; i++) { | ||
Object.assign(tag, prepareRTBRequestParams(i, bidRequests[i])); | ||
} | ||
|
||
return tag; | ||
} | ||
|
||
/** | ||
* Parse mediaType | ||
* @param _index {number} | ||
* @param bid {object} | ||
* @returns {object} | ||
*/ | ||
function prepareRTBRequestParams(_index, bid) { | ||
const mediaType = utils.deepAccess(bid, 'mediaTypes.video') ? VIDEO : DISPLAY; | ||
const index = !_index ? '' : `${_index + 1}`; | ||
|
||
return { | ||
['callbackId' + index]: bid.bidId, | ||
['aid' + index]: bid.params.aid, | ||
['ad_type' + index]: mediaType, | ||
['sizes' + index]: utils.parseSizesInput(bid.sizes).join() | ||
}; | ||
} | ||
|
||
/** | ||
* Prepare all parameters for request | ||
* @param bidderRequest {object} | ||
* @returns {object} | ||
*/ | ||
function getMediaType(bidderRequest) { | ||
const videoMediaType = utils.deepAccess(bidderRequest, 'mediaTypes.video'); | ||
const context = utils.deepAccess(bidderRequest, 'mediaTypes.video.context'); | ||
|
||
return !videoMediaType ? DISPLAY : context === OUTSTREAM ? OUTSTREAM : VIDEO; | ||
} | ||
|
||
/** | ||
* Configure new bid by response | ||
* @param bidResponse {object} | ||
* @param mediaType {Object} | ||
* @returns {object} | ||
*/ | ||
function createBid(bidResponse, mediaType) { | ||
let bid = { | ||
requestId: bidResponse.requestId, | ||
creativeId: bidResponse.cmpId, | ||
height: bidResponse.height, | ||
currency: bidResponse.cur, | ||
width: bidResponse.width, | ||
cpm: bidResponse.cpm, | ||
netRevenue: true, | ||
mediaType, | ||
ttl: 3600 | ||
}; | ||
|
||
if (mediaType === DISPLAY) { | ||
return Object.assign(bid, { | ||
ad: bidResponse.ad | ||
}); | ||
} | ||
|
||
Object.assign(bid, { | ||
vastUrl: bidResponse.vastUrl | ||
}); | ||
|
||
if (mediaType === OUTSTREAM) { | ||
Object.assign(bid, { | ||
mediaType: 'video', | ||
adResponse: bidResponse, | ||
renderer: newRenderer(bidResponse.requestId) | ||
}); | ||
} | ||
|
||
return bid; | ||
} | ||
|
||
/** | ||
* Create Adtelligent renderer | ||
* @param requestId | ||
* @returns {*} | ||
*/ | ||
function newRenderer(requestId) { | ||
const renderer = Renderer.install({ | ||
id: requestId, | ||
url: OUTSTREAM_SRC, | ||
loaded: false | ||
}); | ||
|
||
renderer.setRender(outstreamRender); | ||
|
||
return renderer; | ||
} | ||
|
||
/** | ||
* Initialise Adtelligent outstream | ||
* @param bid | ||
*/ | ||
function outstreamRender(bid) { | ||
bid.renderer.push(() => { | ||
window.VOutstreamAPI.initOutstreams([{ | ||
width: bid.width, | ||
height: bid.height, | ||
vastUrl: bid.vastUrl, | ||
elId: bid.adUnitCode | ||
}]); | ||
}); | ||
} | ||
|
||
registerBidder(spec); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Overview | ||
|
||
**Module Name**: Adtelligent Bidder Adapter | ||
**Module Type**: Bidder Adapter | ||
**Maintainer**: support@adtelligent.com | ||
|
||
# Description | ||
|
||
Get access to multiple demand partners across Adtelligent Marketplace and maximize your yield with Adtelligent header bidding adapter. | ||
|
||
Adtelligent header bidding adapter connects with Adtelligent demand sources in order to fetch bids. | ||
This adapter provides a solution for accessing Video demand and display demand | ||
|
||
|
||
# Test Parameters | ||
``` | ||
var adUnits = [ | ||
// Video instream adUnit | ||
{ | ||
code: 'div-test-div', | ||
sizes: [[640, 480]], | ||
mediaTypes: { | ||
video: { | ||
context: 'instream' | ||
} | ||
}, | ||
bids: [{ | ||
bidder: 'adtelligent', | ||
params: { | ||
aid: 331133 | ||
} | ||
}] | ||
}, | ||
// Video outstream adUnit | ||
{ | ||
code: 'outstream-test-div', | ||
sizes: [[640, 480]], | ||
mediaTypes: { | ||
video: { | ||
context: 'outstream' | ||
} | ||
}, | ||
bids: [{ | ||
bidder: 'adtelligent', | ||
params: { | ||
aid: 331133 | ||
} | ||
}] | ||
}, | ||
// Banner adUnit | ||
{ | ||
code: 'div-test-div', | ||
sizes: [[300, 250]], | ||
bids: [{ | ||
bidder: 'adtelligent', | ||
params: { | ||
aid: 350975 | ||
} | ||
}] | ||
} | ||
]; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.