Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/prebid/Prebid.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Deepthi Neeladri Sravana authored and Deepthi Neeladri Sravana committed Jul 11, 2019
2 parents 0e2d31b + b777ae1 commit 88ac283
Show file tree
Hide file tree
Showing 56 changed files with 2,499 additions and 942 deletions.
34 changes: 33 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@

const sharedWhiteList = [
"core-js/library/fn/array/find", // no ie11
"core-js/library/fn/array/includes", // no ie11
"core-js/library/fn/set", // ie11 supports Set but not Set#values
"core-js/library/fn/string/includes", // no ie11
"core-js/library/fn/number/is-integer", // no ie11,
"core-js/library/fn/array/from" // no ie11
];

module.exports = {
"env": {
"browser": true,
Expand All @@ -11,6 +21,9 @@ module.exports = {
}
},
"extends": "standard",
"plugins": [
"prebid"
],
"globals": {
"$$PREBID_GLOBAL$$": false
},
Expand All @@ -31,5 +44,24 @@ module.exports = {
"no-throw-literal": "off",
"no-undef": "off",
"no-useless-escape": "off",
}
},
"overrides": [{
"files": "modules/**/*.js",
"rules": {
"prebid/validate-imports": ["error", [
...sharedWhiteList,
"jsencrypt",
"crypto-js"
]]
}
}, {
"files": "src/**/*.js",
"rules": {
"prebid/validate-imports": ["error", [
...sharedWhiteList,
"fun-hooks/no-eval",
"just-clone"
]]
}
}]
};
15 changes: 14 additions & 1 deletion gulpHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ const MANIFEST = 'package.json';
const through = require('through2');
const _ = require('lodash');
const gutil = require('gulp-util');
const submodules = require('./modules/.submodules.json');

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
function isModuleDirectory(filePath) {
try {
Expand Down Expand Up @@ -39,7 +41,9 @@ module.exports = {
.replace(/\/>/g, '\\/>');
},
getArgModules() {
var modules = (argv.modules || '').split(',').filter(module => !!module);
var modules = (argv.modules || '')
.split(',')
.filter(module => !!module);

try {
if (modules.length === 1 && path.extname(modules[0]).toLowerCase() === '.json') {
Expand All @@ -56,6 +60,15 @@ module.exports = {
});
}

Object.keys(submodules).forEach(parentModule => {
if (
!modules.includes(parentModule) &&
modules.some(module => submodules[parentModule].includes(module))
) {
modules.unshift(parentModule);
}
});

return modules;
},
getModules: _.memoize(function(externalModules) {
Expand Down
145 changes: 88 additions & 57 deletions integrationExamples/gpt/hello_world_emoteev.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,99 @@
<script async src="//www.googletagservices.com/tag/js/gpt.js"></script>
<script type="text/javascript" src="../../build/dev/prebid.js" async></script>
<script>
const sizes = [
[300, 250],
[250, 300],
[300, 600]
];
const PREBID_TIMEOUT = 3000;
const FAILSAFE_TIMEOUT = 3000;
const sizes = [
[728, 90], // Footer
[750, 200], // Content
[300, 250], // Content
[320, 480], // Overlay

const adUnits = [{
code: '/19968336/header-bid-tag-1',
mediaTypes: {
banner: {
sizes: sizes
}
},
bids: [{
bidder: 'emoteev',
params: {
adSpaceId: 5084,
}
}]
}];
// some further examples from https://www.iab.com/wp-content/uploads/2017/08/IABNewAdPortfolio_FINAL_2017.pdf
[900, 225], // IAB: horizontal, Billboard
[900, 450], // IAB: horizontal, Half Page
[300, 150], // IAB: horizontal 2x1 and tiles Financial
[300, 600], // IAB: vertical 1x2
[300, 900] // IAB: vertical 1x3 Portrait
];
const PREBID_TIMEOUT = 3000;
const FAILSAFE_TIMEOUT = 3000;

// ======== DO NOT EDIT BELOW THIS LINE =========== //
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function () {
googletag.pubads().disableInitialLoad();
});
const adUnits = [{
code: '/19968336/header-bid-tag-1',
mediaTypes: {
banner: {
sizes: sizes
}
},
bids: [{
bidder: 'emoteev',
params: {
adSpaceId: 5084,
context: 'content',
externalId: null
}
}, {
bidder: 'emoteev',
params: {
adSpaceId: 5084,
context: 'footer',
externalId: null
}
}, {
bidder: 'emoteev',
params: {
adSpaceId: 5084,
context: 'overlay',
externalId: null
}
}, {
bidder: 'emoteev',
params: {
adSpaceId: 5084,
context: 'wallpaper',
externalId: null
}
}]
}];

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

pbjs.que.push(function () {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: initAdserver,
timeout: PREBID_TIMEOUT
// ======== DO NOT EDIT BELOW THIS LINE =========== //
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function () {
googletag.pubads().disableInitialLoad();
});
});

function initAdserver() {
if (pbjs.initAdserverSet) return;
pbjs.initAdserverSet = true;
googletag.cmd.push(function () {
pbjs.que.push(function () {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

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

setTimeout(function () {
initAdserver();
}, FAILSAFE_TIMEOUT);
function initAdserver() {
if (pbjs.initAdserverSet) return;
pbjs.initAdserverSet = true;
googletag.cmd.push(function () {
pbjs.que.push(function () {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
}

setTimeout(function () {
initAdserver();
}, FAILSAFE_TIMEOUT);

googletag.cmd.push(function () {
googletag.defineSlot('/19968336/header-bid-tag-1', sizes, 'div-1')
.addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
googletag.cmd.push(function () {
googletag.defineSlot('/19968336/header-bid-tag-1', sizes, 'div-1')
.addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>

Expand All @@ -75,9 +106,9 @@ <h2>Basic Prebid.js Example</h2>
<h5>Div-1</h5>
<div id='div-1'>
<script type='text/javascript'>
googletag.cmd.push(function () {
googletag.display('div-1');
});
googletag.cmd.push(function () {
googletag.display('div-1');
});

</script>
</div>
Expand Down
3 changes: 2 additions & 1 deletion integrationExamples/gpt/x-domain/creative.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// this script can be returned by an ad server delivering a cross domain iframe, into which the
// creative will be rendered, e.g. DFP delivering a SafeFrame

let windowLocation = window.location;
var urlParser = document.createElement('a');
urlParser.href = '%%PATTERN:url%%';
var publisherDomain = urlParser.protocol + '//' + urlParser.hostname;
var adServerDomain = urlParser.protocol + '//tpc.googlesyndication.com';
var adServerDomain = windowLocation.protocol + '//tpc.googlesyndication.com';

function renderAd(ev) {
var key = ev.message ? 'message' : 'data';
Expand Down
10 changes: 10 additions & 0 deletions modules/.submodules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"userId": [
"digiTrustIdSystem",
"id5IdSystem",
"criteortusIdSystem"
],
"adpod": [
"freeWheelAdserverVideo"
]
}
30 changes: 17 additions & 13 deletions modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function _getAdSlotHTMLElement(adUnitCode) {

// Infer the necessary data from valid bid for a minimal ttxRequest and create HTTP request
// NOTE: At this point, TTX only accepts request for a single impression
function _createServerRequest(bidRequest, gdprConsent) {
function _createServerRequest(bidRequest, gdprConsent = {}) {
const ttxRequest = {};
const params = bidRequest.params;
const element = _getAdSlotHTMLElement(bidRequest.adUnitCode);
Expand Down Expand Up @@ -143,14 +143,22 @@ function _createServerRequest(bidRequest, gdprConsent) {
}

// Sync object will always be of type iframe for TTX
function _createSync(siteId) {
function _createSync({siteId, gdprConsent = {}}) {
const ttxSettings = config.getConfig('ttxSettings');
const syncUrl = (ttxSettings && ttxSettings.syncUrl) || SYNC_ENDPOINT;

return {
const {consentString, gdprApplies} = gdprConsent;

const sync = {
type: 'iframe',
url: `${syncUrl}&id=${siteId}`
url: `${syncUrl}&id=${siteId}&gdpr_consent=${encodeURIComponent(consentString)}`
};

if (typeof gdprApplies === 'boolean') {
sync.url += `&gdpr=${Number(gdprApplies)}`;
}

return sync;
}

function _getSize(size) {
Expand Down Expand Up @@ -282,8 +290,6 @@ function isBidRequestValid(bid) {

// NOTE: With regards to gdrp consent data,
// - the server independently infers gdpr applicability therefore, setting the default value to false
// - the server, at this point, also doesn't need the consent string to handle gdpr compliance. So passing
// value whether set or not, for the sake of future dev.
function buildRequests(bidRequests, bidderRequest) {
const gdprConsent = Object.assign({
consentString: undefined,
Expand All @@ -307,14 +313,12 @@ function interpretResponse(serverResponse, bidRequest) {
return bidResponses;
}

// Register one sync per unique guid
// NOTE: If gdpr applies do not sync
// Register one sync per unique guid so long as iframe is enable
// Else no syncs
// For logic on how we handle gdpr data see _createSyncs and module's unit tests
// '33acrossBidAdapter#getUserSyncs'
function getUserSyncs(syncOptions, responses, gdprConsent) {
if (gdprConsent && gdprConsent.gdprApplies === true) {
return []
} else {
return (syncOptions.iframeEnabled) ? adapterState.uniqueSiteIds.map(_createSync) : ([]);
}
return (syncOptions.iframeEnabled) ? adapterState.uniqueSiteIds.map((siteId) => _createSync({gdprConsent, siteId})) : ([]);
}

export const spec = {
Expand Down
2 changes: 1 addition & 1 deletion modules/33acrossBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var adUnits = [
bids: [{
bidder: '33across',
params: {
siteId: 'examplePub1234',
siteId: 'cxBE0qjUir6iopaKkGJozW',
productId: 'siab'
}
}]
Expand Down
Loading

0 comments on commit 88ac283

Please sign in to comment.