Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3648 prebidjs pxyz adapter #3

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
907becf
Merge branch 'master' of https://github.com/prebid/Prebid.js into 364…
LucaConfa May 10, 2018
4f3cd90
Merge branch 'master' of https://github.com/prebid/Prebid.js into 364…
LucaConfa May 10, 2018
77214e0
add playground adapters
LucaConfa May 12, 2018
43143fd
Merge branch 'master' of https://github.com/prebid/Prebid.js into 364…
LucaConfa May 13, 2018
bf2eda5
clean up
LucaConfa May 14, 2018
745620f
add test file clean up adapter by removing native referecnes
LucaConfa May 14, 2018
5449653
test file
LucaConfa May 14, 2018
cdcd95a
replace appnexus with playground reference in error logs
LucaConfa May 14, 2018
958b55a
remove commented code
LucaConfa May 14, 2018
1fd3e6c
Merge branch 'master' of github.com:playground-xyz/Prebid.js into 364…
LucaConfa May 14, 2018
8aea0fa
change key in response object from appnexus to playgroundxyz
LucaConfa May 14, 2018
c4645d2
change tests so we test for ordering by cpm as well
LucaConfa May 14, 2018
1f2a7fb
Add 1024x768 (size_id = 53) in sizeMap (#2527)
hdeodhar May 14, 2018
119e590
Aardvark v1.0 (#2507)
dejanstrbac May 14, 2018
c5a3d12
Show only summary and errors (#2514)
jaiminpanchal27 May 14, 2018
ab5ca4d
added gdpr support to userSync in rubicon adapter (#2531)
idettman May 14, 2018
6785bc5
fixed bug when latitute/longitue are not provided (#2533)
harpere May 15, 2018
2607bcc
change AppNexus endpoint to use ORTB (#2532)
mkendall07 May 15, 2018
735bf76
-GDPR support added in media net bidder (#2538)
vedantseta May 15, 2018
6bfed30
Lifestreet: gdpr and consent string parameters (#2537)
Lifestreet May 15, 2018
3436a13
Create GXOne Bid Adapter and tests for it (#2540)
GeronimoGXOne May 15, 2018
27dca0f
PubMatic Adapter: Bug fix to read all bids from seatBid array (#2520)
PubMatic-OpenWrap May 15, 2018
7848901
fix getPreparedBidForAuction to look for renderer on correct bid (#2505)
kitwestneat May 15, 2018
b746bf1
Smart: GDPR support (#2528)
ytyukhnin May 15, 2018
07e711c
add support for safeframe workflow and new utils method to read aduni…
jsnellbaker May 15, 2018
e610247
GDPR - add consent information to PBS cookie_sync request (#2530)
jsnellbaker May 15, 2018
103c015
replace find reference with imported version (#2542)
jsnellbaker May 15, 2018
849fdf1
Prebid 1.11.0 release
jsnellbaker May 15, 2018
4be6420
increment prebid version
jsnellbaker May 15, 2018
6fd8600
dont drop other bids, just set cpm to 0 and send it through
LucaConfa May 16, 2018
2347af2
clean up
LucaConfa May 16, 2018
7f4a307
Merge branch 'master' of https://github.com/prebid/Prebid.js into 364…
LucaConfa May 16, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var port = 9999;
// Tasks
gulp.task('default', ['webpack']);

gulp.task('serve', ['lint', 'build-bundle-dev', 'watch', 'test']);
gulp.task('serve', ['build-bundle-dev', 'watch']);

gulp.task('serve-nw', ['lint', 'watch', 'e2etest']);

Expand All @@ -49,8 +49,8 @@ gulp.task('build', ['build-bundle-prod']);

gulp.task('clean', function () {
return gulp.src(['build'], {
read: false
})
read: false
})
.pipe(clean());
});

Expand Down Expand Up @@ -78,13 +78,13 @@ var explicitModules = [

function bundle(dev, moduleArr) {
var modules = moduleArr || helpers.getArgModules(),
allModules = helpers.getModuleNames(modules);
allModules = helpers.getModuleNames(modules);

if(modules.length === 0) {
if (modules.length === 0) {
modules = allModules.filter(module => !explicitModules.includes(module));
} else {
var diff = _.difference(modules, allModules);
if(diff.length !== 0) {
if (diff.length !== 0) {
throw new gutil.PluginError({
plugin: 'bundle',
message: 'invalid modules: ' + diff.join(', ')
Expand All @@ -106,13 +106,13 @@ function bundle(dev, moduleArr) {
gutil.log('Generating bundle:', outputFileName);

return gulp.src(
entries
)
entries
)
.pipe(gulpif(dev, sourcemaps.init({loadMaps: true})))
.pipe(concat(outputFileName))
.pipe(gulpif(!argv.manualEnable, footer('\n<%= global %>.processQueue();', {
global: prebid.globalVarName
}
global: prebid.globalVarName
}
)))
.pipe(gulpif(dev, sourcemaps.write('.')));
}
Expand Down Expand Up @@ -229,11 +229,11 @@ gulp.task('watch', function () {
'modules/**/*.js',
'test/spec/**/*.js',
'!test/spec/loaders/**/*.js'
], ['lint', 'build-bundle-dev', 'test']);
], ['build-bundle-dev']);
gulp.watch([
'loaders/**/*.js',
'test/spec/loaders/**/*.js'
], ['lint']);
], []);
connect.server({
https: argv.https,
port: port,
Expand Down Expand Up @@ -264,7 +264,7 @@ gulp.task('docs', ['clean-docs'], function () {

gulp.task('e2etest', ['devpack', 'webpack'], function() {
var cmdQueue = [];
if(argv.browserstack) {
if (argv.browserstack) {
var browsers = require('./browsers.json');
delete browsers['bs_ie_9_windows_7'];

Expand All @@ -276,11 +276,11 @@ gulp.task('e2etest', ['devpack', 'webpack'], function() {

var startWith = 'bs';

Object.keys(browsers).filter(function(v){
Object.keys(browsers).filter(function(v) {
return v.substring(0, startWith.length) === startWith && browsers[v].browser !== 'iphone';
}).map(function(v,i,arr) {
var newArr = (i%2 === 0) ? arr.slice(i,i+2) : null;
if(newArr) {
}).map(function(v, i, arr) {
var newArr = (i % 2 === 0) ? arr.slice(i, i + 2) : null;
if (newArr) {
var cmd = 'nightwatch --env ' + newArr.join(',') + cmdStr;
cmdQueue.push(cmd);
}
Expand Down
3 changes: 2 additions & 1 deletion karma.conf.maker.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ module.exports = function(codeCoverage, browserstack, watchMode, file) {

reporters: ['mocha'],
mochaReporter: {
showDiff: true
showDiff: true,
output: 'minimal'
},

// Continuous Integration mode
Expand Down
159 changes: 159 additions & 0 deletions modules/aardvarkBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import * as utils from 'src/utils';
import {registerBidder} from 'src/adapters/bidderFactory';

const BIDDER_CODE = 'aardvark';
const DEFAULT_ENDPOINT = 'bidder.rtk.io';
const SYNC_ENDPOINT = 'sync.rtk.io';
const AARDVARK_TTL = 300;
const AARDVARK_CURRENCY = 'USD';

let hasSynced = false;

export function resetUserSync() {
hasSynced = false;
}

export const spec = {
code: BIDDER_CODE,

isBidRequestValid: function(bid) {
return ((typeof bid.params.ai === 'string') && !!bid.params.ai.length &&
(typeof bid.params.sc === 'string') && !!bid.params.sc.length);
},

buildRequests: function(validBidRequests, bidderRequest) {
var auctionCodes = [];
var requests = [];
var requestsMap = {};
var referer = utils.getTopWindowUrl();
var pageCategories = [];

if (window.top.rtkcategories && Array.isArray(window.top.rtkcategories)) {
pageCategories = window.top.rtkcategories;
}

utils._each(validBidRequests, function(b) {
var rMap = requestsMap[b.params.ai];
if (!rMap) {
rMap = {
shortCodes: [],
payload: {
version: 1,
jsonp: false,
rtkreferer: referer
},
endpoint: DEFAULT_ENDPOINT
};

if (pageCategories && pageCategories.length) {
rMap.payload.categories = pageCategories.slice(0);
}

if (b.params.categories && b.params.categories.length) {
rMap.payload.categories = rMap.payload.categories || []
utils._each(b.params.categories, function(cat) {
rMap.payload.categories.push(cat);
});
}

if (bidderRequest && bidderRequest.gdprConsent) {
rMap.payload.gdpr = false;
if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') {
rMap.payload.gdpr = bidderRequest.gdprConsent.gdprApplies;
}
if (rMap.payload.gdpr) {
rMap.payload.consent = bidderRequest.gdprConsent.consentString;
}
}

requestsMap[b.params.ai] = rMap;
auctionCodes.push(b.params.ai);
}

rMap.shortCodes.push(b.params.sc);
rMap.payload[b.params.sc] = b.bidId;

if ((typeof b.params.host === 'string') && b.params.host.length &&
(b.params.host !== rMap.endpoint)) {
rMap.endpoint = b.params.host;
}
});

utils._each(auctionCodes, function(auctionId) {
var req = requestsMap[auctionId];
requests.push({
method: 'GET',
url: `//${req.endpoint}/${auctionId}/${req.shortCodes.join('_')}/aardvark`,
data: req.payload,
bidderRequest
});
});

return requests;
},

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

if (!Array.isArray(serverResponse.body)) {
serverResponse.body = [serverResponse.body];
}

utils._each(serverResponse.body, function(rawBid) {
var bidResponse = {
requestId: rawBid.cid,
cpm: rawBid.cpm || 0,
width: rawBid.width || 0,
height: rawBid.height || 0,
currency: rawBid.currency ? rawBid.currency : AARDVARK_CURRENCY,
netRevenue: rawBid.netRevenue ? rawBid.netRevenue : true,
ttl: rawBid.ttl ? rawBid.ttl : AARDVARK_TTL,
creativeId: rawBid.creativeId || 0
};

if (rawBid.hasOwnProperty('dealId')) {
bidResponse.dealId = rawBid.dealId
}

switch (rawBid.media) {
case 'banner':
bidResponse.ad = rawBid.adm + utils.createTrackPixelHtml(decodeURIComponent(rawBid.nurl));
break;

default:
return utils.logError('bad Aardvark response (media)', rawBid);
}

bidResponses.push(bidResponse);
});

return bidResponses;
},

getUserSyncs: function(syncOptions, serverResponses, gdprConsent) {
const syncs = [];
var url = '//' + SYNC_ENDPOINT + '/cs';
var gdprApplies = false;
if (gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean')) {
gdprApplies = gdprConsent.gdprApplies;
}

if (syncOptions.iframeEnabled) {
if (!hasSynced) {
hasSynced = true;
if (gdprApplies) {
url = url + '?g=1&c=' + encodeURIComponent(gdprConsent.consentString);
}
syncs.push({
type: 'iframe',
url: url
});
}
} else {
utils.logWarn('Aardvark: Please enable iframe based user sync.');
}
return syncs;
}
};

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

**Module Name**: Aardvark Bidder Adapter
**Module Type**: Bidder Adapter
**Maintainer**: chris@rtk.io

# Description

Module that connects to a RTK.io Ad Units to fetch bids.

# Test Parameters
```
var adUnits = [{
mediaTypes: {
banner: {
sizes: [[300, 250]],
}
},
code: 'div-gpt-ad-1460505748561-0',

bids: [{
bidder: 'aardvark',
params: {
ai: '0000',
sc: '1234'
}
}]

}];
```
34 changes: 32 additions & 2 deletions modules/consentManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ const cmpCallMap = {
* based on the appropriate result.
* @param {function(string)} cmpSuccess acts as a success callback when CMP returns a value; pass along consentObject (string) from CMP
* @param {function(string)} cmpError acts as an error callback while interacting with CMP; pass along an error message (string)
* @param {[objects]} adUnits used in the safeframe workflow to know what sizes to include in the $sf.ext.register call
*/
function lookupIabConsent(cmpSuccess, cmpError) {
function lookupIabConsent(cmpSuccess, cmpError, adUnits) {
let cmpCallbacks;

// check if the CMP is located on the same window level as the prebid code.
Expand All @@ -47,10 +48,37 @@ function lookupIabConsent(cmpSuccess, cmpError) {
// in this case, use the IAB's iframe locator sample code (which is slightly cutomized) to try to find the CMP and use postMessage() to communicate with the CMP.
if (utils.isFn(window.__cmp)) {
window.__cmp('getVendorConsents', null, cmpSuccess);
} else if (inASafeFrame() && typeof window.$sf.ext.cmp === 'function') {
callCmpWhileInSafeFrame();
} else {
callCmpWhileInIframe();
}

function inASafeFrame() {
return !!(window.$sf && window.$sf.ext);
}

function callCmpWhileInSafeFrame() {
function sfCallback(msgName, data) {
if (msgName === 'cmpReturn') {
cmpSuccess(data.vendorConsents);
}
}

// find sizes from adUnits object
let width = 1;
let height = 1;

if (Array.isArray(adUnits) && adUnits.length > 0) {
let sizes = utils.getAdUnitSizes(adUnits[0]);
width = sizes[0][0];
height = sizes[0][1];
}

window.$sf.ext.register(width, height, sfCallback);
window.$sf.ext.cmp('getVendorConsents');
}

function callCmpWhileInIframe() {
/**
* START OF STOCK CODE FROM IAB 1.1 CMP SPEC
Expand Down Expand Up @@ -134,6 +162,7 @@ export function requestBidsHook(config, fn) {
args = arguments;
nextFn = fn;
haveExited = false;
let adUnits = config.adUnits || $$PREBID_GLOBAL$$.adUnits;

// in case we already have consent (eg during bid refresh)
if (consentData) {
Expand All @@ -145,7 +174,7 @@ export function requestBidsHook(config, fn) {
return nextFn.apply(context, args);
}

cmpCallMap[userCMP].call(this, processCmpData, cmpFailed);
cmpCallMap[userCMP].call(this, processCmpData, cmpFailed, adUnits);

// only let this code run if module is still active (ie if the callbacks used by CMPs haven't already finished)
if (!haveExited) {
Expand Down Expand Up @@ -245,6 +274,7 @@ function exitModule(errMsg) {
*/
export function resetConsentData() {
consentData = undefined;
gdprDataHandler.setConsentData(null);
}

/**
Expand Down
Loading