Skip to content

Commit

Permalink
Sharethrough bid adapter add ortb2 device (#11785)
Browse files Browse the repository at this point in the history
* Sharethrough Bid Adapter: Add full ORTB2 device data to request payload

* Sharethrough Bid Adapter: Add test to verify presence of ORTB2 device data in request

---------

Co-authored-by: Bohdan V <[email protected]>
  • Loading branch information
jwrosewell and BohdanVV authored Jul 22, 2024
1 parent 196d040 commit 264db8c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/sharethroughBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export const sharethroughAdapterSpec = {
req.device.ext['cdep'] = bidderRequest.ortb2.device.ext.cdep;
}

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

req.user = nullish(firstPartyData.user, {});
if (!req.user.ext) req.user.ext = {};
req.user.ext.eids = bidRequests[0].userIdAsEids || [];
Expand Down
35 changes: 35 additions & 0 deletions test/spec/modules/sharethroughBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,41 @@ describe('sharethrough adapter spec', function () {

expect(openRtbReq.user.ext.eids).to.deep.equal([]);
});

it('should add ORTB2 device data to the request', () => {
const bidderRequestWithOrtb2Device = {
...bidderRequest,
...{
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(bidRequests, bidderRequestWithOrtb2Device);

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

describe('no referer provided', () => {
Expand Down

0 comments on commit 264db8c

Please sign in to comment.