Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Groh committed Nov 13, 2017
2 parents 0c040fc + 71fa707 commit 40444f7
Show file tree
Hide file tree
Showing 124 changed files with 10,691 additions and 8,014 deletions.
15 changes: 2 additions & 13 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,7 @@

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2013 APPNEXUS INC
Copyright 2017 PREBID.ORG, INC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -199,4 +188,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
6 changes: 4 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,11 @@ gulp.task('webpack', ['clean'], function () {
// By default, this runs in headless chrome.
//
// If --watch is given, the task will re-run unit tests whenever the source code changes
// If --file "<path-to-test-file>" is given, the task will only run tests in the specified file.
// If --browserstack is given, it will run the full suite of currently supported browsers.
// If --browsers is given, browsers can be chosen explicitly. e.g. --browsers=chrome,firefox,ie9
gulp.task('test', ['clean'], function (done) {
var karmaConf = karmaConfMaker(false, argv.browserstack, argv.watch);
var karmaConf = karmaConfMaker(false, argv.browserstack, argv.watch, argv.file);

var browserOverride = helpers.parseBrowserArgs(argv).map(helpers.toCapitalCase);
if (browserOverride.length > 0) {
Expand All @@ -186,8 +187,9 @@ gulp.task('test', ['clean'], function (done) {
new KarmaServer(karmaConf, newKarmaCallback(done)).start();
});

// If --file "<path-to-test-file>" is given, the task will only run tests in the specified file.
gulp.task('test-coverage', ['clean'], function(done) {
new KarmaServer(karmaConfMaker(true, false), newKarmaCallback(done)).start();
new KarmaServer(karmaConfMaker(true, false, false, argv.file), newKarmaCallback(done)).start();
});

// View the code coverage report in the browser.
Expand Down
19 changes: 19 additions & 0 deletions integrationExamples/gpt/pbjs_example_gpt.html
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,19 @@
params: {
placement_id: 0
}
},
{
bidder: 'pollux',
params: {
zone: '1806' // REQUIRED Zone Id (1806 is a test zone)
}
},
{
bidder: 'adkernelAdn',
params: {
pubId: 50357, //REQUIRED
host: 'dsp-staging.adkernel.com' //OPTIONAL
}
}
]
}, {
Expand Down Expand Up @@ -388,6 +401,12 @@
params: {
placement_id: 0
}
},
{
bidder: 'pollux',
params: {
zone: '276' // REQUIRED Zone Id (276 is a test zone)
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,77 @@
var PREBID_TIMEOUT = 3000;

var adUnits = [{
code: 'div-gpt-ad-1460505661639-0',
sizes: [[728, 90]],
bids: [
{
bidder: 'pollux',
params: {
zone: '276'
}
},
{
bidder: 'pollux',
params: {
zone: '1806'
}
}
]
}];

code: 'div-gpt-ad-1460505661639-0',
sizes: [[728, 90], [300, 250]],
bids: [{
bidder: 'pollux',
params: {
zone: '1806,276'
}
}, {
bidder: 'pollux',
params: {
zone: '276'
}
}
]
},
{
code: 'div-gpt-ad-1460505661631-0',
sizes: [[300, 250]],
bids: [{
bidder: 'pollux',
params: {
zone: '1806,276,855'
}
}
]
}
];
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
</script>
<!-- Prebid Config Section END -->

<!-- Prebid Boilerplate Section START. No Need to Edit. -->
<script type="text/javascript" src="//cdn-assetsx.plxnt.com/assets/public/js/prebid.js" async></script>
<script type="text/javascript" src="//cdn-assetsx.plxnt.com/assets/public/js/prebid/v1/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.requestBids({
bidsBackHandler: sendAdserverRequest
});
});
bidsBackHandler: sendAdserverRequest
});
pbjs.setConfig({
"currency": {
"adServerCurrency": "USD",
"granularityMultiplier": 1
}
});
});

function sendAdserverRequest() {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
googletag.cmd.push(function() {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
};
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();
}, PREBID_TIMEOUT);
setTimeout(function () {
sendAdserverRequest();
}, PREBID_TIMEOUT);

</script>
<!-- Prebid Boilerplate Section END -->
Expand All @@ -79,7 +97,8 @@

<script>
googletag.cmd.push(function () {
googletag.defineSlot('/19968336/header-bid-tag1', [[728, 90]], 'div-gpt-ad-1460505661639-0').addService(googletag.pubads());
googletag.defineSlot('/19968336/header-bid-tag1', [[728, 90], [300, 250]], 'div-gpt-ad-1460505661639-0').addService(googletag.pubads());
googletag.defineSlot('/19968336/header-bid-tag1', [[300, 250]], 'div-gpt-ad-1460505661631-0').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
Expand All @@ -100,5 +119,14 @@
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1460505661639-0'); });
</script>
</div>

<br>
<br>

<div id='div-gpt-ad-1460505661631-0'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1460505661631-0'); });
</script>
</div>
</body>
</html>
4 changes: 2 additions & 2 deletions karma.conf.maker.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ function setBrowsers(karmaConf, browserstack) {
}
}

module.exports = function(codeCoverage, browserstack, watchMode) {
module.exports = function(codeCoverage, browserstack, watchMode, file) {
var webpackConfig = newWebpackConfig(codeCoverage);
var plugins = newPluginsArray(browserstack);
var files = [
'test/helpers/prebidGlobal.js',
'test/**/*_spec.js'
file ? file : 'test/**/*_spec.js'
];
// This file opens the /debug.html tab automatically.
// It has no real value unless you're running --watch, and intend to do some debugging in the browser.
Expand Down
140 changes: 140 additions & 0 deletions modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
const { registerBidder } = require('../src/adapters/bidderFactory');
const utils = require('../src/utils');

const BIDDER_CODE = '33across';
const END_POINT = 'https://ssc.33across.com/api/v1/hb';
const SYNC_ENDPOINT = 'https://de.tynt.com/deb/v2?m=xch';

// All this assumes that only one bid is ever returned by ttx
function _createBidResponse(response) {
return {
requestId: response.id,
bidderCode: BIDDER_CODE,
cpm: response.seatbid[0].bid[0].price,
width: response.seatbid[0].bid[0].w,
height: response.seatbid[0].bid[0].h,
ad: response.seatbid[0].bid[0].adm,
ttl: response.seatbid[0].bid[0].ttl || 60,
creativeId: response.seatbid[0].bid[0].ext.rp.advid,
currency: response.cur,
netRevenue: true
}
}

// infer the necessary data from valid bid for a minimal ttxRequest and create HTTP request
function _createServerRequest(bidRequest) {
const ttxRequest = {};
const params = bidRequest.params;

ttxRequest.imp = [];
ttxRequest.imp[0] = {
banner: {
format: bidRequest.sizes.map(_getFormatSize)
},
ext: {
ttx: {
prod: params.productId
}
}
}

// Allowing site to be a test configuration object or just the id (former required for testing,
// latter when used by publishers)
ttxRequest.site = params.site || { id: params.siteId };

// Go ahead send the bidId in request to 33exchange so it's kept track of in the bid response and
// therefore in ad targetting process
ttxRequest.id = bidRequest.bidId;

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

if (bidRequest.params.customHeaders) {
options.customHeaders = bidRequest.params.customHeaders;
}

return {
'method': 'POST',
'url': bidRequest.params.url || END_POINT,
'data': JSON.stringify(ttxRequest),
'options': options
}
}

// Sync object will always be of type iframe for ttx
function _createSync(bid) {
const syncUrl = bid.params.syncUrl || SYNC_ENDPOINT;

return {
type: 'iframe',
url: `${syncUrl}&id=${bid.params.siteId || bid.params.site.id}`
}
}

function _getFormatSize(sizeArr) {
return {
w: sizeArr[0],
h: sizeArr[1],
ext: {}
}
}

function isBidRequestValid(bid) {
if (bid.bidder !== BIDDER_CODE || typeof bid.params === 'undefined') {
return false;
}

if ((typeof bid.params.site === 'undefined' || typeof bid.params.site.id === 'undefined') &&
(typeof bid.params.siteId === 'undefined')) {
return false;
}

if (typeof bid.params.productId === 'undefined') {
return false;
}

return true;
}

// NOTE: At this point, 33exchange only accepts request for a single impression
function buildRequests(bidRequests) {
return bidRequests.map(_createServerRequest);
}

// NOTE: At this point, the response from 33exchange will only ever contain one bid i.e. the highest bid
function interpretResponse(serverResponse) {
const bidResponses = [];

// If there are bids, look at the first bid of the first seatbid (see NOTE above for assumption about ttx)
if (serverResponse.body.seatbid.length > 0 && serverResponse.body.seatbid[0].bid.length > 0) {
bidResponses.push(_createBidResponse(serverResponse.body));
}

return bidResponses;
}

// Register one sync per bid since each ad unit may potenitally be linked to a uniqe guid
function getUserSyncs(syncOptions) {
let syncs = [];
const ttxBidRequests = utils.getBidderRequestAllAdUnits(BIDDER_CODE).bids;

if (syncOptions.iframeEnabled) {
syncs = ttxBidRequests.map(_createSync);
}

return syncs;
}

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

registerBidder(spec);

module.exports = spec;
Loading

0 comments on commit 40444f7

Please sign in to comment.