Skip to content

Commit

Permalink
ortbConverter: do not override EIDS provided as first party data (pre…
Browse files Browse the repository at this point in the history
…bid#12076)

* ortbConverter: do not override EIDS provided as first party data

* update tests
  • Loading branch information
dgirardi authored Aug 1, 2024
1 parent 1947d97 commit cf98f85
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion modules/userId/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
2 changes: 1 addition & 1 deletion test/spec/modules/openxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/trafficgateBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
25 changes: 23 additions & 2 deletions test/spec/ortbConverter/userId_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {}, [{}]);
Expand Down

0 comments on commit cf98f85

Please sign in to comment.