From 75f2a1ffb6040a7730b40fb0568a88b9e4a54f2e Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Tue, 22 Oct 2024 20:07:49 +0100 Subject: [PATCH] Grid bid adapter add ortb2 device (#11786) * 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> --- modules/gridBidAdapter.js | 5 +++++ test/spec/modules/gridBidAdapter_spec.js | 27 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/modules/gridBidAdapter.js b/modules/gridBidAdapter.js index 4c1876dfb6f..8d10a0f18d2 100644 --- a/modules/gridBidAdapter.js +++ b/modules/gridBidAdapter.js @@ -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]; diff --git a/test/spec/modules/gridBidAdapter_spec.js b/test/spec/modules/gridBidAdapter_spec.js index 4e13b1957b5..18f1f7aa7c8 100644 --- a/test/spec/modules/gridBidAdapter_spec.js +++ b/test/spec/modules/gridBidAdapter_spec.js @@ -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',