Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GumGum Bid Adapter : add ORTB2 device data to request payload #12008

Merged
merged 4 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BohdanVV can you add ip and ipv6 to this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BohdanVV can you add ip and ipv6 to this?

Done 👌🏻

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