Skip to content

Commit

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

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

---------

Co-authored-by: Bohdan V <25197509+BohdanVV@users.noreply.github.com>
  • Loading branch information
jwrosewell and BohdanVV authored Oct 22, 2024
1 parent 2fb16e2 commit 75f2a1f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/gridBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ export const spec = {
userExt.device = { ...ortb2UserExtDevice };
}

// if present, add device data object from ortb2 to the request
if (bidderRequest?.ortb2?.device) {
request.device = bidderRequest.ortb2.device;
}

if (userIdAsEids && userIdAsEids.length) {
userExt = userExt || {};
userExt.eids = [...userIdAsEids];
Expand Down
27 changes: 27 additions & 0 deletions test/spec/modules/gridBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,33 @@ describe('TheMediaGrid Adapter', function () {
expect(payload.tmax).to.equal(null);
})

it('should add ORTB2 device data to the request', function () {
const bidderRequestWithDevice = {
...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[0]], bidderRequestWithDevice);
const payload = parseRequest(request.data);

expect(payload.device).to.deep.equal(bidderRequestWithDevice.ortb2.device);
});

describe('floorModule', function () {
const floorTestData = {
'currency': 'USD',
Expand Down

0 comments on commit 75f2a1f

Please sign in to comment.