diff --git a/modules/livewrappedBidAdapter.js b/modules/livewrappedBidAdapter.js index 84b80ac14d4..6b7c055b295 100644 --- a/modules/livewrappedBidAdapter.js +++ b/modules/livewrappedBidAdapter.js @@ -1,4 +1,4 @@ -import { isSafariBrowser, deepAccess, getWindowTop } from '../src/utils.js'; +import { isSafariBrowser, deepAccess, getWindowTop, mergeDeep } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; import find from 'core-js-pure/features/array/find.js'; @@ -60,11 +60,17 @@ export const spec = { const bundle = find(bidRequests, hasBundleParam); const tid = find(bidRequests, hasTidParam); const schain = bidRequests[0].schain; + let ortb2 = config.getConfig('ortb2'); + const eids = handleEids(bidRequests); bidUrl = bidUrl ? bidUrl.params.bidUrl : URL; url = url ? url.params.url : (getAppDomain() || getTopWindowLocation(bidderRequest)); test = test ? test.params.test : undefined; var adRequests = bidRequests.map(bidToAdRequest); + if (eids) { + ortb2 = mergeDeep(ortb2 || {}, eids); + } + const payload = { auctionId: auctionId ? auctionId.auctionId : undefined, publisherId: publisherId ? publisherId.params.publisherId : undefined, @@ -86,7 +92,7 @@ export const spec = { cookieSupport: !isSafariBrowser() && storage.cookiesAreEnabled(), rcv: getAdblockerRecovered(), adRequests: [...adRequests], - rtbData: handleEids(bidRequests), + rtbData: ortb2, schain: schain }; diff --git a/test/spec/modules/livewrappedBidAdapter_spec.js b/test/spec/modules/livewrappedBidAdapter_spec.js index 085848cb97d..fac1ae1d6a0 100644 --- a/test/spec/modules/livewrappedBidAdapter_spec.js +++ b/test/spec/modules/livewrappedBidAdapter_spec.js @@ -885,6 +885,37 @@ describe('Livewrapped adapter tests', function () { expect(data.rtbData.user.ext.eids).to.deep.equal(testbidRequest.bids[0].userIdAsEids); }); + it('should merge user ids with existing ortb2', function() { + sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); + sandbox.stub(storage, 'cookiesAreEnabled').callsFake(() => true); + + let origGetConfig = config.getConfig; + sandbox.stub(config, 'getConfig').callsFake(function (key) { + if (key === 'ortb2') { + return {user: {ext: {prop: 'value'}}}; + } + return origGetConfig.apply(config, arguments); + }); + + let testbidRequest = clone(bidderRequest); + delete testbidRequest.bids[0].params.userId; + testbidRequest.bids[0].userIdAsEids = [ + { + 'source': 'pubcid.org', + 'uids': [{ + 'id': 'publisher-common-id', + 'atype': 1 + }] + } + ]; + + let result = spec.buildRequests(testbidRequest.bids, testbidRequest); + let data = JSON.parse(result.data); + var expected = {user: {ext: {prop: 'value', eids: testbidRequest.bids[0].userIdAsEids}}} + + expect(data.rtbData).to.deep.equal(expected); + }); + it('should send schain object if available', function() { sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); sandbox.stub(storage, 'cookiesAreEnabled').callsFake(() => true);