Skip to content

Commit

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

* Sovrn 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 Aug 23, 2024
1 parent cd6681c commit 3c30238
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
11 changes: 10 additions & 1 deletion modules/sovrnBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
logError,
deepAccess,
isInteger,
logWarn, getBidIdParameter, isEmptyStr
logWarn,
getBidIdParameter,
isEmptyStr,
mergeDeep
} from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js'
import {
Expand Down Expand Up @@ -198,6 +201,12 @@ export const spec = {
deepSetValue(sovrnBidReq, 'regs.gpp_sid', bidderRequest.gppConsent.applicableSections);
}

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

if (eids) {
deepSetValue(sovrnBidReq, 'user.ext.eids', eids)
if (criteoId) {
Expand Down
25 changes: 25 additions & 0 deletions test/spec/modules/sovrnBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,31 @@ describe('sovrnBidAdapter', function() {
expect(regs.gpp_sid).to.include(8)
})

it('should add ORTB2 device data to the request', function () {
const bidderRequest = {
...baseBidderRequest,
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([baseBidRequest], bidderRequest);
const payload = JSON.parse(request.data);

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

it('should not send gpp info when gppConsent is not defined', function () {
const bidderRequest = {
...baseBidderRequest,
Expand Down

0 comments on commit 3c30238

Please sign in to comment.