Skip to content

Commit

Permalink
Merge pull request #4 from prebid/master
Browse files Browse the repository at this point in the history
Update from Upstream
  • Loading branch information
GLStephen authored Sep 12, 2020
2 parents c23b8eb + 896cc0f commit b17b055
Show file tree
Hide file tree
Showing 73 changed files with 3,726 additions and 531 deletions.
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ function watch(done) {
connect.server({
https: argv.https,
port: port,
host: FAKE_SERVER_HOST,
root: './',
livereload: true
});
Expand Down
6 changes: 6 additions & 0 deletions integrationExamples/gpt/userId_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
{
code: 'test-div',
sizes: [[300,250],[300,600],[728,90]],
mediaTypes: {
banner: {}
},
bids: [
{
bidder: 'rubicon',
Expand Down Expand Up @@ -227,6 +230,9 @@
name: "_li_pbid",
expires: 28
}
},
{
name: "zeotapIdPlus"
}],
syncDelay: 5000,
auctionDelay: 1000
Expand Down
3 changes: 2 additions & 1 deletion modules/.submodules.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"netIdSystem",
"identityLinkIdSystem",
"sharedIdSystem",
"intentIqIdSystem"
"intentIqIdSystem",
"zeotapIdPlusIdSystem"
],
"adpod": [
"freeWheelAdserverVideo",
Expand Down
90 changes: 90 additions & 0 deletions modules/a4gBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import {registerBidder} from '../src/adapters/bidderFactory.js';
import * as utils from '../src/utils.js';

const A4G_BIDDER_CODE = 'a4g';
const A4G_CURRENCY = 'USD';
const A4G_DEFAULT_BID_URL = 'https://ads.ad4game.com/v1/bid';
const A4G_TTL = 120;

const LOCATION_PARAM_NAME = 'siteurl';
const ID_PARAM_NAME = 'id';
const IFRAME_PARAM_NAME = 'if';
const ZONE_ID_PARAM_NAME = 'zoneId';
const SIZE_PARAM_NAME = 'size';

const ARRAY_PARAM_SEPARATOR = ';';
const ARRAY_SIZE_SEPARATOR = ',';
const SIZE_SEPARATOR = 'x';

export const spec = {
code: A4G_BIDDER_CODE,
isBidRequestValid: function(bid) {
return bid.params && !!bid.params.zoneId;
},

buildRequests: function(validBidRequests, bidderRequest) {
let deliveryUrl = '';
const idParams = [];
const sizeParams = [];
const zoneIds = [];

utils._each(validBidRequests, function(bid) {
if (!deliveryUrl && typeof bid.params.deliveryUrl === 'string') {
deliveryUrl = bid.params.deliveryUrl;
}
idParams.push(bid.bidId);
let bidSizes = (bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes) || bid.sizes;
sizeParams.push(bidSizes.map(size => size.join(SIZE_SEPARATOR)).join(ARRAY_SIZE_SEPARATOR));
zoneIds.push(bid.params.zoneId);
});

if (!deliveryUrl) {
deliveryUrl = A4G_DEFAULT_BID_URL;
}

let data = {
[IFRAME_PARAM_NAME]: 0,
[LOCATION_PARAM_NAME]: (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) ? bidderRequest.refererInfo.referer : window.location.href,
[SIZE_PARAM_NAME]: sizeParams.join(ARRAY_PARAM_SEPARATOR),
[ID_PARAM_NAME]: idParams.join(ARRAY_PARAM_SEPARATOR),
[ZONE_ID_PARAM_NAME]: zoneIds.join(ARRAY_PARAM_SEPARATOR)
};

if (bidderRequest && bidderRequest.gdprConsent) {
data.gdpr = {
applies: bidderRequest.gdprConsent.gdprApplies,
consent: bidderRequest.gdprConsent.consentString
};
}

return {
method: 'GET',
url: deliveryUrl,
data: data
};
},

interpretResponse: function(serverResponses, request) {
const bidResponses = [];
utils._each(serverResponses.body, function(response) {
if (response.cpm > 0) {
const bidResponse = {
requestId: response.id,
creativeId: response.id,
adId: response.id,
cpm: response.cpm,
width: response.width,
height: response.height,
currency: A4G_CURRENCY,
netRevenue: true,
ttl: A4G_TTL,
ad: response.ad
};
bidResponses.push(bidResponse);
}
});
return bidResponses;
}
};

registerBidder(spec);
18 changes: 13 additions & 5 deletions modules/a4gBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,40 @@ Maintainer: devops@ad4game.com

# Description

Ad4Game Bidder Adapter for Prebid.js. It should be tested on real domain. `localhost` should be rewritten (ex. example.com).
Ad4Game Bidder Adapter for Prebid.js. It should be tested on real domain. `localhost` should be rewritten (ex. example.com).

# Test Parameters
```
var adUnits = [
{
code: 'test-div',
sizes: [[300, 250]], // a display size
mediaTypes: {
banner: {
sizes: [[300, 250]], // a display size
}
},
bids: [
{
bidder: 'a4g',
params: {
zoneId: 59304,
deliveryUrl: 'http://dev01.ad4game.com/v1/bid'
deliveryUrl: 'https://dev01.ad4game.com/v1/bid'
}
}
]
},{
code: 'test-div',
sizes: [[300, 50]], // a mobile size
mediaTypes: {
banner: {
sizes: [[300, 50]], // a mobile size
}
},
bids: [
{
bidder: 'a4g',
params: {
zoneId: 59354,
deliveryUrl: 'http://dev01.ad4game.com/v1/bid'
deliveryUrl: 'https://dev01.ad4game.com/v1/bid'
}
}
]
Expand Down
74 changes: 72 additions & 2 deletions modules/amxBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { parseUrl, deepAccess, _each, formatQS, getUniqueIdentifierStr, triggerPixel } from '../src/utils.js';
import { config } from '../src/config.js';
import { getStorageManager } from '../src/storageManager.js';

const BIDDER_CODE = 'amx';
const storage = getStorageManager(737, BIDDER_CODE);
const SIMPLE_TLD_TEST = /\.co\.\w{2,4}$/;
const DEFAULT_ENDPOINT = 'https://prebid.a-mo.net/a/c';
const VERSION = 'pba1.0';
const VERSION = 'pba1.2';
const xmlDTDRxp = /^\s*<\?xml[^\?]+\?>/;
const VAST_RXP = /^\s*<\??(?:vast|xml)/i;
const TRACKING_ENDPOINT = 'https://1x1.a-mo.net/hbx/';
const AMUID_KEY = '__amuidpb';

const getLocation = (request) =>
parseUrl(deepAccess(request, 'refererInfo.canonicalUrl', location.href))
Expand Down Expand Up @@ -47,6 +51,22 @@ function getID(loc) {

const enc = encodeURIComponent;

function getUIDSafe() {
try {
return storage.getDataFromLocalStorage(AMUID_KEY)
} catch (e) {
return null
}
}

function setUIDSafe(uid) {
try {
storage.setDataInLocalStorage(AMUID_KEY, uid)
} catch (e) {
// do nothing
}
}

function nestedQs (qsData) {
const out = [];
Object.keys(qsData || {}).forEach((key) => {
Expand Down Expand Up @@ -77,9 +97,20 @@ function convertRequest(bid) {
const av = isVideoBid || size[1] > 100;
const tid = deepAccess(bid, 'params.tagId')

const au = bid.params != null && typeof bid.params.adUnitId === 'string'
? bid.params.adUnitId : bid.adUnitCode;

const multiSizes = [
bid.sizes,
deepAccess(bid, `mediaTypes.${BANNER}.sizes`, []) || [],
deepAccess(bid, `mediaTypes.${VIDEO}.sizes`, []) || [],
]

const params = {
au,
av,
vr: isVideoBid,
ms: multiSizes,
aw: size[0],
ah: size[1],
tf: 0,
Expand Down Expand Up @@ -159,6 +190,16 @@ function resolveSize(bid, request, bidId) {
return [bidRequest.aw, bidRequest.ah];
}

function values(source) {
if (Object.values != null) {
return Object.values(source)
}

return Object.keys(source).map((key) => {
return source[key]
});
}

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER, VIDEO],
Expand All @@ -173,11 +214,19 @@ export const spec = {
const loc = getLocation(bidderRequest);
const tagId = deepAccess(bidRequests[0], 'params.tagId', null);
const testMode = deepAccess(bidRequests[0], 'params.testMode', 0);
const fbid = bidRequests[0] != null ? bidRequests[0] : {
bidderRequestsCount: 0,
bidderWinsCount: 0,
bidRequestsCount: 0
}

const payload = {
a: bidderRequest.auctionId,
B: 0,
b: loc.host,
brc: fbid.bidderRequestsCount || 0,
bwc: fbid.bidderWinsCount || 0,
trc: fbid.bidRequestsCount || 0,
tm: testMode,
V: '$prebid.version$',
i: (testMode && tagId != null) ? tagId : getID(loc),
Expand All @@ -187,15 +236,32 @@ export const spec = {
st: 'prebid',
h: screen.height,
w: screen.width,
gs: deepAccess(bidderRequest, 'gdprConsent.gdprApplies', '0'),
gs: deepAccess(bidderRequest, 'gdprConsent.gdprApplies', ''),
gc: deepAccess(bidderRequest, 'gdprConsent.consentString', ''),
u: deepAccess(bidderRequest, 'refererInfo.canonicalUrl', loc.href),
do: loc.host,
re: deepAccess(bidderRequest, 'refererInfo.referer'),
am: getUIDSafe(),
usp: bidderRequest.uspConsent || '1---',
smt: 1,
d: '',
m: createBidMap(bidRequests),
cpp: config.getConfig('coppa') ? 1 : 0,
fpd: config.getConfig('fpd'),
eids: values(bidRequests.reduce((all, bid) => {
// we only want unique ones in here
if (bid == null || bid.userIdAsEids == null) {
return all
}

_each(bid.userIdAsEids, (value) => {
if (value == null) {
return;
}
all[value.source] = value
});
return all;
}, {})),
};

return {
Expand Down Expand Up @@ -234,6 +300,10 @@ export const spec = {
return [];
}

if (response.am && typeof response.am === 'string') {
setUIDSafe(response.am);
}

return flatMap(Object.keys(response.r), (bidID) => {
return flatMap(response.r[bidID], (siteBid) =>
siteBid.b.map((bid) => {
Expand Down
1 change: 1 addition & 0 deletions modules/amxBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This module connects web publishers to AMX RTB video and display demand.
| --- | -------- | ------- | ----------- |
| `testMode` | no | `true` | this will activate test mode / 100% fill with sample ads |
| `tagId` | no | `"cHJlYmlkLm9yZw"` | can be used for more specific targeting of inventory. Your account manager will provide this ID if needed |
| `adUnitId` | no | `"sticky_banner"` | optional. To override the bid.adUnitCode provided by prebid. For use in ad-unit level reporting |

# Test Parameters

Expand Down
Loading

0 comments on commit b17b055

Please sign in to comment.