Skip to content

Commit

Permalink
Merge pull request #3 from prebid/master
Browse files Browse the repository at this point in the history
Update sspbc-adapter branch
  • Loading branch information
wojciech-bialy-wpm authored Aug 24, 2020
2 parents 72269fd + 32066aa commit e87dd78
Show file tree
Hide file tree
Showing 46 changed files with 3,830 additions and 655 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ master branch.
Pull requests must have 80% code coverage before beign considered for merge.
Additional details about the process can be found [here](./PR_REVIEW.md).

There are more details available if you'd like to contribute a [bid adapter](https://docs.prebid.org/dev-docs/bidder-adaptor.html) or [analytics adapter](https://docs.prebid.org/dev-docs/integrate-with-the-prebid-analytics-api.html).

## Issues
[prebid.org](http://prebid.org/) contains documentation that may help answer questions you have about using Prebid.js.
If you can't find the answer there, try searching for a similar issue on the [issues page](https://github.com/prebid/Prebid.js/issues).
Expand Down
23 changes: 11 additions & 12 deletions PR_REVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For modules and core platform updates, the initial reviewer should request an ad
- Review for obvious errors or bad coding practice / use best judgement here.
- If the change is a new feature / change to core prebid.js - review the change with a Tech Lead on the project and make sure they agree with the nature of change.
- If the change results in needing updates to docs (such as public API change, module interface etc), add a label for "needs docs" and inform the submitter they must submit a docs PR to update the appropriate area of Prebid.org **before the PR can merge**. Help them with finding where the docs are located on prebid.org if needed.
- Below are some examples of bidder specific updates that should require docs update (in their dev-docs/bidders/bidder.md file):
- Below are some examples of bidder specific updates that should require docs update (in their dev-docs/bidders/BIDDER.md file):
- If they support the GDPR consentManagement module and TCF1, add `gdpr_supported: true`
- If they support the GDPR consentManagement module and TCF2, add `tcf2_supported: true`
- If they support the US Privacy consentManagementUsp module, add `usp_supported: true`
Expand All @@ -23,7 +23,7 @@ For modules and core platform updates, the initial reviewer should request an ad
- If they support COPPA, add `coppa_supported: true`
- If they support SChain, add `schain_supported: true`
- If their bidder doesn't work well with safeframed creatives, add `safeframes_ok: false`. This will alert publishers to not use safeframed creatives when creating the ad server entries for their bidder.
- If they're a member of Prebid.org, add `prebid_member: true`
- If they're setting a deal ID in some scenarios, add `bidder_supports_deals: true`
- If all above is good, add a `LGTM` comment and request 1 additional core member to review.
- Once there is 2 `LGTM` on the PR, merge to master
- Ask the submitter to add a PR for documentation if applicable.
Expand All @@ -34,18 +34,17 @@ For modules and core platform updates, the initial reviewer should request an ad
- Follow steps above for general review process. In addition, please verify the following:
- Verify that bidder has submitted valid bid params and that bids are being received.
- Verify that bidder is not manipulating the prebid.js auction in any way or doing things that go against the principles of the project. If unsure check with the Tech Lead.
- Verify that the bidder is being as efficient as possible, ideally not loading an external library, however if they do load a library it should be cached.
- Verify that code re-use is being done properly and that changes introduced by a bidder don't impact other bidders.
- If the adapter being submitted is an alias type, check with the bidder contact that is being aliased to make sure it's allowed.
- If the adapter is triggering any user syncs make sure they are using the user sync module in the Prebid.js core.
- Requests to the bidder should support HTTPS
- Responses from the bidder should be compressed (such as gzip, compress, deflate)
- Bid responses may not use JSONP: All requests must be AJAX with JSON responses
- Video openrtb params should be read from the ad unit when available; however bidder config can override the ad unit.
- All user-sync (aka pixel) activity must be registered via the provided functions
- Adapters may not use the $$PREBID_GLOBAL$$ variable
- All adapters must support the creation of multiple concurrent instances. This means, for example, that adapters cannot rely on mutable global variables.
- Adapters may not globally override or default the standard ad server targeting values: hb_adid, hb_bidder, hb_pb, hb_deal, or hb_size, hb_source, hb_format.
- All required global and bidder-adapter rules defined in the [Module Rules](https://docs.prebid.org/dev-docs/module-rules.html) must be followed. Please review these rules often - we depend on reviewers to enforce them.
- All bidder parameter conventions must be followed:
- Video params must be read from AdUnit.mediaTypes.video when available; however bidder config can override the ad unit.
- First party data must be read from [`fpd.context` and `fpd.user`](https://docs.prebid.org/dev-docs/publisher-api-reference.html#setConfig-fpd).
- Adapters that accept a floor parameter must also support the [floors module](https://docs.prebid.org/dev-docs/modules/floors.html) -- look for a call to the `getFloors()` function.
- Adapters cannot accept an schain parameter. Rather, they must look for the schain parameter at bidRequest.schain.
- The bidRequest page referrer must checked in addition to any bidder-specific parameter.
- If they're getting the COPPA flag, it must come from config.getConfig('coppa');

- After a new adapter is approved, let the submitter know they may open a PR in the [headerbid-expert repository](https://github.com/prebid/headerbid-expert) to have their adapter recognized by the [Headerbid Expert extension](https://chrome.google.com/webstore/detail/headerbid-expert/cgfkddgbnfplidghapbbnngaogeldmop). The PR should be to the [bidder patterns file](https://github.com/prebid/headerbid-expert/blob/master/bidderPatterns.js), adding an entry with their adapter's name and the url the adapter uses to send and receive bid responses.

## Ticket Coordinator
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,15 @@ As you make code changes, the bundles will be rebuilt and the page reloaded auto

## Contribute

Many SSPs, bidders, and publishers have contributed to this project. [60+ Bidders](https://github.com/prebid/Prebid.js/tree/master/src/adapters) are supported by Prebid.js.
Many SSPs, bidders, and publishers have contributed to this project. [Hundreds of bidders](https://github.com/prebid/Prebid.js/tree/master/src/adapters) are supported by Prebid.js.

For guidelines, see [Contributing](./CONTRIBUTING.md).

Our PR review process can be found [here](https://github.com/prebid/Prebid.js/tree/master/PR_REVIEW.md).

### Add a Bidder Adapter

To add a bidder adapter module, see the instructions in [How to add a bidder adaptor](http://prebid.org/dev-docs/bidder-adaptor.html).

Please **do NOT load Prebid.js inside your adapter**. If you do this, we will reject or remove your adapter as appropriate.
To add a bidder adapter module, see the instructions in [How to add a bidder adapter](https://docs.prebid.org/dev-docs/bidder-adaptor.html).

### Code Quality

Expand Down
98 changes: 98 additions & 0 deletions integrationExamples/gpt/jwplayerRtdProvider_example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script async src="../../build/dev/prebid.js"></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<meta charset="UTF-8">
<title>JW Player RTD Provider Example</title>
<script>
var FAILSAFE_TIMEOUT = 3300;
var PREBID_TIMEOUT = 1000;

var adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
jwTargeting: {
playerID: '123',
mediaID: 'abc'
},
mediaTypes: {
banner: {
sizes: [[300, 250], [300,600]],
}
},
// Replace this object to test a new Adapter!
bids: [{
bidder: 'appnexus',
params: {
placementId: 13144370
}
}]

}];

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({
realTimeData: {
dataProviders: [{
name: "jwplayer",
params: {
mediaIDs: ['abc', 'def', 'ghi', 'jkl']
}
}]
}
});
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: sendAdserverRequest,
timeout: PREBID_TIMEOUT
});
});

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>
</head>

<body>
<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>
</body>
</html>
6 changes: 4 additions & 2 deletions modules/.submodules.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
"criteoIdSystem",
"netIdSystem",
"identityLinkIdSystem",
"sharedIdSystem"
"sharedIdSystem",
"intentIqIdSystem"
],
"adpod": [
"freeWheelAdserverVideo",
"dfpAdServerVideo"
],
"rtdModule": [
"browsiRtdProvider"
"browsiRtdProvider",
"jwplayerRtdProvider"
]
}
17 changes: 11 additions & 6 deletions modules/adheseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';

const BIDDER_CODE = 'adhese';
const GVLID = 553;
const USER_SYNC_BASE_URL = 'https://user-sync.adhese.com/iframe/user_sync.html';

export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
supportedMediaTypes: [BANNER, VIDEO],

isBidRequestValid: function(bid) {
Expand Down Expand Up @@ -112,12 +114,15 @@ function mergeTargets(targets, target) {
if (target) {
Object.keys(target).forEach(function (key) {
const val = target[key];
const values = Array.isArray(val) ? val : [val];
if (targets[key]) {
const distinctValues = values.filter(v => targets[key].indexOf(v) < 0);
targets[key].push.apply(targets[key], distinctValues);
} else {
targets[key] = values;
const dirtyValues = Array.isArray(val) ? val : [val];
const values = dirtyValues.filter(v => v === 0 || v);
if (values.length > 0) {
if (targets[key]) {
const distinctValues = values.filter(v => targets[key].indexOf(v) < 0);
targets[key].push.apply(targets[key], distinctValues);
} else {
targets[key] = values;
}
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion modules/aniviewBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function getUserSyncs(syncOptions, serverResponses) {

export const spec = {
code: BIDDER_CODE,
aliases: ['selectmediavideo'],
aliases: ['avantisvideo', 'selectmediavideo'],
supportedMediaTypes: [VIDEO],
isBidRequestValid,
buildRequests,
Expand Down
32 changes: 20 additions & 12 deletions modules/browsiRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ let _moduleParams = {};
let _data = null;
/** @type {null | function} */
let _dataReadyCallback = null;
/** @type {string} */
const DEF_KEYNAME = 'browsiViewability';

/**
* add browsi script to page
Expand Down Expand Up @@ -117,16 +119,14 @@ function waitForData(callback) {
function sendDataToModule(adUnits, onDone) {
try {
waitForData(_predictionsData => {
const _predictions = _predictionsData.p;
if (!_predictions || !Object.keys(_predictions).length) {
return onDone({});
}
const _predictions = _predictionsData.p || {};
let dataToReturn = adUnits.reduce((rp, cau) => {
const adUnitCode = cau && cau.code;
if (!adUnitCode) { return rp }
const adSlot = getSlotByCode(adUnitCode);
const identifier = adSlot ? getMacroId(_predictionsData.pmd, adSlot) : adUnitCode;
const predictionData = _predictions[identifier];
rp[adUnitCode] = getKVObject(-1, _predictionsData.kn);
if (!predictionData) { return rp }

if (predictionData.p) {
Expand Down Expand Up @@ -160,7 +160,7 @@ function getAllSlots() {
function getKVObject(p, keyName) {
const prValue = p < 0 ? 'NA' : (Math.floor(p * 10) / 10).toFixed(2);
let prObject = {};
prObject[((_moduleParams['keyName'] || keyName).toString())] = prValue.toString();
prObject[((_moduleParams['keyName'] || keyName || DEF_KEYNAME).toString())] = prValue.toString();
return prObject;
}
/**
Expand Down Expand Up @@ -231,7 +231,7 @@ function evaluate(macro, divId, adUnit, replacer) {
* @param {string} url server url with query params
*/
function getPredictionsFromServer(url) {
let ajax = ajaxBuilder(_moduleParams.auctionDelay || _moduleParams.timeout || DEF_TIMEOUT);
let ajax = ajaxBuilder(_moduleParams.auctionDelay || _moduleParams.timeout);

ajax(url,
{
Expand Down Expand Up @@ -286,27 +286,35 @@ export const browsiSubmodule = {
* @param {adUnit[]} adUnits
* @param {function} onDone
*/
getData: sendDataToModule
getData: sendDataToModule,
init: init
};

export function init(config) {
function init(config, gdpr, usp) {
return true;
}

export function beforeInit(config) {
const confListener = config.getConfig(MODULE_NAME, ({realTimeData}) => {
try {
_moduleParams = realTimeData.dataProviders && realTimeData.dataProviders.filter(
pr => pr.name && pr.name.toLowerCase() === 'browsi')[0].params;
confListener();
_moduleParams.auctionDelay = realTimeData.auctionDelay;
_moduleParams.timeout = realTimeData.timeout;
_moduleParams.timeout = realTimeData.timeout || DEF_TIMEOUT;
} catch (e) {
_moduleParams = {};
}
if (_moduleParams.siteKey && _moduleParams.pubKey && _moduleParams.url) {
confListener();
collectData();
} else {
utils.logError('missing params for Browsi provider');
}
});
}

submodule('realTimeData', browsiSubmodule);
init(config);
function registerSubModule() {
submodule('realTimeData', browsiSubmodule);
}
registerSubModule();
beforeInit(config);
Loading

0 comments on commit e87dd78

Please sign in to comment.