Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playground XYZ - new adapter #2606

Merged
merged 40 commits into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5ce4579
Merge pull request #1 from prebid/master
teranchristian Oct 18, 2017
121df8f
Merge branch 'master' of https://github.com/prebid/Prebid.js
LucaConfa May 8, 2018
907becf
Merge branch 'master' of https://github.com/prebid/Prebid.js into 364…
LucaConfa May 10, 2018
4f3cd90
Merge branch 'master' of https://github.com/prebid/Prebid.js into 364…
LucaConfa May 10, 2018
77214e0
add playground adapters
LucaConfa May 12, 2018
43143fd
Merge branch 'master' of https://github.com/prebid/Prebid.js into 364…
LucaConfa May 13, 2018
bf2eda5
clean up
LucaConfa May 14, 2018
e8729b8
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
LucaConfa May 14, 2018
843d90e
update with upstream master
LucaConfa May 14, 2018
ac1dfeb
Merge pull request #2 from playground-xyz/master-updated-upstream
LucaConfa May 14, 2018
745620f
add test file clean up adapter by removing native referecnes
LucaConfa May 14, 2018
5449653
test file
LucaConfa May 14, 2018
cdcd95a
replace appnexus with playground reference in error logs
LucaConfa May 14, 2018
958b55a
remove commented code
LucaConfa May 14, 2018
1fd3e6c
Merge branch 'master' of github.com:playground-xyz/Prebid.js into 364…
LucaConfa May 14, 2018
8aea0fa
change key in response object from appnexus to playgroundxyz
LucaConfa May 14, 2018
c4645d2
change tests so we test for ordering by cpm as well
LucaConfa May 14, 2018
6fd8600
dont drop other bids, just set cpm to 0 and send it through
LucaConfa May 16, 2018
2347af2
clean up
LucaConfa May 16, 2018
814763e
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
LucaConfa May 16, 2018
7f4a307
Merge branch 'master' of https://github.com/prebid/Prebid.js into 364…
LucaConfa May 16, 2018
f0b84d9
Merge pull request #4 from playground-xyz/master-updated-upstream
LucaConfa May 16, 2018
3129be9
Merge branch 'master' of github.com:playground-xyz/Prebid.js into 364…
LucaConfa May 16, 2018
4d01623
restore glulp file
LucaConfa May 16, 2018
6351d40
fix documentation
LucaConfa May 16, 2018
412f5a6
Merge pull request #5 from playground-xyz/3648-prebidjs-pxyz-adapter
LucaConfa May 16, 2018
60bda45
remove cpm logic from adapter
LucaConfa May 16, 2018
269bcbe
Merge pull request #6 from playground-xyz/3648-prebidjs-pxyz-adapter
LucaConfa May 17, 2018
434d0b6
change application type to application\json for playground adapter
LucaConfa May 17, 2018
bc705b0
Merge pull request #7 from playground-xyz/3648-prebidjs-pxyz-adapter
LucaConfa May 17, 2018
946e03a
update adaptor to use openRtb
teranchristian May 22, 2018
d4df2c4
add device and site to bid
teranchristian May 22, 2018
622ce4e
Merge pull request #8 from playground-xyz/3648-prebidjs-pxyz-adapter
LucaConfa May 24, 2018
a8a7a27
add extra space on error msg
teranchristian May 24, 2018
cfc570f
Merge pull request #9 from playground-xyz/3648-prebidjs-pxyz-adapter
teranchristian May 24, 2018
7360e83
remove package-lock
teranchristian Jun 6, 2018
39d9679
Merge branch 'master' of https://github.com/playground-xyz/Prebid.js …
teranchristian Jun 6, 2018
639e60e
update pg details
teranchristian Jun 6, 2018
b27be4c
Update playgroundxyzBidAdapter.md
monofonik Jun 7, 2018
3552ab2
Merge pull request #10 from playground-xyz/3648-prebidjs-pxyz-adapter
teranchristian Jun 7, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 160 additions & 0 deletions modules/playgroundxyzBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
import * as utils from 'src/utils';
import { registerBidder } from 'src/adapters/bidderFactory';
import { BANNER } from 'src/mediaTypes';

const BIDDER_CODE = 'playgroundxyz';
const URL = 'https://ads.playground.xyz/host-config/prebid';

export const spec = {
code: BIDDER_CODE,
aliases: ['playgroundxyz'],
supportedMediaTypes: [BANNER],

/**
* Determines whether or not the given bid request is valid.
*
* @param {object} bid The bid to validate.
* @return boolean True if this is a valid bid, and false otherwise.
*/
isBidRequestValid: function (bid) {
return !!(bid.params.placementId);
},

/**
* Make a server request from the list of BidRequests.
*
* @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, bidderRequest) {
const topLocation = utils.getTopWindowLocation();
const payload = JSON.stringify({
id: bidRequests[0].auctionId,
site: {
domain: window.location.protocol + '//' + topLocation.hostname,
name: topLocation.hostname,
page: topLocation.href,
},
device: {
ua: navigator.userAgent,
language: navigator.language,
devicetype: isMobile() ? 1 : isConnectedTV() ? 3 : 2,
},
imp: bidRequests.map(mapImpression)
});

const options = {
contentType: 'application/json',
withCredentials: false
};

return {
method: 'POST',
url: URL,
data: payload,
options,
bidderRequest
};
},

/**
* Unpack the response from the server into a list of bids.
*
* @param {*} serverResponse A successful response from the server.
* @return {Bid[]} An array of bids which were nested inside the server.
*/
interpretResponse: function (serverResponse, { bidderRequest }) {
serverResponse = serverResponse.body;
const bids = [];

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 (!utils.isArray(serverResponse.seatbid)) {
let errorMessage = `in response for ${bidderRequest.bidderCode} adapter `;
utils.logError(errorMessage += 'Malformed seatbid response');
return bids;
}

serverResponse.seatbid.forEach(sBid => {
if (sBid.hasOwnProperty('bid')) {
sBid.bid.forEach(iBid => {
if (iBid.price !== 0) {
const bid = newBid(iBid);
bids.push(bid);
}
});
}
});
return bids;
},

getUserSyncs: function (syncOptions) {
if (syncOptions.iframeEnabled) {
return [{
type: 'iframe',
url: '//acdn.adnxs.com/ib/static/usersync/v3/async_usersync.html'
}];
}
}
}

function newBid(bid) {
return {
requestId: bid.impid,
mediaType: BANNER,
cpm: bid.price,
creativeId: bid.adid,
ad: bid.adm,
width: bid.w,
height: bid.h,
ttl: 300,
netRevenue: true,
currency: 'USD',
};
}

function mapImpression(bid) {
return {
id: bid.bidId,
banner: mapBanner(bid),
ext: {
appnexus: {
placement_id: parseInt(bid.params.placementId, 10)
}
}
};
}

function mapBanner(bid) {
return {
w: parseInt(bid.sizes[0][0], 10),
h: parseInt(bid.sizes[0][1], 10),
format: mapSizes(bid.sizes)
};
}

function mapSizes(bidSizes) {
const format = [];
bidSizes.forEach(size => {
format.push({
w: parseInt(size[0], 10),
h: parseInt(size[1], 10)
});
});
return format;
}

function isMobile() {
return (/(ios|ipod|ipad|iphone|android)/i).test(navigator.userAgent);
}

function isConnectedTV() {
return (/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(global.navigator.userAgent);
}

registerBidder(spec);
72 changes: 72 additions & 0 deletions modules/playgroundxyzBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Overview

```
Module Name: Playground XYZ Bid Adapter
Module Type: Bidder Adapter
Maintainer: tech+prebid@playgroundxyz.com
```

# Description

Connects to playgroundxyz ad server for bids.

Playground XYZ bid adapter supports Banner.

# Test Parameters
```
var adUnits = [
// Banner adUnit
{
code: 'banner-div',
sizes: [[300, 250], [300,600]],
bids: [{
bidder: 'playgroundxyz',
params: {
placementId: '10433394'
}
}]
},
// Video instream adUnit
{
code: 'video-instream',
sizes: [640, 480],
mediaTypes: {
video: {
context: 'instream'
},
},
bids: [{
bidder: 'playgroundxyz',
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: 'playgroundxyz',
params: {
placementId: '5768085',
video: {
skippable: true,
playback_method: ['auto_play_sound_off']
}
}
}
]
}
];
```
Loading