Skip to content

Commit

Permalink
ORTB2 bcat & badv support + ORTB2 tests (#9871)
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrj-rtbh authored Apr 28, 2023
1 parent 22ff9c2 commit 1ac3572
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
15 changes: 6 additions & 9 deletions modules/rtbhouseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,12 @@ export const spec = {
}

const ortb2Params = bidderRequest?.ortb2 || {};
if (ortb2Params.site) {
mergeDeep(request, { site: ortb2Params.site });
}
if (ortb2Params.user) {
mergeDeep(request, { user: ortb2Params.user });
}
if (ortb2Params.device) {
mergeDeep(request, { device: ortb2Params.device });
}
['site', 'user', 'device', 'bcat', 'badv'].forEach(entry => {
const ortb2Param = ortb2Params[entry];
if (ortb2Param) {
mergeDeep(request, { [entry]: ortb2Param });
}
});

let computedEndpointUrl = ENDPOINT_URL;

Expand Down
22 changes: 22 additions & 0 deletions test/spec/modules/rtbhouseBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,28 @@ describe('RTBHouseAdapter', () => {
expect(data.source).to.not.have.property('ext');
});

it('should include first party data', function () {
const bidRequest = Object.assign([], bidRequests);
const localBidderRequest = {
...bidderRequest,
ortb2: {
bcat: ['IAB1', 'IAB2-1'],
badv: ['domain1.com', 'domain2.com'],
site: { ext: { data: 'some site data' } },
device: { ext: { data: 'some device data' } },
user: { ext: { data: 'some user data' } }
}
};

const request = spec.buildRequests(bidRequest, localBidderRequest);
const data = JSON.parse(request.data);
expect(data.bcat).to.deep.equal(localBidderRequest.ortb2.bcat);
expect(data.badv).to.deep.equal(localBidderRequest.ortb2.badv);
expect(data.site).to.nested.include({'ext.data': 'some site data'});
expect(data.device).to.nested.include({'ext.data': 'some device data'});
expect(data.user).to.nested.include({'ext.data': 'some user data'});
});

context('FLEDGE', function() {
afterEach(function () {
config.resetConfig();
Expand Down

0 comments on commit 1ac3572

Please sign in to comment.