Skip to content

Commit

Permalink
Merge branch 'prebid:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztofequativ authored May 15, 2024
2 parents 1fa0600 + 0612325 commit b746640
Show file tree
Hide file tree
Showing 399 changed files with 18,444 additions and 5,305 deletions.
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ For any user facing change, submit a link to a PR on the docs repo at https://gi
<!-- Remove items that don't apply and/or select an item by changing [ ] to [x] -->
- [ ] Bugfix
- [ ] Feature
- [ ] New bidder adapter <!-- IMPORTANT: if checking here, also submit your bidder params documentation here https://github.com/prebid/prebid.github.io/tree/master/dev-docs/bidders -->
- [ ] New bidder adapter <!-- IMPORTANT: also submit your bidder parameter documentation as noted in https://docs.prebid.org/dev-docs/bidder-adaptor.html#submitting-your-adapter -->
- [ ] Updated bidder adapter <!-- IMPORTANT: (1) consider whether you need to upgrade your bidder parameter documentation in https://github.com/prebid/prebid.github.io/tree/master/dev-docs/bidders and (2) if you have a Prebid Server adapter, please consider whether that should be updated as well. -->
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ Or, if you are consuming Prebid through npm, with the `disableFeatures` option i

**Note**: this is still a work in progress - at the moment, `NATIVE` is the only feature that can be disabled this way, resulting in a minimal decrease in size (but you can expect that to improve over time).

## Unminified code

You can get a version of the code that's unminified for debugging with `build-bundle-dev`:

```bash
gulp build-bundle-dev --modules=bidderA,module1,...
```

The results will be in build/dev/prebid.js.

## Test locally

To lint the code:
Expand All @@ -237,6 +247,12 @@ To lint the code:
gulp lint
```

To lint and only show errors

```bash
gulp lint --no-lint-warnings
```

To run the unit tests:

```bash
Expand All @@ -245,7 +261,7 @@ gulp test

To run the unit tests for a particular file (example for pubmaticBidAdapter_spec.js):
```bash
gulp test --file "test/spec/modules/pubmaticBidAdapter_spec.js"
gulp test --file "test/spec/modules/pubmaticBidAdapter_spec.js" --nolint
```

To generate and view the code coverage reports:
Expand Down
2 changes: 1 addition & 1 deletion allowedModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
],
'src': [
'fun-hooks/no-eval',
'just-clone',
'klona',
'dlv',
'dset'
],
Expand Down
14 changes: 7 additions & 7 deletions creative/constants.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// eslint-disable-next-line prebid/validate-imports
import CONSTANTS from '../src/constants.json';
import { AD_RENDER_FAILED_REASON, EVENTS, MESSAGES } from '../src/constants.js';

export const MESSAGE_REQUEST = CONSTANTS.MESSAGES.REQUEST;
export const MESSAGE_RESPONSE = CONSTANTS.MESSAGES.RESPONSE;
export const MESSAGE_EVENT = CONSTANTS.MESSAGES.EVENT;
export const EVENT_AD_RENDER_FAILED = CONSTANTS.EVENTS.AD_RENDER_FAILED;
export const EVENT_AD_RENDER_SUCCEEDED = CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED;
export const ERROR_EXCEPTION = CONSTANTS.AD_RENDER_FAILED_REASON.EXCEPTION;
export const MESSAGE_REQUEST = MESSAGES.REQUEST;
export const MESSAGE_RESPONSE = MESSAGES.RESPONSE;
export const MESSAGE_EVENT = MESSAGES.EVENT;
export const EVENT_AD_RENDER_FAILED = EVENTS.AD_RENDER_FAILED;
export const EVENT_AD_RENDER_SUCCEEDED = EVENTS.AD_RENDER_SUCCEEDED;
export const ERROR_EXCEPTION = AD_RENDER_FAILED_REASON.EXCEPTION;
4 changes: 2 additions & 2 deletions creative/renderers/display/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// eslint-disable-next-line prebid/validate-imports
import CONSTANTS from '../../../src/constants.json';
import { AD_RENDER_FAILED_REASON } from '../../../src/constants.js';

export const ERROR_NO_AD = CONSTANTS.AD_RENDER_FAILED_REASON.NO_AD;
export const ERROR_NO_AD = AD_RENDER_FAILED_REASON.NO_AD;
4 changes: 2 additions & 2 deletions creative/renderers/native/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// eslint-disable-next-line prebid/validate-imports
import CONSTANTS from '../../../src/constants.json';
import { MESSAGES } from '../../../src/constants.js';

export const MESSAGE_NATIVE = CONSTANTS.MESSAGES.NATIVE;
export const MESSAGE_NATIVE = MESSAGES.NATIVE;
export const ACTION_RESIZE = 'resizeNativeHeight';
export const ACTION_CLICK = 'click';
export const ACTION_IMP = 'fireNativeImpressionTrackers';
Expand Down
97 changes: 56 additions & 41 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var webpackStream = require('webpack-stream');
var gulpClean = require('gulp-clean');
var opens = require('opn');
var webpackConfig = require('./webpack.conf.js');
const standaloneDebuggingConfig = require('./webpack.debugging.js');
var helpers = require('./gulpHelpers.js');
var concat = require('gulp-concat');
var replace = require('gulp-replace');
Expand Down Expand Up @@ -127,35 +128,56 @@ function viewReview(done) {

viewReview.displayName = 'view-review';

function makeDevpackPkg() {
var cloned = _.cloneDeep(webpackConfig);
Object.assign(cloned, {
devtool: 'source-map',
mode: 'development'
})
function makeVerbose(config = webpackConfig) {
return _.merge({}, config, {
optimization: {
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
mangle: false,
format: {
comments: 'all'
}
},
extractComments: false,
}),
],
}
});
}

const babelConfig = require('./babelConfig.js')({disableFeatures: helpers.getDisabledFeatures(), prebidDistUrlBase: argv.distUrlBase || '/build/dev/'});
function makeDevpackPkg(config = webpackConfig) {
return function() {
var cloned = _.cloneDeep(config);
Object.assign(cloned, {
devtool: 'source-map',
mode: 'development'
})

const babelConfig = require('./babelConfig.js')({disableFeatures: helpers.getDisabledFeatures(), prebidDistUrlBase: argv.distUrlBase || '/build/dev/'});

// update babel config to set local dist url
cloned.module.rules
.flatMap((rule) => rule.use)
.filter((use) => use.loader === 'babel-loader')
.forEach((use) => use.options = Object.assign({}, use.options, babelConfig));
// update babel config to set local dist url
cloned.module.rules
.flatMap((rule) => rule.use)
.filter((use) => use.loader === 'babel-loader')
.forEach((use) => use.options = Object.assign({}, use.options, babelConfig));

var externalModules = helpers.getArgModules();
var externalModules = helpers.getArgModules();

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

return gulp.src([].concat(moduleSources, analyticsSources, 'src/prebid.js'))
.pipe(helpers.nameModules(externalModules))
.pipe(webpackStream(cloned, webpack))
.pipe(gulp.dest('build/dev'))
.pipe(connect.reload());
return gulp.src([].concat(moduleSources, analyticsSources, 'src/prebid.js'))
.pipe(helpers.nameModules(externalModules))
.pipe(webpackStream(cloned, webpack))
.pipe(gulp.dest('build/dev'))
.pipe(connect.reload());
}
}

function makeWebpackPkg(extraConfig = {}) {
var cloned = _.merge(_.cloneDeep(webpackConfig), extraConfig);
function makeWebpackPkg(config = webpackConfig) {
var cloned = _.cloneDeep(config)
if (!argv.sourceMaps) {
delete cloned.devtool;
}
Expand Down Expand Up @@ -446,7 +468,15 @@ function startLocalServer(options = {}) {
port: port,
host: INTEG_SERVER_HOST,
root: './',
livereload: options.livereload
livereload: options.livereload,
middleware: function () {
return [
function (req, res, next) {
res.setHeader('Ad-Auction-Allowed', 'True');
next();
}
];
}
});
}

Expand Down Expand Up @@ -487,26 +517,11 @@ gulp.task(escapePostbidConfig);
gulp.task('build-creative-dev', gulp.series(buildCreative(argv.creativeDev ? 'development' : 'production'), updateCreativeRenderers));
gulp.task('build-creative-prod', gulp.series(buildCreative(), updateCreativeRenderers));

gulp.task('build-bundle-dev', gulp.series('build-creative-dev', makeDevpackPkg, gulpBundle.bind(null, true)));
gulp.task('build-bundle-prod', gulp.series('build-creative-prod', makeWebpackPkg(), gulpBundle.bind(null, false)));
gulp.task('build-bundle-dev', gulp.series('build-creative-dev', makeDevpackPkg(standaloneDebuggingConfig), makeDevpackPkg(), gulpBundle.bind(null, true)));
gulp.task('build-bundle-prod', gulp.series('build-creative-prod', makeWebpackPkg(standaloneDebuggingConfig), makeWebpackPkg(), gulpBundle.bind(null, false)));
// build-bundle-verbose - prod bundle except names and comments are preserved. Use this to see the effects
// of dead code elimination.
gulp.task('build-bundle-verbose', gulp.series(makeWebpackPkg({
optimization: {
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
mangle: false,
format: {
comments: 'all'
}
},
extractComments: false,
}),
],
}
}), gulpBundle.bind(null, false)));
gulp.task('build-bundle-verbose', gulp.series('build-creative-dev', makeWebpackPkg(makeVerbose(standaloneDebuggingConfig)), makeWebpackPkg(makeVerbose()), gulpBundle.bind(null, true)));

// public tasks (dependencies are needed for each task since they can be ran on their own)
gulp.task('test-only', test);
Expand Down
8 changes: 7 additions & 1 deletion integrationExamples/gpt/adnuntius_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
bidder: 'adnuntius',
params: {
auId: "201208",
network: "adnuntius",
network: "1287",
bidType: 'netBid'
}
}]
Expand Down Expand Up @@ -50,6 +50,12 @@
}
});

pbjs.bidderSettings = {
standard: {
storageAllowed: true
}
};

pbjs.addAdUnits(adUnits);
pbjs.requestBids({bidsBackHandler: initAdserver});
});
Expand Down
112 changes: 112 additions & 0 deletions integrationExamples/gpt/anonymised_segments_example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<html>
<head>
<script async src="../../build/dev/prebid.js"></script>
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
var FAILSAFE_TIMEOUT = 3300;
var PREBID_TIMEOUT = 2000;

var adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
sizes: [[300, 250], [300,600]],
}
},
// Replace this object to test a new Adapter!
bids: [
{
bidder: 'pubmatic',
params: {
publisherId: '156276', // required
adSlot: 'pubmatic_test', // required
}
}
]
}];

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

</script>

<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function() {
googletag.pubads().disableInitialLoad();
});

pbjs.que.push(function() {
pbjs.setConfig({
debugging: {
enabled: true
},
ortb2: {
user: {
data: [
// Anonymised segment taxonomy inserted here
]
},
},
realTimeData: {
dataProviders: [
{
name: "anonymised",
params: {
cohortStorageKey: "cohort_ids",
bidders: ['smartadserver', 'appnexus'],
segtax: 1000
}
}
]
}
});
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: sendAdserverRequest,
timeout: PREBID_TIMEOUT
});

document.getElementById( "user-segments" ).innerHTML = JSON.stringify( pbjs.getConfig('ortb2') );
});

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();
}, FAILSAFE_TIMEOUT);

</script>

<script>
googletag.cmd.push(function () {
googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>

<script>!function(a){var e="https://s.go-mpulse.net/boomerang/",t="addEventListener";if("False"=="True")a.BOOMR_config=a.BOOMR_config||{},a.BOOMR_config.PageParams=a.BOOMR_config.PageParams||{},a.BOOMR_config.PageParams.pci=!0,e="https://s2.go-mpulse.net/boomerang/";if(window.BOOMR_API_key="5G3ZS-8L7PG-U23WM-5CA4K-LQ3YP",function(){function n(e){a.BOOMR_onload=e&&e.timeStamp||(new Date).getTime()}if(!a.BOOMR||!a.BOOMR.version&&!a.BOOMR.snippetExecuted){a.BOOMR=a.BOOMR||{},a.BOOMR.snippetExecuted=!0;var i,_,o,r=document.createElement("iframe");if(a[t])a[t]("load",n,!1);else if(a.attachEvent)a.attachEvent("onload",n);r.src="javascript:void(0)",r.title="",r.role="presentation",(r.frameElement||r).style.cssText="width:0;height:0;border:0;display:none;",o=document.getElementsByTagName("script")[0],o.parentNode.insertBefore(r,o);try{_=r.contentWindow.document}catch(O){i=document.domain,r.src="javascript:var d=document.open();d.domain='"+i+"';void(0);",_=r.contentWindow.document}_.open()._l=function(){var a=this.createElement("script");if(i)this.domain=i;a.id="boomr-if-as",a.src=e+"5G3ZS-8L7PG-U23WM-5CA4K-LQ3YP",BOOMR_lstart=(new Date).getTime(),this.body.appendChild(a)},_.write("<bo"+'dy onload="document._l();">'),_.close()}}(),"".length>0)if(a&&"performance"in a&&a.performance&&"function"==typeof a.performance.setResourceTimingBufferSize)a.performance.setResourceTimingBufferSize();!function(){if(BOOMR=a.BOOMR||{},BOOMR.plugins=BOOMR.plugins||{},!BOOMR.plugins.AK){var e=""=="true"?1:0,t="",n="ghh4w4yxem66iyi6ijxa-f-a8f1ed317-clientnsv4-s.akamaihd.net",i="false"=="true"?2:1,_={"ak.v":"32","ak.cp":"540505","ak.ai":parseInt("351538",10),"ak.ol":"0","ak.cr":17,"ak.ipv":4,"ak.proto":"http/1.1","ak.rid":"322de403","ak.r":36326,"ak.a2":e,"ak.m":"dscx","ak.n":"essl","ak.bpcip":"49.207.203.0","ak.cport":5172,"ak.gh":"23.47.149.85","ak.quicv":"","ak.tlsv":"tls1.2","ak.0rtt":"","ak.csrc":"-","ak.acc":"bbr","ak.t":"1629373038","ak.ak":"hOBiQwZUYzCg5VSAfCLimQ==admFPBlxVf0VKeanKFKUThzq+or23aIaVFP5DBXpeOGEuvD5mQz0UZbvK242Y8cupS91bsNaM7uJT3/O00EszGTxlFhkv439YkTWfyegvqVlJhcrZ7jcRkIoyrmjoBqDZoF0WaG4rhwmNzkKEv6T1noRYwEWwRHOG8p7osPXWy5as6KkmhOYUiYk8S5hQj+HFzhYI5YUTx+8urmHdpVIDBkramcrT2V89mb0cH5L2bSGS2hahAA3Kkf+0Dul7r5hDFQaVTf17e4oKdM1G8cKVF5LGRxRl3v4Rn6tBJ+fjrJ7XYQWV30w1LPwcAmSfRX8iTCK4xzHwG1fwDFHb5tWVsxHeEkRgNN3/KhnrCjxKtaROjJeWypJf/rjn1HWHwy7uVVsP9f/HRN3drCCkEvJBmu6yi0jzFFCoeEkbUEoq+8=","ak.pv":"396","ak.dpoabenc":"","ak.tf":i};if(""!==t)_["ak.ruds"]=t;var o={i:!1,av:function(e){var t="http.initiator";if(e&&(!e[t]||"spa_hard"===e[t]))_["ak.feo"]=void 0!==a.aFeoApplied?1:0,BOOMR.addVar(_)},rv:function(){var a=["ak.bpcip","ak.cport","ak.cr","ak.csrc","ak.gh","ak.ipv","ak.m","ak.n","ak.ol","ak.proto","ak.quicv","ak.tlsv","ak.0rtt","ak.r","ak.acc","ak.t","ak.tf"];BOOMR.removeVar(a)}};BOOMR.plugins.AK={akVars:_,akDNSPreFetchDomain:n,init:function(){if(!o.i){var a=BOOMR.subscribe;a("before_beacon",o.av,null,null),a("onbeacon",o.rv,null,null),o.i=!0}return this},is_complete:function(){return!0}}}}()}(window);</script></head>

<body>
<h2>Prebid.js Test</h2>
<h5>Div-1</h5>
<div id='div-gpt-ad-1460505748561-0'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1460505748561-0'); });
</script>
</div>
<h5>First Party Data (ortb2) Sent to Bidding Adapter</h5>
<div id="user-segments"></div>
</body>
</html>
6 changes: 3 additions & 3 deletions integrationExamples/gpt/azerionedgeRtdProvider_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@
{
name: "azerionedge",
waitForIt: true,
params: { bidders: ["appnexus"] },
params: { bidders: ["improvedigital"] },
},
],
},
});
pbjs.setBidderConfig({ bidders: ["appnexus"], config: {} });
pbjs.setBidderConfig({ bidders: ["improvedigital"], config: {} });
pbjs.addAdUnits([
{
code: TEST_DIV,
mediaTypes: { banner: { sizes: TEST_SIZES } },
bids: [{ bidder: "appnexus", params: { placementId: 13144370 } }],
bids: [{ bidder: "improvedigital", params: { placementId: 13144370 } }],
},
]);
pbjs.requestBids({
Expand Down
Loading

0 comments on commit b746640

Please sign in to comment.