prebid.js 5.20.0 → 5.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/modules/appnexusBidAdapter.js +4 -0
- package/modules/ipromBidAdapter.js +79 -0
- package/modules/kinessoIdSystem.js +1 -1
- package/package.json +1 -1
- package/test/spec/modules/appnexusBidAdapter_spec.js +14 -0
- package/test/spec/modules/eplanningBidAdapter_spec.js +8 -8
- package/test/spec/modules/ipromBidAdapter_spec.js +195 -0
- package/test/spec/unit/core/adapterManager_spec.js +5 -2
|
@@ -598,6 +598,10 @@ function newBid(serverBid, rtbBid, bidderRequest) {
|
|
|
598
598
|
bid.meta = Object.assign({}, bid.meta, { advertiserId: rtbBid.advertiser_id });
|
|
599
599
|
}
|
|
600
600
|
|
|
601
|
+
if (rtbBid.brand_id) {
|
|
602
|
+
bid.meta = Object.assign({}, bid.meta, { brandId: rtbBid.brand_id });
|
|
603
|
+
}
|
|
604
|
+
|
|
601
605
|
if (rtbBid.rtb.video) {
|
|
602
606
|
// shared video properties used for all 3 contexts
|
|
603
607
|
Object.assign(bid, {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { logError } from '../src/utils.js';
|
|
2
|
+
import { registerBidder } from '../src/adapters/bidderFactory.js';
|
|
3
|
+
|
|
4
|
+
const BIDDER_CODE = 'iprom';
|
|
5
|
+
const ENDPOINT_URL = 'https://core.iprom.net/programmatic';
|
|
6
|
+
const VERSION = 'v1.0.2';
|
|
7
|
+
const DEFAULT_CURRENCY = 'EUR';
|
|
8
|
+
const DEFAULT_NETREVENUE = true;
|
|
9
|
+
const DEFAULT_TTL = 360;
|
|
10
|
+
|
|
11
|
+
export const spec = {
|
|
12
|
+
code: BIDDER_CODE,
|
|
13
|
+
isBidRequestValid: function ({ bidder, params = {} } = {}) {
|
|
14
|
+
// id parameter checks
|
|
15
|
+
if (!params.id) {
|
|
16
|
+
logError(`${bidder}: Parameter 'id' missing`);
|
|
17
|
+
return false;
|
|
18
|
+
} else if (typeof params.id !== 'string') {
|
|
19
|
+
logError(`${bidder}: Parameter 'id' needs to be a string`);
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
// dimension parameter checks
|
|
23
|
+
if (!params.dimension) {
|
|
24
|
+
logError(`${bidder}: Required parameter 'dimension' missing`);
|
|
25
|
+
return false;
|
|
26
|
+
} else if (typeof params.dimension !== 'string') {
|
|
27
|
+
logError(`${bidder}: Parameter 'dimension' needs to be a string`);
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return true;
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
buildRequests: function (validBidRequests, bidderRequest) {
|
|
35
|
+
const payload = {
|
|
36
|
+
bids: validBidRequests,
|
|
37
|
+
referer: bidderRequest.refererInfo,
|
|
38
|
+
version: VERSION
|
|
39
|
+
};
|
|
40
|
+
const payloadString = JSON.stringify(payload);
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
url: ENDPOINT_URL,
|
|
45
|
+
data: payloadString
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
interpretResponse: function (serverResponse, request) {
|
|
50
|
+
let bids = serverResponse.body;
|
|
51
|
+
|
|
52
|
+
const bidResponses = [];
|
|
53
|
+
|
|
54
|
+
bids.forEach(bid => {
|
|
55
|
+
const b = {
|
|
56
|
+
ad: bid.ad,
|
|
57
|
+
requestId: bid.requestId,
|
|
58
|
+
cpm: bid.cpm,
|
|
59
|
+
width: bid.width,
|
|
60
|
+
height: bid.height,
|
|
61
|
+
creativeId: bid.creativeId,
|
|
62
|
+
currency: bid.currency || DEFAULT_CURRENCY,
|
|
63
|
+
netRevenue: bid.netRevenue || DEFAULT_NETREVENUE,
|
|
64
|
+
ttl: bid.ttl || DEFAULT_TTL,
|
|
65
|
+
meta: {},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
if (bid.aDomains && bid.aDomains.length) {
|
|
69
|
+
b.meta.advertiserDomains = bid.aDomains;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
bidResponses.push(b);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return bidResponses;
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
registerBidder(spec);
|
|
@@ -180,7 +180,7 @@ function kinessoSyncUrl(accountId, consentData) {
|
|
|
180
180
|
const usPrivacyString = uspDataHandler.getConsentData();
|
|
181
181
|
let kinessoSyncUrl = `${ID_SVC}?accountid=${accountId}`;
|
|
182
182
|
if (usPrivacyString) {
|
|
183
|
-
kinessoSyncUrl = `${kinessoSyncUrl}
|
|
183
|
+
kinessoSyncUrl = `${kinessoSyncUrl}&us_privacy=${usPrivacyString}`;
|
|
184
184
|
}
|
|
185
185
|
if (!consentData || typeof consentData.gdprApplies !== 'boolean' || !consentData.gdprApplies) return kinessoSyncUrl;
|
|
186
186
|
|
package/package.json
CHANGED
|
@@ -1335,6 +1335,20 @@ describe('AppNexusAdapter', function () {
|
|
|
1335
1335
|
expect(Object.keys(result[0].meta)).to.include.members(['advertiserId']);
|
|
1336
1336
|
});
|
|
1337
1337
|
|
|
1338
|
+
it('should add brand id', function() {
|
|
1339
|
+
let responseBrandId = deepClone(response);
|
|
1340
|
+
responseBrandId.tags[0].ads[0].brand_id = 123;
|
|
1341
|
+
|
|
1342
|
+
let bidderRequest = {
|
|
1343
|
+
bids: [{
|
|
1344
|
+
bidId: '3db3773286ee59',
|
|
1345
|
+
adUnitCode: 'code'
|
|
1346
|
+
}]
|
|
1347
|
+
}
|
|
1348
|
+
let result = spec.interpretResponse({ body: responseBrandId }, {bidderRequest});
|
|
1349
|
+
expect(Object.keys(result[0].meta)).to.include.members(['brandId']);
|
|
1350
|
+
});
|
|
1351
|
+
|
|
1338
1352
|
it('should add advertiserDomains', function() {
|
|
1339
1353
|
let responseAdvertiserId = deepClone(response);
|
|
1340
1354
|
responseAdvertiserId.tags[0].ads[0].adomain = ['123'];
|
|
@@ -328,26 +328,25 @@ describe('E-Planning Adapter', function () {
|
|
|
328
328
|
describe('buildRequests', function () {
|
|
329
329
|
let bidRequests = [validBid];
|
|
330
330
|
let sandbox;
|
|
331
|
+
let getWindowSelfStub;
|
|
332
|
+
let innerWidth;
|
|
331
333
|
beforeEach(() => {
|
|
332
334
|
sandbox = sinon.sandbox.create();
|
|
335
|
+
getWindowSelfStub = sandbox.stub(utils, 'getWindowSelf');
|
|
336
|
+
getWindowSelfStub.returns(createWindow(800));
|
|
333
337
|
});
|
|
334
338
|
|
|
335
339
|
afterEach(() => {
|
|
336
340
|
sandbox.restore();
|
|
337
341
|
});
|
|
338
342
|
|
|
339
|
-
const createWindow = () => {
|
|
343
|
+
const createWindow = (innerWidth) => {
|
|
340
344
|
const win = {};
|
|
341
345
|
win.self = win;
|
|
342
|
-
win.innerWidth =
|
|
346
|
+
win.innerWidth = innerWidth;
|
|
343
347
|
return win;
|
|
344
348
|
};
|
|
345
349
|
|
|
346
|
-
function setupSingleWindow(sandBox) {
|
|
347
|
-
const win = createWindow();
|
|
348
|
-
sandBox.stub(utils, 'getWindowSelf').returns(win);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
350
|
it('should create the url correctly', function () {
|
|
352
351
|
const url = spec.buildRequests(bidRequests, bidderRequest).url;
|
|
353
352
|
expect(url).to.equal('https://pbjs.e-planning.net/pbjs/1/' + CI + '/1/localhost/ROS');
|
|
@@ -516,7 +515,8 @@ describe('E-Planning Adapter', function () {
|
|
|
516
515
|
|
|
517
516
|
it('should return the e parameter with a value according to the sizes in order corresponding to the desktop priority list of the ad units', function () {
|
|
518
517
|
let bidRequestsPrioritySizes = [validBidExistingSizesInPriorityListForDesktop];
|
|
519
|
-
|
|
518
|
+
// overwrite default innerWdith for tests with a larger one we consider "Desktop" or NOT Mobile
|
|
519
|
+
getWindowSelfStub.returns(createWindow(1025));
|
|
520
520
|
const e = spec.buildRequests(bidRequestsPrioritySizes, bidderRequest).data.e;
|
|
521
521
|
expect(e).to.equal('300x250_0:300x250,300x600,970x250');
|
|
522
522
|
});
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import {expect} from 'chai';
|
|
2
|
+
import {spec} from 'modules/ipromBidAdapter.js';
|
|
3
|
+
|
|
4
|
+
describe('iPROM Adapter', function () {
|
|
5
|
+
let bidRequests;
|
|
6
|
+
let bidderRequest;
|
|
7
|
+
|
|
8
|
+
beforeEach(function () {
|
|
9
|
+
bidRequests = [
|
|
10
|
+
{
|
|
11
|
+
bidder: 'iprom',
|
|
12
|
+
params: {
|
|
13
|
+
id: '1234',
|
|
14
|
+
dimension: '300x250',
|
|
15
|
+
},
|
|
16
|
+
adUnitCode: '/19966331/header-bid-tag-1',
|
|
17
|
+
mediaTypes: {
|
|
18
|
+
banner: {
|
|
19
|
+
sizes: [[300, 250], [300, 600]],
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
bidId: '29a72b151f7bd3',
|
|
23
|
+
auctionId: 'e36abb27-g3b1-1ad6-8a4c-701c8919d3hh',
|
|
24
|
+
bidderRequestId: '2z76da40m1b3cb8',
|
|
25
|
+
transactionId: 'j51lhf58-1ad6-g3b1-3j6s-912c9493g0gu'
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
bidderRequest = {
|
|
30
|
+
timeout: 3000,
|
|
31
|
+
refererInfo: {
|
|
32
|
+
referer: 'https://adserver.si/index.html',
|
|
33
|
+
reachedTop: true,
|
|
34
|
+
numIframes: 1,
|
|
35
|
+
stack: [
|
|
36
|
+
'https://adserver.si/index.html',
|
|
37
|
+
'https://adserver.si/iframe1.html',
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('validating bids', function () {
|
|
44
|
+
it('should accept valid bid', function () {
|
|
45
|
+
let validBid = {
|
|
46
|
+
bidder: 'iprom',
|
|
47
|
+
params: {
|
|
48
|
+
id: '1234',
|
|
49
|
+
dimension: '300x250',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const isValid = spec.isBidRequestValid(validBid);
|
|
54
|
+
|
|
55
|
+
expect(isValid).to.equal(true);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should reject bid if missing dimension and id', function () {
|
|
59
|
+
let invalidBid = {
|
|
60
|
+
bidder: 'iprom',
|
|
61
|
+
params: {}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const isValid = spec.isBidRequestValid(invalidBid);
|
|
65
|
+
|
|
66
|
+
expect(isValid).to.equal(false);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should reject bid if missing dimension', function () {
|
|
70
|
+
let invalidBid = {
|
|
71
|
+
bidder: 'iprom',
|
|
72
|
+
params: {
|
|
73
|
+
id: '1234',
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const isValid = spec.isBidRequestValid(invalidBid);
|
|
78
|
+
|
|
79
|
+
expect(isValid).to.equal(false);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should reject bid if dimension is not a string', function () {
|
|
83
|
+
let invalidBid = {
|
|
84
|
+
bidder: 'iprom',
|
|
85
|
+
params: {
|
|
86
|
+
id: '1234',
|
|
87
|
+
dimension: 404,
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const isValid = spec.isBidRequestValid(invalidBid);
|
|
92
|
+
|
|
93
|
+
expect(isValid).to.equal(false);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should reject bid if missing id', function () {
|
|
97
|
+
let invalidBid = {
|
|
98
|
+
bidder: 'iprom',
|
|
99
|
+
params: {
|
|
100
|
+
dimension: '300x250',
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const isValid = spec.isBidRequestValid(invalidBid);
|
|
105
|
+
|
|
106
|
+
expect(isValid).to.equal(false);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should reject bid if id is not a string', function () {
|
|
110
|
+
let invalidBid = {
|
|
111
|
+
bidder: 'iprom',
|
|
112
|
+
params: {
|
|
113
|
+
id: 1234,
|
|
114
|
+
dimension: '300x250',
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const isValid = spec.isBidRequestValid(invalidBid);
|
|
119
|
+
|
|
120
|
+
expect(isValid).to.equal(false);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe('building requests', function () {
|
|
125
|
+
it('should go to correct endpoint', function () {
|
|
126
|
+
const request = spec.buildRequests(bidRequests, bidderRequest);
|
|
127
|
+
|
|
128
|
+
expect(request.method).to.exist;
|
|
129
|
+
expect(request.method).to.equal('POST');
|
|
130
|
+
expect(request.url).to.exist;
|
|
131
|
+
expect(request.url).to.equal('https://core.iprom.net/programmatic');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('should add referer info', function () {
|
|
135
|
+
const request = spec.buildRequests(bidRequests, bidderRequest);
|
|
136
|
+
const requestparse = JSON.parse(request.data);
|
|
137
|
+
|
|
138
|
+
expect(requestparse.referer).to.exist;
|
|
139
|
+
expect(requestparse.referer.referer).to.equal('https://adserver.si/index.html');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('should add adapter version', function () {
|
|
143
|
+
const request = spec.buildRequests(bidRequests, bidderRequest);
|
|
144
|
+
const requestparse = JSON.parse(request.data);
|
|
145
|
+
|
|
146
|
+
expect(requestparse.version).to.exist;
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('should contain id and dimension', function () {
|
|
150
|
+
const request = spec.buildRequests(bidRequests, bidderRequest);
|
|
151
|
+
const requestparse = JSON.parse(request.data);
|
|
152
|
+
|
|
153
|
+
expect(requestparse.bids[0].params.id).to.equal('1234');
|
|
154
|
+
expect(requestparse.bids[0].params.dimension).to.equal('300x250');
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe('handling responses', function () {
|
|
159
|
+
it('should return complete bid response', function () {
|
|
160
|
+
const serverResponse = {
|
|
161
|
+
body: [{
|
|
162
|
+
requestId: '29a72b151f7bd3',
|
|
163
|
+
cpm: 0.5,
|
|
164
|
+
width: '300',
|
|
165
|
+
height: '250',
|
|
166
|
+
creativeId: 1234,
|
|
167
|
+
ad: '<html><head><title>Iprom Header bidding example</title></head><body><img src="https://iprom.si/files/2015/08/iprom-logo.svg"></body></html>',
|
|
168
|
+
aDomains: ['https://example.com'],
|
|
169
|
+
}
|
|
170
|
+
]};
|
|
171
|
+
|
|
172
|
+
const request = spec.buildRequests(bidRequests, bidderRequest);
|
|
173
|
+
const bids = spec.interpretResponse(serverResponse, request);
|
|
174
|
+
|
|
175
|
+
expect(bids).to.be.lengthOf(1);
|
|
176
|
+
expect(bids[0].requestId).to.equal('29a72b151f7bd3');
|
|
177
|
+
expect(bids[0].cpm).to.equal(0.5);
|
|
178
|
+
expect(bids[0].width).to.equal('300');
|
|
179
|
+
expect(bids[0].height).to.equal('250');
|
|
180
|
+
expect(bids[0].ad).to.have.length.above(1);
|
|
181
|
+
expect(bids[0].meta.advertiserDomains).to.deep.equal(['https://example.com']);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('should return empty bid response', function () {
|
|
185
|
+
const emptyServerResponse = {
|
|
186
|
+
body: []
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const request = spec.buildRequests(bidRequests, bidderRequest);
|
|
190
|
+
const bids = spec.interpretResponse(emptyServerResponse, request);
|
|
191
|
+
|
|
192
|
+
expect(bids).to.be.lengthOf(0);
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
});
|
|
@@ -1697,14 +1697,17 @@ describe('adapterManager tests', function () {
|
|
|
1697
1697
|
});
|
|
1698
1698
|
|
|
1699
1699
|
describe('sizeMapping', function () {
|
|
1700
|
+
let sandbox;
|
|
1700
1701
|
beforeEach(function () {
|
|
1702
|
+
sandbox = sinon.sandbox.create();
|
|
1701
1703
|
allS2SBidders.length = 0;
|
|
1702
1704
|
clientTestAdapters.length = 0;
|
|
1703
|
-
|
|
1705
|
+
// always have matchMedia return true for us
|
|
1706
|
+
sandbox.stub(utils.getWindowTop(), 'matchMedia').callsFake(() => ({matches: true}));
|
|
1704
1707
|
});
|
|
1705
1708
|
|
|
1706
1709
|
afterEach(function () {
|
|
1707
|
-
|
|
1710
|
+
sandbox.restore();
|
|
1708
1711
|
config.resetConfig();
|
|
1709
1712
|
setSizeConfig([]);
|
|
1710
1713
|
});
|