Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ortbConverter: do not override EIDS provided as first party data #12076

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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