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

OpenX Bid Adapter : support native #12625

Merged
merged 25 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c4fbc28
[EXCH-10877] Add support for native to OpenX bid adapter
gmiedlar-ox Dec 30, 2024
abfe5b0
Merge branch 'master' into EXCH-10877-add-support-for-native-imps
gmiedlar-ox Dec 30, 2024
9e548a5
[EXCH-10877] Add unit tests for interpretResponse and native
gmiedlar-ox Jan 2, 2025
55a23a5
[EXCH-10877] Fix formatting
gmiedlar-ox Jan 2, 2025
0889166
[EXCH-10877] Add support for native to OpenX bid adapter
gmiedlar-ox Dec 30, 2024
ba54f2c
[EXCH-10877] Add unit tests for interpretResponse and native
gmiedlar-ox Jan 2, 2025
6c39451
[EXCH-10877] Fix formatting
gmiedlar-ox Jan 2, 2025
c881386
Merge remote-tracking branch 'origin/EXCH-10877-add-support-for-nativ…
gmiedlar-ox Jan 2, 2025
77648f0
Revert "Merge remote-tracking branch 'origin/EXCH-10877-add-support-f…
gmiedlar-ox Jan 2, 2025
b33ba81
[EXCH-10877] Add info about native support to the docs
gmiedlar-ox Jan 3, 2025
6044ea0
[EXCH-10877] create const, use null instead of undefined
gmiedlar-ox Jan 7, 2025
ad05066
Merge branch 'master' into EXCH-10877-add-support-for-native-imps
gmiedlar-ox Jan 8, 2025
2bcbb2a
[EXCH-10877] Add support for native to OpenX bid adapter
gmiedlar-ox Dec 30, 2024
3629d50
[EXCH-10877] Add unit tests for interpretResponse and native
gmiedlar-ox Jan 2, 2025
1d10835
[EXCH-10877] Fix formatting
gmiedlar-ox Jan 2, 2025
e17035d
[EXCH-10877] Add support for native to OpenX bid adapter
gmiedlar-ox Dec 30, 2024
ccbcf98
[EXCH-10877] Add unit tests for interpretResponse and native
gmiedlar-ox Jan 2, 2025
100ffae
[EXCH-10877] Fix formatting
gmiedlar-ox Jan 2, 2025
6a40ca2
Revert "Merge remote-tracking branch 'origin/EXCH-10877-add-support-f…
gmiedlar-ox Jan 2, 2025
12cf332
[EXCH-10877] Add info about native support to the docs
gmiedlar-ox Jan 3, 2025
bbf0317
[EXCH-10877] create const, use null instead of undefined
gmiedlar-ox Jan 7, 2025
63eb715
Merge remote-tracking branch 'origin/EXCH-10877-add-support-for-nativ…
gmiedlar-ox Jan 8, 2025
bd7a12e
[EXCH-10877] Fix merge issues
gmiedlar-ox Jan 8, 2025
8f62f37
Merge branch 'master' into EXCH-10877-add-support-for-native-imps
gmiedlar-ox Jan 10, 2025
156137d
[EXCH-10877] Use various params.platform in test
gmiedlar-ox Jan 13, 2025
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
25 changes: 19 additions & 6 deletions modules/openxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {config} from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import * as utils from '../src/utils.js';
import {mergeDeep} from '../src/utils.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import {ortbConverter} from '../libraries/ortbConverter/converter.js';

const bidderConfig = 'hb_pb_ortb';
Expand All @@ -13,7 +13,7 @@ export const DEFAULT_PH = '2d1251ae-7f3a-47cf-bd2a-2f288854a0ba';
export const spec = {
code: 'openx',
gvlid: 69,
supportedMediaTypes: [BANNER, VIDEO],
supportedMediaTypes: [BANNER, VIDEO, NATIVE],
isBidRequestValid,
buildRequests,
interpretResponse,
Expand All @@ -25,7 +25,12 @@ registerBidder(spec);
const converter = ortbConverter({
context: {
netRevenue: true,
ttl: 300
ttl: 300,
nativeRequest: {
eventtrackers: [
{event: 1, methods: [1, 2]},
]
}
},
imp(buildImp, bidRequest, context) {
const imp = buildImp(bidRequest, context);
Expand Down Expand Up @@ -158,8 +163,11 @@ function isBidRequestValid(bidRequest) {

function buildRequests(bids, bidderRequest) {
let videoBids = bids.filter(bid => isVideoBid(bid));
let bannerBids = bids.filter(bid => isBannerBid(bid));
let requests = bannerBids.length ? [createRequest(bannerBids, bidderRequest, BANNER)] : [];
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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh no, why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When it comes to video we wanted to keep the implementation unchanged, so create separate bid request with video mediaType only. We didn't want to introduce two separate changes at once to our adapter. Also we're be changing it probably in near future as we start supporting multi-format requests.

.map(bid => ({...bid, mediaTypes: {...bid.mediaTypes, video: undefined}}));

let requests = bannerAndNativeBids.length ? [createRequest(bannerAndNativeBids, bidderRequest, null)] : [];
videoBids.forEach(bid => {
requests.push(createRequest([bid], bidderRequest, VIDEO));
});
Expand All @@ -178,8 +186,13 @@ function isVideoBid(bid) {
return utils.deepAccess(bid, 'mediaTypes.video');
}

function isNativeBid(bid) {
return utils.deepAccess(bid, 'mediaTypes.native');
}

function isBannerBid(bid) {
return utils.deepAccess(bid, 'mediaTypes.banner') || !isVideoBid(bid);
const isNotVideoOrNativeBid = !isVideoBid(bid) && !isNativeBid(bid)
return utils.deepAccess(bid, 'mediaTypes.banner') || isNotVideoOrNativeBid;
}

function interpretResponse(resp, req) {
Expand Down
47 changes: 46 additions & 1 deletion modules/openxBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ Please note you should only include either openxBidAdapter or openxOrtbBidAdapte
| `delDomain` | required | String | OpenX delivery domain provided by your OpenX representative. | "PUBLISHER-d.openx.net"
| `video` | optional | OpenRTB video subtypes | Use of adUnit.mediaTypes.video is now preferred. | `{ video: {mimes: ['video/mp4']}`

## Native

| Name | Scope | Type | Description | Example
| ---- | ----- | ---- | ----------- | -------
| `delDomain` or `platform` | required | String | OpenX delivery domain or platform id provided by your OpenX representative. | "PUBLISHER-d.openx.net" or "555not5a-real-plat-form-id0123456789"
| `unit` | required | String | OpenX ad unit ID provided by your OpenX representative. | "1611023122"
| `customParams` | optional | Object | User-defined targeting key-value pairs. customParams applies to a specific unit. | `{key1: "v1", key2: ["v2","v3"]}`
| `customFloor` | optional | Number | Minimum price in USD. customFloor applies to a specific unit. For example, use the following value to set a $1.50 floor: 1.50 <br/><br/> **WARNING:**<br/> Misuse of this parameter can impact revenue | 1.50
| `doNotTrack` | optional | Boolean | Prevents advertiser from using data for this user. <br/><br/> **WARNING:**<br/> Request-level setting. May impact revenue. | true
| `coppa` | optional | Boolean | Enables Child's Online Privacy Protection Act (COPPA) regulations. Use of `pbjs.setConfig({coppa: true});` is now preferred. | true

# Example
```javascript
Expand Down Expand Up @@ -84,7 +94,42 @@ var adUnits = [
mimes: ['video/x-ms-wmv, video/mp4'] // mediaTypes.video preferred
}
}
}]p
}]
},
{
code: 'native1',
mediaTypes: {
native: {
ortb: {
ver: '1.2',
assets: [
{
required: 1,
img: {
type: 1,
hmin: 50
},
}, {
required: 1,
title: {
len: 80
}
}
]
}
}
},
bids: [{
bidder: 'openx',
params: {
unit: '1611023124',
delDomain: 'PUBLISHER-d.openx.net',
customParams: {
key1: 'v1',
key2: ['v2', 'v3']
}
}
}]
}
];
```
Expand Down
Loading
Loading