Skip to content

Commit

Permalink
Consumable Bid Adapter: remove EID non-objects (#12646)
Browse files Browse the repository at this point in the history
* consumableBidAdapter: remove eid non-objects

* fix lint errors
  • Loading branch information
jpiros authored Jan 22, 2025
1 parent e5bf921 commit e5da6c8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/consumableBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const spec = {
/**
* Make a server request from the list of BidRequests.
*
* @param {validBidRequests[]} - an array of bids
* @param {validBidRequests[]} validBidRequests An array of bids
* @param {Object} bidderRequest The bidder's request info.
* @return ServerRequest Info describing the request to the server.
*/

Expand Down Expand Up @@ -300,6 +301,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 e5da6c8

Please sign in to comment.