Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Negru committed Feb 19, 2018
2 parents d24543e + 2d1d0e0 commit b5ad2b4
Show file tree
Hide file tree
Showing 17 changed files with 18,861 additions and 99 deletions.
2 changes: 1 addition & 1 deletion PR_REVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ For modules and core platform updates, the initial reviewer should request an ad
- If all above is good, add a `LGTM` comment and request 1 additional core member to review.
- Once there is 2 `LGTM` on the PR, merge to master
- Ask the submitter to add a PR for documentation if applicable.
- Add a line into the `draft release` notes for this submission. If no draft release is available, create one using [this template]( https://gist.github.com/mkendall07/c3af6f4691bed8a46738b3675cb5a479)
- Add a line into the [draft release](https://github.com/prebid/Prebid.js/releases) notes for this submission. If no draft release is available, create one using [this template]( https://gist.github.com/mkendall07/c3af6f4691bed8a46738b3675cb5a479)

### New Adapter or updates to adapter process
- Follow steps above for general review process. In addition, please verify the following:
Expand Down
3 changes: 3 additions & 0 deletions modules/adgenerationBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ function createNativeAd(body) {
native.clickUrl = body.native_ad.link.url;
native.clickTrackers = body.native_ad.link.clicktrackers || [];
native.impressionTrackers = body.native_ad.imptrackers || [];
if (body.beaconurl && body.beaconurl != '') {
native.impressionTrackers.push(body.beaconurl)
}
}
return native;
}
Expand Down
6 changes: 3 additions & 3 deletions modules/adgenerationBidAdapter.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Overview

```
Module Name: Adgeneration Bid Adapter
Module Name: AdGeneration Bid Adapter
Module Type: Bidder Adapter
Maintainer: [email protected]
```

# Description

Connects to Adgeneration exchange for bids.
Connects to AdGeneration exchange for bids.

Adgeneration bid adapter supports Banner and Native.
AdGeneration bid adapter supports Banner and Native.

# Test Parameters
```
Expand Down
137 changes: 70 additions & 67 deletions modules/aolBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as utils from 'src/utils';
import { registerBidder } from 'src/adapters/bidderFactory';
import { config } from 'src/config';
import constants from 'src/constants.json';
import { EVENTS } from 'src/constants.json';

const AOL_BIDDERS_CODES = {
AOL: 'aol',
Expand Down Expand Up @@ -180,55 +180,6 @@ function _buildOneMobileGetUrl(bid) {
return nexageApi;
}

function _parseBidResponse(response, bidRequest) {
let bidData;

try {
bidData = response.seatbid[0].bid[0];
} catch (e) {
return;
}

let cpm;

if (bidData.ext && bidData.ext.encp) {
cpm = bidData.ext.encp;
} else {
cpm = bidData.price;

if (cpm === null || isNaN(cpm)) {
utils.logError('Invalid price in bid response', AOL_BIDDERS_CODES.AOL, bid);
return;
}
}

let ad = bidData.adm;
if (response.ext && response.ext.pixels) {
if (config.getConfig('aol.userSyncOn') !== constants.EVENTS.BID_RESPONSE) {
let formattedPixels = response.ext.pixels.replace(/<\/?script( type=('|")text\/javascript('|")|)?>/g, '');

ad += '<script>if(!parent.$$PREBID_GLOBAL$$.aolGlobals.pixelsDropped){' +
'parent.$$PREBID_GLOBAL$$.aolGlobals.pixelsDropped=true;' + formattedPixels +
'}</script>';
}
}

return {
bidderCode: bidRequest.bidderCode,
requestId: bidRequest.bidId,
ad: ad,
cpm: cpm,
width: bidData.w,
height: bidData.h,
creativeId: bidData.crid,
pubapiId: response.id,
currency: response.cur,
dealId: bidData.dealid,
netRevenue: true,
ttl: bidRequest.ttl
};
}

function _isMarketplaceBidder(bidder) {
return bidder === AOL_BIDDERS_CODES.AOL || bidder === AOL_BIDDERS_CODES.ONEDISPLAY;
}
Expand Down Expand Up @@ -311,20 +262,6 @@ function formatBidRequest(endpointCode, bid) {
return bidRequest;
}

function interpretResponse({body}, bidRequest) {
showCpmAdjustmentWarning();

if (!body) {
utils.logError('Empty bid response', bidRequest.bidderCode, body);
} else {
let bid = _parseBidResponse(body, bidRequest);

if (bid) {
return bid;
}
}
}

export const spec = {
code: AOL_BIDDERS_CODES.AOL,
aliases: [AOL_BIDDERS_CODES.ONEMOBILE, AOL_BIDDERS_CODES.ONEDISPLAY],
Expand All @@ -340,12 +277,78 @@ export const spec = {
}
});
},
interpretResponse: interpretResponse,
interpretResponse: function ({body}, bidRequest) {
showCpmAdjustmentWarning();

if (!body) {
utils.logError('Empty bid response', bidRequest.bidderCode, body);
} else {
let bid = this._parseBidResponse(body, bidRequest);

if (bid) {
return bid;
}
}
},
_formatPixels: function (pixels) {
let formattedPixels = pixels.replace(/<\/?script( type=('|")text\/javascript('|")|)?>/g, '');

return '<script>var w=window,prebid;' +
'for(var i=0;i<10;i++){w = w.parent;prebid=w.$$PREBID_GLOBAL$$;' +
'if(prebid && prebid.aolGlobals && !prebid.aolGlobals.pixelsDropped){' +
'try{prebid.aolGlobals.pixelsDropped=true;' + formattedPixels + 'break;}' +
'catch(e){continue;}' +
'}}</script>';
},
_parseBidResponse: function (response, bidRequest) {
let bidData;

try {
bidData = response.seatbid[0].bid[0];
} catch (e) {
return;
}

let cpm;

if (bidData.ext && bidData.ext.encp) {
cpm = bidData.ext.encp;
} else {
cpm = bidData.price;

if (cpm === null || isNaN(cpm)) {
utils.logError('Invalid price in bid response', AOL_BIDDERS_CODES.AOL, bid);
return;
}
}

let ad = bidData.adm;
if (response.ext && response.ext.pixels) {
if (config.getConfig('aol.userSyncOn') !== EVENTS.BID_RESPONSE) {
ad += this._formatPixels(response.ext.pixels);
}
}

return {
bidderCode: bidRequest.bidderCode,
requestId: bidRequest.bidId,
ad: ad,
cpm: cpm,
width: bidData.w,
height: bidData.h,
creativeId: bidData.crid,
pubapiId: response.id,
currency: response.cur,
dealId: bidData.dealid,
netRevenue: true,
ttl: bidRequest.ttl
};
},
getUserSyncs: function(options, bidResponses) {
let bidResponse = bidResponses[0];

if (config.getConfig('aol.userSyncOn') === constants.EVENTS.BID_RESPONSE) {
if (!$$PREBID_GLOBAL$$.aolGlobals.pixelsDropped && bidResponse && bidResponse.ext && bidResponse.ext.pixels) {
if (config.getConfig('aol.userSyncOn') === EVENTS.BID_RESPONSE) {
if (!$$PREBID_GLOBAL$$.aolGlobals.pixelsDropped && bidResponse.ext && bidResponse.ext.pixels) {
$$PREBID_GLOBAL$$.aolGlobals.pixelsDropped = true;

return parsePixelItems(bidResponse.ext.pixels);
Expand Down
147 changes: 147 additions & 0 deletions modules/orbitsoftBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import * as utils from 'src/utils';
import {registerBidder} from 'src/adapters/bidderFactory';
import {config} from 'src/config';

const BIDDER_CODE = 'orbitsoft';
let styleParamsMap = {
'title.family': 'f1', // headerFont
'title.size': 'fs1', // headerFontSize
'title.weight': 'w1', // headerWeight
'title.style': 's1', // headerStyle
'title.color': 'c3', // headerColor
'description.family': 'f2', // descriptionFont
'description.size': 'fs2', // descriptionFontSize
'description.weight': 'w2', // descriptionWeight
'description.style': 's2', // descriptionStyle
'description.color': 'c4', // descriptionColor
'url.family': 'f3', // urlFont
'url.size': 'fs3', // urlFontSize
'url.weight': 'w3', // urlWeight
'url.style': 's3', // urlStyle
'url.color': 'c5', // urlColor
'colors.background': 'c2', // borderColor
'colors.border': 'c1', // borderColor
'colors.link': 'c6', // lnkColor
};
export const spec = {
code: BIDDER_CODE,
aliases: ['oas', '152media'], // short code and customer aliases
isBidRequestValid: function (bid) {
switch (true) {
case !('params' in bid):
utils.logError(bid.bidder + ': No required params');
return false;
case !(bid.params.placementId):
utils.logError(bid.bidder + ': No required param placementId');
return false;
case !(bid.params.requestUrl):
utils.logError(bid.bidder + ': No required param requestUrl');
return false;
}
return true;
},
buildRequests: function (validBidRequests) {
let bidRequest;
let serverRequests = [];
for (let i = 0; i < validBidRequests.length; i++) {
bidRequest = validBidRequests[i];
let bidRequestParams = bidRequest.params;
let callbackId = utils.getUniqueIdentifierStr();
let placementId = utils.getBidIdParameter('placementId', bidRequestParams);
let requestUrl = utils.getBidIdParameter('requestUrl', bidRequestParams);
let referrer = utils.getBidIdParameter('ref', bidRequestParams);
let location = utils.getBidIdParameter('loc', bidRequestParams);
// Append location & referrer
if (location === '') {
location = utils.getTopWindowUrl();
}
if (referrer === '') {
referrer = utils.getTopWindowReferrer();
}

// Styles params
let stylesParams = utils.getBidIdParameter('style', bidRequestParams);
let stylesParamsArray = {};
for (let currentValue in stylesParams) {
if (stylesParams.hasOwnProperty(currentValue)) {
let currentStyle = stylesParams[currentValue];
for (let field in currentStyle) {
if (currentStyle.hasOwnProperty(field)) {
let styleField = styleParamsMap[currentValue + '.' + field];
if (typeof styleField !== 'undefined') {
stylesParamsArray[styleField] = currentStyle[field];
}
}
}
}
}
// Custom params
let customParams = utils.getBidIdParameter('customParams', bidRequestParams);
let customParamsArray = {};
for (let customField in customParams) {
if (customParams.hasOwnProperty(customField)) {
customParamsArray['c.' + customField] = customParams[customField];
}
}

// Sizes params (not supports by server, for future features)
let sizesParams = bidRequest.sizes;
let parsedSizes = utils.parseSizesInput(sizesParams);

serverRequests.push({
method: 'GET',
url: requestUrl,
data: Object.assign({
'scid': placementId,
'callback_uid': callbackId,
'loc': location,
'ref': referrer,
'size': parsedSizes
}, stylesParamsArray, customParamsArray),
options: {withCredentials: false},
bidRequest: bidRequest
});
}
return serverRequests;
},
interpretResponse: function (serverResponse, request) {
let bidResponses = [];
if (!serverResponse || serverResponse.error) {
utils.logError(BIDDER_CODE + ': Server response error');
return bidResponses;
}

const serverBody = serverResponse.body;
if (!serverBody) {
utils.logError(BIDDER_CODE + ': Empty bid response');
return bidResponses;
}

const CPM = serverBody.cpm;
const WIDTH = serverBody.width;
const HEIGHT = serverBody.height;
const CREATIVE = serverBody.content_url;
const CALLBACK_UID = serverBody.callback_uid;
const TIME_TO_LIVE = config.getConfig('_bidderTimeout');
const REFERER = utils.getTopWindowUrl();
let bidRequest = request.bidRequest;
if (CPM > 0 && WIDTH > 0 && HEIGHT > 0) {
let bidResponse = {
requestId: bidRequest.bidId,
cpm: CPM,
width: WIDTH,
height: HEIGHT,
creativeId: CALLBACK_UID,
ttl: TIME_TO_LIVE,
referrer: REFERER,
currency: 'USD',
netRevenue: true,
adUrl: CREATIVE
};
bidResponses.push(bidResponse);
}

return bidResponses;
}
};
registerBidder(spec);
Loading

0 comments on commit b5ad2b4

Please sign in to comment.