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

[EXCH-10877] Add support for native to OpenX bid adapter #59

Closed
wants to merge 25 commits into from

Conversation

gmiedlar-ox
Copy link

No description provided.

@gmiedlar-ox gmiedlar-ox marked this pull request as ready for review January 2, 2025 09:13
@gmiedlar-ox gmiedlar-ox requested a review from RajcaS January 7, 2025 09:46
function isBannerBid(bid) {
return utils.deepAccess(bid, 'mediaTypes.banner') || !isVideoBid(bid);
return utils.deepAccess(bid, 'mediaTypes.banner') || (!isVideoBid(bid) && !isNativeBid(bid));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move this condition (!isVideoBid(bid) && !isNativeBid(bid)) to const as this is getting less readable

// In case of multi-format bids remove `video` from mediaTypes as for video a separate bid request is built
.map(bid => ({...bid, mediaTypes: {...bid.mediaTypes, video: undefined}}));

let requests = bannerAndNativeBids.length ? [createRequest(bannerAndNativeBids, bidderRequest, undefined)] : [];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we fine now, all of our banner bids with end up with

{
    context: {
        mediaType: undefined
    }
}

Does undefined means explicitly that is some kind of mixed? (or it can be also uknown type)

What about null rather than undefined?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, undefined in this case means that this request can contain both - banner and native imps. So we cannot say what is the media type of whole bid request.
I can change it to null - it should work the same as undefined.

Comment on lines +166 to +168
let bannerAndNativeBids = bids.filter(bid => isBannerBid(bid) || isNativeBid(bid))
// In case of multi-format bids remove `video` from mediaTypes as for video a separate bid request is built
.map(bid => ({...bid, mediaTypes: {...bid.mediaTypes, video: undefined}}));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case of this map, we dont need something similar for video?

What i do understand for multi video we will end up with
{native: [value], video: [value]} - not marking other types as undefined

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually for video we don't need to do something similar because for each element of videoBids we specify VIDEO mediaType when we build bid request. Because of this, converter will skip all other mediaTypes (banner, native) when converting request to openRTB. So at the end we will have only video format in such bid request.
I added assertions to unit tests which verify it.

@gmiedlar-ox gmiedlar-ox requested a review from RajcaS January 7, 2025 10:57
Copy link

@bukrain bukrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Some minor comments.

expect(requests[1].data.imp).to.have.length(1);
expect(requests[1].data.imp[0].banner).to.not.exist;
expect(requests[1].data.imp[0].native).to.not.exist;
if (FEATURES.VIDEO) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering what is FEATURES.VIDEO and FEATURES.NATIVE.
Are those if's necessary?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our adapter utilizes ortbConverter library and there are some checks there which verifies if video/native feature is enabled.

When all tests are executed with gulp test command, test-all-features-disabled task will be executed firstly, and then test-only.
I enclosed native-related tests in this if, so that they won't be run when native feature is disabled (test-all-features-disabled). However those tests should be run in test-only task.
I've also seen similar pattern in other adapters tests: example.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Thanks for clarification :).

@@ -333,7 +488,7 @@ describe('OpenxRtbAdapter', function () {

const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest);
expect(request[0].data.ext.platform).to.equal(bidRequestsWithMediaTypes[0].params.platform);
expect(request[1].data.ext.platform).to.equal(bidRequestsWithMediaTypes[0].params.platform);
expect(request[1].data.ext.platform).to.equal(bidRequestsWithMediaTypes[1].params.platform);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are changing this line, maybe it would be a good idea to give bidRequestsWithMediaTypes[1].params.platform different value than for bidRequestsWithMediaTypes[0].params.platform

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Updated, thanks!

@gmiedlar-ox
Copy link
Author

Changes were merged to upstream repo: prebid#12625

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants