prebid.js 6.2.0 → 6.3.0
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/gulpfile.js +0 -8
- package/integrationExamples/gpt/weboramaRtdProvider_example.html +23 -14
- package/modules/33acrossBidAdapter.js +189 -102
- package/modules/adagioBidAdapter.js +1 -1
- package/modules/addefendBidAdapter.js +1 -0
- package/modules/admanBidAdapter.js +1 -0
- package/modules/admixerBidAdapter.js +1 -1
- package/modules/adnuntiusBidAdapter.js +3 -1
- package/modules/adxcgBidAdapter.js +311 -359
- package/modules/adxcgBidAdapter.md +22 -21
- package/modules/appnexusBidAdapter.js +0 -1
- package/modules/beopBidAdapter.js +5 -3
- package/modules/colossussspBidAdapter.js +7 -0
- package/modules/criteoBidAdapter.js +1 -1
- package/modules/cwireBidAdapter.js +3 -0
- package/modules/dspxBidAdapter.js +1 -1
- package/modules/futureads.md +48 -0
- package/modules/glimpseBidAdapter.js +16 -3
- package/modules/gumgumBidAdapter.js +2 -2
- package/modules/kinessoIdSystem.js +1 -1
- package/modules/lotamePanoramaIdSystem.js +80 -8
- package/modules/mediasquareBidAdapter.js +1 -9
- package/modules/nextMillenniumBidAdapter.js +29 -1
- package/modules/prebidServerBidAdapter/index.js +16 -12
- package/modules/richaudienceBidAdapter.js +1 -2
- package/modules/rtdModule/index.js +48 -18
- package/modules/rubiconBidAdapter.js +10 -8
- package/modules/sharedIdSystem.js +27 -1
- package/modules/targetVideoBidAdapter.js +187 -0
- package/modules/targetVideoBidAdapter.md +34 -0
- package/modules/vidoomyBidAdapter.js +16 -10
- package/modules/weboramaRtdProvider.js +288 -73
- package/modules/weboramaRtdProvider.md +27 -10
- package/modules/yahoosspBidAdapter.js +5 -1
- package/modules/zetaSspBidAdapter.md +33 -1
- package/modules/zeta_global_sspBidAdapter.js +22 -1
- package/package.json +1 -1
- package/plugins/pbjsGlobals.js +28 -1
- package/src/prebid.js +1 -2
- package/src/targeting.js +22 -1
- package/src/utils.js +34 -7
- package/test/spec/modules/33acrossBidAdapter_spec.js +300 -78
- package/test/spec/modules/adnuntiusBidAdapter_spec.js +17 -0
- package/test/spec/modules/adxcgBidAdapter_spec.js +820 -571
- package/test/spec/modules/colossussspBidAdapter_spec.js +9 -0
- package/test/spec/modules/cwireBidAdapter_spec.js +10 -8
- package/test/spec/modules/lotamePanoramaIdSystem_spec.js +227 -0
- package/test/spec/modules/mediasquareBidAdapter_spec.js +4 -4
- package/test/spec/modules/nextMillenniumBidAdapter_spec.js +18 -0
- package/test/spec/modules/prebidServerBidAdapter_spec.js +43 -0
- package/test/spec/modules/realTimeDataModule_spec.js +135 -49
- package/test/spec/modules/richaudienceBidAdapter_spec.js +2 -2
- package/test/spec/modules/rubiconBidAdapter_spec.js +17 -0
- package/test/spec/modules/sharedIdSystem_spec.js +52 -6
- package/test/spec/modules/targetVideoBidAdapter_spec.js +96 -0
- package/test/spec/modules/weboramaRtdProvider_spec.js +408 -214
- package/test/spec/modules/yahoosspBidAdapter_spec.js +28 -1
- package/test/spec/modules/zeta_global_sspBidAdapter_spec.js +33 -1
- package/test/spec/unit/core/targeting_spec.js +72 -0
- package/test/spec/utils_spec.js +38 -0
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import {
|
|
2
|
+
weboramaSubmodule
|
|
3
|
+
} from 'modules/weboramaRtdProvider.js';
|
|
4
|
+
import {
|
|
5
|
+
server
|
|
6
|
+
} from 'test/mocks/xhr.js';
|
|
7
|
+
import {
|
|
8
|
+
storage,
|
|
9
|
+
DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY
|
|
10
|
+
} from '../../../modules/weboramaRtdProvider.js';
|
|
11
|
+
|
|
12
|
+
const responseHeader = {
|
|
13
|
+
'Content-Type': 'application/json'
|
|
14
|
+
};
|
|
8
15
|
|
|
9
16
|
describe('weboramaRtdProvider', function() {
|
|
10
17
|
describe('weboramaSubmodule', function() {
|
|
11
|
-
it('successfully instantiates and call contextual api', function
|
|
18
|
+
it('successfully instantiates and call contextual api', function() {
|
|
12
19
|
const moduleConfig = {
|
|
13
20
|
params: {
|
|
14
21
|
weboCtxConf: {
|
|
@@ -18,271 +25,458 @@ describe('weboramaRtdProvider', function() {
|
|
|
18
25
|
}
|
|
19
26
|
};
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
let request = server.requests[0];
|
|
24
|
-
|
|
25
|
-
expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&');
|
|
26
|
-
expect(request.method).to.equal('GET')
|
|
28
|
+
expect(weboramaSubmodule.init(moduleConfig)).to.equal(true);
|
|
27
29
|
});
|
|
28
|
-
|
|
30
|
+
|
|
31
|
+
it('instantiate without contextual token should fail', function() {
|
|
29
32
|
const moduleConfig = {
|
|
30
33
|
params: {
|
|
31
34
|
weboCtxConf: {}
|
|
32
35
|
}
|
|
33
36
|
};
|
|
34
|
-
|
|
37
|
+
expect(weboramaSubmodule.init(moduleConfig)).to.equal(false);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('instantiate with empty weboUserData conf should return true', function() {
|
|
41
|
+
const moduleConfig = {
|
|
42
|
+
params: {
|
|
43
|
+
weboUserDataConf: {}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
expect(weboramaSubmodule.init(moduleConfig)).to.equal(true);
|
|
35
47
|
});
|
|
36
48
|
});
|
|
37
49
|
|
|
38
|
-
describe('
|
|
50
|
+
describe('Handle Set Targeting', function() {
|
|
51
|
+
let sandbox;
|
|
52
|
+
|
|
39
53
|
beforeEach(function() {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
sandbox = sinon.sandbox.create();
|
|
55
|
+
|
|
56
|
+
storage.removeDataFromLocalStorage('webo_wam2gam_entry');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
afterEach(function() {
|
|
60
|
+
sandbox.restore();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe('Add Contextual Data', function() {
|
|
64
|
+
it('should set gam targeting and send to bidders by default', function() {
|
|
65
|
+
const moduleConfig = {
|
|
66
|
+
params: {
|
|
67
|
+
weboCtxConf: {
|
|
68
|
+
token: 'foo',
|
|
69
|
+
targetURL: 'https://prebid.org',
|
|
45
70
|
}
|
|
46
71
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
72
|
+
};
|
|
73
|
+
const data = {
|
|
74
|
+
webo_ctx: ['foo', 'bar'],
|
|
75
|
+
webo_ds: ['baz'],
|
|
76
|
+
};
|
|
77
|
+
const adUnitsCodes = ['adunit1', 'adunit2'];
|
|
78
|
+
const reqBidsConfigObj = {
|
|
79
|
+
adUnits: [{
|
|
80
|
+
bids: [{
|
|
81
|
+
bidder: 'smartadserver'
|
|
82
|
+
}]
|
|
83
|
+
}]
|
|
84
|
+
};
|
|
85
|
+
const onDoneSpy = sinon.spy();
|
|
86
|
+
|
|
87
|
+
expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
|
|
88
|
+
weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
|
|
89
|
+
|
|
90
|
+
let request = server.requests[0];
|
|
91
|
+
|
|
92
|
+
expect(request.method).to.equal('GET');
|
|
93
|
+
expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&');
|
|
94
|
+
expect(request.withCredentials).to.be.false;
|
|
95
|
+
|
|
96
|
+
request.respond(200, responseHeader, JSON.stringify(data));
|
|
97
|
+
|
|
98
|
+
expect(onDoneSpy.calledOnce).to.be.true;
|
|
99
|
+
|
|
100
|
+
const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
|
|
101
|
+
|
|
102
|
+
expect(targeting).to.deep.equal({
|
|
103
|
+
'adunit1': data,
|
|
104
|
+
'adunit2': data,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_ctx=foo;webo_ctx=bar;webo_ds=baz');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('should set gam targeting but not send to bidders with setPrebidTargeting=true/sendToBidders=false', function() {
|
|
111
|
+
const moduleConfig = {
|
|
112
|
+
params: {
|
|
113
|
+
weboCtxConf: {
|
|
114
|
+
token: 'foo',
|
|
115
|
+
targetURL: 'https://prebid.org',
|
|
116
|
+
setPrebidTargeting: true,
|
|
117
|
+
sendToBidders: false,
|
|
52
118
|
}
|
|
53
119
|
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
120
|
+
};
|
|
121
|
+
const data = {
|
|
122
|
+
webo_ctx: ['foo', 'bar'],
|
|
123
|
+
webo_ds: ['baz'],
|
|
124
|
+
};
|
|
125
|
+
const adUnitsCodes = ['adunit1', 'adunit2'];
|
|
126
|
+
const reqBidsConfigObj = {
|
|
127
|
+
adUnits: [{
|
|
128
|
+
bids: [{
|
|
129
|
+
bidder: 'smartadserver',
|
|
130
|
+
params: {
|
|
131
|
+
target: 'foo=bar'
|
|
132
|
+
}
|
|
133
|
+
}]
|
|
134
|
+
}]
|
|
135
|
+
};
|
|
136
|
+
const onDoneSpy = sinon.spy();
|
|
137
|
+
|
|
138
|
+
expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
|
|
139
|
+
weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
|
|
140
|
+
|
|
141
|
+
let request = server.requests[0];
|
|
142
|
+
|
|
143
|
+
expect(request.method).to.equal('GET');
|
|
144
|
+
expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&');
|
|
145
|
+
expect(request.withCredentials).to.be.false;
|
|
146
|
+
|
|
147
|
+
request.respond(200, responseHeader, JSON.stringify(data));
|
|
148
|
+
|
|
149
|
+
expect(onDoneSpy.calledOnce).to.be.true;
|
|
150
|
+
|
|
151
|
+
const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
|
|
152
|
+
|
|
153
|
+
expect(targeting).to.deep.equal({
|
|
154
|
+
'adunit1': data,
|
|
155
|
+
'adunit2': data,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar');
|
|
159
|
+
});
|
|
57
160
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
setOrtb2: true,
|
|
161
|
+
it('should not set gam targeting with setPrebidTargeting=false but send to bidders', function() {
|
|
162
|
+
const moduleConfig = {
|
|
163
|
+
params: {
|
|
164
|
+
weboCtxConf: {
|
|
165
|
+
token: 'foo',
|
|
166
|
+
targetURL: 'https://prebid.org',
|
|
167
|
+
setPrebidTargeting: false,
|
|
168
|
+
}
|
|
67
169
|
}
|
|
170
|
+
};
|
|
171
|
+
const data = {
|
|
172
|
+
webo_ctx: ['foo', 'bar'],
|
|
173
|
+
webo_ds: ['baz'],
|
|
174
|
+
};
|
|
175
|
+
const adUnitsCodes = ['adunit1', 'adunit2'];
|
|
176
|
+
const reqBidsConfigObj = {
|
|
177
|
+
adUnits: [{
|
|
178
|
+
bids: [{
|
|
179
|
+
bidder: 'smartadserver',
|
|
180
|
+
params: {
|
|
181
|
+
target: 'foo=bar'
|
|
182
|
+
}
|
|
183
|
+
}]
|
|
184
|
+
}]
|
|
68
185
|
}
|
|
69
|
-
|
|
70
|
-
const data = {
|
|
71
|
-
webo_ctx: ['foo', 'bar'],
|
|
72
|
-
webo_ds: ['baz'],
|
|
73
|
-
};
|
|
74
|
-
const adUnitsCodes = ['adunit1', 'adunit2'];
|
|
75
|
-
weboramaSubmodule.init(moduleConfig);
|
|
186
|
+
const onDoneSpy = sinon.spy();
|
|
76
187
|
|
|
77
|
-
|
|
78
|
-
|
|
188
|
+
expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
|
|
189
|
+
weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
|
|
79
190
|
|
|
80
|
-
|
|
191
|
+
let request = server.requests[0];
|
|
81
192
|
|
|
82
|
-
|
|
83
|
-
'
|
|
84
|
-
|
|
85
|
-
});
|
|
193
|
+
expect(request.method).to.equal('GET');
|
|
194
|
+
expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&');
|
|
195
|
+
expect(request.withCredentials).to.be.false;
|
|
86
196
|
|
|
87
|
-
|
|
197
|
+
request.respond(200, responseHeader, JSON.stringify(data));
|
|
88
198
|
|
|
89
|
-
|
|
90
|
-
expect(ortb2.site.ext.data.webo_ds).to.deep.equal(data.webo_ds);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('should set targeting and ortb2 with setTargeting=true', function() {
|
|
94
|
-
const moduleConfig = {
|
|
95
|
-
params: {
|
|
96
|
-
weboCtxConf: {
|
|
97
|
-
token: 'foo',
|
|
98
|
-
targetURL: 'https://prebid.org',
|
|
99
|
-
setTargeting: true,
|
|
100
|
-
setOrtb2: true,
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
const data = {
|
|
105
|
-
webo_ctx: ['foo', 'bar'],
|
|
106
|
-
webo_ds: ['baz'],
|
|
107
|
-
};
|
|
108
|
-
const adUnitsCodes = ['adunit1', 'adunit2'];
|
|
109
|
-
weboramaSubmodule.init(moduleConfig);
|
|
199
|
+
expect(onDoneSpy.calledOnce).to.be.true;
|
|
110
200
|
|
|
111
|
-
|
|
112
|
-
request.respond(200, responseHeader, JSON.stringify(data));
|
|
201
|
+
const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
|
|
113
202
|
|
|
114
|
-
|
|
203
|
+
expect(targeting).to.deep.equal({});
|
|
115
204
|
|
|
116
|
-
|
|
117
|
-
'adunit1': data,
|
|
118
|
-
'adunit2': data,
|
|
205
|
+
expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar;webo_ctx=foo;webo_ctx=bar;webo_ds=baz');
|
|
119
206
|
});
|
|
120
207
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
setOrtb2: true,
|
|
208
|
+
it('should use default profile in case of api error', function() {
|
|
209
|
+
const defaultProfile = {
|
|
210
|
+
webo_ctx: ['baz'],
|
|
211
|
+
};
|
|
212
|
+
const moduleConfig = {
|
|
213
|
+
params: {
|
|
214
|
+
weboCtxConf: {
|
|
215
|
+
token: 'foo',
|
|
216
|
+
targetURL: 'https://prebid.org',
|
|
217
|
+
setPrebidTargeting: true,
|
|
218
|
+
defaultProfile: defaultProfile,
|
|
219
|
+
}
|
|
134
220
|
}
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
const data = {
|
|
138
|
-
webo_ctx: ['foo', 'bar'],
|
|
139
|
-
};
|
|
221
|
+
};
|
|
140
222
|
|
|
141
|
-
|
|
142
|
-
|
|
223
|
+
const adUnitsCodes = ['adunit1', 'adunit2'];
|
|
224
|
+
const reqBidsConfigObj = {
|
|
225
|
+
adUnits: [{
|
|
226
|
+
bids: [{
|
|
227
|
+
bidder: 'smartadserver'
|
|
228
|
+
}]
|
|
229
|
+
}]
|
|
230
|
+
};
|
|
231
|
+
const onDoneSpy = sinon.spy();
|
|
143
232
|
|
|
144
|
-
|
|
145
|
-
|
|
233
|
+
expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
|
|
234
|
+
weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
|
|
146
235
|
|
|
147
|
-
|
|
236
|
+
let request = server.requests[0];
|
|
148
237
|
|
|
149
|
-
|
|
150
|
-
'
|
|
151
|
-
|
|
152
|
-
});
|
|
238
|
+
expect(request.method).to.equal('GET');
|
|
239
|
+
expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&');
|
|
240
|
+
expect(request.withCredentials).to.be.false;
|
|
153
241
|
|
|
154
|
-
|
|
242
|
+
request.respond(500, responseHeader);
|
|
155
243
|
|
|
156
|
-
|
|
157
|
-
expect(ortb2.site.ext.data).to.not.have.property('webo_ds');
|
|
158
|
-
});
|
|
159
|
-
it('should set only targeting and not ortb2 with setTargeting=true and setOrtb2=false', function() {
|
|
160
|
-
const moduleConfig = {
|
|
161
|
-
params: {
|
|
162
|
-
weboCtxConf: {
|
|
163
|
-
token: 'foo',
|
|
164
|
-
targetURL: 'https://prebid.org',
|
|
165
|
-
setTargeting: true,
|
|
166
|
-
setOrtb2: false,
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
const data = {
|
|
171
|
-
webo_ctx: ['foo', 'bar'],
|
|
172
|
-
};
|
|
244
|
+
expect(onDoneSpy.calledOnce).to.be.true;
|
|
173
245
|
|
|
174
|
-
|
|
175
|
-
weboramaSubmodule.init(moduleConfig);
|
|
246
|
+
const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
|
|
176
247
|
|
|
177
|
-
|
|
178
|
-
|
|
248
|
+
expect(targeting).to.deep.equal({
|
|
249
|
+
'adunit1': defaultProfile,
|
|
250
|
+
'adunit2': defaultProfile,
|
|
251
|
+
});
|
|
179
252
|
|
|
180
|
-
|
|
253
|
+
expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_ctx=baz');
|
|
254
|
+
});
|
|
255
|
+
});
|
|
181
256
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
257
|
+
describe('Add WAM2GAM Data', function() {
|
|
258
|
+
it('should set gam targeting from local storage and send to bidders by default', function() {
|
|
259
|
+
const moduleConfig = {
|
|
260
|
+
params: {
|
|
261
|
+
weboUserDataConf: {}
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
const data = {
|
|
265
|
+
webo_cs: ['foo', 'bar'],
|
|
266
|
+
webo_audiences: ['baz'],
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const entry = {
|
|
270
|
+
targeting: data,
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
|
|
274
|
+
sandbox.stub(storage, 'getDataFromLocalStorage')
|
|
275
|
+
.withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY)
|
|
276
|
+
.returns(JSON.stringify(entry));
|
|
277
|
+
|
|
278
|
+
const adUnitsCodes = ['adunit1', 'adunit2'];
|
|
279
|
+
const reqBidsConfigObj = {
|
|
280
|
+
adUnits: [{
|
|
281
|
+
bids: [{
|
|
282
|
+
bidder: 'smartadserver'
|
|
283
|
+
}]
|
|
284
|
+
}]
|
|
285
|
+
};
|
|
286
|
+
const onDoneSpy = sinon.spy();
|
|
287
|
+
|
|
288
|
+
expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
|
|
289
|
+
weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
|
|
290
|
+
|
|
291
|
+
expect(onDoneSpy.calledOnce).to.be.true;
|
|
292
|
+
|
|
293
|
+
const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
|
|
294
|
+
|
|
295
|
+
expect(targeting).to.deep.equal({
|
|
296
|
+
'adunit1': data,
|
|
297
|
+
'adunit2': data,
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_cs=foo;webo_cs=bar;webo_audiences=baz');
|
|
185
301
|
});
|
|
186
302
|
|
|
187
|
-
|
|
303
|
+
it('should set gam targeting but not send to bidders with setPrebidTargeting=true/sendToBidders=false', function() {
|
|
304
|
+
const moduleConfig = {
|
|
305
|
+
params: {
|
|
306
|
+
weboUserDataConf: {
|
|
307
|
+
setPrebidTargeting: true,
|
|
308
|
+
sendToBidders: false
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
const data = {
|
|
313
|
+
webo_cs: ['foo', 'bar'],
|
|
314
|
+
webo_audiences: ['baz'],
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
const entry = {
|
|
318
|
+
targeting: data,
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
|
|
322
|
+
sandbox.stub(storage, 'getDataFromLocalStorage')
|
|
323
|
+
.withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY)
|
|
324
|
+
.returns(JSON.stringify(entry));
|
|
325
|
+
|
|
326
|
+
const adUnitsCodes = ['adunit1', 'adunit2'];
|
|
327
|
+
const reqBidsConfigObj = {
|
|
328
|
+
adUnits: [{
|
|
329
|
+
bids: [{
|
|
330
|
+
bidder: 'smartadserver',
|
|
331
|
+
params: {
|
|
332
|
+
target: 'foo=bar'
|
|
333
|
+
}
|
|
334
|
+
}]
|
|
335
|
+
}]
|
|
336
|
+
};
|
|
337
|
+
const onDoneSpy = sinon.spy();
|
|
338
|
+
|
|
339
|
+
expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
|
|
340
|
+
weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
|
|
341
|
+
|
|
342
|
+
expect(onDoneSpy.calledOnce).to.be.true;
|
|
343
|
+
|
|
344
|
+
const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
|
|
345
|
+
|
|
346
|
+
expect(targeting).to.deep.equal({
|
|
347
|
+
'adunit1': data,
|
|
348
|
+
'adunit2': data,
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar');
|
|
352
|
+
});
|
|
188
353
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
weboCtxConf: {
|
|
196
|
-
token: 'foo',
|
|
197
|
-
targetURL: 'https://prebid.org',
|
|
198
|
-
setTargeting: true,
|
|
354
|
+
it('should not set gam targeting with setPrebidTargeting=false but send to bidders', function() {
|
|
355
|
+
const moduleConfig = {
|
|
356
|
+
params: {
|
|
357
|
+
weboUserDataConf: {
|
|
358
|
+
setPrebidTargeting: false,
|
|
359
|
+
}
|
|
199
360
|
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
361
|
+
};
|
|
362
|
+
const data = {
|
|
363
|
+
webo_cs: ['foo', 'bar'],
|
|
364
|
+
webo_audiences: ['baz'],
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
const entry = {
|
|
368
|
+
targeting: data,
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
|
|
372
|
+
sandbox.stub(storage, 'getDataFromLocalStorage')
|
|
373
|
+
.withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY)
|
|
374
|
+
.returns(JSON.stringify(entry));
|
|
375
|
+
|
|
376
|
+
const adUnitsCodes = ['adunit1', 'adunit2'];
|
|
377
|
+
const reqBidsConfigObj = {
|
|
378
|
+
adUnits: [{
|
|
379
|
+
bids: [{
|
|
380
|
+
bidder: 'smartadserver',
|
|
381
|
+
params: {
|
|
382
|
+
target: 'foo=bar'
|
|
383
|
+
}
|
|
384
|
+
}]
|
|
385
|
+
}]
|
|
386
|
+
};
|
|
387
|
+
const onDoneSpy = sinon.spy();
|
|
388
|
+
|
|
389
|
+
expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
|
|
390
|
+
weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
|
|
391
|
+
|
|
392
|
+
expect(onDoneSpy.calledOnce).to.be.true;
|
|
393
|
+
|
|
394
|
+
const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
|
|
395
|
+
|
|
396
|
+
expect(targeting).to.deep.equal({});
|
|
397
|
+
|
|
398
|
+
expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar;webo_cs=foo;webo_cs=bar;webo_audiences=baz');
|
|
399
|
+
});
|
|
205
400
|
|
|
206
|
-
|
|
207
|
-
|
|
401
|
+
it('should use default profile in case of nothing on local storage', function() {
|
|
402
|
+
const defaultProfile = {
|
|
403
|
+
webo_audiences: ['baz']
|
|
404
|
+
};
|
|
405
|
+
const moduleConfig = {
|
|
406
|
+
params: {
|
|
407
|
+
weboUserDataConf: {
|
|
408
|
+
setPrebidTargeting: true,
|
|
409
|
+
defaultProfile: defaultProfile,
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
};
|
|
208
413
|
|
|
209
|
-
|
|
210
|
-
request.respond(200, responseHeader, JSON.stringify(data));
|
|
414
|
+
sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
|
|
211
415
|
|
|
212
|
-
|
|
416
|
+
const adUnitsCodes = ['adunit1', 'adunit2'];
|
|
417
|
+
const reqBidsConfigObj = {
|
|
418
|
+
adUnits: [{
|
|
419
|
+
bids: [{
|
|
420
|
+
bidder: 'smartadserver'
|
|
421
|
+
}]
|
|
422
|
+
}]
|
|
423
|
+
};
|
|
424
|
+
const onDoneSpy = sinon.spy();
|
|
213
425
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
'adunit2': data,
|
|
217
|
-
});
|
|
426
|
+
expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
|
|
427
|
+
weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
|
|
218
428
|
|
|
219
|
-
|
|
429
|
+
expect(onDoneSpy.calledOnce).to.be.true;
|
|
220
430
|
|
|
221
|
-
|
|
222
|
-
expect(ortb2.site.ext.data).to.not.have.property('webo_ds');
|
|
223
|
-
});
|
|
431
|
+
const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
|
|
224
432
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
token: 'foo',
|
|
230
|
-
targetURL: 'https://prebid.org',
|
|
231
|
-
setTargeting: false,
|
|
232
|
-
setOrtb2: true,
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
const data = {
|
|
237
|
-
webo_ctx: ['foo', 'bar'],
|
|
238
|
-
};
|
|
239
|
-
const adUnitsCodes = ['adunit1', 'adunit2'];
|
|
240
|
-
weboramaSubmodule.init(moduleConfig);
|
|
433
|
+
expect(targeting).to.deep.equal({
|
|
434
|
+
'adunit1': defaultProfile,
|
|
435
|
+
'adunit2': defaultProfile,
|
|
436
|
+
});
|
|
241
437
|
|
|
242
|
-
|
|
243
|
-
|
|
438
|
+
expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_audiences=baz');
|
|
439
|
+
});
|
|
244
440
|
|
|
245
|
-
|
|
441
|
+
it('should use default profile if cant read from local storage', function() {
|
|
442
|
+
const defaultProfile = {
|
|
443
|
+
webo_audiences: ['baz']
|
|
444
|
+
};
|
|
445
|
+
const moduleConfig = {
|
|
446
|
+
params: {
|
|
447
|
+
weboUserDataConf: {
|
|
448
|
+
setPrebidTargeting: true,
|
|
449
|
+
defaultProfile: defaultProfile,
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
};
|
|
246
453
|
|
|
247
|
-
|
|
454
|
+
sandbox.stub(storage, 'localStorageIsEnabled').returns(false);
|
|
248
455
|
|
|
249
|
-
|
|
456
|
+
const adUnitsCodes = ['adunit1', 'adunit2'];
|
|
457
|
+
const reqBidsConfigObj = {
|
|
458
|
+
adUnits: [{
|
|
459
|
+
bids: [{
|
|
460
|
+
bidder: 'smartadserver'
|
|
461
|
+
}]
|
|
462
|
+
}]
|
|
463
|
+
};
|
|
464
|
+
const onDoneSpy = sinon.spy();
|
|
250
465
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
});
|
|
254
|
-
it('should use default profile in case of api error', function() {
|
|
255
|
-
const defaultProfile = {
|
|
256
|
-
webo_ctx: ['baz'],
|
|
257
|
-
};
|
|
258
|
-
const moduleConfig = {
|
|
259
|
-
params: {
|
|
260
|
-
weboCtxConf: {
|
|
261
|
-
token: 'foo',
|
|
262
|
-
targetURL: 'https://prebid.org',
|
|
263
|
-
setTargeting: true,
|
|
264
|
-
defaultProfile: defaultProfile,
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
};
|
|
466
|
+
expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
|
|
467
|
+
weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
|
|
268
468
|
|
|
269
|
-
|
|
270
|
-
weboramaSubmodule.init(moduleConfig);
|
|
469
|
+
expect(onDoneSpy.calledOnce).to.be.true;
|
|
271
470
|
|
|
272
|
-
|
|
273
|
-
request.respond(500, responseHeader);
|
|
471
|
+
const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
|
|
274
472
|
|
|
275
|
-
|
|
473
|
+
expect(targeting).to.deep.equal({
|
|
474
|
+
'adunit1': defaultProfile,
|
|
475
|
+
'adunit2': defaultProfile,
|
|
476
|
+
});
|
|
276
477
|
|
|
277
|
-
|
|
278
|
-
'adunit1': defaultProfile,
|
|
279
|
-
'adunit2': defaultProfile,
|
|
478
|
+
expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_audiences=baz');
|
|
280
479
|
});
|
|
281
|
-
|
|
282
|
-
const ortb2 = config.getConfig('ortb2');
|
|
283
|
-
|
|
284
|
-
expect(ortb2.site.ext.data).to.not.have.property('webo_ctx');
|
|
285
|
-
expect(ortb2.site.ext.data).to.not.have.property('webo_ds');
|
|
286
480
|
});
|
|
287
481
|
});
|
|
288
482
|
});
|