Skip to content

Commit

Permalink
Add support of bcat/badv/bapp
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhang-criteo committed May 30, 2023
1 parent 5199712 commit 2b1de6d
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/criteoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,15 @@ function buildCdbRequest(context, bidRequests, bidderRequest) {
request.user.ext = request.user.ext || {};
request.user.ext.eids = [...userIdAsEids];
}
if (bidderRequest && bidderRequest.ortb2?.bcat) {
request.bcat = bidderRequest.ortb2.bcat;
}
if (bidderRequest && bidderRequest.ortb2?.badv) {
request.badv = bidderRequest.ortb2.badv;
}
if (bidderRequest && bidderRequest.ortb2?.bapp) {
request.bapp = bidderRequest.ortb2.bapp;
}
return request;
}

Expand Down
84 changes: 84 additions & 0 deletions test/spec/modules/criteoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,90 @@ describe('The Criteo bidding adapter', function () {
expect(request.data.source.ext.schain).to.equal(expectedSchain);
});

it('should properly build a request with bcat field', function () {
const bcat = [ 'IAB1', 'IAB2' ];
const bidRequests = [
{
bidder: 'criteo',
adUnitCode: 'bid-123',
transactionId: 'transaction-123',
mediaTypes: {
banner: {
sizes: [[728, 90]]
}
},
params: {
zoneId: 123,
},
},
];
const bidderRequest = {
ortb2: {
bcat
}
};

const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.data.bcat).to.not.be.null;
expect(request.data.bcat).to.equal(bcat);
});

it('should properly build a request with badv field', function () {
const badv = [ 'ford.com' ];
const bidRequests = [
{
bidder: 'criteo',
adUnitCode: 'bid-123',
transactionId: 'transaction-123',
mediaTypes: {
banner: {
sizes: [[728, 90]]
}
},
params: {
zoneId: 123,
},
},
];
const bidderRequest = {
ortb2: {
badv
}
};

const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.data.badv).to.not.be.null;
expect(request.data.badv).to.equal(badv);
});

it('should properly build a request with bapp field', function () {
const bapp = [ 'com.foo.mygame' ];
const bidRequests = [
{
bidder: 'criteo',
adUnitCode: 'bid-123',
transactionId: 'transaction-123',
mediaTypes: {
banner: {
sizes: [[728, 90]]
}
},
params: {
zoneId: 123,
},
},
];
const bidderRequest = {
ortb2: {
bapp
}
};

const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.data.bapp).to.not.be.null;
expect(request.data.bapp).to.equal(bapp);
});

it('should properly build a request with if ccpa consent field is not provided', function () {
const bidRequests = [
{
Expand Down

0 comments on commit 2b1de6d

Please sign in to comment.