This repository has been archived by the owner on Feb 13, 2021. It is now read-only.
forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request prebid#154 from CRAFT/release/2.9.0
Release/2.9.0
- Loading branch information
Showing
76 changed files
with
4,533 additions
and
845 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
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,103 @@ | ||
<html> | ||
<head> | ||
<script>window.__cmp = {config: {logging: 'debug'}}</script> | ||
<script src="//acdn.adnxs.com/cmp/cmp.complete.bundle.js" async></script> | ||
|
||
<script> | ||
var PREBID_TIMEOUT = 700; | ||
|
||
var adUnits = [{ | ||
code: 'div-gpt-ad-1460505748561-0', | ||
sizes: [[300, 250], [300,600]], | ||
|
||
// Replace this object to test a new Adapter! | ||
bids: [{ | ||
bidder: 'appnexusAst', | ||
params: { | ||
placementId: '10433394' | ||
} | ||
}] | ||
|
||
}]; | ||
|
||
var pbjs = pbjs || {}; | ||
pbjs.que = pbjs.que || []; | ||
|
||
</script> | ||
|
||
<script type="text/javascript" src="../../build/dev/prebid.js" async></script> | ||
<script> | ||
var googletag = googletag || {}; | ||
googletag.cmd = googletag.cmd || []; | ||
googletag.cmd.push(function() { | ||
googletag.pubads().disableInitialLoad(); | ||
}); | ||
|
||
pbjs.que.push(function() { | ||
pbjs.addAdUnits(adUnits); | ||
pbjs.setConfig({ | ||
consentManagement: { | ||
cmpApi: 'iab', | ||
timeout: 5000, | ||
allowAuctionWithoutConsent: true | ||
}, | ||
pubcid: { | ||
enable: false | ||
} | ||
}); | ||
pbjs.requestBids({ | ||
bidsBackHandler: sendAdserverRequest | ||
}); | ||
}); | ||
|
||
function sendAdserverRequest() { | ||
if (pbjs.adserverRequestSent) return; | ||
pbjs.adserverRequestSent = true; | ||
googletag.cmd.push(function() { | ||
pbjs.que.push(function() { | ||
pbjs.setTargetingForGPTAsync(); | ||
googletag.pubads().refresh(); | ||
}); | ||
}); | ||
} | ||
|
||
// setTimeout(function() { | ||
// sendAdserverRequest(); | ||
// console.log('timeout in main pbjs fired'); | ||
// }, PREBID_TIMEOUT); | ||
|
||
</script> | ||
|
||
<script> | ||
(function () { | ||
var gads = document.createElement('script'); | ||
gads.async = true; | ||
gads.type = 'text/javascript'; | ||
var useSSL = 'https:' == document.location.protocol; | ||
gads.src = (useSSL ? 'https:' : 'http:') + | ||
'//www.googletagservices.com/tag/js/gpt.js'; | ||
var node = document.getElementsByTagName('script')[0]; | ||
node.parentNode.insertBefore(gads, node); | ||
})(); | ||
</script> | ||
|
||
<script> | ||
googletag.cmd.push(function () { | ||
googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads()); | ||
|
||
googletag.pubads().enableSingleRequest(); | ||
googletag.enableServices(); | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<h2>Prebid.js Test</h2> | ||
<h5>Div-1</h5> | ||
<div id='div-gpt-ad-1460505748561-0'> | ||
<script type='text/javascript'> | ||
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1460505748561-0'); }); | ||
</script> | ||
</div> | ||
</body> | ||
</html> |
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,147 @@ | ||
import * as utils from 'src/utils'; | ||
import { registerBidder } from 'src/adapters/bidderFactory'; | ||
|
||
const BIDDER_CODE = 'admatic'; | ||
const ENDPOINT_URL = '//ads4.admatic.com.tr/prebid/v3/bidrequest'; | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
aliases: ['admatic'], // 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) { | ||
return !!(bid.params.pid && bid.params.wid && bid.params.url); | ||
}, | ||
/** | ||
* Make a server request from the list of BidRequests. | ||
* | ||
* @param {validBidRequests[]} - an array of bids | ||
* @return ServerRequest Info describing the request to the server. | ||
*/ | ||
buildRequests: function (validBidRequests) { | ||
const payload = { | ||
request: [] | ||
}; | ||
|
||
for (var i = 0; i < validBidRequests.length; i++) { | ||
var validBidRequest = validBidRequests[i]; | ||
payload.auctionId = validBidRequest.auctionId; | ||
payload.bidder = validBidRequest.bidder; | ||
payload.bidderRequestId = validBidRequest.bidderRequestId; | ||
payload.pid = validBidRequest.params.pid; | ||
payload.wid = validBidRequest.params.wid; | ||
payload.url = validBidRequest.params.url; | ||
|
||
var request = { | ||
adUnitCode: validBidRequest.adUnitCode, | ||
bidId: validBidRequest.bidId, | ||
transactionId: validBidRequest.transactionId, | ||
priceType: validBidRequest.params.priceType, | ||
sizes: transformSizes(validBidRequest.sizes) | ||
} | ||
|
||
payload.request.push(request); | ||
} | ||
|
||
const payloadString = JSON.stringify(payload); | ||
|
||
return { | ||
method: 'POST', | ||
url: ENDPOINT_URL, | ||
data: payloadString, | ||
bidder: 'admatic', | ||
bids: validBidRequests | ||
}; | ||
}, | ||
|
||
/** | ||
* Unpack the response from the server into a list of bids. | ||
* | ||
* @param {ServerResponse} serverResponse A successful response from the server. | ||
* @return {Bid[]} An array of bids which were nested inside the server. | ||
*/ | ||
interpretResponse: function (serverResponse, bidRequest) { | ||
const serverBody = serverResponse.body; | ||
const bidResponses = []; | ||
|
||
if (serverBody) { | ||
if (serverBody.tags && serverBody.tags.length > 0) { | ||
serverBody.tags.forEach(serverBid => { | ||
if (serverBid != null) { | ||
if (serverBid.cpm !== 0) { | ||
const bidResponse = { | ||
requestId: serverBid.bidId, | ||
cpm: serverBid.cpm, | ||
width: serverBid.width, | ||
height: serverBid.height, | ||
creativeId: serverBid.creativeId, | ||
dealId: serverBid.dealId, | ||
currency: serverBid.currency, | ||
netRevenue: serverBid.netRevenue, | ||
ttl: serverBid.ttl, | ||
referrer: serverBid.referrer, | ||
ad: serverBid.ad | ||
}; | ||
|
||
bidResponses.push(bidResponse); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
|
||
return bidResponses; | ||
}, | ||
/** | ||
* Register the user sync pixels which should be dropped after the auction. | ||
* | ||
* @param {SyncOptions} syncOptions Which user syncs are allowed? | ||
* @param {ServerResponse[]} serverResponses List of server's responses. | ||
* @return {UserSync[]} The user syncs which should be dropped. | ||
*/ | ||
getUserSyncs: function (syncOptions, serverResponses) { | ||
const syncs = []; | ||
if (syncOptions.iframeEnabled) { | ||
syncs.push({ | ||
type: 'iframe', | ||
url: '//ads4.admatic.com.tr/prebid/static/usersync/v3/async_usersync.html' | ||
}); | ||
} | ||
|
||
if (syncOptions.pixelEnabled && serverResponses.length > 0) { | ||
syncs.push({ | ||
type: 'image', | ||
url: 'https://ads5.admatic.com.tr/prebid/v3/bidrequest/usersync' | ||
}); | ||
} | ||
return syncs; | ||
} | ||
} | ||
|
||
/* Turn bid request sizes into ut-compatible format */ | ||
function transformSizes(requestSizes) { | ||
let sizes = []; | ||
let sizeObj = {}; | ||
|
||
if (utils.isArray(requestSizes) && requestSizes.length === 2 && !utils.isArray(requestSizes[0])) { | ||
sizeObj.width = parseInt(requestSizes[0], 10); | ||
sizeObj.height = parseInt(requestSizes[1], 10); | ||
sizes.push(sizeObj); | ||
} else if (typeof requestSizes === 'object') { | ||
for (let i = 0; i < requestSizes.length; i++) { | ||
let size = requestSizes[i]; | ||
sizeObj = {}; | ||
sizeObj.width = parseInt(size[0], 10); | ||
sizeObj.height = parseInt(size[1], 10); | ||
sizes.push(sizeObj); | ||
} | ||
} | ||
|
||
return sizes; | ||
} | ||
|
||
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,54 @@ | ||
# Overview | ||
|
||
``` | ||
Module Name: AdMatic Bidder Adapter | ||
Module Type: Bidder Adapter | ||
Maintainer: prebid@admatic.com.tr | ||
``` | ||
|
||
# Description | ||
|
||
Module that connects to AdMatic demand sources | ||
|
||
# Test Parameters | ||
``` | ||
var adUnits = [ | ||
{ | ||
code: 'test-div', | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[300, 250]], // a display size | ||
} | ||
}, | ||
bids: [ | ||
{ | ||
bidder: "admatic", | ||
params: { | ||
pid: 193937152158, // publisher id without "adm-pub-" prefix | ||
wid: 104276324971, // website id | ||
priceType: 'gross', // default is net | ||
url: window.location.href || window.top.location.href //page url from js | ||
} | ||
} | ||
] | ||
},{ | ||
code: 'test-div', | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[320, 50]], // a mobile size | ||
} | ||
}, | ||
bids: [ | ||
{ | ||
bidder: "admatic", | ||
params: { | ||
pid: 193937152158, // publisher id without "adm-pub-" prefix | ||
wid: 104276324971, // website id | ||
priceType: 'gross', // default is net | ||
url: window.location.href || window.top.location.href //page url from js | ||
} | ||
} | ||
] | ||
} | ||
]; | ||
``` |
Oops, something went wrong.