Skip to content
This repository has been archived by the owner on Feb 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request prebid#130 in AOLP_ADS_JS/prebid.js from release/1…
Browse files Browse the repository at this point in the history
….31.0 to aolgithub-master

* commit 'e7341c948014a789084849495171d08d4b353d07': (21 commits)
  Added changelog entry.
  Fix for prebid#1628 (allowing standard bidCpmAdjustment) (prebid#1645)
  Prebid 0.31.0 Release
  Support native click tracking (prebid#1691)
  Initial commit for video support for pbs (prebid#1706)
  Fixes: Immediate adapter response may end auction (prebid#1690)
  Rubicon feature/s2s test module (prebid#1678)
  Renaming of "huddledmasses" adapter into colossusssp (prebid#1701)
  Don't set non-object configurations (prebid#1704)
  Update JSDoc for `pbjs.enableAnalytics` (prebid#1565)
  Add ad units event (prebid#1702)
  AppnexusAst adapter: logging error message from endpoint (prebid#1697)
  AppnexusAst bidadapter markdown file (prebid#1696)
  Change Default Content-Type for POST Requests to 'application/json' (prebid#1681)
  Code improvement for trustx adapter (prebid#1673)
  PulsePoint Lite adapter - Enabling Sync pixel (prebid#1686)
  Update spotx video adapter to set the spotx_ad_key used in DFP (prebid#1614)
  Fix broken AOL mobile endpoint secure bid requests (prebid#1684)
  Fix adapter tests that hardcoded pbjs. (prebid#1666)
  no longer attaching gpt slots to adUnits, which breaks utils.cloneJson(adUnit) (prebid#1676)
  ...
  • Loading branch information
vzhukovsky committed Oct 25, 2017
2 parents ae0895f + e7341c9 commit 279bbae
Show file tree
Hide file tree
Showing 35 changed files with 1,410 additions and 552 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
AOL Prebid 1.31.0
----------------
Updated to Prebid 0.31.0


AOL Prebid 1.30.0
----------------
Updated to Prebid 0.30.1
Expand Down
4 changes: 2 additions & 2 deletions integrationExamples/gpt/pbjs_example_gpt.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
}
},
{
bidder: 'huddledmasses',
bidder: 'colossusssp',
params: {
placement_id: 0
}
Expand Down Expand Up @@ -384,7 +384,7 @@
}
},
{
bidder: 'huddledmasses',
bidder: 'colossusssp',
params: {
placement_id: 0
}
Expand Down
33 changes: 22 additions & 11 deletions modules/appnexusAstBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const spec = {
* @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server.
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function(bidRequests) {
buildRequests: function(bidRequests, bidderRequest) {
const tags = bidRequests.map(bidToTag);
const userObjBid = bidRequests.find(hasUserInfo);
let userObj;
Expand Down Expand Up @@ -76,6 +76,7 @@ export const spec = {
method: 'POST',
url: URL,
data: payloadString,
bidderRequest
};
},

Expand All @@ -85,18 +86,27 @@ export const spec = {
* @param {*} serverResponse A successful response from the server.
* @return {Bid[]} An array of bids which were nested inside the server.
*/
interpretResponse: function(serverResponse) {
interpretResponse: function(serverResponse, {bidderRequest}) {
const bids = [];
serverResponse.tags.forEach(serverBid => {
const rtbBid = getRtbBid(serverBid);
if (rtbBid) {
if (rtbBid.cpm !== 0 && SUPPORTED_AD_TYPES.includes(rtbBid.ad_type)) {
const bid = newBid(serverBid, rtbBid);
bid.mediaType = parseMediaType(rtbBid);
bids.push(bid);
if (!serverResponse || serverResponse.error) {
let errorMessage = `in response for ${bidderRequest.bidderCode} adapter`;
if (serverResponse && serverResponse.error) { errorMessage += `: ${serverResponse.error}`; }
utils.logError(errorMessage);
return bids;
}

if (serverResponse.tags) {
serverResponse.tags.forEach(serverBid => {
const rtbBid = getRtbBid(serverBid);
if (rtbBid) {
if (rtbBid.cpm !== 0 && SUPPORTED_AD_TYPES.includes(rtbBid.ad_type)) {
const bid = newBid(serverBid, rtbBid);
bid.mediaType = parseMediaType(rtbBid);
bids.push(bid);
}
}
}
});
});
}
return bids;
},

Expand Down Expand Up @@ -201,6 +211,7 @@ function newBid(serverBid, rtbBid) {
image: nativeAd.main_img && nativeAd.main_img.url,
icon: nativeAd.icon && nativeAd.icon.url,
clickUrl: nativeAd.link.url,
clickTrackers: nativeAd.link.click_trackers,
impressionTrackers: nativeAd.impression_trackers,
};
} else {
Expand Down
103 changes: 103 additions & 0 deletions modules/appnexusAstBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Overview

```
Module Name: AppnexusAst Bid Adapter
Module Type: Bidder Adapter
Maintainer: info@prebid.org
```

# Description

Connects to Appnexus exchange for bids.

AppnexusAst bid adapter supports Banner, Video (instream and outstream) and Native.

# Test Parameters
```
var adUnits = [
// Banner adUnit
{
code: 'banner-div',
sizes: [[300, 250], [300,600]],
bids: [{
bidder: 'appnexusAst',
params: {
placementId: '10433394'
}
}]
},
// Native adUnit
{
code: 'native-div',
sizes: [[300, 250], [300,600]],
mediaTypes: {
native: {
title: {
required: true,
len: 80
},
body: {
required: true
},
brand: {
required: true
},
image: {
required: true
},
clickUrl: {
required: true
},
}
},
bids: [{
bidder: 'appnexusAst',
params: {
placementId: '9880618'
}
}]
},
// Video instream adUnit
{
code: 'video-instream',
sizes: [640, 480],
mediaTypes: {
video: {
context: 'instream'
},
},
bids: [{
bidder: 'appnexusAst',
params: {
placementId: '9333431',
video: {
skippable: true,
playback_methods: ['auto_play_sound_off']
}
}
}]
},
// Video outstream adUnit
{
code: 'video-outstream',
sizes: [[640, 480]],
mediaTypes: {
video: {
context: 'outstream'
}
},
bids: [
{
bidder: 'appnexusAst',
params: {
placementId: '5768085',
video: {
skippable: true,
playback_method: ['auto_play_sound_off']
}
}
}
]
}
];
```
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {ajax} from 'src/ajax';
import {STATUS} from 'src/constants';
import adaptermanager from 'src/adaptermanager';

var BIDDER_CODE = 'huddledmasses';
var BIDDER_CODE = 'colossusssp';

var sizeObj = {
1: '468x60',
Expand Down Expand Up @@ -39,7 +39,7 @@ var sizeObj = {

utils._each(sizeObj, (item, key) => sizeObj[item] = key);

function HuddledMassesAdapter() {
function ColossusSspAdapter() {
function _callBids(bidderRequest) {
var bids = bidderRequest.bids || [];

Expand All @@ -50,9 +50,9 @@ function HuddledMassesAdapter() {
handleRpCB(responseText, bid);
} catch (err) {
if (typeof err === 'string') {
utils.logWarn(`${err} when processing huddledmasses response for placement code ${bid.placementCode}`);
utils.logWarn(`${err} when processing colossus response for placement code ${bid.placementCode}`);
} else {
utils.logError('Error processing huddledmasses response for placement code ' + bid.placementCode, null, err);
utils.logError('Error processing colossus response for placement code ' + bid.placementCode, null, err);
}
var badBid = bidfactory.createBid(STATUS.NO_BID, bid);
badBid.bidderCode = bid.bidder;
Expand All @@ -64,15 +64,15 @@ function HuddledMassesAdapter() {
try {
ajax(buildOptimizedCall(bid), bidCallback, undefined, { withCredentials: true });
} catch (err) {
utils.logError('Error sending huddledmasses request for placement code ' + bid.placementCode, null, err);
utils.logError('Error sending colossus request for placement code ' + bid.placementCode, null, err);
}
});
}

function buildOptimizedCall(bid) {
bid.startTime = (new Date()).getTime();

var parsedSizes = HuddledMassesAdapter.masSizeOrdering(
var parsedSizes = ColossusSspAdapter.masSizeOrdering(
Array.isArray(bid.params.sizes) ? bid.params.sizes.map(size => (sizeObj[size] || '').split('x')) : bid.sizes
);

Expand Down Expand Up @@ -117,7 +117,7 @@ function HuddledMassesAdapter() {
index % 2 === 0 && queryString[index + 1] !== undefined
? memo + curr + '=' + encodeURIComponent(queryString[index + 1]) + '&'
: memo,
'//huddledmassessupply.com/?'
'//colossusssp.com/?'
).slice(0, -1);
}

Expand All @@ -136,12 +136,12 @@ function HuddledMassesAdapter() {
bidmanager.addBidResponse(bidRequest.placementCode, bid);
}

return Object.assign(new Adapter(BIDDER_CODE), { // BIDDER_CODE huddledmasses
return Object.assign(new Adapter(BIDDER_CODE), { // BIDDER_CODE colossusssp
callBids: _callBids
});
}

HuddledMassesAdapter.masSizeOrdering = function (sizes) {
ColossusSspAdapter.masSizeOrdering = function (sizes) {
var MAS_SIZE_PRIORITY = [15, 2, 9];
return utils.parseSizesInput(sizes)
.reduce((result, size) => {
Expand Down Expand Up @@ -169,6 +169,6 @@ HuddledMassesAdapter.masSizeOrdering = function (sizes) {
});
};

adaptermanager.registerBidAdapter(new HuddledMassesAdapter(), 'huddledmasses');
adaptermanager.registerBidAdapter(new ColossusSspAdapter(), BIDDER_CODE);

module.exports = HuddledMassesAdapter;
module.exports = ColossusSspAdapter;
10 changes: 6 additions & 4 deletions modules/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) {
utils.logWarn('no valid adUnits found, not loading ' + MODULE_NAME);
}

// store gpt slots in a more performant hash lookup by elementId (adUnit code)
var gptSlotCache = {};
// put adUnits in a more performant hash lookup by code.
var adUnitsCache = adUnits.reduce(function (cache, adUnit) {
if (adUnit.code && adUnit.bids) {
Expand Down Expand Up @@ -72,7 +74,7 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) {
const adUnit = adUnitsCache[elemId];

if (adUnit) {
adUnit._gptSlot = gptSlot;
gptSlotCache[elemId] = gptSlot; // store by elementId
adUnit.sizes = adUnit.sizes || mapGptSlotSizes(gptSlot.getSizes());
adUnits.push(adUnit);
gptSlots.splice(i, 1);
Expand Down Expand Up @@ -141,7 +143,7 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) {
$$PREBID_GLOBAL$$.setTargetingForGPTAsync();
fGptRefresh.apply(pads(), [
adUnits.map(function (adUnit) {
return adUnit._gptSlot;
return gptSlotCache[adUnit.code];
})
]);
}
Expand All @@ -157,7 +159,7 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) {
// get already displayed adUnits from aGptSlots if provided, else all defined gptSlots
aGptSlots = defaultSlots(aGptSlots);
var adUnits = pickAdUnits(/* mutated: */ aGptSlots).filter(function (adUnit) {
return adUnit._gptSlot._displayed;
return gptSlotCache[adUnit.code]._displayed;
});

if (aGptSlots.length) {
Expand All @@ -171,7 +173,7 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) {
$$PREBID_GLOBAL$$.setTargetingForGPTAsync();
fGptRefresh.apply(pads(), [
adUnits.map(function (adUnit) {
return adUnit._gptSlot
return gptSlotCache[adUnit.code];
}),
options
]);
Expand Down
13 changes: 11 additions & 2 deletions modules/prebidServerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,16 @@ function PrebidServer() {
/* Prebid executes this function when the page asks to send out bid requests */
baseAdapter.callBids = function(bidRequest) {
const isDebug = !!getConfig('debug');
convertTypes(bidRequest.ad_units);
const adUnits = utils.cloneJson(bidRequest.ad_units);
adUnits.forEach(adUnit => {
let videoMediaType = utils.deepAccess(adUnit, 'mediaTypes.video');
if (videoMediaType) {
// pbs expects a ad_unit.video attribute if the imp is video
adUnit.video = Object.assign({}, videoMediaType);
delete adUnit.mediaTypes.video;
}
})
convertTypes(adUnits);
let requestJson = {
account_id: config.accountId,
tid: bidRequest.tid,
Expand All @@ -114,7 +123,7 @@ function PrebidServer() {
secure: config.secure,
url: utils.getTopWindowUrl(),
prebid_version: '$prebid.version$',
ad_units: bidRequest.ad_units.filter(hasSizes),
ad_units: adUnits.filter(hasSizes),
is_debug: isDebug
};

Expand Down
5 changes: 5 additions & 0 deletions modules/pulsepointLiteBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export const spec = {
type: 'iframe',
url: '//bh.contextweb.com/visitormatch'
}];
} else if (syncOptions.pixelEnabled) {
return [{
type: 'image',
url: '//bh.contextweb.com/visitormatch/prebid'
}];
}
}

Expand Down
Loading

0 comments on commit 279bbae

Please sign in to comment.