Skip to content

Commit 6e856c0

Browse files
Merge pull request #3 from prebid/master
merge from prebid master to fork
2 parents 8082b2e + 90656ee commit 6e856c0

32 files changed

+1709
-2089
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Working examples can be found in [the developer docs](http://prebid.org/dev-docs
2929
$ cd Prebid.js
3030
$ npm install
3131

32-
*Note:* You need to have `NodeJS` 4.x or greater installed.
32+
*Note:* You need to have `NodeJS` 6.x or greater installed.
3333

3434
*Note:* In the 1.24.0 release of Prebid.js we have transitioned to using gulp 4.0 from using gulp 3.9.1. To compily with gulp's recommended setup for 4.0, you'll need to have `gulp-cli` installed globally prior to running the general `npm install`. This shouldn't impact any other projects you may work on that use an earlier version of gulp in it's setup.
3535

@@ -217,7 +217,7 @@ For instructions on writing tests for Prebid.js, see [Testing Prebid.js](http://
217217

218218
### Supported Browsers
219219

220-
Prebid.js is supported on IE10+ and modern browsers.
220+
Prebid.js is supported on IE11 and modern browsers.
221221

222222
### Governance
223223
Review our governance model [here](https://github.com/prebid/Prebid.js/tree/master/governance.md).

gulpfile.js

+31-28
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ var _ = require('lodash');
44
var argv = require('yargs').argv;
55
var gulp = require('gulp');
66
var gutil = require('gulp-util');
7-
var webserver = require('gulp-webserver');
7+
var connect = require('gulp-connect');
88
var webpack = require('webpack');
99
var webpackStream = require('webpack-stream');
1010
var uglify = require('gulp-uglify');
1111
var gulpClean = require('gulp-clean');
1212
var KarmaServer = require('karma').Server;
1313
var karmaConfMaker = require('./karma.conf.maker');
14-
var opens = require('open');
14+
var opens = require('opn');
1515
var webpackConfig = require('./webpack.conf');
1616
var helpers = require('./gulpHelpers');
1717
var concat = require('gulp-concat');
@@ -56,12 +56,11 @@ function e2etestReport() {
5656
var reportPort = 9010;
5757
var targetDestinationDir = './e2etest-report';
5858
helpers.createEnd2EndTestReport(targetDestinationDir);
59-
gulp.src('./')
60-
.pipe(webserver({
61-
port: reportPort,
62-
directoryListing: true,
63-
livereload: true
64-
}));
59+
connect.server({
60+
port: reportPort,
61+
root: './',
62+
livereload: true
63+
});
6564

6665
setTimeout(function() {
6766
opens('http://localhost:' + reportPort + '/' + targetDestinationDir.slice(2) + '/results.html');
@@ -81,25 +80,29 @@ function lint(done) {
8180
if (argv.nolint) {
8281
return done();
8382
}
84-
return gulp.src(['src/**/*.js', 'modules/**/*.js', 'test/**/*.js'])
85-
.pipe(eslint())
83+
const isFixed = function(file) {
84+
return file.eslint != null && file.eslint.fixed;
85+
}
86+
return gulp.src(['src/**/*.js', 'modules/**/*.js', 'test/**/*.js'], {base: './'})
87+
.pipe(eslint({fix: true}))
8688
.pipe(eslint.format('stylish'))
87-
.pipe(eslint.failAfterError());
89+
.pipe(eslint.failAfterError())
90+
.pipe(gulpif(isFixed, gulp.dest('./')));
8891
};
8992

9093
// View the code coverage report in the browser.
9194
function viewCoverage(done) {
9295
var coveragePort = 1999;
9396

94-
var stream = gulp.src('./')
95-
.pipe(webserver({
96-
port: coveragePort,
97-
directoryListing: true,
98-
livereload: false,
99-
open: 'build/coverage/karma_html/index.html'
100-
}));
101-
stream.on('finish', done);
97+
connect.server({
98+
port: coveragePort,
99+
root: 'build/coverage/karma_html',
100+
livereload: false
101+
});
102+
opens('http://localhost:' + coveragePort);
103+
done();
102104
};
105+
103106
viewCoverage.displayName = 'view-coverage';
104107

105108
// Watch Task with Live Reload
@@ -115,17 +118,16 @@ function watch(done) {
115118
'test/spec/loaders/**/*.js'
116119
]);
117120

118-
var stream = gulp.src('./')
119-
.pipe(webserver({
120-
https: argv.https,
121-
port: port,
122-
directoryListing: true,
123-
livereload: true
124-
}));
121+
connect.server({
122+
https: argv.https,
123+
port: port,
124+
root: './',
125+
livereload: true
126+
});
125127

126128
mainWatcher.on('all', gulp.series(clean, gulp.parallel(lint, 'build-bundle-dev', test)));
127129
loaderWatcher.on('all', gulp.series(lint));
128-
stream.on('finish', done);
130+
done();
129131
};
130132

131133
function makeDevpackPkg() {
@@ -140,7 +142,8 @@ function makeDevpackPkg() {
140142
.pipe(helpers.nameModules(externalModules))
141143
.pipe(webpackStream(cloned, webpack))
142144
.pipe(replace('$prebid.version$', prebid.version))
143-
.pipe(gulp.dest('build/dev'));
145+
.pipe(gulp.dest('build/dev'))
146+
.pipe(connect.reload());
144147
}
145148

146149
function makeWebpackPkg() {

karma.conf.maker.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ function newPluginsArray(browserstack) {
3434
'karma-es5-shim',
3535
'karma-mocha',
3636
'karma-chai',
37-
'karma-requirejs',
3837
'karma-sinon',
3938
'karma-sourcemap-loader',
4039
'karma-spec-reporter',
@@ -125,6 +124,7 @@ module.exports = function(codeCoverage, browserstack, watchMode, file) {
125124

126125
webpack: webpackConfig,
127126
webpackMiddleware: {
127+
stats: 'errors-only',
128128
noInfo: true
129129
},
130130
// frameworks to use

modules/adbutlerBidAdapter.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const BIDDER_CODE = 'adbutler';
99
export const spec = {
1010
code: BIDDER_CODE,
1111
pageID: Math.floor(Math.random() * 10e6),
12+
aliases: ['divreach'],
1213

1314
isBidRequestValid: function (bid) {
1415
return !!(bid.params.accountID && bid.params.zoneID);
@@ -98,7 +99,7 @@ export const spec = {
9899
});
99100
if (isCorrectCPM && isCorrectSize) {
100101
bidResponse.requestId = bidObj.bidId;
101-
bidResponse.bidderCode = spec.code;
102+
bidResponse.bidderCode = bidObj.bidder;
102103
bidResponse.creativeId = serverResponse.placement_id;
103104
bidResponse.cpm = CPM;
104105
bidResponse.width = width;

modules/appnexusBidAdapter.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ const NATIVE_MAPPING = {
2727
minimumParams: { sizes: [{}] },
2828
},
2929
sponsoredBy: 'sponsored_by',
30-
privacyLink: 'privacy_link'
30+
privacyLink: 'privacy_link',
31+
salePrice: 'saleprice',
32+
displayUrl: 'displayurl'
3133
};
3234
const SOURCE = 'pbjs';
3335

@@ -338,10 +340,17 @@ function newBid(serverBid, rtbBid, bidderRequest) {
338340
rating: nativeAd.rating,
339341
sponsoredBy: nativeAd.sponsored,
340342
privacyLink: nativeAd.privacy_link,
343+
address: nativeAd.address,
344+
downloads: nativeAd.downloads,
345+
likes: nativeAd.likes,
346+
phone: nativeAd.phone,
347+
price: nativeAd.price,
348+
salePrice: nativeAd.saleprice,
341349
clickUrl: nativeAd.link.url,
350+
displayUrl: nativeAd.displayurl,
342351
clickTrackers: nativeAd.link.click_trackers,
343352
impressionTrackers: nativeAd.impression_trackers,
344-
javascriptTrackers: nativeAd.javascript_trackers,
353+
javascriptTrackers: nativeAd.javascript_trackers
345354
};
346355
if (nativeAd.main_img) {
347356
bid['native'].image = {

modules/coinzillaBidAdapter.js

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import * as utils from 'src/utils';
2+
import {config} from 'src/config';
3+
import {registerBidder} from 'src/adapters/bidderFactory';
4+
5+
const BIDDER_CODE = 'coinzilla';
6+
const ENDPOINT_URL = 'https://request.czilladx.com/serve/request.php';
7+
8+
export const spec = {
9+
code: BIDDER_CODE,
10+
aliases: ['czlla'], // short code
11+
12+
/**
13+
* Determines whether or not the given bid request is valid.
14+
*
15+
* @param {BidRequest} bid The bid params to validate.
16+
* @return boolean True if this is a valid bid, and false otherwise.
17+
*/
18+
isBidRequestValid: function (bid) {
19+
return !!(bid.params.placementId);
20+
},
21+
22+
/**
23+
* Make a server request from the list of BidRequests.
24+
*
25+
* @return Array Info describing the request to the server.
26+
* @param validBidRequests
27+
* @param bidderRequest
28+
*/
29+
buildRequests: function (validBidRequests, bidderRequest) {
30+
if (validBidRequests.length === 0) {
31+
return [];
32+
}
33+
return validBidRequests.map(bidRequest => {
34+
const sizes = utils.parseSizesInput(bidRequest.sizes)[0];
35+
const width = sizes.split('x')[0];
36+
const height = sizes.split('x')[1];
37+
const payload = {
38+
placementId: bidRequest.params.placementId,
39+
width: width,
40+
height: height,
41+
bidId: bidRequest.bidId,
42+
referer: bidderRequest.refererInfo.referer,
43+
};
44+
return {
45+
method: 'POST',
46+
url: ENDPOINT_URL,
47+
data: payload
48+
};
49+
});
50+
},
51+
52+
/**
53+
* Unpack the response from the server into a list of bids.
54+
*
55+
* @param {ServerResponse} serverResponse A successful response from the server.
56+
* @param bidRequest
57+
* @return {Bid[]} An array of bids which were nested inside the server.
58+
*/
59+
interpretResponse: function (serverResponse, bidRequest) {
60+
const bidResponses = [];
61+
const response = serverResponse.body;
62+
const creativeId = response.creativeId || 0;
63+
const width = response.width || 0;
64+
const height = response.height || 0;
65+
const cpm = response.cpm || 0;
66+
if (width !== 0 && height !== 0 && cpm !== 0 && creativeId !== 0) {
67+
const dealId = response.dealid || '';
68+
const currency = response.currency || 'EUR';
69+
const netRevenue = (response.netRevenue === undefined) ? true : response.netRevenue;
70+
const referrer = bidRequest.data.referer;
71+
const bidResponse = {
72+
requestId: response.requestId,
73+
cpm: cpm,
74+
width: response.width,
75+
height: response.height,
76+
creativeId: creativeId,
77+
dealId: dealId,
78+
currency: currency,
79+
netRevenue: netRevenue,
80+
ttl: config.getConfig('_bidderTimeout'),
81+
referrer: referrer,
82+
ad: response.ad
83+
};
84+
bidResponses.push(bidResponse);
85+
}
86+
return bidResponses;
87+
},
88+
};
89+
registerBidder(spec);

modules/coinzillaBidAdapter.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Overview
2+
3+
```
4+
Module Name: Coinzilla Bidder Adapter
5+
Module Type: Coinzilla Adapter
6+
Maintainer: [email protected]
7+
```
8+
9+
# Description
10+
11+
Our module helps you have an easier time implementing Coinzilla on your website. All you have to do is replace the ``placementId`` with your zoneID, depending on the required size in your account dashboard. If you need additional information please contact us at ``[email protected]``.
12+
# Test Parameters
13+
```
14+
var adUnits = [{
15+
code: 'test-ad-div',
16+
sizes: [[300, 250]],
17+
bids: [{
18+
bidder: 'coinzilla',
19+
params: {
20+
placementId: 'testPlacementId'
21+
}
22+
}]
23+
}];
24+
```

modules/consentManagement.js

+17-11
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export let allowAuction;
2020
export let staticConsentData;
2121

2222
let consentData;
23+
let addedConsentHook = false;
2324

2425
// add new CMPs here, with their dedicated lookup function
2526
const cmpCallMap = {
@@ -56,11 +57,11 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) {
5657
}
5758

5859
return {
59-
consentDataCallback: function(consentResponse) {
60+
consentDataCallback: function (consentResponse) {
6061
cmpResponse.getConsentData = consentResponse;
6162
afterEach();
6263
},
63-
vendorConsentsCallback: function(consentResponse) {
64+
vendorConsentsCallback: function (consentResponse) {
6465
cmpResponse.getVendorConsents = consentResponse;
6566
afterEach();
6667
}
@@ -82,7 +83,7 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) {
8283
// if the CMP is not found, the iframe function will call the cmpError exit callback to abort the rest of the CMP workflow
8384
try {
8485
cmpFunction = window.__cmp || utils.getWindowTop().__cmp;
85-
} catch (e) {}
86+
} catch (e) { }
8687

8788
if (utils.isFn(cmpFunction)) {
8889
cmpFunction('getConsentData', null, callbackHandler.consentDataCallback);
@@ -97,7 +98,7 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) {
9798
while (!cmpFrame) {
9899
try {
99100
if (f.frames['__cmpLocator']) cmpFrame = f;
100-
} catch (e) {}
101+
} catch (e) { }
101102
if (f === window.top) break;
102103
f = f.parent;
103104
}
@@ -139,13 +140,15 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) {
139140
function callCmpWhileInIframe(commandName, cmpFrame, moduleCallback) {
140141
/* Setup up a __cmp function to do the postMessage and stash the callback.
141142
This function behaves (from the caller's perspective identicially to the in-frame __cmp call */
142-
window.__cmp = function(cmd, arg, callback) {
143+
window.__cmp = function (cmd, arg, callback) {
143144
let callId = Math.random() + '';
144-
let msg = {__cmpCall: {
145-
command: cmd,
146-
parameter: arg,
147-
callId: callId
148-
}};
145+
let msg = {
146+
__cmpCall: {
147+
command: cmd,
148+
parameter: arg,
149+
callId: callId
150+
}
151+
};
149152
cmpCallbacks[callId] = callback;
150153
cmpFrame.postMessage(msg, '*');
151154
}
@@ -371,6 +374,9 @@ export function setConfig(config) {
371374
utils.logError(`consentManagement config with cmpApi: 'static' did not specify consentData. No consents will be available to adapters.`);
372375
}
373376
}
374-
$$PREBID_GLOBAL$$.requestBids.addHook(requestBidsHook, 50);
377+
if (!addedConsentHook) {
378+
$$PREBID_GLOBAL$$.requestBids.addHook(requestBidsHook, 50);
379+
}
380+
addedConsentHook = true;
375381
}
376382
config.getConfig('consentManagement', config => setConfig(config.consentManagement));

0 commit comments

Comments
 (0)