Skip to content

Commit

Permalink
Permutive - add AC support for TrustX (#6393)
Browse files Browse the repository at this point in the history
  • Loading branch information
dreischer authored Mar 10, 2021
1 parent 20f3cd8 commit b65ea73
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 21 deletions.
19 changes: 14 additions & 5 deletions integrationExamples/gpt/permutiveRtdProvider_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
params: {
placementId: 13144370,
keywords: {
inline_kvs: ['1']
test_kv: ['true']
}
}
},
Expand All @@ -64,7 +64,7 @@
area: ['home']
},
visitor: {
inline_kvs: ['1']
test_kv: ['true']
}
}
},
Expand All @@ -78,12 +78,21 @@
{
settings: {},
targeting: {
inline_kvs: ['1', '2', '3', '4']
test_kv: ['true']
}
}
],
ozoneData: {}
}
},
{
bidder: 'trustx',
params: {
uid: 45,
keywords: {
test_kv: ['true']
}
}
}
]
},
Expand Down Expand Up @@ -127,13 +136,13 @@
pbjs.setConfig({
debug: true,
realTimeData: {
auctionDelay: 50, // maximum time for RTD modules to respond
auctionDelay: 80, // maximum time for RTD modules to respond
dataProviders: [
{
name: 'permutive',
waitForIt: true,
params: {
acBidders: ['appnexus', 'rubicon', 'ozone'],
acBidders: ['appnexus', 'rubicon', 'ozone', 'trustx'],
maxSegs: 500,
overwrites: {
rubicon: function (bid, data, acEnabled, utils, defaultFn) {
Expand Down
7 changes: 7 additions & 0 deletions modules/permutiveRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ function getDefaultBidderFn (bidder) {
deepSetValue(bid, 'params.customData.0.targeting.p_standard', data.ac)
}

return bid
},
trustx: function (bid, data, acEnabled) {
if (acEnabled && data.ac && data.ac.length) {
deepSetValue(bid, 'params.keywords.p_standard', data.ac)
}

return bid
}
}
Expand Down
1 change: 1 addition & 0 deletions modules/permutiveRtdProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ The below bidders are currently support by the Permutive RTD module. Please reac
| Xandr | `appnexus` | Yes | Yes |
| Magnite | `rubicon` | Yes | Yes |
| Ozone | `ozone` | No | Yes |
| TrustX | `trustx` | No | Yes |

* **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.

Expand Down
147 changes: 131 additions & 16 deletions test/spec/modules/permutiveRtdProvider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('permutiveRtdProvider', function () {
})
}
})
it('sets segment targeting for Rubicon', function () {
it('sets segment targeting for Magnite', function () {
const data = transformedTargeting()
const adUnits = getAdUnits()
const config = getConfig()
Expand Down Expand Up @@ -93,10 +93,29 @@ describe('permutiveRtdProvider', function () {
})
}
})
it('sets segment targeting for TrustX', function () {
const data = transformedTargeting()
const adUnits = getAdUnits()
const config = getConfig()

initSegments({ adUnits }, callback, config)

function callback () {
adUnits.forEach(adUnit => {
adUnit.bids.forEach(bid => {
const { bidder, params } = bid

if (bidder === 'trustx') {
expect(deepAccess(params, 'keywords.p_standard')).to.eql(data.ac)
}
})
})
}
})
})

describe('Custom segment targeting', function () {
it('sets custom segment targeting for Rubicon', function () {
it('sets custom segment targeting for Magnite', function () {
const data = transformedTargeting()
const adUnits = getAdUnits()
const config = getConfig()
Expand Down Expand Up @@ -129,6 +148,81 @@ describe('permutiveRtdProvider', function () {
})
})

describe('Existing key-value targeting', function () {
it('doesn\'t overwrite existing key-values for Xandr', function () {
const adUnits = getAdUnits()
const config = getConfig()

initSegments({ adUnits }, callback, config)

function callback () {
adUnits.forEach(adUnit => {
adUnit.bids.forEach(bid => {
const { bidder, params } = bid

if (bidder === 'appnexus') {
expect(deepAccess(params, 'keywords.test_kv')).to.eql(['true'])
}
})
})
}
})
it('doesn\'t overwrite existing key-values for Magnite', function () {
const adUnits = getAdUnits()
const config = getConfig()

initSegments({ adUnits }, callback, config)

function callback () {
adUnits.forEach(adUnit => {
adUnit.bids.forEach(bid => {
const { bidder, params } = bid

if (bidder === 'rubicon') {
expect(deepAccess(params, 'visitor.test_kv')).to.eql(['true'])
}
})
})
}
})
it('doesn\'t overwrite existing key-values for Ozone', function () {
const adUnits = getAdUnits()
const config = getConfig()

initSegments({ adUnits }, callback, config)

function callback () {
adUnits.forEach(adUnit => {
adUnit.bids.forEach(bid => {
const { bidder, params } = bid

if (bidder === 'ozone') {
expect(deepAccess(params, 'customData.0.targeting.test_kv')).to.eql(['true'])
}
})
})
}
})
it('doesn\'t overwrite existing key-values for TrustX', function () {
const adUnits = getAdUnits()
const config = getConfig()

initSegments({ adUnits }, callback, config)

function callback () {
adUnits.forEach(adUnit => {
adUnit.bids.forEach(bid => {
const { bidder, params } = bid

if (bidder === 'trustx') {
expect(deepAccess(params, 'keywords.test_kv')).to.eql(['true'])
}
})
})
}
})
})

describe('Permutive on page', function () {
it('checks if Permutive is on page', function () {
expect(isPermutiveOnPage()).to.equal(false)
Expand Down Expand Up @@ -168,7 +262,7 @@ function getConfig () {
name: 'permutive',
waitForIt: true,
params: {
acBidders: ['appnexus', 'rubicon', 'ozone'],
acBidders: ['appnexus', 'rubicon', 'ozone', 'trustx'],
maxSegs: 500
}
}
Expand Down Expand Up @@ -197,15 +291,20 @@ function getTargetingData () {
}

function getAdUnits () {
const div_1_sizes = [
[300, 250],
[300, 600]
]
const div_2_sizes = [
[728, 90],
[970, 250]
]
return [
{
code: '/19968336/header-bid-tag-0',
mediaTypes: {
banner: {
sizes: [
[300, 250],
[300, 600]
]
sizes: div_1_sizes
}
},
bids: [
Expand All @@ -214,7 +313,7 @@ function getAdUnits () {
params: {
placementId: 13144370,
keywords: {
inline_kvs: ['1']
test_kv: ['true']
}
}
},
Expand All @@ -228,7 +327,7 @@ function getAdUnits () {
area: ['home']
},
visitor: {
inline_kvs: ['1']
test_kv: ['true']
}
}
},
Expand All @@ -242,38 +341,54 @@ function getAdUnits () {
{
settings: {},
targeting: {
inline_kvs: ['1', '2', '3', '4']
test_kv: ['true']
}
}
],
ozoneData: {}
}
},
{
bidder: 'trustx',
params: {
uid: 45,
keywords: {
test_kv: ['true']
}
}
}
]
},
{
code: '/19968336/header-bid-tag-1',
mediaTypes: {
banner: {
sizes: [
[728, 90],
[970, 250]
]
sizes: div_2_sizes
}
},
bids: [
{
bidder: 'appnexus',
params: {
placementId: 13144370
placementId: 13144370,
keywords: {
test_kv: ['true']
}
}
},
{
bidder: 'ozone',
params: {
publisherId: 'OZONEGMG0001',
siteId: '4204204209',
placementId: '0420420500'
placementId: '0420420500',
customData: [
{
targeting: {
test_kv: ['true']
}
}
]
}
}
]
Expand Down

0 comments on commit b65ea73

Please sign in to comment.