forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 1
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' into Widespace_adapter
* master: Update Vertoz adapter for Prebid 1.0 (prebid#2104) Add multiple bids request (prebid#2136) [NEW Adapter] RTBHouseBidAdapter (prebid#2184) Update Innity Adapter to Prebid.js v1.0 (prebid#2180) Update Adyoulike Adapter to prebid 1.0 (prebid#2077) Change bidderCode for DAN Marketplace Bid Adapter (prebid#2183) only count bid timeouts if bidder didn't call done. fixes prebid#2146 (prebid#2154) [Edit BidAdapter] rxrtb adapter for Perbid.js 1.0 (prebid#2182) Update NasmediaAdmixer adapter (prebid#2164) only do video caching if we don't already have a videoCacheKey (prebid#2143)
- Loading branch information
Showing
21 changed files
with
1,329 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
import * as utils from 'src/utils'; | ||
import { format } from 'src/url'; | ||
// import { config } from 'src/config'; | ||
import { registerBidder } from 'src/adapters/bidderFactory'; | ||
|
||
const VERSION = '1.0'; | ||
const BIDDER_CODE = 'adyoulike'; | ||
const DEFAULT_DC = 'hb-api'; | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
aliases: ['ayl'], // short code | ||
/** | ||
* Determines whether or not the given bid request is valid. | ||
* | ||
* @param {BidRequest} bid The bid params to validate. | ||
* @return boolean True if this is a valid bid, and false otherwise. | ||
*/ | ||
isBidRequestValid: function (bid) { | ||
const sizes = getSize(bid.sizes); | ||
if (!bid.params || !bid.params.placement || !sizes.width || !sizes.height) { | ||
return false; | ||
} | ||
return true; | ||
}, | ||
/** | ||
* Make a server request from the list of BidRequests. | ||
* | ||
* @param {bidderRequest} - bidderRequest.bids[] is an array of AdUnits and bids | ||
* @return ServerRequest Info describing the request to the server. | ||
*/ | ||
buildRequests: function (bidderRequest) { | ||
let dcHostname = getHostname(bidderRequest); | ||
const payload = { | ||
Version: VERSION, | ||
Bids: bidderRequest.reduce((accumulator, bid) => { | ||
let size = getSize(bid.sizes); | ||
accumulator[bid.bidId] = {}; | ||
accumulator[bid.bidId].PlacementID = bid.params.placement; | ||
accumulator[bid.bidId].TransactionID = bid.transactionId; | ||
accumulator[bid.bidId].Width = size.width; | ||
accumulator[bid.bidId].Height = size.height; | ||
return accumulator; | ||
}, {}), | ||
PageRefreshed: getPageRefreshed() | ||
}; | ||
const data = JSON.stringify(payload); | ||
const options = { | ||
withCredentials: false | ||
}; | ||
|
||
return { | ||
method: 'POST', | ||
url: createEndpoint(dcHostname), | ||
data, | ||
options | ||
}; | ||
}, | ||
/** | ||
* 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, bidRequest) { | ||
const bidResponses = []; | ||
// For this adapter, serverResponse is a list | ||
serverResponse.body.forEach(response => { | ||
const bid = createBid(response); | ||
if (bid) { | ||
bidResponses.push(bid); | ||
} | ||
}); | ||
return bidResponses; | ||
} | ||
} | ||
|
||
/* Get hostname from bids */ | ||
function getHostname(bidderRequest) { | ||
let dcHostname = bidderRequest.find(bid => bid.params.DC); | ||
if (dcHostname) { | ||
return ('-' + dcHostname.params.DC); | ||
} | ||
return ''; | ||
} | ||
|
||
/* Get current page referrer url */ | ||
function getReferrerUrl() { | ||
let referer = ''; | ||
if (window.self !== window.top) { | ||
try { | ||
referer = window.top.document.referrer; | ||
} catch (e) { } | ||
} else { | ||
referer = document.referrer; | ||
} | ||
return referer; | ||
} | ||
|
||
/* Get current page canonical url */ | ||
function getCanonicalUrl() { | ||
let link; | ||
if (window.self !== window.top) { | ||
try { | ||
link = window.top.document.head.querySelector('link[rel="canonical"][href]'); | ||
} catch (e) { } | ||
} else { | ||
link = document.head.querySelector('link[rel="canonical"][href]'); | ||
} | ||
|
||
if (link) { | ||
return link.href; | ||
} | ||
return ''; | ||
} | ||
|
||
/* Get information on page refresh */ | ||
function getPageRefreshed() { | ||
try { | ||
if (performance && performance.navigation) { | ||
return performance.navigation.type === performance.navigation.TYPE_RELOAD; | ||
} | ||
} catch (e) { } | ||
return false; | ||
} | ||
|
||
/* Create endpoint url */ | ||
function createEndpoint(host) { | ||
return format({ | ||
protocol: (document.location.protocol === 'https:') ? 'https' : 'http', | ||
host: `${DEFAULT_DC}${host}.omnitagjs.com`, | ||
pathname: '/hb-api/prebid/v1', | ||
search: createEndpointQS() | ||
}); | ||
} | ||
|
||
/* Create endpoint query string */ | ||
function createEndpointQS() { | ||
const qs = {}; | ||
|
||
const ref = getReferrerUrl(); | ||
if (ref) { | ||
qs.RefererUrl = encodeURIComponent(ref); | ||
} | ||
|
||
const can = getCanonicalUrl(); | ||
if (can) { | ||
qs.CanonicalUrl = encodeURIComponent(can); | ||
} | ||
|
||
return qs; | ||
} | ||
|
||
/* Get parsed size from request size */ | ||
function getSize(requestSizes) { | ||
const parsed = {}; | ||
const size = utils.parseSizesInput(requestSizes)[0]; | ||
|
||
if (typeof size !== 'string') { | ||
return parsed; | ||
} | ||
|
||
const parsedSize = size.toUpperCase().split('X'); | ||
const width = parseInt(parsedSize[0], 10); | ||
if (width) { | ||
parsed.width = width; | ||
} | ||
|
||
const height = parseInt(parsedSize[1], 10); | ||
if (height) { | ||
parsed.height = height; | ||
} | ||
|
||
return parsed; | ||
} | ||
|
||
/* Create bid from response */ | ||
function createBid(response) { | ||
if (!response || !response.Ad) { | ||
return | ||
} | ||
|
||
return { | ||
requestId: response.BidID, | ||
bidderCode: spec.code, | ||
width: response.Width, | ||
height: response.Height, | ||
ad: response.Ad, | ||
ttl: 3600, | ||
creativeId: response.CreativeID, | ||
cpm: response.Price, | ||
netRevenue: true, | ||
currency: 'USD' | ||
}; | ||
} | ||
|
||
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,29 @@ | ||
# Overview | ||
|
||
Module Name: Adyoulike Bidder Adapter | ||
Module Type: Bidder Adapter | ||
Maintainer: prebid@adyoulike.com | ||
|
||
# Description | ||
|
||
Module that connects to Adyoulike demand sources. | ||
Banner formats are supported. | ||
|
||
# Test Parameters | ||
``` | ||
var adUnits = [ | ||
{ | ||
code: 'test-div', | ||
sizes: [[300, 250]], | ||
bids: [ | ||
{ | ||
bidder: "adyoulike", | ||
params: { | ||
placement: 194f787b85c829fb8822cdaf1ae64435, | ||
DC: 'fra01', // Optional for set the data center name | ||
} | ||
} | ||
] | ||
} | ||
]; | ||
``` |
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,54 @@ | ||
import * as utils from 'src/utils'; | ||
import { registerBidder } from 'src/adapters/bidderFactory'; | ||
|
||
const BIDDER_CODE = 'innity'; | ||
const ENDPOINT = location.protocol + '//as.innity.com/synd/'; | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
isBidRequestValid: function(bid) { | ||
return !!(bid.params && bid.params.pub && bid.params.zone); | ||
}, | ||
buildRequests: function(validBidRequests) { | ||
return validBidRequests.map(bidRequest => { | ||
let parseSized = utils.parseSizesInput(bidRequest.sizes); | ||
let arrSize = parseSized[0].split('x'); | ||
return { | ||
method: 'GET', | ||
url: ENDPOINT, | ||
data: { | ||
cb: utils.timestamp(), | ||
ver: 2, | ||
hb: 1, | ||
output: 'js', | ||
pub: bidRequest.params.pub, | ||
zone: bidRequest.params.zone, | ||
url: encodeURIComponent(utils.getTopWindowUrl()), | ||
width: arrSize[0], | ||
height: arrSize[1], | ||
vpw: window.screen.width, | ||
vph: window.screen.height, | ||
callback: 'json', | ||
callback_uid: bidRequest.bidId, | ||
auction: bidRequest.auctionId, | ||
}, | ||
}; | ||
}); | ||
}, | ||
interpretResponse: function(serverResponse, request) { | ||
const res = serverResponse.body; | ||
const bidResponse = { | ||
requestId: res.callback_uid, | ||
cpm: parseFloat(res.cpm) / 100, | ||
width: res.width, | ||
height: res.height, | ||
creativeId: res.creative_id, | ||
currency: 'USD', | ||
netRevenue: true, | ||
ttl: 60, | ||
ad: '<script src="' + location.protocol + '//cdn.innity.net/frame_util.js"></script>' + res.tag, | ||
}; | ||
return [bidResponse]; | ||
} | ||
} | ||
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,25 @@ | ||
# Overview | ||
|
||
**Module Name**: Innity Bidder Adapter | ||
**Module Type**: Bidder Adapter | ||
**Maintainer**: engtat@innity.com | ||
|
||
# Description | ||
|
||
Innity Bidder Adapter for Prebid.js. | ||
|
||
# Test Parameters | ||
``` | ||
var adUnits = [{ | ||
code: 'div-gpt-ad-1460505748561-0', | ||
sizes: [[300, 250]], | ||
bids: [{ | ||
bidder: 'innity', | ||
params: { | ||
pub: 267, | ||
zone: 62546 | ||
} | ||
}] | ||
}]; | ||
``` |
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
Oops, something went wrong.