Skip to content

Commit

Permalink
Merge pull request prebid#3 from prebid/master
Browse files Browse the repository at this point in the history
merge from prebid master to fork
  • Loading branch information
pm-manasi-moghe authored Jan 9, 2019
2 parents 8082b2e + 90656ee commit 6e856c0
Show file tree
Hide file tree
Showing 32 changed files with 1,709 additions and 2,089 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Working examples can be found in [the developer docs](http://prebid.org/dev-docs
$ cd Prebid.js
$ npm install

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

*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.

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

### Supported Browsers

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

### Governance
Review our governance model [here](https://github.com/prebid/Prebid.js/tree/master/governance.md).
59 changes: 31 additions & 28 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ var _ = require('lodash');
var argv = require('yargs').argv;
var gulp = require('gulp');
var gutil = require('gulp-util');
var webserver = require('gulp-webserver');
var connect = require('gulp-connect');
var webpack = require('webpack');
var webpackStream = require('webpack-stream');
var uglify = require('gulp-uglify');
var gulpClean = require('gulp-clean');
var KarmaServer = require('karma').Server;
var karmaConfMaker = require('./karma.conf.maker');
var opens = require('open');
var opens = require('opn');
var webpackConfig = require('./webpack.conf');
var helpers = require('./gulpHelpers');
var concat = require('gulp-concat');
Expand Down Expand Up @@ -56,12 +56,11 @@ function e2etestReport() {
var reportPort = 9010;
var targetDestinationDir = './e2etest-report';
helpers.createEnd2EndTestReport(targetDestinationDir);
gulp.src('./')
.pipe(webserver({
port: reportPort,
directoryListing: true,
livereload: true
}));
connect.server({
port: reportPort,
root: './',
livereload: true
});

setTimeout(function() {
opens('http://localhost:' + reportPort + '/' + targetDestinationDir.slice(2) + '/results.html');
Expand All @@ -81,25 +80,29 @@ function lint(done) {
if (argv.nolint) {
return done();
}
return gulp.src(['src/**/*.js', 'modules/**/*.js', 'test/**/*.js'])
.pipe(eslint())
const isFixed = function(file) {
return file.eslint != null && file.eslint.fixed;
}
return gulp.src(['src/**/*.js', 'modules/**/*.js', 'test/**/*.js'], {base: './'})
.pipe(eslint({fix: true}))
.pipe(eslint.format('stylish'))
.pipe(eslint.failAfterError());
.pipe(eslint.failAfterError())
.pipe(gulpif(isFixed, gulp.dest('./')));
};

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

var stream = gulp.src('./')
.pipe(webserver({
port: coveragePort,
directoryListing: true,
livereload: false,
open: 'build/coverage/karma_html/index.html'
}));
stream.on('finish', done);
connect.server({
port: coveragePort,
root: 'build/coverage/karma_html',
livereload: false
});
opens('http://localhost:' + coveragePort);
done();
};

viewCoverage.displayName = 'view-coverage';

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

var stream = gulp.src('./')
.pipe(webserver({
https: argv.https,
port: port,
directoryListing: true,
livereload: true
}));
connect.server({
https: argv.https,
port: port,
root: './',
livereload: true
});

mainWatcher.on('all', gulp.series(clean, gulp.parallel(lint, 'build-bundle-dev', test)));
loaderWatcher.on('all', gulp.series(lint));
stream.on('finish', done);
done();
};

function makeDevpackPkg() {
Expand All @@ -140,7 +142,8 @@ function makeDevpackPkg() {
.pipe(helpers.nameModules(externalModules))
.pipe(webpackStream(cloned, webpack))
.pipe(replace('$prebid.version$', prebid.version))
.pipe(gulp.dest('build/dev'));
.pipe(gulp.dest('build/dev'))
.pipe(connect.reload());
}

function makeWebpackPkg() {
Expand Down
2 changes: 1 addition & 1 deletion karma.conf.maker.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ function newPluginsArray(browserstack) {
'karma-es5-shim',
'karma-mocha',
'karma-chai',
'karma-requirejs',
'karma-sinon',
'karma-sourcemap-loader',
'karma-spec-reporter',
Expand Down Expand Up @@ -125,6 +124,7 @@ module.exports = function(codeCoverage, browserstack, watchMode, file) {

webpack: webpackConfig,
webpackMiddleware: {
stats: 'errors-only',
noInfo: true
},
// frameworks to use
Expand Down
3 changes: 2 additions & 1 deletion modules/adbutlerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const BIDDER_CODE = 'adbutler';
export const spec = {
code: BIDDER_CODE,
pageID: Math.floor(Math.random() * 10e6),
aliases: ['divreach'],

isBidRequestValid: function (bid) {
return !!(bid.params.accountID && bid.params.zoneID);
Expand Down Expand Up @@ -98,7 +99,7 @@ export const spec = {
});
if (isCorrectCPM && isCorrectSize) {
bidResponse.requestId = bidObj.bidId;
bidResponse.bidderCode = spec.code;
bidResponse.bidderCode = bidObj.bidder;
bidResponse.creativeId = serverResponse.placement_id;
bidResponse.cpm = CPM;
bidResponse.width = width;
Expand Down
13 changes: 11 additions & 2 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ const NATIVE_MAPPING = {
minimumParams: { sizes: [{}] },
},
sponsoredBy: 'sponsored_by',
privacyLink: 'privacy_link'
privacyLink: 'privacy_link',
salePrice: 'saleprice',
displayUrl: 'displayurl'
};
const SOURCE = 'pbjs';

Expand Down Expand Up @@ -338,10 +340,17 @@ function newBid(serverBid, rtbBid, bidderRequest) {
rating: nativeAd.rating,
sponsoredBy: nativeAd.sponsored,
privacyLink: nativeAd.privacy_link,
address: nativeAd.address,
downloads: nativeAd.downloads,
likes: nativeAd.likes,
phone: nativeAd.phone,
price: nativeAd.price,
salePrice: nativeAd.saleprice,
clickUrl: nativeAd.link.url,
displayUrl: nativeAd.displayurl,
clickTrackers: nativeAd.link.click_trackers,
impressionTrackers: nativeAd.impression_trackers,
javascriptTrackers: nativeAd.javascript_trackers,
javascriptTrackers: nativeAd.javascript_trackers
};
if (nativeAd.main_img) {
bid['native'].image = {
Expand Down
89 changes: 89 additions & 0 deletions modules/coinzillaBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import * as utils from 'src/utils';
import {config} from 'src/config';
import {registerBidder} from 'src/adapters/bidderFactory';

const BIDDER_CODE = 'coinzilla';
const ENDPOINT_URL = 'https://request.czilladx.com/serve/request.php';

export const spec = {
code: BIDDER_CODE,
aliases: ['czlla'], // 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.placementId);
},

/**
* Make a server request from the list of BidRequests.
*
* @return Array Info describing the request to the server.
* @param validBidRequests
* @param bidderRequest
*/
buildRequests: function (validBidRequests, bidderRequest) {
if (validBidRequests.length === 0) {
return [];
}
return validBidRequests.map(bidRequest => {
const sizes = utils.parseSizesInput(bidRequest.sizes)[0];
const width = sizes.split('x')[0];
const height = sizes.split('x')[1];
const payload = {
placementId: bidRequest.params.placementId,
width: width,
height: height,
bidId: bidRequest.bidId,
referer: bidderRequest.refererInfo.referer,
};
return {
method: 'POST',
url: ENDPOINT_URL,
data: payload
};
});
},

/**
* Unpack the response from the server into a list of bids.
*
* @param {ServerResponse} serverResponse A successful response from the server.
* @param bidRequest
* @return {Bid[]} An array of bids which were nested inside the server.
*/
interpretResponse: function (serverResponse, bidRequest) {
const bidResponses = [];
const response = serverResponse.body;
const creativeId = response.creativeId || 0;
const width = response.width || 0;
const height = response.height || 0;
const cpm = response.cpm || 0;
if (width !== 0 && height !== 0 && cpm !== 0 && creativeId !== 0) {
const dealId = response.dealid || '';
const currency = response.currency || 'EUR';
const netRevenue = (response.netRevenue === undefined) ? true : response.netRevenue;
const referrer = bidRequest.data.referer;
const bidResponse = {
requestId: response.requestId,
cpm: cpm,
width: response.width,
height: response.height,
creativeId: creativeId,
dealId: dealId,
currency: currency,
netRevenue: netRevenue,
ttl: config.getConfig('_bidderTimeout'),
referrer: referrer,
ad: response.ad
};
bidResponses.push(bidResponse);
}
return bidResponses;
},
};
registerBidder(spec);
24 changes: 24 additions & 0 deletions modules/coinzillaBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Overview

```
Module Name: Coinzilla Bidder Adapter
Module Type: Coinzilla Adapter
Maintainer: technical@sevio.com
```

# Description

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 ``publishers@coinzilla.com``.
# Test Parameters
```
var adUnits = [{
code: 'test-ad-div',
sizes: [[300, 250]],
bids: [{
bidder: 'coinzilla',
params: {
placementId: 'testPlacementId'
}
}]
}];
```
28 changes: 17 additions & 11 deletions modules/consentManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export let allowAuction;
export let staticConsentData;

let consentData;
let addedConsentHook = false;

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

return {
consentDataCallback: function(consentResponse) {
consentDataCallback: function (consentResponse) {
cmpResponse.getConsentData = consentResponse;
afterEach();
},
vendorConsentsCallback: function(consentResponse) {
vendorConsentsCallback: function (consentResponse) {
cmpResponse.getVendorConsents = consentResponse;
afterEach();
}
Expand All @@ -82,7 +83,7 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) {
// if the CMP is not found, the iframe function will call the cmpError exit callback to abort the rest of the CMP workflow
try {
cmpFunction = window.__cmp || utils.getWindowTop().__cmp;
} catch (e) {}
} catch (e) { }

if (utils.isFn(cmpFunction)) {
cmpFunction('getConsentData', null, callbackHandler.consentDataCallback);
Expand All @@ -97,7 +98,7 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) {
while (!cmpFrame) {
try {
if (f.frames['__cmpLocator']) cmpFrame = f;
} catch (e) {}
} catch (e) { }
if (f === window.top) break;
f = f.parent;
}
Expand Down Expand Up @@ -139,13 +140,15 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) {
function callCmpWhileInIframe(commandName, cmpFrame, moduleCallback) {
/* Setup up a __cmp function to do the postMessage and stash the callback.
This function behaves (from the caller's perspective identicially to the in-frame __cmp call */
window.__cmp = function(cmd, arg, callback) {
window.__cmp = function (cmd, arg, callback) {
let callId = Math.random() + '';
let msg = {__cmpCall: {
command: cmd,
parameter: arg,
callId: callId
}};
let msg = {
__cmpCall: {
command: cmd,
parameter: arg,
callId: callId
}
};
cmpCallbacks[callId] = callback;
cmpFrame.postMessage(msg, '*');
}
Expand Down Expand Up @@ -371,6 +374,9 @@ export function setConfig(config) {
utils.logError(`consentManagement config with cmpApi: 'static' did not specify consentData. No consents will be available to adapters.`);
}
}
$$PREBID_GLOBAL$$.requestBids.addHook(requestBidsHook, 50);
if (!addedConsentHook) {
$$PREBID_GLOBAL$$.requestBids.addHook(requestBidsHook, 50);
}
addedConsentHook = true;
}
config.getConfig('consentManagement', config => setConfig(config.consentManagement));
Loading

0 comments on commit 6e856c0

Please sign in to comment.