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

OpenxOrtbAdapter: add back missing params support for coppa and video #9782

Merged
merged 1 commit into from
Apr 10, 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
14 changes: 14 additions & 0 deletions modules/openxOrtbBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ const converter = ortbConverter({
}
})
const bid = context.bidRequests[0];
if (bid.params.coppa) {
utils.deepSetValue(req, 'regs.coppa', 1);
}
if (bid.params.doNotTrack) {
utils.deepSetValue(req, 'device.dnt', 1);
}
Expand Down Expand Up @@ -127,6 +130,17 @@ const converter = ortbConverter({
if (floor.bidfloorcur === 'USD') {
Object.assign(imp, floor);
}
},
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}}
}
orig(imp, bidRequest, context);
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions modules/openxOrtbBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ Publishers are welcome to test this adapter and give feedback. Please note you s
| `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. | true
| `coppa` | optional | Boolean | Enables Child's Online Privacy Protection Act (COPPA) regulations. Use of `pbjs.setConfig({coppa: true});` is now preferred. | true

## Video

| Name | Scope | Type | Description | Example
| ---- | ----- | ---- | ----------- | -------
| `unit` | required | String | OpenX ad unit ID provided by your OpenX representative. | "1611023122"
| `delDomain` | required | String | OpenX delivery domain provided by your OpenX representative. | "PUBLISHER-d.openx.net"
| `video` | optional | OpenRTB video subtypes | Alternatively can be added under adUnit.mediaTypes.video | `{ video: {mimes: ['video/mp4']}`
| `video` | optional | OpenRTB video subtypes | Use of adUnit.mediaTypes.video is now preferred. | `{ video: {mimes: ['video/mp4']}`


# Example
Expand Down Expand Up @@ -68,7 +68,8 @@ var adUnits = [
mediaTypes: {
video: {
playerSize: [640, 480],
context: 'instream'
context: 'instream',
mimes: ['video/x-ms-wmv, video/mp4']
}
},
bids: [{
Expand All @@ -77,10 +78,10 @@ var adUnits = [
unit: '1611023124',
delDomain: 'PUBLISHER-d.openx.net',
video: {
mimes: ['video/x-ms-wmv, video/mp4']
mimes: ['video/x-ms-wmv, video/mp4'] // mediaTypes.video preferred
}
}
}]
}]p
}
];
```
Expand Down
107 changes: 96 additions & 11 deletions test/spec/modules/openxOrtbBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,57 @@ import {hook} from '../../../src/hook.js';

const DEFAULT_SYNC = SYNC_URL + '?ph=' + DEFAULT_PH;

const BidRequestBuilder = function BidRequestBuilder(options) {
const defaults = {
request: {
auctionId: '4fd1ca2d-846c-4211-b9e5-321dfe1709c9',
adUnitCode: 'adunit-code',
bidder: 'openx'
},
params: {
unit: '12345678',
delDomain: 'test-del-domain'
},
sizes: [[300, 250], [300, 600]],
};

const request = {
...defaults.request,
...options
};

this.withParams = (options) => {
request.params = {
...defaults.params,
...options
};
return this;
};

this.build = () => request;
};

const BidderRequestBuilder = function BidderRequestBuilder(options) {
const defaults = {
bidderCode: 'openx',
auctionId: '4fd1ca2d-846c-4211-b9e5-321dfe1709c9',
bidderRequestId: '7g36s867Tr4xF90X',
timeout: 3000,
refererInfo: {
numIframes: 0,
reachedTop: true,
referer: 'http://test.io/index.html?pbjs_debug=true'
}
};

const request = {
...defaults,
...options
};

this.build = () => request;
};

describe('OpenxRtbAdapter', function () {
before(() => {
hook.ready();
Expand Down Expand Up @@ -789,6 +840,12 @@ describe('OpenxRtbAdapter', function () {
expect(request[0].data.regs.coppa).to.equal(1);
});

it('should send a coppa flag there is when there is coppa param settings in the bid params', function () {
const request = spec.buildRequests(bidRequestsWithMediaTypes, syncAddFPDToBidderRequest(mockBidderRequest));
request.params = {coppa: true};
expect(request[0].data.regs.coppa).to.equal(1);
});

after(function () {
config.getConfig.restore()
});
Expand Down Expand Up @@ -963,17 +1020,6 @@ describe('OpenxRtbAdapter', function () {
});

context('FLEDGE', function() {
it('when FLEDGE is disabled, should not send imp.ext.ae', function () {
const request = spec.buildRequests(
bidRequestsWithMediaTypes,
{
...mockBidderRequest,
fledgeEnabled: false
}
);
expect(request[0].data.imp[0].ext).to.not.have.property('ae');
});

it('when FLEDGE is enabled, should send whatever is set in ortb2imp.ext.ae in all bid requests', function () {
const request = spec.buildRequests(bidRequestsWithMediaTypes, {
...mockBidderRequest,
Expand All @@ -997,6 +1043,45 @@ describe('OpenxRtbAdapter', function () {
const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest);
expect(request[1].data.imp[0]).to.have.any.keys(VIDEO);
});

it('Update imp.video with OpenRTB options from mimeTypes and params', function() {
const bid01 = new BidRequestBuilder({
adUnitCode: 'adunit-code-01',
mediaTypes: {
banner: { sizes: [[300, 250]] },
video: {
context: 'outstream',
playerSize: [[300, 250]],
mimes: ['video/mp4'],
protocols: [8]
}
},
}).withParams({
// options in video, will merge
video: {
skip: 1,
skipafter: 4,
minduration: 10,
maxduration: 30
}
}).build();

const bidderRequest = new BidderRequestBuilder().build();
const expected = {
mimes: ['video/mp4'],
skip: 1,
skipafter: 4,
minduration: 10,
maxduration: 30,
placement: 4,
protocols: [8],
w: 300,
h: 250
};
const requests = spec.buildRequests([bid01], bidderRequest);
expect(requests).to.have.lengthOf(2);
expect(requests[1].data.imp[0].video).to.deep.equal(expected);
});
});
}

Expand Down