diff --git a/modules/permutiveRtdProvider.js b/modules/permutiveRtdProvider.js index ab827f2b6a5..697d7721205 100644 --- a/modules/permutiveRtdProvider.js +++ b/modules/permutiveRtdProvider.js @@ -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 } @@ -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) } }) }) @@ -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 diff --git a/test/spec/modules/permutiveRtdProvider_spec.js b/test/spec/modules/permutiveRtdProvider_spec.js index 1f39d1a2cda..942ec2eaa46 100644 --- a/test/spec/modules/permutiveRtdProvider_spec.js +++ b/test/spec/modules/permutiveRtdProvider_spec.js @@ -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()