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

OpenXOrtb Bid Adapter: fix multiformat requests #9790

Merged
merged 3 commits into from
Apr 11, 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
24 changes: 13 additions & 11 deletions modules/openxOrtbBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ const converter = ortbConverter({
},
imp(buildImp, bidRequest, context) {
const imp = buildImp(bidRequest, context);
if (bidRequest.mediaTypes[VIDEO]?.context === 'outstream') {
imp.video.placement = imp.video.placement || 4;
}
mergeDeep(imp, {
tagid: bidRequest.params.unit,
ext: {
Expand Down Expand Up @@ -132,15 +129,20 @@ const converter = ortbConverter({
}
},
video(orig, imp, bidRequest, context) {
// `orig` is the video imp processor, which looks at bidRequest.mediaTypes[VIDEO]
// to populate imp.video
// alter its input `bidRequest` to also pick up parameters from `bidRequest.params`
let videoParams = bidRequest.mediaTypes[VIDEO];
if (videoParams) {
videoParams = Object.assign({}, videoParams, bidRequest.params.video);
bidRequest = {...bidRequest, mediaTypes: {[VIDEO]: videoParams}}
if (FEATURES.VIDEO) {
// `orig` is the video imp processor, which looks at bidRequest.mediaTypes[VIDEO]
// to populate imp.video
// alter its input `bidRequest` to also pick up parameters from `bidRequest.params`
let videoParams = bidRequest.mediaTypes[VIDEO];
if (videoParams) {
videoParams = Object.assign({}, videoParams, bidRequest.params.video);
bidRequest = {...bidRequest, mediaTypes: {[VIDEO]: videoParams}}
}
orig(imp, bidRequest, context);
if (imp.video && videoParams?.context === 'outstream') {
imp.video.placement = imp.video.placement || 4;
}
}
orig(imp, bidRequest, context);
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions test/spec/modules/openxOrtbBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,18 @@ describe('OpenxRtbAdapter', function () {
});

context('common requests checks', function() {
it('should be able to handle multiformat requests', () => {
const multiformat = utils.deepClone(bidRequestsWithMediaTypes[0]);
multiformat.mediaTypes.video = {
context: 'outstream',
playerSize: [640, 480]
}
const requests = spec.buildRequests([multiformat], mockBidderRequest);
const outgoingFormats = requests.flatMap(rq => rq.data.imp.flatMap(imp => ['banner', 'video'].filter(k => imp[k] != null)));
const expected = FEATURES.VIDEO ? ['banner', 'video'] : ['banner']
expect(outgoingFormats).to.have.members(expected);
})

it('should send bid request to openx url via POST', function () {
const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest);
expect(request[0].url).to.equal(REQUEST_URL);
Expand Down