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

New adapter Proxistore #4365

Merged
merged 13 commits into from
Nov 12, 2019
122 changes: 61 additions & 61 deletions integrationExamples/gpt/hello_world.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,84 +8,84 @@
-->

<html>
<head>
<script async src="../../build/dev/prebid.js"></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script>
<head>
<script async src="../../build/dev/prebid.js"></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script>
var FAILSAFE_TIMEOUT = 3300;
var PREBID_TIMEOUT = 1000;

var adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
sizes: [[300, 250], [300,600]],
}
},
// Replace this object to test a new Adapter!
bids: [{
bidder: 'appnexus',
params: {
placementId: 13144370
}
}]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the commit to revert this did not work?

If you could just take the hello_world example from master branch and replace it with the one on your branch that's what we are looking for.

code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
sizes: [[300, 250], [300,600]],
}
},
// Replace this object to test a new Adapter!
bids: [{
bidder: 'appnexus',
params: {
placementId: 13144370
}
}]

}];

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
</script>
<script>

</script>

<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function() {
googletag.pubads().disableInitialLoad();
googletag.pubads().disableInitialLoad();
});

pbjs.que.push(function() {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: sendAdserverRequest,
timeout: PREBID_TIMEOUT
});
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: sendAdserverRequest,
timeout: PREBID_TIMEOUT
});
});

function sendAdserverRequest() {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
googletag.cmd.push(function() {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
googletag.cmd.push(function() {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
});
}

setTimeout(function() {
sendAdserverRequest();
sendAdserverRequest();
}, FAILSAFE_TIMEOUT);
</script>
<script>

</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();
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'>
</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>
</script>
</div>
</body>
</html>
118 changes: 118 additions & 0 deletions integrationExamples/gpt/proxistore_example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<html>

<head>
<script async src="../../build/dev/prebid.js"></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script>
var FAILSAFE_TIMEOUT = 3300;
var PREBID_TIMEOUT = 1000;

var adUnits = [
{
code: 'div-test-half-page',
mediaTypes: {
banner: {
sizes: [[300, 600]]
}
},
bids: [
{
bidder: 'proxistore',
params: {
website: 'example.com',
language: 'fr'
}
}]
},
{
code: 'rectangle',
mediaTypes: {
banner: {
sizes: [[300, 250]]
}
},
bids: [{
bidder: 'proxistore',
params: {
website: 'example.com',
language: 'fr'
}
}]
},
{
code: 'leaderboard',
mediaTypes: {
banner: {
sizes: [[970, 250]]
}
},
bids: [{
bidder: 'proxistore',
params: {
website: 'example.com',
language: 'fr'
}
}]
}
];

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

</script>

<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function () {
googletag.pubads().disableInitialLoad();
});

pbjs.que.push(function () {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: sendAdserverRequest,
timeout: PREBID_TIMEOUT
});
});

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();
}, FAILSAFE_TIMEOUT);

</script>

<script>
googletag.cmd.push(function () {
googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-test-half-page').addService(googletag.pubads());

googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>

<body>
<h2>Prebid.js Test</h2>

<h5>Div-1</h5>

<div id='div-test-half-page'>
<script type='text/javascript'>
googletag.cmd.push(function () { googletag.display('div-test-half-page'); });
</script>
</div>
</body>

</html>
125 changes: 125 additions & 0 deletions modules/proxistoreBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
const { registerBidder } = require('../src/adapters/bidderFactory');
const BIDDER_CODE = 'proxistore';

function _getFormatSize(sizeArr) {
return {
width: sizeArr[0],
height: sizeArr[1]
}
}

function _createServerRequest(bidRequest, bidderRequest) {
const payload = {
bidId: bidRequest.bidId,
auctionId: bidRequest.auctionId,
transactionId: bidRequest.transactionId,
sizes: bidRequest.sizes.map(_getFormatSize),
website: bidRequest.params.website,
language: bidRequest.params.language,
gdpr: {
applies: false
}
};

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

if (bidderRequest && bidderRequest.gdprConsent) {
if ((typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') && bidderRequest.gdprConsent.gdprApplies) {
payload.gdpr.applies = true;
}
if ((typeof bidderRequest.gdprConsent.consentString === 'string') && bidderRequest.gdprConsent.consentString) {
payload.gdpr['consentString'] = bidderRequest.gdprConsent.consentString;
}
}

return {
method: 'POST',
url: bidRequest.params.url || '//abs.proxistore.com/' + bidRequest.params.language + '/v3/rtb/prebid',
data: JSON.stringify(payload),
options: options
};
}

function _createBidResponse(response) {
return {
requestId: response.requestId,
cpm: response.cpm,
width: response.width,
height: response.height,
ad: response.ad,
ttl: response.ttl,
creativeId: response.creativeId,
currency: response.currency,
netRevenue: response.netRevenue,
vastUrl: response.vastUrl,
vastXml: response.vastXml,
dealId: response.dealId
}
}

/**
* Determines whether or not the given bid request is valid.
*
* @param bid The bid params to validate.
* @return boolean True if this is a valid bid, and false otherwise.
*/
function isBidRequestValid(bid) {
return !!(bid.params.website && bid.params.language);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest maybe logging a warning / error here if the user does not have one of your required params.

Because the default console log does not point out exactly what the issue is!

image

Maybe something like:

utils.logWarning('Proxistore Adapter: Both language and website are required params');

No big deal though you don't have to!

}

/**
* Make a server request from the list of BidRequests.
*
* @param bidRequests - an array of bids
* @param bidderRequest
* @return ServerRequest Info describing the request to the server.
*/
function buildRequests(bidRequests, bidderRequest) {
var requests = [];
for (var i = 0; i < bidRequests.length; i++) {
var prebidReq = _createServerRequest(bidRequests[i], bidderRequest);
requests.push(prebidReq);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we are not supporting SRA here.

Prebid.org is not actively enforcing adapters support SRA at the moment but just wanted to let you know that it might be coming later on.

}
return requests;
}

/**
* Unpack the response from the server into a list of bids.
*
* @param serverResponse A successful response from the server.
* @param bidRequest Request original server request
* @return An array of bids which were nested inside the server.
*/
function interpretResponse(serverResponse, bidRequest) {
if (serverResponse.body.length > 0) {
return serverResponse.body.map(_createBidResponse);
} else {
return [];
}
}

/**
* Register the user sync pixels which should be dropped after the auction.
*
* @param syncOptions Which user syncs are allowed?
* @param serverResponses List of server's responses.
* @return The user syncs which should be dropped.
*/
function getUserSyncs(syncOptions, serverResponses) {
return [];
}

const spec = {
code: BIDDER_CODE,
isBidRequestValid: isBidRequestValid,
buildRequests: buildRequests,
interpretResponse: interpretResponse,
getUserSyncs: getUserSyncs
};

registerBidder(spec);

module.exports = spec;
Loading