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

Adding sua to device object #27

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
13 changes: 1 addition & 12 deletions modules/yieldmoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ function openRtbRequest(bidRequests, bidderRequest) {
at: 1,
imp: bidRequests.map(bidRequest => openRtbImpression(bidRequest)),
site: openRtbSite(bidRequests[0], bidderRequest),
device: openRtbDevice(bidRequests[0]),
device: deepAccess(bidderRequest, 'ortb2.device'),
badv: bidRequests[0].params.badv || [],
bcat: deepAccess(bidderRequest, 'bcat') || bidRequests[0].params.bcat || [],
ext: {
Expand Down Expand Up @@ -507,17 +507,6 @@ function openRtbSite(bidRequest, bidderRequest) {
return result;
}

/**
* @return Object OpenRTB's 'device' object
*/
function openRtbDevice(bidRequest) {
const deviceObj = {
ua: navigator.userAgent,
language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage),
};
return deviceObj;
}

/**
* Updates openRtbRequest with GDPR info from bidderRequest, if present.
* @param {Object} openRtbRequest OpenRTB's request to update.
Expand Down
70 changes: 70 additions & 0 deletions test/spec/modules/yieldmoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,76 @@ describe('YieldmoAdapter', function () {
};
expect(buildAndGetData([mockVideoBid({...params})]).user.eids).to.eql(params.fakeUserIdAsEids);
});
it('should add device info to payload if available', function () {
let videoBidder = mockBidderRequest({ ortb2: {
device: {
sua: {
platform: {
brand: 'macOS',
version: [ '12', '4', '0' ]
},
browsers: [
{
brand: 'Chromium',
version: [ '106', '0', '5249', '119' ]
},
{
brand: 'Google Chrome',
version: [ '106', '0', '5249', '119' ]
},
{
brand: 'Not;A=Brand',
version: [ '99', '0', '0', '0' ]
}
],
mobile: 0,
model: '',
bitness: '64',
architecture: 'x86'
}
}
}}, [mockVideoBid()]);
let payload = buildAndGetData([mockVideoBid()], 0, videoBidder);
expect(payload.device.sua).to.exist;
expect(payload.device.sua).to.deep.equal({
platform: {
brand: 'macOS',
version: [ '12', '4', '0' ]
},
browsers: [
{
brand: 'Chromium',
version: [ '106', '0', '5249', '119' ]
},
{
brand: 'Google Chrome',
version: [ '106', '0', '5249', '119' ]
},
{
brand: 'Not;A=Brand',
version: [ '99', '0', '0', '0' ]
}
],
mobile: 0,
model: '',
bitness: '64',
architecture: 'x86'
}
);
expect(payload.device.ua).to.not.exist;
expect(payload.device.language).to.not.exist;
// remove sua info and check device object
videoBidder = mockBidderRequest({ ortb2: {
device: {
ua: navigator.userAgent,
language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage),
}
}}, [mockVideoBid()]);
payload = buildAndGetData([mockVideoBid()], 0, videoBidder);
expect(payload.device.sua).to.not.exist;
expect(payload.device.ua).to.exist;
expect(payload.device.language).to.exist;
});
});
});

Expand Down