diff --git a/modules/.submodules.json b/modules/.submodules.json index 1ca72def9f3..0216b928858 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -32,7 +32,7 @@ "netIdSystem", "nextrollIdSystem", "novatiqIdSystem", - "pafIdSystem", + "oneKeyIdSystem", "parrableIdSystem", "pubProvidedIdSystem", "publinkIdSystem", @@ -61,7 +61,7 @@ "jwplayerRtdProvider", "medianetRtdProvider", "optimeraRtdProvider", - "pafRtdProvider", + "oneKeyRtdProvider", "permutiveRtdProvider", "reconciliationRtdProvider", "sirdataRtdProvider", diff --git a/modules/pafIdSystem.js b/modules/oneKeyIdSystem.js similarity index 51% rename from modules/pafIdSystem.js rename to modules/oneKeyIdSystem.js index 3de42ea2c94..4d65408e5f3 100644 --- a/modules/pafIdSystem.js +++ b/modules/oneKeyIdSystem.js @@ -1,19 +1,22 @@ /** - * This module adds pafData to the User ID module + * This module adds Onekey data to the User ID module * The {@link module:modules/userId} module is required - * @module modules/swanIdSystem + * @module modules/oneKeyIdSystem * @requires module:modules/userId */ import {submodule} from '../src/hook.js'; +window.PAF = window.PAF || {}; +window.PAF.queue = window.PAF.queue || []; + /** @type {Submodule} */ -export const pafIdSubmodule = { +export const oneKeyIdSubmodule = { /** * used to link submodule with config * @type {string} */ - name: 'pafData', + name: 'oneKeyData', /** * decode the stored data value for passing to bid requests * @function decode @@ -32,12 +35,22 @@ export const pafIdSubmodule = { * @returns {IdResponse|undefined} */ getId(config, consentData) { - if (window.PAF && window.PAF.getIdsAndPreferences()) { - return {id: window.PAF.getIdsAndPreferences()}; - } else { - return undefined; - } + const idResponseCallback = function (callbackResp) { + window.PAF.queue.push(function() { + if (config.params === undefined || config.params.proxyHostName === undefined) { + callbackResp(); + return + } + const options = { + proxyHostName: config.params.proxyHostName, + callback: callbackResp + }; + window.PAF.getIdsAndPreferencesAsync(options); + }); + }; + + return { callback: idResponseCallback }; } }; -submodule('userId', pafIdSubmodule); +submodule('userId', oneKeyIdSubmodule); diff --git a/modules/pafIdSystem.md b/modules/oneKeyIdSystem.md similarity index 75% rename from modules/pafIdSystem.md rename to modules/oneKeyIdSystem.md index 3c9a3c16aa8..9d55cca883c 100644 --- a/modules/pafIdSystem.md +++ b/modules/oneKeyIdSystem.md @@ -1,33 +1,33 @@ # Prebid Addressability Framework (OneKey) -The PAF real-time data module in Prebid has been built so that publishers -can quickly and easily setup the Prebid Addressability Framework and utilize OneKey. -This module is used along with the pafRtdProvider to pass PAF data to your partners. -Both modules are required. This module will pass paData to your partners -while the pafRtdProvider will pass the transmission requests. +The OneKey real-time data module in Prebid has been built so that publishers +can quickly and easily setup the OneKey Addressability Framework. +This module is used along with the oneKeyRtdProvider to pass OneKey data to your partners. +Both modules are required. This module will pass oneKeyData to your partners +while the oneKeyRtdProvider will pass the transmission requests. Background information: - [prebid/addressability-framework](https://github.com/prebid/addressability-framework) - [prebid/paf-mvp-implementation](https://github.com/prebid/paf-mvp-implementation) -## PAF Configuration +## OneKey Configuration -The pafData module depends on paf-lib.js existing in the page. +The oneKeyData module depends on paf-lib.js existing in the page. -Compile the pafData module into your Prebid build. -You will also want to add the pafRtdProvider module as well. +Compile the oneKeyData module into your Prebid build. +You will also want to add the oneKeyRtdProvider module as well. -`gulp build --modules=userId,pafIdSystem,rtdModule,pafRtdProvider,appnexusBidAdapter` +`gulp build --modules=userId,oneKeyIdSystem,rtdModule,oneKeyRtdProvider,appnexusBidAdapter` -There are no custom configuration parameters for PAF. The module -will retrieve the PAF data from the page if available and pass the +There are no custom configuration parameters for OneKey. The module +will retrieve the OneKey data from the page if available and pass the information to bidders. Here is a configuration example: ```javascript pbjs.setConfig({ userSync: { userIds: [{ - name: "pafData", + name: "oneKeyData", params: {} }] }], diff --git a/modules/pafRtdProvider.js b/modules/oneKeyRtdProvider.js similarity index 54% rename from modules/pafRtdProvider.js rename to modules/oneKeyRtdProvider.js index 07cc322842b..96b04ca5a4f 100644 --- a/modules/pafRtdProvider.js +++ b/modules/oneKeyRtdProvider.js @@ -4,7 +4,10 @@ import { mergeDeep, isPlainObject, logError, logMessage, deepSetValue, generateU import { getGlobal } from '../src/prebidGlobal.js'; import {config} from '../src/config.js'; -const SUBMODULE_NAME = 'paf'; +const SUBMODULE_NAME = 'oneKey'; + +window.PAF = window.PAF || {}; +window.PAF.queue = window.PAF.queue || []; /** * @@ -14,28 +17,40 @@ const SUBMODULE_NAME = 'paf'; * @param {Object} userConsent */ export function getBidRequestData(reqBidsConfigObj, onDone, rtdConfig, userConsent) { - let idsAndPreferences; - const adUnits = (reqBidsConfigObj.adUnits || getGlobal().adUnits); - - if (rtdConfig.params && rtdConfig.params.proxyHostName && window.PAF) { - idsAndPreferences = window.PAF.getIdsAndPreferences(); - if (!idsAndPreferences) { - onDone(); - logMessage(SUBMODULE_NAME, 'No id and preferences. Not creating Seed.'); - return; - } - - let transactionIds = []; - for (var i = 0; i < adUnits.length; i++) { - const uuid = generateUUID(); - transactionIds.push(uuid) - deepSetValue(adUnits[i], `ortb2Imp.ext.data.paf.transaction_id`, uuid) - } - - window.PAF.generateSeed({proxyHostName: rtdConfig.params.proxyHostName, callback: function (seed) { setData(seed, rtdConfig, onDone); }}, transactionIds) - } else { + if (rtdConfig.params === undefined || rtdConfig.params.proxyHostName === undefined) { onDone(); + return } + window.PAF.queue.push(function() { + const idsAndPreferencesAsyncOptions = { + proxyHostName: rtdConfig.params.proxyHostName, + callback: function (idsAndPreferences) { + if (!idsAndPreferences) { + onDone(); + logMessage(SUBMODULE_NAME, 'No id and preferences. Not creating Seed.'); + return; + } + + const adUnits = (reqBidsConfigObj.adUnits || getGlobal().adUnits); + let transactionIds = []; + for (var i = 0; i < adUnits.length; i++) { + const uuid = generateUUID(); + transactionIds.push(uuid) + deepSetValue(adUnits[i], `ortb2Imp.ext.data.paf.transaction_id`, uuid) + } + + const generateSeedOption = { + proxyHostName: rtdConfig.params.proxyHostName, + callback: function (seed) { + setData(seed, rtdConfig, onDone); + } + } + window.PAF.generateSeed(generateSeedOption, transactionIds) + } + }; + + window.PAF.getIdsAndPreferencesAsync(idsAndPreferencesAsyncOptions); + }); } /** @@ -62,7 +77,7 @@ export function setData(seed, rtdConfig, onDone) { return; } logMessage(SUBMODULE_NAME, 'Created Seed:', seed); - const pafOrtb2 = { + const okOrtb2 = { ortb2: { user: { ext: { @@ -78,7 +93,7 @@ export function setData(seed, rtdConfig, onDone) { if (rtdConfig.params && rtdConfig.params.bidders) { let bidderConfig = config.getBidderConfig(); - logMessage(SUBMODULE_NAME, `set ortb2 for: ${rtdConfig.params.bidders}`, pafOrtb2); + logMessage(SUBMODULE_NAME, `set ortb2 for: ${rtdConfig.params.bidders}`, okOrtb2); rtdConfig.params.bidders.forEach(bidder => { let bidderOptions = {}; if (isPlainObject(bidderConfig[bidder])) { @@ -87,19 +102,19 @@ export function setData(seed, rtdConfig, onDone) { config.setBidderConfig({ bidders: [bidder], - config: mergeLazy(bidderOptions, pafOrtb2) + config: mergeLazy(bidderOptions, okOrtb2) }); }); } else { let ortb2 = config.getConfig('ortb2') || {}; - logMessage(SUBMODULE_NAME, 'set ortb2:', pafOrtb2); - config.setConfig({ortb2: mergeLazy(ortb2, pafOrtb2.ortb2)}); + logMessage(SUBMODULE_NAME, 'set ortb2:', okOrtb2); + config.setConfig({ortb2: mergeLazy(ortb2, okOrtb2.ortb2)}); } onDone(); } /** @type {RtdSubmodule} */ -export const pafDataSubmodule = { +export const oneKeyDataSubmodule = { /** * used to link submodule with realTimeData * @type {string} @@ -110,7 +125,7 @@ export const pafDataSubmodule = { }; function registerSubModule() { - submodule('realTimeData', pafDataSubmodule); + submodule('realTimeData', oneKeyDataSubmodule); } registerSubModule(); diff --git a/modules/pafRtdProvider.md b/modules/oneKeyRtdProvider.md similarity index 79% rename from modules/pafRtdProvider.md rename to modules/oneKeyRtdProvider.md index a685413aa77..d728f0703c8 100644 --- a/modules/pafRtdProvider.md +++ b/modules/oneKeyRtdProvider.md @@ -1,10 +1,10 @@ ## Prebid Addressability Framework Real-time Data Submodule -The PAF real-time data module in Prebid has been built so that publishers -can quickly and easily setup the Prebid Addressability Framework and utilize OneKey. -This module is used along with the pafIdSysytem to pass PAF data to your partners. +The OneKey real-time data module in Prebid has been built so that publishers +can quickly and easily setup the OneKey Addressability Framework. +This module is used along with the oneKeyIdSystem to pass OneKey data to your partners. Both modules are required. This module will pass transmission requests to your partners -while the pafIdSystem will pass the pafData. +while the oneKeyIdSystem will pass the oneKeyData. Background information: - [prebid/addressability-framework](https://github.com/prebid/addressability-framework) @@ -12,13 +12,13 @@ Background information: ### Publisher Usage -The paf RTD module depends on paf-lib.js existing in the page. +The OneKey RTD module depends on paf-lib.js existing in the page. -Compile the paf RTD module into your Prebid build: +Compile the OneKey RTD module into your Prebid build: -`gulp build --modules=userId,pafIdSystem,rtdModule,pafRtdProvider,appnexusBidAdapter` +`gulp build --modules=userId,oneKeyIdSystem,rtdModule,oneKeyRtdProvider,appnexusBidAdapter` -Add the PAF RTD provider to your Prebid config. In this example we will configure +Add the OneKey RTD provider to your Prebid config. In this example we will configure a sample proxyHostName. See the "Parameter Descriptions" below for more detailed information of the configuration parameters. @@ -41,14 +41,14 @@ pbjs.setConfig( } ``` -### Parameter Descriptions for the PAF Configuration Section +### Parameter Descriptions for the OneKey Configuration Section | Name |Type | Description | Notes | | :------------ | :------------ | :------------ |:------------ | -| name | String | Real time data module name | Always 'paf' | +| name | String | Real time data module name | Always 'oneKey' | | waitForIt | Boolean | Required to ensure that the auction is delayed until prefetch is complete | Optional. Defaults to false | | params | Object | | | -| params.proxyHostName | String | servername of the PAF Proxy which will generate seeds. | Required | +| params.proxyHostName | String | servername of the OneKey Proxy which will generate seeds. | Required | | params.bidders | Array | List of bidders to restrict the data to. | Optional | ### Data for bidders @@ -93,7 +93,7 @@ The following is an example of the format of the data: ### Bidder Responses -Bidders who are part of the Prebid Addressability Framework and receive PAF +Bidders who are part of the OneKey Addressability Framework and receive OneKey transmissions are required to return transmission responses as outlined in [prebid/addressability-framework](https://github.com/prebid/addressability-framework/blob/main/mvp-spec/ad-auction.md). Transmission responses should be appended to bids along with the releveant content_id using the meta.paf field. The paf-lib will diff --git a/modules/userId/eids.js b/modules/userId/eids.js index d49af8fbad8..855210a0ffa 100644 --- a/modules/userId/eids.js +++ b/modules/userId/eids.js @@ -315,8 +315,8 @@ export const USER_IDS_CONFIG = { } }, - // PAF Data - 'pafData': { + // OneKey Data + 'oneKeyData': { getValue: function(data) { if (data && Array.isArray(data.identifiers) && data.identifiers[0]) { return data.identifiers[0].value; diff --git a/test/spec/modules/pafIdSystem_spec.js b/test/spec/modules/oneKeyIdSystem_spec.js similarity index 71% rename from test/spec/modules/pafIdSystem_spec.js rename to test/spec/modules/oneKeyIdSystem_spec.js index 22825e2922f..448ce02347f 100644 --- a/test/spec/modules/pafIdSystem_spec.js +++ b/test/spec/modules/oneKeyIdSystem_spec.js @@ -1,4 +1,4 @@ -import { pafIdSubmodule } from 'modules/pafIdSystem' +import { oneKeyIdSubmodule } from 'modules/oneKeyIdSystem' import { config } from 'src/config.js'; import {find} from 'src/polyfill.js'; import { init, requestBidsHook, setSubmoduleRegistry } from 'modules/userId/index.js'; @@ -34,7 +34,7 @@ function getConfigMock() { userSync: { syncDelay: 0, userIds: [{ - name: 'pafData' + name: 'oneKeyData' }] } } @@ -55,29 +55,31 @@ function getAdUnitMock(code = 'adUnit-code') { }; } -describe('pafData module', function () { - it('returns undefined if paf-lib is not found', function () { - const moduleIdResponse = pafIdSubmodule.getId(); - expect(moduleIdResponse).to.be.undefined; - }) - it('returns undefined if no Data', function () { - window.PAF = { - getIdsAndPreferences() { - return undefined; - } - } - const moduleIdResponse = pafIdSubmodule.getId(); - expect(moduleIdResponse).to.be.undefined; - }) - it('gets pafData from page context', function () { - window.PAF = { - getIdsAndPreferences() { - return idsAndPrefs; - } - } - const moduleIdResponse = pafIdSubmodule.getId(); - expect(moduleIdResponse).to.deep.equal({id: idsAndPrefs}); - }) +describe('oneKeyData module', function () { + it('create PAF object with operation queue if they don\'t exist yet and return object with callback', function () { + const moduleIdResponse = oneKeyIdSubmodule.getId(); + expect(window.PAF.queue.length).to.equal(1); + expect(moduleIdResponse.callback).to.be.an('function'); + }); + + // it('returns undefined if no Data', function () { + // window.PAF = { + // getIdsAndPreferences() { + // return undefined; + // } + // } + // const moduleIdResponse = oneKeyIdSubmodule.getId(); + // expect(moduleIdResponse).to.be.undefined; + // }) + // it('gets pafData from page context', function () { + // window.PAF = { + // getIdsAndPreferences() { + // return idsAndPrefs; + // } + // } + // const moduleIdResponse = pafIdSubmodule.getId(); + // expect(moduleIdResponse).to.deep.equal({id: idsAndPrefs}); + // }) // this test format was copied from other id module tests // but it is failing on the hook and im not sure why, if someone diff --git a/test/spec/modules/oneKeyRtdProvider_spec.js b/test/spec/modules/oneKeyRtdProvider_spec.js new file mode 100644 index 00000000000..247cb8470b8 --- /dev/null +++ b/test/spec/modules/oneKeyRtdProvider_spec.js @@ -0,0 +1,213 @@ +import {config} from 'src/config.js'; +import {setData, getBidRequestData, oneKeyDataSubmodule} from 'modules/oneKeyRtdProvider.js'; +import {getAdUnits} from '../../fixtures/fixtures.js'; + +describe('oneKeyRtdProvider', function() { + beforeEach(function() { + config.resetConfig(); + }); + + describe('oneKeyDataSubmodule', function() { + it('successfully instantiates', function () { + expect(oneKeyDataSubmodule.init()).to.equal(true); + }); + }); + + // describe('setData', function() { + // it('merges global ortb2 data', function() { + // let rtdConfig = {params: {proxyHostName: 'host'}}; + // let seed = 'seed_placeholder'; + + // const setConfigUserObj1 = { + // name: 'www.dataprovider1.com', + // ext: { taxonomyname: 'iab_audience_taxonomy' }, + // segment: [{ + // id: '1776' + // }] + // }; + + // config.setConfig({ + // ortb2: { + // user: { + // data: [setConfigUserObj1], + // ext: {other: 'data'} + // } + // } + // }); + + // setData(seed, rtdConfig, () => {}); + + // let ortb2Config = config.getConfig().ortb2; + + // expect(ortb2Config.user.data).to.deep.include.members([setConfigUserObj1]); + // expect(ortb2Config.user.ext.paf.transmission.seed).to.equal(seed); + // expect(ortb2Config.user.ext.other).to.equal('data'); + // }); + + // it('merges bidder-specific ortb2 data', function() { + // let rtdConfig = {params: {proxyHostName: 'host', bidders: ['openx']}}; + // let seed = 'seed_placeholder'; + + // const setConfigUserObj1 = { + // name: 'www.dataprovider1.com', + // ext: { taxonomyname: 'iab_audience_taxonomy' }, + // segment: [{ + // id: '1776' + // }] + // }; + + // config.setBidderConfig({ + // bidders: ['bidder1'], + // config: { + // ortb2: { + // user: { + // data: [setConfigUserObj1], + // ext: {other: 'data'} + // } + // } + // } + // }); + + // config.setBidderConfig({ + // bidders: ['openx'], + // config: { + // ortb2: { + // user: { + // data: [setConfigUserObj1], + // ext: {other: 'data'} + // } + // } + // } + // }); + + // setData(seed, rtdConfig, () => {}); + + // let ortb2Config = config.getBidderConfig().bidder1.ortb2; + + // expect(ortb2Config.user.data).to.deep.include.members([setConfigUserObj1]); + // expect(ortb2Config.user.ext.paf).to.be.undefined; + // expect(ortb2Config.user.ext.other).to.equal('data'); + + // ortb2Config = config.getBidderConfig().openx.ortb2; + + // expect(ortb2Config.user.data).to.deep.include.members([setConfigUserObj1]); + // expect(ortb2Config.user.ext.paf.transmission.seed).to.equal(seed); + // expect(ortb2Config.user.ext.other).to.equal('data'); + // }); + // }); + + // describe('getBidRequestData', function() { + // it('gets seed from paf-lib and sets data and transaction_ids', function() { + // const adUnits = getAdUnits(); + // window.PAF = { + // getIdsAndPreferences() { + // return true; + // }, + // generateSeed(options, ids) { + // options.callback({ + // transaction_ids: ids + // }) + // } + // } + // let bidConfig = {adUnits}; + // let rtdConfig = {params: {proxyHostName: 'host'}}; + + // const setConfigUserObj1 = { + // name: 'www.dataprovider1.com', + // ext: { taxonomyname: 'iab_audience_taxonomy' }, + // segment: [{ + // id: '1776' + // }] + // }; + + // config.setConfig({ + // ortb2: { + // user: { + // data: [setConfigUserObj1], + // ext: {other: 'data'} + // } + // } + // }); + + // getBidRequestData(bidConfig, () => {}, rtdConfig, {}); + // let ortb2Config = config.getConfig().ortb2; + + // adUnits.forEach(adUnit => { + // const transaction_id = adUnit.ortb2Imp.ext.data.paf.transaction_id; + // expect(transaction_id).to.not.be.undefined; + // expect(ortb2Config.user.ext.paf.transmission.seed.transaction_ids).contain(transaction_id) + // }); + + // expect(ortb2Config.user.data).to.deep.include.members([setConfigUserObj1]); + // expect(ortb2Config.user.ext.paf.transmission.seed).to.have.property('transaction_ids'); + // expect(ortb2Config.user.ext.other).to.equal('data'); + // }); + // }); + + // it('does nothing if paf-lib doesnt exist', function() { + // const adUnits = getAdUnits(); + // window.PAF = undefined; + // let bidConfig = {adUnits}; + // let rtdConfig = {params: {proxyHostName: 'host'}}; + + // const setConfigUserObj1 = { + // name: 'www.dataprovider1.com', + // ext: { taxonomyname: 'iab_audience_taxonomy' }, + // segment: [{ + // id: '1776' + // }] + // }; + + // config.setConfig({ + // ortb2: { + // user: { + // data: [setConfigUserObj1], + // ext: {other: 'data'} + // } + // } + // }); + + // getBidRequestData(bidConfig, () => {}, rtdConfig, {}); + // let ortb2Config = config.getConfig().ortb2; + // expect(ortb2Config.user.data).to.deep.include.members([setConfigUserObj1]); + // expect(ortb2Config.user.ext.other).to.equal('data'); + // }); + + // it('requires proxyHostName', function() { + // const adUnits = getAdUnits(); + // window.PAF = { + // getIdsAndPreferences() { + // return true; + // }, + // generateSeed(options, ids) { + // options.callback({ + // transaction_ids: ids + // }) + // } + // } + // let bidConfig = {adUnits}; + // let rtdConfig = {params: {}}; + + // const setConfigUserObj1 = { + // name: 'www.dataprovider1.com', + // ext: { taxonomyname: 'iab_audience_taxonomy' }, + // segment: [{ + // id: '1776' + // }] + // }; + + // config.setConfig({ + // ortb2: { + // user: { + // data: [setConfigUserObj1], + // ext: {other: 'data'} + // } + // } + // }); + + // getBidRequestData(bidConfig, () => {}, rtdConfig, {}); + // let ortb2Config = config.getConfig().ortb2; + // expect(ortb2Config.user.data).to.deep.include.members([setConfigUserObj1]); + // expect(ortb2Config.user.ext.other).to.equal('data'); + // }); +}); diff --git a/test/spec/modules/pafRtdProvider_spec.js b/test/spec/modules/pafRtdProvider_spec.js deleted file mode 100644 index 7d719fb4610..00000000000 --- a/test/spec/modules/pafRtdProvider_spec.js +++ /dev/null @@ -1,213 +0,0 @@ -import {config} from 'src/config.js'; -import {setData, getBidRequestData, pafDataSubmodule} from 'modules/pafRtdProvider.js'; -import {getAdUnits} from '../../fixtures/fixtures.js'; - -describe('pafRtdProvider', function() { - beforeEach(function() { - config.resetConfig(); - }); - - describe('pafDataSubmodule', function() { - it('successfully instantiates', function () { - expect(pafDataSubmodule.init()).to.equal(true); - }); - }); - - describe('setData', function() { - it('merges global ortb2 data', function() { - let rtdConfig = {params: {proxyHostName: 'host'}}; - let seed = 'seed_placeholder'; - - const setConfigUserObj1 = { - name: 'www.dataprovider1.com', - ext: { taxonomyname: 'iab_audience_taxonomy' }, - segment: [{ - id: '1776' - }] - }; - - config.setConfig({ - ortb2: { - user: { - data: [setConfigUserObj1], - ext: {other: 'data'} - } - } - }); - - setData(seed, rtdConfig, () => {}); - - let ortb2Config = config.getConfig().ortb2; - - expect(ortb2Config.user.data).to.deep.include.members([setConfigUserObj1]); - expect(ortb2Config.user.ext.paf.transmission.seed).to.equal(seed); - expect(ortb2Config.user.ext.other).to.equal('data'); - }); - - it('merges bidder-specific ortb2 data', function() { - let rtdConfig = {params: {proxyHostName: 'host', bidders: ['openx']}}; - let seed = 'seed_placeholder'; - - const setConfigUserObj1 = { - name: 'www.dataprovider1.com', - ext: { taxonomyname: 'iab_audience_taxonomy' }, - segment: [{ - id: '1776' - }] - }; - - config.setBidderConfig({ - bidders: ['bidder1'], - config: { - ortb2: { - user: { - data: [setConfigUserObj1], - ext: {other: 'data'} - } - } - } - }); - - config.setBidderConfig({ - bidders: ['openx'], - config: { - ortb2: { - user: { - data: [setConfigUserObj1], - ext: {other: 'data'} - } - } - } - }); - - setData(seed, rtdConfig, () => {}); - - let ortb2Config = config.getBidderConfig().bidder1.ortb2; - - expect(ortb2Config.user.data).to.deep.include.members([setConfigUserObj1]); - expect(ortb2Config.user.ext.paf).to.be.undefined; - expect(ortb2Config.user.ext.other).to.equal('data'); - - ortb2Config = config.getBidderConfig().openx.ortb2; - - expect(ortb2Config.user.data).to.deep.include.members([setConfigUserObj1]); - expect(ortb2Config.user.ext.paf.transmission.seed).to.equal(seed); - expect(ortb2Config.user.ext.other).to.equal('data'); - }); - }); - - describe('getBidRequestData', function() { - it('gets seed from paf-lib and sets data and transaction_ids', function() { - const adUnits = getAdUnits(); - window.PAF = { - getIdsAndPreferences() { - return true; - }, - generateSeed(options, ids) { - options.callback({ - transaction_ids: ids - }) - } - } - let bidConfig = {adUnits}; - let rtdConfig = {params: {proxyHostName: 'host'}}; - - const setConfigUserObj1 = { - name: 'www.dataprovider1.com', - ext: { taxonomyname: 'iab_audience_taxonomy' }, - segment: [{ - id: '1776' - }] - }; - - config.setConfig({ - ortb2: { - user: { - data: [setConfigUserObj1], - ext: {other: 'data'} - } - } - }); - - getBidRequestData(bidConfig, () => {}, rtdConfig, {}); - let ortb2Config = config.getConfig().ortb2; - - adUnits.forEach(adUnit => { - const transaction_id = adUnit.ortb2Imp.ext.data.paf.transaction_id; - expect(transaction_id).to.not.be.undefined; - expect(ortb2Config.user.ext.paf.transmission.seed.transaction_ids).contain(transaction_id) - }); - - expect(ortb2Config.user.data).to.deep.include.members([setConfigUserObj1]); - expect(ortb2Config.user.ext.paf.transmission.seed).to.have.property('transaction_ids'); - expect(ortb2Config.user.ext.other).to.equal('data'); - }); - }); - - it('does nothing if paf-lib doesnt exist', function() { - const adUnits = getAdUnits(); - window.PAF = undefined; - let bidConfig = {adUnits}; - let rtdConfig = {params: {proxyHostName: 'host'}}; - - const setConfigUserObj1 = { - name: 'www.dataprovider1.com', - ext: { taxonomyname: 'iab_audience_taxonomy' }, - segment: [{ - id: '1776' - }] - }; - - config.setConfig({ - ortb2: { - user: { - data: [setConfigUserObj1], - ext: {other: 'data'} - } - } - }); - - getBidRequestData(bidConfig, () => {}, rtdConfig, {}); - let ortb2Config = config.getConfig().ortb2; - expect(ortb2Config.user.data).to.deep.include.members([setConfigUserObj1]); - expect(ortb2Config.user.ext.other).to.equal('data'); - }); - - it('requires proxyHostName', function() { - const adUnits = getAdUnits(); - window.PAF = { - getIdsAndPreferences() { - return true; - }, - generateSeed(options, ids) { - options.callback({ - transaction_ids: ids - }) - } - } - let bidConfig = {adUnits}; - let rtdConfig = {params: {}}; - - const setConfigUserObj1 = { - name: 'www.dataprovider1.com', - ext: { taxonomyname: 'iab_audience_taxonomy' }, - segment: [{ - id: '1776' - }] - }; - - config.setConfig({ - ortb2: { - user: { - data: [setConfigUserObj1], - ext: {other: 'data'} - } - } - }); - - getBidRequestData(bidConfig, () => {}, rtdConfig, {}); - let ortb2Config = config.getConfig().ortb2; - expect(ortb2Config.user.data).to.deep.include.members([setConfigUserObj1]); - expect(ortb2Config.user.ext.other).to.equal('data'); - }); -});