Skip to content

Commit

Permalink
GumGum Bid Adapter : add ORTB2 device data to request payload (#12008)
Browse files Browse the repository at this point in the history
* GumGum Bid Adapter: Add ORTB2 device data to request payload

* GumGum Bid Adapter: add `ip` and `ipv6` to request payload

---------

Co-authored-by: Bohdan V <[email protected]>
  • Loading branch information
jwrosewell and BohdanVV authored Oct 11, 2024
1 parent 73da00f commit 953a7ac
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
42 changes: 41 additions & 1 deletion modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,41 @@ function _getFloor(mediaTypes, staticBidFloor, bid) {
return bidFloor;
}

/**
* Retrieves the device data from the ORTB2 object
* @param {Object} ortb2Data ORTB2 object
* @returns {Object} Device data
*/
function _getDeviceData(ortb2Data) {
const _device = deepAccess(ortb2Data, 'device') || {};

// set device data params from ortb2
const _deviceRequestParams = {
ip: _device.ip,
ipv6: _device.ipv6,
ua: _device.ua,
dnt: _device.dnt,
os: _device.os,
osv: _device.osv,
dt: _device.devicetype,
lang: _device.language,
make: _device.make,
model: _device.model,
ppi: _device.ppi,
pxratio: _device.pxratio,
foddid: _device?.ext?.fiftyonedegrees_deviceId,
};

// return device data params with only non-empty values
return Object.keys(_deviceRequestParams)
.reduce((r, key) => {
if (_deviceRequestParams[key] !== undefined) {
r[key] = _deviceRequestParams[key];
}
return r;
}, {});
}

/**
* loops through bannerSizes array to get greatest slot dimensions
* @param {number[][]} sizes
Expand Down Expand Up @@ -437,6 +472,11 @@ function buildRequests(validBidRequests, bidderRequest) {
if (schain && schain.nodes) {
data.schain = _serializeSupplyChainObj(schain);
}
Object.assign(
data,
_getBrowserParams(topWindowUrl, mosttopLocation),
_getDeviceData(bidderRequest?.ortb2),
);

bids.push({
id: bidId,
Expand All @@ -447,7 +487,7 @@ function buildRequests(validBidRequests, bidderRequest) {
sizes,
url: BID_ENDPOINT,
method: 'GET',
data: Object.assign(data, _getBrowserParams(topWindowUrl, mosttopLocation))
data
});
});
return bids;
Expand Down
34 changes: 34 additions & 0 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,40 @@ describe('gumgumAdapter', function () {
expect(bidRequest.data.pu.includes('ggad')).to.be.false;
expect(bidRequest.data.pu.includes('ggdeal')).to.be.false;
});

it('should handle ORTB2 device data', function () {
const 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',
ext: {fiftyonedegrees_deviceId: '17595-133085-133468-18092'},
ip: '127.0.0.1',
ipv6: '51dc:5e20:fd6a:c955:66be:03b4:dfa3:35b2',
},
};

const bidRequest = spec.buildRequests(bidRequests, { ortb2 })[0];

expect(bidRequest.data.dnt).to.equal(ortb2.device.dnt);
expect(bidRequest.data.ua).to.equal(ortb2.device.ua);
expect(bidRequest.data.lang).to.equal(ortb2.device.language);
expect(bidRequest.data.dt).to.equal(ortb2.device.devicetype);
expect(bidRequest.data.make).to.equal(ortb2.device.make);
expect(bidRequest.data.model).to.equal(ortb2.device.model);
expect(bidRequest.data.os).to.equal(ortb2.device.os);
expect(bidRequest.data.osv).to.equal(ortb2.device.osv);
expect(bidRequest.data.foddid).to.equal(ortb2.device.ext.fiftyonedegrees_deviceId);
expect(bidRequest.data.ip).to.equal(ortb2.device.ip);
expect(bidRequest.data.ipv6).to.equal(ortb2.device.ipv6);
});
})

describe('interpretResponse', function () {
Expand Down

0 comments on commit 953a7ac

Please sign in to comment.