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

Consumable Bid Adapter: remove EID non-objects #12646

Merged
merged 2 commits into from
Jan 22, 2025
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
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
Loading