Skip to content

Commit

Permalink
fix(permutiveRtd): remove ozone map and set site ext (prebid#9628)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioGargaro authored May 15, 2023
1 parent 38cf634 commit 3de4b67
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 58 deletions.
47 changes: 9 additions & 38 deletions modules/permutiveRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ function updateOrtbConfig(bidder, currConfig, segmentIDs, sspSegmentIDs, transfo
logger.logInfo(`Extending ortb2.user.ext.data with "${PERMUTIVE_CUSTOM_COHORTS_KEYWORD}"`, customCohortsData)
}

// Set site extensions
if (segmentIDs.length > 0) {
deepSetValue(ortbConfig, `ortb2.site.ext.permutive.${PERMUTIVE_STANDARD_KEYWORD}`, segmentIDs)
logger.logInfo(`Extending ortb2.site.ext.permutive with "${PERMUTIVE_STANDARD_KEYWORD}"`, segmentIDs)
}

logger.logInfo(`Updated ortb2 config`, { bidder, config: ortbConfig })
return ortbConfig
}
Expand Down Expand Up @@ -230,12 +236,11 @@ function setSegments (reqBidsConfigObj, moduleConfig, segmentData) {
}
const acEnabled = isAcEnabled(moduleConfig, bidder)
const customFn = getCustomBidderFn(moduleConfig, bidder)
const defaultFn = getDefaultBidderFn(bidder)

if (customFn) {
customFn(bid, segmentData, acEnabled, utils, defaultFn)
} else if (defaultFn) {
defaultFn(bid, segmentData, acEnabled)
// For backwards compatibility we pass an identity function to any custom bidder function set by a publisher
const bidIdentity = (bid) => bid
customFn(bid, segmentData, acEnabled, utils, bidIdentity)
}
})
})
Expand Down Expand Up @@ -263,40 +268,6 @@ function getCustomBidderFn (moduleConfig, bidder) {
}
}

/**
* Returns a function that receives a `bid` object, a `data` object and a `acEnabled` boolean
* and which will set the right segment targeting keys for `bid` based on `data` and `acEnabled`
* @param {string} bidder - Bidder name
* @return {Object} Bidder function
*/
function getDefaultBidderFn (bidder) {
const isPStandardTargetingEnabled = (data, acEnabled) => {
return (acEnabled && data.ac && data.ac.length) || (data.ssp && data.ssp.cohorts && data.ssp.cohorts.length)
}
const pStandardTargeting = (data, acEnabled) => {
const ac = (acEnabled) ? (data.ac ?? []) : []
const ssp = data?.ssp?.cohorts ?? []
return [...new Set([...ac, ...ssp])]
}
const bidderMap = {
ozone: function (bid, data, acEnabled) {
if (isPStandardTargetingEnabled(data, acEnabled)) {
const segments = pStandardTargeting(data, acEnabled)
deepSetValue(bid, 'params.customData.0.targeting.p_standard', segments)
}

return bid
}
}

// On no default bidder just return the same bid as passed in
function bidIdentity(bid) {
return bid
}

return bidderMap[bidder] || bidIdentity
}

/**
* Check whether ac is enabled for bidder
* @param {Object} moduleConfig - Module configuration
Expand Down
20 changes: 0 additions & 20 deletions test/spec/modules/permutiveRtdProvider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,26 +560,6 @@ describe('permutiveRtdProvider', function () {
})
})

describe('Default segment targeting', function () {
it('sets segment targeting for Ozone', function () {
const data = transformedTargeting()
const adUnits = getAdUnits()
const config = getConfig()

readAndSetCohorts({ adUnits }, config)

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

if (bidder === 'ozone') {
expect(deepAccess(params, 'customData.0.targeting.p_standard')).to.eql(data.ac.concat(data.ssp.cohorts))
}
})
})
})
})

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

0 comments on commit 3de4b67

Please sign in to comment.