Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* '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
mifefr committed Mar 29, 2018
2 parents 9d0425e + 1b9d022 commit c70ef45
Show file tree
Hide file tree
Showing 56 changed files with 2,815 additions and 173 deletions.
3 changes: 2 additions & 1 deletion .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ exemptLabels:
- pinned
- security
- bug
- feature
# Label to use when marking an issue as stale
staleLabel: wontfix
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
Expand Down
36 changes: 16 additions & 20 deletions modules/a4gBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const spec = {

buildRequests: function(validBidRequests) {
let deliveryUrl = '';
let bidId = '';
const idParams = [];
const sizeParams = [];
const zoneIds = [];
Expand All @@ -33,10 +32,7 @@ export const spec = {
if (!deliveryUrl && typeof bid.params.deliveryUrl === 'string') {
deliveryUrl = bid.params.deliveryUrl;
}
if (!bidId) {
bidId = bid.bidId;
}
idParams.push(bid.placementCode);
idParams.push(bid.bidId);
sizeParams.push(bid.sizes.map(size => size.join(SIZE_SEPARATOR)).join(ARRAY_SIZE_SEPARATOR));
zoneIds.push(bid.params.zoneId);
});
Expand All @@ -48,7 +44,6 @@ export const spec = {
return {
method: 'GET',
url: deliveryUrl,
bidId: bidId,
data: {
[IFRAME_PARAM_NAME]: 0,
[LOCATION_PARAM_NAME]: utils.getTopWindowUrl(),
Expand All @@ -62,21 +57,22 @@ export const spec = {
interpretResponse: function(serverResponses, request) {
const bidResponses = [];
utils._each(serverResponses.body, function(response) {
const bidResponse = {
requestId: request.bidId,
cpm: response.cpm,
width: response.width,
height: response.height,
creativeId: response.zoneid,
currency: A4G_CURRENCY,
netRevenue: true,
ttl: A4G_TTL,
ad: response.ad,
adId: response.id
};
bidResponses.push(bidResponse);
if (response.cpm > 0) {
const bidResponse = {
requestId: response.id,
creativeId: response.id,
adId: response.id,
cpm: response.cpm,
width: response.width,
height: response.height,
currency: A4G_CURRENCY,
netRevenue: true,
ttl: A4G_TTL,
ad: response.ad
};
bidResponses.push(bidResponse);
}
});

return bidResponses;
}
};
Expand Down
199 changes: 199 additions & 0 deletions modules/adtelligentBidAdapter.js
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);
65 changes: 65 additions & 0 deletions modules/adtelligentBidAdapter.md
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
}
}]
}
];
```
9 changes: 7 additions & 2 deletions modules/audienceNetworkBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { registerBidder } from 'src/adapters/bidderFactory';
import { config } from 'src/config';
import { formatQS } from 'src/url';
import { getTopWindowUrl } from 'src/utils';
import { generateUUID, getTopWindowUrl, isSafariBrowser } from 'src/utils';
import findIndex from 'core-js/library/fn/array/find-index';
import includes from 'core-js/library/fn/array/includes';

Expand All @@ -15,6 +15,7 @@ const url = 'https://an.facebook.com/v2/placementbid.json';
const supportedMediaTypes = ['banner', 'video'];
const netRevenue = true;
const hb_bidder = 'fan';
const pbv = '$prebid.version$';

/**
* Does this bid request contain valid parameters?
Expand Down Expand Up @@ -164,12 +165,16 @@ const buildRequests = bids => {
adformats,
testmode,
pageurl,
sdk
sdk,
pbv
};
const video = findIndex(adformats, isVideo);
if (video !== -1) {
[search.playerwidth, search.playerheight] = expandSize(sizes[video]);
}
if (isSafariBrowser()) {
search.cb = generateUUID();
}
const data = formatQS(search);

return [{ adformats, data, method, requestIds, sizes, url }];
Expand Down
Loading

0 comments on commit c70ef45

Please sign in to comment.