Skip to content

Commit

Permalink
Merge branch 'master' of github.com:prebid/Prebid.js into translation…
Browse files Browse the repository at this point in the history
…-module
  • Loading branch information
Jaimin Panchal committed Feb 27, 2019
2 parents e334120 + 36f1230 commit e7e485e
Show file tree
Hide file tree
Showing 70 changed files with 7,699 additions and 970 deletions.
29 changes: 24 additions & 5 deletions gulpHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const gutil = require('gulp-util');
const MODULE_PATH = './modules';
const BUILD_PATH = './build/dist';
const DEV_PATH = './build/dev';
const ANALYTICS_PATH = '../analytics';


// get only subdirectories that contain package.json with 'main' property
Expand Down Expand Up @@ -126,18 +127,36 @@ module.exports = {
* Invoke with gulp <task> --analytics
* Returns an array of source files for inclusion in build process
*/
getAnalyticsSources: function(directory) {
getAnalyticsSources: function() {
if (!argv.analytics) {return [];} // empty arrays won't affect a standard build

const directoryContents = fs.readdirSync(directory);
const directoryContents = fs.readdirSync(ANALYTICS_PATH);
return directoryContents
.filter(file => isModuleDirectory(path.join(directory, file)))
.filter(file => isModuleDirectory(path.join(ANALYTICS_PATH, file)))
.map(moduleDirectory => {
const module = require(path.join(directory, moduleDirectory, MANIFEST));
return path.join(directory, moduleDirectory, module.main);
const module = require(path.join(ANALYTICS_PATH, moduleDirectory, MANIFEST));
return path.join(ANALYTICS_PATH, moduleDirectory, module.main);
});
},

/*
* Returns the babel options object necessary for allowing analytics packages
* to have their own configs. Gets added to prebid's webpack config with the
* flag --analytics
*/
getAnalyticsOptions: function() {
let options;

if (argv.analytics) {
// https://babeljs.io/docs/en/options#babelrcroots
options = {
babelrcRoots: ['.', ANALYTICS_PATH],
}
}

return options;
},

createEnd2EndTestReport : function(targetDestinationDir) {
var browsers = require('./browsers.json');
var env = [];
Expand Down
6 changes: 2 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ var jsEscape = require('gulp-js-escape');
var prebid = require('./package.json');
var dateString = 'Updated : ' + (new Date()).toISOString().substring(0, 10);
var banner = '/* <%= prebid.name %> v<%= prebid.version %>\n' + dateString + ' */\n';
var analyticsDirectory = '../analytics';
var port = 9999;

// these modules must be explicitly listed in --modules to be included in the build, won't be part of "all" modules
Expand Down Expand Up @@ -135,7 +134,7 @@ function makeDevpackPkg() {
cloned.devtool = 'source-map';
var externalModules = helpers.getArgModules();

const analyticsSources = helpers.getAnalyticsSources(analyticsDirectory);
const analyticsSources = helpers.getAnalyticsSources();
const moduleSources = helpers.getModulePaths(externalModules);

return gulp.src([].concat(moduleSources, analyticsSources, 'src/prebid.js'))
Expand All @@ -147,12 +146,11 @@ function makeDevpackPkg() {

function makeWebpackPkg() {
var cloned = _.cloneDeep(webpackConfig);

delete cloned.devtool;

var externalModules = helpers.getArgModules();

const analyticsSources = helpers.getAnalyticsSources(analyticsDirectory);
const analyticsSources = helpers.getAnalyticsSources();
const moduleSources = helpers.getModulePaths(externalModules);

return gulp.src([].concat(moduleSources, analyticsSources, 'src/prebid.js'))
Expand Down
3 changes: 2 additions & 1 deletion integrationExamples/gpt/pbjs_example_gpt.html
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@
bidder: 'zedo',
params: {
channelCode: 2264002816, //REQUIRED
dimId: 9 //REQUIRED
dimId: 9, //REQUIRED
pubId: 1 // OPTIONAL
}
},
{
Expand Down
71 changes: 71 additions & 0 deletions modules/admediaBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import * as utils from '../src/utils';
import {registerBidder} from '../src/adapters/bidderFactory';

const BIDDER_CODE = 'admedia';
const ENDPOINT_URL = '//prebid.admedia.com/bidder/';

export const spec = {
code: BIDDER_CODE,

isBidRequestValid: function (bid) {
return bid.params && !!bid.params.aid;
},

buildRequests: function (validBidRequests, bidderRequest) {
let payload = {};

if (bidderRequest && bidderRequest.refererInfo) {
payload.referer = encodeURIComponent(bidderRequest.refererInfo.referer);
}

payload.tags = [];

utils._each(validBidRequests, function (bid) {
const tag = {
id: bid.bidId,
sizes: bid.sizes,
aid: bid.params.aid
};
payload.tags.push(tag);
});

const payloadString = JSON.stringify(payload);
return {
method: 'POST',
url: ENDPOINT_URL,
data: payloadString,
};
},

interpretResponse: function (serverResponse, bidRequest) {
const bidResponses = [];

if (!serverResponse.body.tags) {
return bidResponses;
}

utils._each(serverResponse.body.tags, function (response) {
if (!response.error && response.cpm > 0) {
const bidResponse = {
requestId: response.id,
cpm: response.cpm,
width: response.width,
height: response.height,
creativeId: response.id,
dealId: response.id,
currency: 'USD',
netRevenue: true,
ttl: 120,
// referrer: REFERER,
ad: response.ad
};

bidResponses.push(bidResponse);
}
});

return bidResponses;
}
};

registerBidder(spec);
42 changes: 42 additions & 0 deletions modules/admediaBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Overview

```
Module Name: Admedia Bidder Adapter
Module Type: Bidder Adapter
Maintainer: developers@admedia.com
```

# Description

Admedia Bidder Adapter for Prebid.js.
Only Banner format is supported.

# Test Parameters
```
var adUnits = [
{
code: 'test-div-0',
sizes: [[300, 250]], // a display size
bids: [
{
bidder: 'admedia',
params: {
aid: 86858
}
}
]
},
{
code: 'test-div-1',
sizes: [[300, 50]], // a mobile size
bids: [
{
bidder: 'admedia',
params: {
aid: 86858
}
}
]
}
];
```
2 changes: 1 addition & 1 deletion modules/adtelligentBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function bidToTag(bidRequests, bidderRequest) {
domain: utils.getTopWindowLocation().hostname
};

if (bidderRequest && bidderRequest.gdprConsent) {
if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) {
tag.gdpr = 1;
tag.gdpr_consent = bidderRequest.gdprConsent.consentString;
}
Expand Down
Loading

0 comments on commit e7e485e

Please sign in to comment.