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

Criteo Bid Adapter: map native assets to slot.ext.assets #9851

Merged
merged 1 commit into from
Apr 27, 2023
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
8 changes: 3 additions & 5 deletions modules/criteoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { find } from '../src/polyfill.js';
import { verify } from 'criteo-direct-rsa-validate/build/verify.js'; // ref#2
import { getStorageManager } from '../src/storageManager.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';
import { getRefererInfo } from '../src/refererDetection.js';
import { hasPurpose1Consent } from '../src/utils/gpdr.js';

const GVLID = 91;
export const ADAPTER_VERSION = 35;
const BIDDER_CODE = 'criteo';
Expand Down Expand Up @@ -146,9 +144,6 @@ export const spec = {
* @return {ServerRequest}
*/
buildRequests: (bidRequests, bidderRequest) => {
// convert Native ORTB definition to old-style prebid native definition
bidRequests = convertOrtbRequestToProprietaryNative(bidRequests);

let url;
let data;
let fpd = bidderRequest.ortb2 || {};
Expand Down Expand Up @@ -439,6 +434,9 @@ function buildCdbRequest(context, bidRequests, bidderRequest) {
if (bidRequest.params.ext) {
slot.ext = Object.assign({}, slot.ext, bidRequest.params.ext);
}
if (bidRequest.nativeOrtbRequest?.assets) {
slot.ext = Object.assign({}, slot.ext, {assets: bidRequest.nativeOrtbRequest.assets});
}
if (bidRequest.params.publisherSubId) {
slot.publishersubid = bidRequest.params.publisherSubId;
}
Expand Down
56 changes: 56 additions & 0 deletions test/spec/modules/criteoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,62 @@ describe('The Criteo bidding adapter', function () {
expect(ortbRequest.slots[0].native).to.equal(true);
});

it('should map ortb native assets to slot ext assets', function () {
const assets = [{
required: 1,
id: 1,
img: {
type: 3,
wmin: 100,
hmin: 100,
}
},
{
required: 1,
id: 2,
title: {
len: 140,
}
},
{
required: 1,
id: 3,
data: {
type: 1,
}
},
{
required: 0,
id: 4,
data: {
type: 2,
}
},
{
required: 0,
id: 5,
img: {
type: 1,
wmin: 20,
hmin: 20,
}
}];
const bidRequests = [
{
nativeOrtbRequest: {
assets: assets
},
params: {
nativeCallback: function () { }
},
},
];
const request = spec.buildRequests(bidRequests, bidderRequest);
const ortbRequest = request.data;
expect(ortbRequest.slots[0].native).to.equal(true);
expect(ortbRequest.slots[0].ext.assets).to.deep.equal(assets);
});

it('should properly build a networkId request', function () {
const bidderRequest = {
refererInfo: {
Expand Down