Skip to content

Commit 7e5986c

Browse files
Merge pull request #1 from prebid/master
Latest Pull
2 parents 79af988 + 7990f92 commit 7e5986c

File tree

134 files changed

+9110
-1467
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+9110
-1467
lines changed

gulpfile.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ function escapePostbidConfig() {
7676
};
7777
escapePostbidConfig.displayName = 'escape-postbid-config';
7878

79-
function lint() {
79+
function lint(done) {
80+
if (argv.nolint) {
81+
return done();
82+
}
8083
return gulp.src(['src/**/*.js', 'modules/**/*.js', 'test/**/*.js'])
8184
.pipe(eslint())
8285
.pipe(eslint.format('stylish'))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<html>
2+
3+
<head>
4+
<link rel="icon" type="image/png" href="/favicon.png">
5+
<script async src="//www.googletagservices.com/tag/js/gpt.js"></script>
6+
<script type="text/javascript" src="../../build/dev/prebid.js" async></script>
7+
<script>
8+
var sizes = [
9+
[300, 250],
10+
[250, 300],
11+
[300, 600]
12+
];
13+
var PREBID_TIMEOUT = 3000;
14+
var FAILSAFE_TIMEOUT = 3000;
15+
16+
var adUnits = [{
17+
code: '/19968336/header-bid-tag-1',
18+
mediaTypes: {
19+
banner: {
20+
sizes: sizes
21+
}
22+
},
23+
bids: [{
24+
bidder: 'adikteev',
25+
params: {
26+
placementId: 13144370,
27+
stagingEnvironment: true,
28+
bidFloorPrice: 0.1,
29+
}
30+
}]
31+
}];
32+
33+
// ======== DO NOT EDIT BELOW THIS LINE =========== //
34+
var googletag = googletag || {};
35+
googletag.cmd = googletag.cmd || [];
36+
googletag.cmd.push(function () {
37+
googletag.pubads().disableInitialLoad();
38+
});
39+
40+
var pbjs = pbjs || {};
41+
pbjs.que = pbjs.que || [];
42+
43+
pbjs.que.push(function () {
44+
pbjs.addAdUnits(adUnits);
45+
pbjs.requestBids({
46+
bidsBackHandler: initAdserver,
47+
timeout: PREBID_TIMEOUT
48+
});
49+
});
50+
51+
function initAdserver() {
52+
if (pbjs.initAdserverSet) return;
53+
pbjs.initAdserverSet = true;
54+
googletag.cmd.push(function () {
55+
pbjs.que.push(function () {
56+
pbjs.setTargetingForGPTAsync();
57+
googletag.pubads().refresh();
58+
});
59+
});
60+
}
61+
62+
63+
// in case PBJS doesn't load
64+
setTimeout(function () {
65+
console.log("prebid.js setTimeout");
66+
initAdserver();
67+
}, FAILSAFE_TIMEOUT);
68+
69+
googletag.cmd.push(function () {
70+
googletag.defineSlot('/19968336/header-bid-tag-1', sizes, 'div-1')
71+
.addService(googletag.pubads());
72+
googletag.pubads().enableSingleRequest();
73+
googletag.enableServices();
74+
});
75+
76+
</script>
77+
78+
</head>
79+
80+
<body>
81+
<h2>Basic Prebid.js Example</h2>
82+
<h5>Div-1</h5>
83+
<div id='div-1'>
84+
<script type='text/javascript'>
85+
googletag.cmd.push(function () {
86+
googletag.display('div-1');
87+
});
88+
89+
</script>
90+
</div>
91+
</body>
92+
93+
</html>

integrationExamples/gpt/pbjs_example_gpt.html

+9-2
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,15 @@
312312
width: '300',
313313
height: '250',
314314
}
315-
}
316-
315+
},
316+
{
317+
bidder: 'adikteev',
318+
params: {
319+
placementId: 12345,
320+
currency: 'EUR',
321+
bidFloorPrice: 0.1,
322+
}
323+
},
317324
]
318325
}, {
319326
code: 'div-gpt-ad-12345678-1',

modules/33acrossBidAdapter.js

+8
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ function _createServerRequest(bidRequest, gdprConsent) {
8383
gdpr: (gdprConsent.gdprApplies === true) ? 1 : 0
8484
}
8585
};
86+
ttxRequest.ext = {
87+
ttx: {
88+
caller: [{
89+
'name': 'prebidjs',
90+
'version': '$prebid.version$'
91+
}]
92+
}
93+
}
8694

8795
// Finally, set the openRTB 'test' param if this is to be a test bid
8896
if (params.test === 1) {

modules/adformOpenRTBBidAdapter.js

+173
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
// jshint esversion: 6, es3: false, node: true
2+
'use strict';
3+
4+
import {
5+
registerBidder
6+
} from 'src/adapters/bidderFactory';
7+
import {
8+
NATIVE
9+
} from 'src/mediaTypes';
10+
import * as utils from 'src/utils';
11+
12+
const BIDDER_CODE = 'adformOpenRTB';
13+
const NATIVE_ASSET_IDS = { 0: 'title', 2: 'icon', 3: 'image', 5: 'sponsoredBy', 4: 'body', 1: 'cta' };
14+
const NATIVE_PARAMS = {
15+
title: {
16+
id: 0,
17+
name: 'title'
18+
},
19+
icon: {
20+
id: 2,
21+
type: 1,
22+
name: 'img'
23+
},
24+
image: {
25+
id: 3,
26+
type: 3,
27+
name: 'img'
28+
},
29+
sponsoredBy: {
30+
id: 5,
31+
name: 'data',
32+
type: 1
33+
},
34+
body: {
35+
id: 4,
36+
name: 'data',
37+
type: 2
38+
},
39+
cta: {
40+
id: 1,
41+
type: 12,
42+
name: 'data'
43+
}
44+
};
45+
46+
export const spec = {
47+
code: BIDDER_CODE,
48+
supportedMediaTypes: [ NATIVE ],
49+
isBidRequestValid: bid => !!bid.params.mid,
50+
buildRequests: (validBidRequests, bidderRequest) => {
51+
const page = bidderRequest.refererInfo.referer;
52+
const adxDomain = setOnAny(validBidRequests, 'params.adxDomain') || 'adx.adform.net';
53+
const ua = navigator.userAgent;
54+
const pt = setOnAny(validBidRequests, 'params.pt') || setOnAny(validBidRequests, 'params.priceType') || 'net';
55+
const tid = validBidRequests[0].transactionId; // ??? check with ssp
56+
const test = setOnAny(validBidRequests, 'params.test');
57+
const publisher = setOnAny(validBidRequests, 'params.publisher');
58+
const siteId = setOnAny(validBidRequests, 'params.siteId');
59+
60+
const imp = validBidRequests.map((bid, id) => {
61+
bid.netRevenue = pt;
62+
const assets = utils._map(bid.nativeParams, (bidParams, key) => {
63+
const props = NATIVE_PARAMS[key];
64+
const asset = {
65+
required: bidParams.required & 1,
66+
};
67+
if (props) {
68+
asset.id = props.id;
69+
asset[props.name] = {
70+
len: bidParams.len,
71+
wmin: bidParams.sizes && bidParams.sizes[0],
72+
hmin: bidParams.sizes && bidParams.sizes[1],
73+
type: props.type
74+
};
75+
76+
return asset;
77+
}
78+
}).filter(Boolean);
79+
80+
return {
81+
id: id + 1,
82+
tagid: bid.params.mid,
83+
native: {
84+
request: {
85+
assets
86+
}
87+
}
88+
};
89+
});
90+
91+
const request = {
92+
id: bidderRequest.auctionId,
93+
site: { id: siteId, page, publisher },
94+
device: { ua },
95+
source: { tid, fd: 1 },
96+
ext: { pt },
97+
imp
98+
};
99+
100+
if (test) {
101+
request.is_debug = !!test;
102+
request.test = 1;
103+
}
104+
if (utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies')) {
105+
request.user = { ext: { consent: bidderRequest.gdprConsent.consentString } };
106+
request.regs = { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies & 1 } };
107+
}
108+
109+
return {
110+
method: 'POST',
111+
url: '//' + adxDomain + '/adx/openrtb',
112+
data: JSON.stringify(request),
113+
options: {
114+
contentType: 'application/json'
115+
},
116+
bids: validBidRequests
117+
};
118+
},
119+
interpretResponse: function(serverResponse, { bids }) {
120+
if (!serverResponse.body) {
121+
return;
122+
}
123+
const { seatbid, cur } = serverResponse.body;
124+
125+
return bids.map((bid, id) => {
126+
const _cbid = seatbid && seatbid[id] && seatbid[id].bid;
127+
const bidResponse = _cbid && _cbid[0];
128+
if (bidResponse) {
129+
return {
130+
requestId: bid.bidId,
131+
cpm: bidResponse.price,
132+
creativeId: bidResponse.crid,
133+
ttl: 360,
134+
netRevenue: bid.netRevenue === 'net',
135+
currency: cur,
136+
mediaType: NATIVE,
137+
bidderCode: BIDDER_CODE,
138+
native: parseNative(bidResponse)
139+
};
140+
}
141+
}).filter(Boolean);
142+
}
143+
};
144+
145+
registerBidder(spec);
146+
147+
function parseNative(bid) {
148+
const { assets, link, imptrackers, jstracker } = bid.native;
149+
const result = {
150+
clickUrl: link.url,
151+
clickTrackers: link.clicktrackers || undefined,
152+
impressionTrackers: imptrackers || undefined,
153+
javascriptTrackers: jstracker ? [ jstracker ] : undefined
154+
};
155+
assets.forEach(asset => {
156+
const kind = NATIVE_ASSET_IDS[asset.id];
157+
const content = kind && asset[NATIVE_PARAMS[kind].name];
158+
if (content) {
159+
result[kind] = content.text || content.value || { url: content.url, width: content.w, height: content.h };
160+
}
161+
});
162+
163+
return result;
164+
}
165+
166+
function setOnAny(collection, key) {
167+
for (let i = 0, result; i < collection.length; i++) {
168+
result = utils.deepAccess(collection[i], key);
169+
if (result) {
170+
return result;
171+
}
172+
}
173+
}

modules/adformOpenRTBBidAdapter.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Overview
2+
3+
Module Name: Adform OpenRTB Adapter
4+
Module Type: Bidder Adapter
5+
Maintainer: [email protected]
6+
7+
# Description
8+
9+
Module that connects to Adform demand sources to fetch bids.
10+
Only native format is supported. Using OpenRTB standard.
11+
12+
# Test Parameters
13+
```
14+
var adUnits = [
15+
code: '/19968336/prebid_native_example_1',
16+
sizes: [
17+
[360, 360]
18+
],
19+
mediaTypes: {
20+
native: {
21+
image: {
22+
required: false,
23+
sizes: [100, 50]
24+
},
25+
title: {
26+
required: false,
27+
len: 140
28+
},
29+
sponsoredBy: {
30+
required: false
31+
},
32+
clickUrl: {
33+
required: false
34+
},
35+
body: {
36+
required: false
37+
},
38+
icon: {
39+
required: false,
40+
sizes: [50, 50]
41+
}
42+
}
43+
},
44+
bids: [{
45+
bidder: 'adformOpenRTB',
46+
params: {
47+
mid: 606169, // required
48+
adxDomain: 'axd.adform.net', // optional
49+
siteId: '23455', // optional
50+
priceType: 'gross' // optional, default is 'net'
51+
publisher: { // optional block
52+
id: "2706",
53+
name: "Publishers Name",
54+
domain: "publisher.com"
55+
}
56+
}
57+
}]
58+
];
59+
```

0 commit comments

Comments
 (0)