Skip to content

Commit

Permalink
Criteo Bid Adapter: add eids to bid request sent to bidder (prebid#9949)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardlabat authored May 15, 2023
1 parent a773c4f commit 38cf634
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
10 changes: 9 additions & 1 deletion modules/criteoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ function checkNativeSendId(bidRequest) {
function buildCdbRequest(context, bidRequests, bidderRequest) {
let networkId;
let schain;
let userIdAsEids;
const request = {
publisher: {
url: context.url,
Expand All @@ -421,6 +422,9 @@ function buildCdbRequest(context, bidRequests, bidderRequest) {
gpp_sid: bidderRequest.ortb2?.regs?.gpp_sid
},
slots: bidRequests.map(bidRequest => {
if (!userIdAsEids) {
userIdAsEids = bidRequest.userIdAsEids;
}
networkId = bidRequest.params.networkId || networkId;
schain = bidRequest.schain || schain;
const slot = {
Expand All @@ -438,7 +442,7 @@ function buildCdbRequest(context, bidRequests, bidderRequest) {
slot.ext = Object.assign({}, slot.ext, bidRequest.params.ext);
}
if (bidRequest.nativeOrtbRequest?.assets) {
slot.ext = Object.assign({}, slot.ext, {assets: bidRequest.nativeOrtbRequest.assets});
slot.ext = Object.assign({}, slot.ext, { assets: bidRequest.nativeOrtbRequest.assets });
}
if (bidRequest.params.publisherSubId) {
slot.publishersubid = bidRequest.params.publisherSubId;
Expand Down Expand Up @@ -519,6 +523,10 @@ function buildCdbRequest(context, bidRequests, bidderRequest) {
request.user.ext = request.user.ext || {};
request.user.ext.sua = bidderRequest.ortb2?.device?.sua || {};
}
if (userIdAsEids) {
request.user.ext = request.user.ext || {};
request.user.ext.eids = [...userIdAsEids];
}
return request;
}

Expand Down
36 changes: 36 additions & 0 deletions test/spec/modules/criteoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,42 @@ describe('The Criteo bidding adapter', function () {
expect(ortbRequest.slots[0].native).to.equal(true);
});

it('should properly forward eids', function () {
const bidRequests = [
{
bidder: 'criteo',
adUnitCode: 'bid-123',
transactionId: 'transaction-123',
mediaTypes: {
banner: {
sizes: [[728, 90]]
}
},
userIdAsEids: [
{
source: 'criteo.com',
uids: [{
id: 'abc',
atype: 1
}]
}
],
params: {}
},
];
const request = spec.buildRequests(bidRequests, bidderRequest);
const ortbRequest = request.data;
expect(ortbRequest.user.ext.eids).to.deep.equal([
{
source: 'criteo.com',
uids: [{
id: 'abc',
atype: 1
}]
}
]);
});

it('should properly detect and forward native flag', function () {
const bidRequests = [
{
Expand Down

0 comments on commit 38cf634

Please sign in to comment.