From cf98f85fda395b70bfe5816b2481b318417aac5c Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Thu, 1 Aug 2024 12:41:45 -0700 Subject: [PATCH] ortbConverter: do not override EIDS provided as first party data (#12076) * ortbConverter: do not override EIDS provided as first party data * update tests --- modules/userId/index.js | 2 +- test/spec/modules/openxBidAdapter_spec.js | 2 +- .../modules/trafficgateBidAdapter_spec.js | 2 +- test/spec/ortbConverter/userId_spec.js | 25 +++++++++++++++++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/modules/userId/index.js b/modules/userId/index.js index b8d013df1c6..31083fd1e47 100644 --- a/modules/userId/index.js +++ b/modules/userId/index.js @@ -1196,7 +1196,7 @@ module('userId', attachIdSystem, { postInstallAllowed: true }); export function setOrtbUserExtEids(ortbRequest, bidderRequest, context) { const eids = deepAccess(context, 'bidRequests.0.userIdAsEids'); if (eids && Object.keys(eids).length > 0) { - deepSetValue(ortbRequest, 'user.ext.eids', eids); + deepSetValue(ortbRequest, 'user.ext.eids', eids.concat(ortbRequest.user?.ext?.eids || [])); } } registerOrtbProcessor({type: REQUEST, name: 'userExtEids', fn: setOrtbUserExtEids}); diff --git a/test/spec/modules/openxBidAdapter_spec.js b/test/spec/modules/openxBidAdapter_spec.js index ad4ee1e74ce..e895574b9aa 100644 --- a/test/spec/modules/openxBidAdapter_spec.js +++ b/test/spec/modules/openxBidAdapter_spec.js @@ -1025,7 +1025,7 @@ describe('OpenxRtbAdapter', function () { // enrich bid request with userId key/value const request = spec.buildRequests(bidRequestsWithUserId, mockBidderRequest); - expect(request[0].data.user.ext.eids).to.equal(userIdAsEids); + expect(request[0].data.user.ext.eids).to.eql(userIdAsEids); }); it(`when no user ids are available, it should not send any extended ids`, function () { diff --git a/test/spec/modules/trafficgateBidAdapter_spec.js b/test/spec/modules/trafficgateBidAdapter_spec.js index 9c564606186..7fbc566d375 100644 --- a/test/spec/modules/trafficgateBidAdapter_spec.js +++ b/test/spec/modules/trafficgateBidAdapter_spec.js @@ -1006,7 +1006,7 @@ describe('TrafficgateOpenxRtbAdapter', function () { // enrich bid request with userId key/value const request = spec.buildRequests(bidRequestsWithUserId, mockBidderRequest); - expect(request[0].data.user.ext.eids).to.equal(userIdAsEids); + expect(request[0].data.user.ext.eids).to.eql(userIdAsEids); }); it(`when no user ids are available, it should not send any extended ids`, function () { diff --git a/test/spec/ortbConverter/userId_spec.js b/test/spec/ortbConverter/userId_spec.js index 04a4d39ee48..2084cb0cfae 100644 --- a/test/spec/ortbConverter/userId_spec.js +++ b/test/spec/ortbConverter/userId_spec.js @@ -6,13 +6,34 @@ describe('pbjs - ortb user eids', () => { setOrtbUserExtEids(req, {}, { bidRequests: [ { - userIdAsEids: {e: 'id'} + userIdAsEids: [{e: 'id'}] } ] }); - expect(req.user.ext.eids).to.eql({e: 'id'}); + expect(req.user.ext.eids).to.eql([{e: 'id'}]); }); + it('should not override eids from fpd', () => { + const req = { + user: { + ext: { + eids: [{existing: 'id'}] + } + } + }; + setOrtbUserExtEids(req, {}, { + bidRequests: [ + { + userIdAsEids: [{nw: 'id'}] + } + ] + }); + expect(req.user.ext.eids).to.eql([ + {nw: 'id'}, + {existing: 'id'}, + ]) + }) + it('has no effect if requests have no eids', () => { const req = {}; setOrtbUserExtEids(req, {}, [{}]);