Skip to content

Commit

Permalink
Merge pull request #24 from prebid/master
Browse files Browse the repository at this point in the history
Rebase off master prebid
  • Loading branch information
idettman authored Jun 26, 2018
2 parents d9032d2 + 0c4b815 commit 587ae69
Show file tree
Hide file tree
Showing 58 changed files with 1,648 additions and 524 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ When you are adding code to Prebid.js, or modifying code that isn't covered by a
Prebid.js already has many tests. Read them to see how Prebid.js is tested, and for inspiration:

- Look in `test/spec` and its subdirectories
- Tests for bidder adaptors are located in `test/spec/adapters`
- Tests for bidder adaptors are located in `test/spec/modules`

A test module might have the following general structure:

Expand Down
16 changes: 16 additions & 0 deletions RELEASE_SCHEDULE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
**Table of Contents**
- [Release Schedule](#release-schedule)
- [Release Process](#release-process)
- [Beta Releases](#beta-releases)
- [FAQs](#faqs)

## Release Schedule
Expand Down Expand Up @@ -91,6 +92,21 @@ Announcements regarding releases will be made to the #headerbidding-dev channel
git push
```

## Beta Releases

Prebid.js features may be released as Beta or as Generally Available (GA).

Characteristics of a `Beta` release:
- May be a partial implementation (e.g. more work needed to flesh out the feature)
- May not be fully tested with other features
- Limited documentation, focused on technical aspects
- Few users

Characteristics of a `GA` release:
- Complete set of functionality
- Significant user base with no major issues for at least a month
- Decent documentation that includes business need, use cases, and examples


## FAQs

Expand Down
16 changes: 0 additions & 16 deletions browsers.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,5 @@
"browser_version": "8.0",
"device": null,
"os": "OS X"
},
"bs_ios_9": {
"base": "BrowserStack",
"os": "ios",
"os_version": "9.1",
"browser": "iphone",
"device": "iPhone 6S",
"browser_version": null
},
"bs_ios_8": {
"base": "BrowserStack",
"os": "ios",
"os_version": "8.3",
"browser": "iphone",
"device": "iPhone 6",
"browser_version": null
}
}
7 changes: 7 additions & 0 deletions integrationExamples/gpt/pbjs_example_gpt.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@
placement_id: 0
}
},
{
bidder: 'weborama',
params: {
placementId: 0,
traffic: 'banner'
}
},
{
bidder: 'pollux',
params: {
Expand Down
2 changes: 1 addition & 1 deletion modules/admixerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const spec = {
buildRequests: function (bidderRequest) {
const payload = {
imps: [],
referrer: utils.getTopWindowUrl(),
referrer: encodeURIComponent(utils.getTopWindowUrl()),
};
bidderRequest.forEach((bid) => {
if (bid.bidder === BIDDER_CODE) {
Expand Down
2 changes: 1 addition & 1 deletion modules/adyoulikeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const spec = {

const data = JSON.stringify(payload);
const options = {
withCredentials: false
withCredentials: true
};

return {
Expand Down
8 changes: 6 additions & 2 deletions modules/audienceNetworkBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const url = 'https://an.facebook.com/v2/placementbid.json';
const supportedMediaTypes = ['banner', 'video'];
const netRevenue = true;
const hb_bidder = 'fan';
const pbv = '$prebid.version$';
const platver = '$prebid.version$';
const platform = '241394079772386';
const adapterver = '1.0.0';

/**
* Does this bid request contain valid parameters?
Expand Down Expand Up @@ -166,7 +168,9 @@ const buildRequests = bids => {
testmode,
pageurl,
sdk,
pbv
adapterver,
platform,
platver
};
const video = findIndex(adformats, isVideo);
if (video !== -1) {
Expand Down
71 changes: 54 additions & 17 deletions modules/beachfrontBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { VIDEO, BANNER } from 'src/mediaTypes';
import find from 'core-js/library/fn/array/find';
import includes from 'core-js/library/fn/array/includes';

const ADAPTER_VERSION = '1.1';
const ADAPTER_VERSION = '1.2';
const ADAPTER_NAME = 'BFIO_PREBID';
const OUTSTREAM = 'outstream';

Expand All @@ -16,6 +16,8 @@ export const OUTSTREAM_SRC = '//player-cdn.beachfrontmedia.com/playerapi/loader/
export const VIDEO_TARGETING = ['mimes'];
export const DEFAULT_MIMES = ['video/mp4', 'application/javascript'];

let appId = '';

export const spec = {
code: 'beachfront',
supportedMediaTypes: [ VIDEO, BANNER ],
Expand All @@ -29,14 +31,16 @@ export const spec = {
let videoBids = bids.filter(bid => isVideoBidValid(bid));
let bannerBids = bids.filter(bid => isBannerBidValid(bid));
videoBids.forEach(bid => {
appId = getVideoBidParam(bid, 'appId');
requests.push({
method: 'POST',
url: VIDEO_ENDPOINT + getVideoBidParam(bid, 'appId'),
url: VIDEO_ENDPOINT + appId,
data: createVideoRequestData(bid, bidderRequest),
bidRequest: bid
});
});
if (bannerBids.length) {
appId = getBannerBidParam(bannerBids[0], 'appId');
requests.push({
method: 'POST',
url: BANNER_ENDPOINT,
Expand Down Expand Up @@ -77,23 +81,56 @@ export const spec = {
utils.logWarn(`No valid banner bids from ${spec.code} bidder`);
return [];
}
return response.map((bid) => {
let request = find(bidRequest, req => req.adUnitCode === bid.slot);
return {
requestId: request.bidId,
bidderCode: spec.code,
ad: bid.adm,
creativeId: bid.crid,
cpm: bid.price,
width: bid.w,
height: bid.h,
mediaType: BANNER,
currency: 'USD',
netRevenue: true,
ttl: 300
};
return response
.filter(bid => bid.adm)
.map((bid) => {
let request = find(bidRequest, req => req.adUnitCode === bid.slot);
return {
requestId: request.bidId,
bidderCode: spec.code,
ad: bid.adm,
creativeId: bid.crid,
cpm: bid.price,
width: bid.w,
height: bid.h,
mediaType: BANNER,
currency: 'USD',
netRevenue: true,
ttl: 300
};
});
}
},

getUserSyncs(syncOptions, serverResponses = [], gdprConsent = {}) {
let syncs = [];
let { gdprApplies, consentString } = gdprConsent;
let bannerResponse = find(serverResponses, (res) => utils.isArray(res.body));

if (bannerResponse) {
if (syncOptions.iframeEnabled) {
bannerResponse.body
.filter(bid => bid.sync)
.forEach(bid => {
syncs.push({
type: 'iframe',
url: bid.sync
});
});
}
} else if (syncOptions.iframeEnabled) {
syncs.push({
type: 'iframe',
url: `//sync.bfmio.com/sync_iframe?ifg=1&id=${appId}&gdpr=${gdprApplies ? 1 : 0}&gc=${consentString || ''}&gce=1`
});
} else if (syncOptions.pixelEnabled) {
syncs.push({
type: 'image',
url: `//sync.bfmio.com/syncb?pid=144&id=${appId}&gdpr=${gdprApplies ? 1 : 0}&gc=${consentString || ''}&gce=1`
});
}

return syncs;
}
};

Expand Down
2 changes: 1 addition & 1 deletion modules/beachfrontBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Module that connects to Beachfront's demand sources
code: 'test-video-banner',
mediaTypes: {
video: {
context: 'instream',
context: 'outstream',
playerSize: [ 640, 360 ]
},
banner: {
Expand Down
36 changes: 21 additions & 15 deletions modules/consentManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) {
f = f.parent;
}

if (!cmpFrame) {
return cmpError('CMP not found.', hookConfig);
}

callCmpWhileInIframe('getConsentData', cmpFrame, callbackHandler.consentDataCallback);
callCmpWhileInIframe('getVendorConsents', cmpFrame, callbackHandler.vendorConsentsCallback);
}
Expand Down Expand Up @@ -124,12 +128,6 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) {
/* 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) {
if (!cmpFrame) {
removePostMessageListener();

let errmsg = 'CMP not found';
return cmpError(errmsg, hookConfig);
}
let callId = Math.random() + '';
let msg = {__cmpCall: {
command: cmd,
Expand Down Expand Up @@ -219,11 +217,17 @@ export function requestBidsHook(reqBidsConfigObj, fn) {
* @param {object} hookConfig contains module related variables (see comment in requestBidsHook function)
*/
function processCmpData(consentObject, hookConfig) {
let gdprApplies = consentObject && consentObject.getConsentData && consentObject.getConsentData.gdprApplies;
if (
!utils.isPlainObject(consentObject) ||
(!utils.isPlainObject(consentObject.getVendorConsents) || Object.keys(consentObject.getVendorConsents).length === 0) ||
(!utils.isPlainObject(consentObject.getConsentData) || Object.keys(consentObject.getConsentData).length === 0)) {
cmpFailed(`CMP returned unexpected value during lookup process; returned value was (${consentObject}).`, hookConfig);
(typeof gdprApplies !== 'boolean') ||
(gdprApplies === true &&
!(utils.isStr(consentObject.getConsentData.consentData) &&
utils.isPlainObject(consentObject.getVendorConsents) &&
Object.keys(consentObject.getVendorConsents).length > 1
)
)
) {
cmpFailed(`CMP returned unexpected value during lookup process.`, hookConfig, consentObject);
} else {
clearTimeout(hookConfig.timer);
storeConsentData(consentObject);
Expand All @@ -243,15 +247,16 @@ function cmpTimedOut(hookConfig) {
* This function contains the controlled steps to perform when there's a problem with CMP.
* @param {string} errMsg required; should be a short descriptive message for why the failure/issue happened.
* @param {object} hookConfig contains module related variables (see comment in requestBidsHook function)
* @param {object} extraArgs contains additional data that's passed along in the error/warning messages for easier debugging
*/
function cmpFailed(errMsg, hookConfig) {
function cmpFailed(errMsg, hookConfig, extraArgs) {
clearTimeout(hookConfig.timer);

// still set the consentData to undefined when there is a problem as per config options
if (allowAuction) {
storeConsentData(undefined);
}
exitModule(errMsg, hookConfig);
exitModule(errMsg, hookConfig, extraArgs);
}

/**
Expand Down Expand Up @@ -282,8 +287,9 @@ function storeConsentData(cmpConsentObject) {
* 3. bad exit with auction canceled (error message is logged).
* @param {string} errMsg optional; only to be used when there was a 'bad' exit. String is a descriptive message for the failure/issue encountered.
* @param {object} hookConfig contains module related variables (see comment in requestBidsHook function)
* @param {object} extraArgs contains additional data that's passed along in the error/warning messages for easier debugging
*/
function exitModule(errMsg, hookConfig) {
function exitModule(errMsg, hookConfig, extraArgs) {
if (hookConfig.haveExited === false) {
hookConfig.haveExited = true;

Expand All @@ -293,10 +299,10 @@ function exitModule(errMsg, hookConfig) {

if (errMsg) {
if (allowAuction) {
utils.logWarn(errMsg + ' Resuming auction without consent data as per consentManagement config.');
utils.logWarn(errMsg + ' Resuming auction without consent data as per consentManagement config.', extraArgs);
nextFn.apply(context, args);
} else {
utils.logError(errMsg + ' Canceling auction as per consentManagement config.');
utils.logError(errMsg + ' Canceling auction as per consentManagement config.', extraArgs);
if (typeof hookConfig.bidsBackHandler === 'function') {
hookConfig.bidsBackHandler();
} else {
Expand Down
16 changes: 16 additions & 0 deletions modules/eplanningBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ export const spec = {
isBidRequestValid: function(bid) {
return Boolean(bid.params.ci) || Boolean(bid.params.t);
},

buildRequests: function(bidRequests) {
const method = 'GET';
const dfpClientId = '1';
const sec = 'ROS';
let url;
let params;
const urlConfig = getUrlConfig(bidRequests);
const pcrs = getCharset();

if (urlConfig.t) {
url = urlConfig.isv + '/layers/t_pbjs_2.json';
Expand All @@ -40,6 +42,11 @@ export const spec = {
pbv: '$prebid.version$',
ncb: '1'
};

if (pcrs) {
params.crs = pcrs;
}

if (referrerUrl) {
params.fr = referrerUrl;
}
Expand Down Expand Up @@ -147,6 +154,15 @@ function getSpacesString(bids) {

return spacesString;
}

function getCharset() {
try {
return window.top.document.charset || window.top.document.characterSet;
} catch (e) {
return document.charset || document.characterSet;
}
}

function getBidIdMap(bidRequests) {
let map = {};
bidRequests.forEach(bid => map[cleanName(bid.adUnitCode)] = bid.bidId);
Expand Down
3 changes: 2 additions & 1 deletion modules/googleAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ function sendBidTimeouts(timedOutBidders) {
_analyticsQueue.push(function () {
utils._each(timedOutBidders, function (bidderCode) {
_eventCount++;
window[_gaGlobal](_trackerSend, 'event', _category, 'Timeouts', bidderCode, _disableInteraction);
var bidderName = bidderCode.bidder;
window[_gaGlobal](_trackerSend, 'event', _category, 'Timeouts', bidderName, _disableInteraction);
});
});

Expand Down
2 changes: 1 addition & 1 deletion modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const spec = {
return false;
}

if (typeof bid.params.siteId !== 'string') {
if (typeof bid.params.siteId !== 'string' && typeof bid.params.siteId !== 'number') {
return false;
}

Expand Down
Loading

0 comments on commit 587ae69

Please sign in to comment.