Skip to content

Commit

Permalink
PubMatic bid adapter add ortb2 device (#11783)
Browse files Browse the repository at this point in the history
* Pubmatic Bid Adapter: Add full ORTB2 device data to request payload and Adds test to verify presence of ORTB2 device data in request

---------

Co-authored-by: Bohdan V <[email protected]>
  • Loading branch information
jwrosewell and BohdanVV authored Oct 28, 2024
1 parent 39a7888 commit 19c6382
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,11 @@ export const spec = {
}
}

// if present, merge device object from ortb2 into `payload.device`
if (bidderRequest?.ortb2?.device) {
mergeDeep(payload.device, bidderRequest.ortb2.device);
}

if (commonFpd.ext?.prebid?.bidderparams?.[bidderRequest.bidderCode]?.acat) {
const acatParams = commonFpd.ext.prebid.bidderparams[bidderRequest.bidderCode].acat;
_allowedIabCategoriesValidation(payload, acatParams);
Expand Down
34 changes: 34 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2378,6 +2378,40 @@ describe('PubMatic adapter', function () {
expect(data.device.ext).to.deep.equal(cdepObj);
});

it('should pass enriched device data from ortb2 object if present in bidderRequest fpd', function () {
const fpdBidderRequest = {
auctionId: 'new-auction-id',
ortb2: {
device: {
w: 980,
h: 1720,
dnt: 0,
ua: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/125.0.6422.80 Mobile/15E148 Safari/604.1',
language: 'en',
devicetype: 1,
make: 'Apple',
model: 'iPhone 12 Pro Max',
os: 'iOS',
osv: '17.4',
}
},
};

const request = spec.buildRequests(multipleMediaRequests, fpdBidderRequest);
const data = JSON.parse(request.data);

expect(data.device.w).to.equal(fpdBidderRequest.ortb2.device.w);
expect(data.device.h).to.equal(fpdBidderRequest.ortb2.device.h);
expect(data.device.dnt).to.equal(fpdBidderRequest.ortb2.device.dnt);
expect(data.device.ua).to.equal(fpdBidderRequest.ortb2.device.ua);
expect(data.device.language).to.equal(fpdBidderRequest.ortb2.device.language);
expect(data.device.devicetype).to.equal(fpdBidderRequest.ortb2.device.devicetype);
expect(data.device.make).to.equal(fpdBidderRequest.ortb2.device.make);
expect(data.device.model).to.equal(fpdBidderRequest.ortb2.device.model);
expect(data.device.os).to.equal(fpdBidderRequest.ortb2.device.os);
expect(data.device.osv).to.equal(fpdBidderRequest.ortb2.device.osv);
});

it('Request params should have valid native bid request for all valid params', function () {
let request = spec.buildRequests(nativeBidRequests, {
auctionId: 'new-auction-id'
Expand Down

0 comments on commit 19c6382

Please sign in to comment.