Skip to content

Commit

Permalink
consumableBidAdapter: remove eid non-objects
Browse files Browse the repository at this point in the history
  • Loading branch information
jpiros committed Jan 13, 2025
1 parent 7a210da commit b043465
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/consumableBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ function retrieveAd(decision, unitId, unitName) {
function handleEids(data, validBidRequests) {
let bidUserIdAsEids = deepAccess(validBidRequests, '0.userIdAsEids');
if (isArray(bidUserIdAsEids) && bidUserIdAsEids.length > 0) {
bidUserIdAsEids = bidUserIdAsEids.filter(e => typeof e === 'object');
deepSetValue(data, 'user.eids', bidUserIdAsEids);
} else {
deepSetValue(data, 'user.eids', undefined);
Expand Down
42 changes: 42 additions & 0 deletions test/spec/modules/consumableBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,48 @@ describe('Consumable BidAdapter', function () {
expect(data.user.eids).to.deep.equal(bidderRequest.bidRequest[0].userIdAsEids);
});

it("Request should remove non-objects for userIdAsEids", function () {
bidderRequest.bidRequest[0].userId = {};
bidderRequest.bidRequest[0].userId.tdid = "TTD_ID";
bidderRequest.bidRequest[0].userIdAsEids = [
{
source: "adserver.org",
uids: [
{
id: "TTD_ID_FROM_USER_ID_MODULE",
atype: 1,
ext: {
rtiPartner: "TDID",
},
},
],
},
'RANDOM_IDENTIFIER_STRING'
];
let scrubbedEids = [
{
source: "adserver.org",
uids: [
{
id: "TTD_ID_FROM_USER_ID_MODULE",
atype: 1,
ext: {
rtiPartner: "TDID",
},
},
],
},
];
let request = spec.buildRequests(
bidderRequest.bidRequest,
BIDDER_REQUEST_1
);
let data = JSON.parse(request.data);
expect(data.user.eids).to.deep.equal(
scrubbedEids
);
});

it('Request should NOT have adsrvrOrgId params if userId is NOT object', function() {
let request = spec.buildRequests(bidderRequest.bidRequest, BIDDER_REQUEST_1);
let data = JSON.parse(request.data);
Expand Down

0 comments on commit b043465

Please sign in to comment.