Skip to content

Commit 306d59f

Browse files
dreischerseergiioo6
authored andcommitted
Permutive - add AC support for TrustX (prebid#6393)
1 parent 8de0498 commit 306d59f

File tree

4 files changed

+153
-21
lines changed

4 files changed

+153
-21
lines changed

integrationExamples/gpt/permutiveRtdProvider_example.html

+14-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
params: {
5151
placementId: 13144370,
5252
keywords: {
53-
inline_kvs: ['1']
53+
test_kv: ['true']
5454
}
5555
}
5656
},
@@ -64,7 +64,7 @@
6464
area: ['home']
6565
},
6666
visitor: {
67-
inline_kvs: ['1']
67+
test_kv: ['true']
6868
}
6969
}
7070
},
@@ -78,12 +78,21 @@
7878
{
7979
settings: {},
8080
targeting: {
81-
inline_kvs: ['1', '2', '3', '4']
81+
test_kv: ['true']
8282
}
8383
}
8484
],
8585
ozoneData: {}
8686
}
87+
},
88+
{
89+
bidder: 'trustx',
90+
params: {
91+
uid: 45,
92+
keywords: {
93+
test_kv: ['true']
94+
}
95+
}
8796
}
8897
]
8998
},
@@ -127,13 +136,13 @@
127136
pbjs.setConfig({
128137
debug: true,
129138
realTimeData: {
130-
auctionDelay: 50, // maximum time for RTD modules to respond
139+
auctionDelay: 80, // maximum time for RTD modules to respond
131140
dataProviders: [
132141
{
133142
name: 'permutive',
134143
waitForIt: true,
135144
params: {
136-
acBidders: ['appnexus', 'rubicon', 'ozone'],
145+
acBidders: ['appnexus', 'rubicon', 'ozone', 'trustx'],
137146
maxSegs: 500,
138147
overwrites: {
139148
rubicon: function (bid, data, acEnabled, utils, defaultFn) {

modules/permutiveRtdProvider.js

+7
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ function getDefaultBidderFn (bidder) {
110110
deepSetValue(bid, 'params.customData.0.targeting.p_standard', data.ac)
111111
}
112112

113+
return bid
114+
},
115+
trustx: function (bid, data, acEnabled) {
116+
if (acEnabled && data.ac && data.ac.length) {
117+
deepSetValue(bid, 'params.keywords.p_standard', data.ac)
118+
}
119+
113120
return bid
114121
}
115122
}

modules/permutiveRtdProvider.md

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ The below bidders are currently support by the Permutive RTD module. Please reac
3333
| Xandr | `appnexus` | Yes | Yes |
3434
| Magnite | `rubicon` | Yes | Yes |
3535
| Ozone | `ozone` | No | Yes |
36+
| TrustX | `trustx` | No | Yes |
3637

3738
* **First-party segments:** When enabling the respective Activation for a segment in Permutive, this module will automatically attach that segment to the bid request. There is no need to enable individual bidders in the module configuration, it will automatically reflect which SSP integrations you have enabled in Permutive. Permutive segments will be sent in the `permutive` key-value.
3839

test/spec/modules/permutiveRtdProvider_spec.js

+131-16
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('permutiveRtdProvider', function () {
5454
})
5555
}
5656
})
57-
it('sets segment targeting for Rubicon', function () {
57+
it('sets segment targeting for Magnite', function () {
5858
const data = transformedTargeting()
5959
const adUnits = getAdUnits()
6060
const config = getConfig()
@@ -93,10 +93,29 @@ describe('permutiveRtdProvider', function () {
9393
})
9494
}
9595
})
96+
it('sets segment targeting for TrustX', function () {
97+
const data = transformedTargeting()
98+
const adUnits = getAdUnits()
99+
const config = getConfig()
100+
101+
initSegments({ adUnits }, callback, config)
102+
103+
function callback () {
104+
adUnits.forEach(adUnit => {
105+
adUnit.bids.forEach(bid => {
106+
const { bidder, params } = bid
107+
108+
if (bidder === 'trustx') {
109+
expect(deepAccess(params, 'keywords.p_standard')).to.eql(data.ac)
110+
}
111+
})
112+
})
113+
}
114+
})
96115
})
97116

98117
describe('Custom segment targeting', function () {
99-
it('sets custom segment targeting for Rubicon', function () {
118+
it('sets custom segment targeting for Magnite', function () {
100119
const data = transformedTargeting()
101120
const adUnits = getAdUnits()
102121
const config = getConfig()
@@ -129,6 +148,81 @@ describe('permutiveRtdProvider', function () {
129148
})
130149
})
131150

151+
describe('Existing key-value targeting', function () {
152+
it('doesn\'t overwrite existing key-values for Xandr', function () {
153+
const adUnits = getAdUnits()
154+
const config = getConfig()
155+
156+
initSegments({ adUnits }, callback, config)
157+
158+
function callback () {
159+
adUnits.forEach(adUnit => {
160+
adUnit.bids.forEach(bid => {
161+
const { bidder, params } = bid
162+
163+
if (bidder === 'appnexus') {
164+
expect(deepAccess(params, 'keywords.test_kv')).to.eql(['true'])
165+
}
166+
})
167+
})
168+
}
169+
})
170+
it('doesn\'t overwrite existing key-values for Magnite', function () {
171+
const adUnits = getAdUnits()
172+
const config = getConfig()
173+
174+
initSegments({ adUnits }, callback, config)
175+
176+
function callback () {
177+
adUnits.forEach(adUnit => {
178+
adUnit.bids.forEach(bid => {
179+
const { bidder, params } = bid
180+
181+
if (bidder === 'rubicon') {
182+
expect(deepAccess(params, 'visitor.test_kv')).to.eql(['true'])
183+
}
184+
})
185+
})
186+
}
187+
})
188+
it('doesn\'t overwrite existing key-values for Ozone', function () {
189+
const adUnits = getAdUnits()
190+
const config = getConfig()
191+
192+
initSegments({ adUnits }, callback, config)
193+
194+
function callback () {
195+
adUnits.forEach(adUnit => {
196+
adUnit.bids.forEach(bid => {
197+
const { bidder, params } = bid
198+
199+
if (bidder === 'ozone') {
200+
expect(deepAccess(params, 'customData.0.targeting.test_kv')).to.eql(['true'])
201+
}
202+
})
203+
})
204+
}
205+
})
206+
it('doesn\'t overwrite existing key-values for TrustX', function () {
207+
const adUnits = getAdUnits()
208+
const config = getConfig()
209+
210+
initSegments({ adUnits }, callback, config)
211+
212+
function callback () {
213+
adUnits.forEach(adUnit => {
214+
adUnit.bids.forEach(bid => {
215+
const { bidder, params } = bid
216+
217+
if (bidder === 'trustx') {
218+
expect(deepAccess(params, 'keywords.test_kv')).to.eql(['true'])
219+
}
220+
})
221+
})
222+
}
223+
})
224+
})
225+
132226
describe('Permutive on page', function () {
133227
it('checks if Permutive is on page', function () {
134228
expect(isPermutiveOnPage()).to.equal(false)
@@ -168,7 +262,7 @@ function getConfig () {
168262
name: 'permutive',
169263
waitForIt: true,
170264
params: {
171-
acBidders: ['appnexus', 'rubicon', 'ozone'],
265+
acBidders: ['appnexus', 'rubicon', 'ozone', 'trustx'],
172266
maxSegs: 500
173267
}
174268
}
@@ -197,15 +291,20 @@ function getTargetingData () {
197291
}
198292

199293
function getAdUnits () {
294+
const div_1_sizes = [
295+
[300, 250],
296+
[300, 600]
297+
]
298+
const div_2_sizes = [
299+
[728, 90],
300+
[970, 250]
301+
]
200302
return [
201303
{
202304
code: '/19968336/header-bid-tag-0',
203305
mediaTypes: {
204306
banner: {
205-
sizes: [
206-
[300, 250],
207-
[300, 600]
208-
]
307+
sizes: div_1_sizes
209308
}
210309
},
211310
bids: [
@@ -214,7 +313,7 @@ function getAdUnits () {
214313
params: {
215314
placementId: 13144370,
216315
keywords: {
217-
inline_kvs: ['1']
316+
test_kv: ['true']
218317
}
219318
}
220319
},
@@ -228,7 +327,7 @@ function getAdUnits () {
228327
area: ['home']
229328
},
230329
visitor: {
231-
inline_kvs: ['1']
330+
test_kv: ['true']
232331
}
233332
}
234333
},
@@ -242,38 +341,54 @@ function getAdUnits () {
242341
{
243342
settings: {},
244343
targeting: {
245-
inline_kvs: ['1', '2', '3', '4']
344+
test_kv: ['true']
246345
}
247346
}
248347
],
249348
ozoneData: {}
250349
}
350+
},
351+
{
352+
bidder: 'trustx',
353+
params: {
354+
uid: 45,
355+
keywords: {
356+
test_kv: ['true']
357+
}
358+
}
251359
}
252360
]
253361
},
254362
{
255363
code: '/19968336/header-bid-tag-1',
256364
mediaTypes: {
257365
banner: {
258-
sizes: [
259-
[728, 90],
260-
[970, 250]
261-
]
366+
sizes: div_2_sizes
262367
}
263368
},
264369
bids: [
265370
{
266371
bidder: 'appnexus',
267372
params: {
268-
placementId: 13144370
373+
placementId: 13144370,
374+
keywords: {
375+
test_kv: ['true']
376+
}
269377
}
270378
},
271379
{
272380
bidder: 'ozone',
273381
params: {
274382
publisherId: 'OZONEGMG0001',
275383
siteId: '4204204209',
276-
placementId: '0420420500'
384+
placementId: '0420420500',
385+
customData: [
386+
{
387+
targeting: {
388+
test_kv: ['true']
389+
}
390+
}
391+
]
277392
}
278393
}
279394
]

0 commit comments

Comments
 (0)