Skip to content

Commit

Permalink
Smaato: Adapters that accept geolocation data from bid parameters sho…
Browse files Browse the repository at this point in the history
…uld also accept it from ortb2.(device|user).geo (#9676) (#9725)
  • Loading branch information
el-chuck authored Mar 29, 2023
1 parent e582396 commit 81fd111
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
20 changes: 16 additions & 4 deletions modules/smaatoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,23 @@ const buildOpenRtbBidRequest = (bidRequest, bidderRequest) => {
deepSetValue(requestTemplate, 'regs.ext.gpp_sid', ortb2.regs.gpp_sid);
}

if (ortb2.device?.ifa !== undefined) {
deepSetValue(requestTemplate, 'device.ifa', ortb2.device.ifa);
}

if (ortb2.device?.geo !== undefined) {
deepSetValue(requestTemplate, 'device.geo', ortb2.device.geo);
}

if (deepAccess(bidRequest, 'params.app')) {
const geo = deepAccess(bidRequest, 'params.app.geo');
deepSetValue(requestTemplate, 'device.geo', geo);
const ifa = deepAccess(bidRequest, 'params.app.ifa');
deepSetValue(requestTemplate, 'device.ifa', ifa);
if (!deepAccess(requestTemplate, 'device.geo')) {
const geo = deepAccess(bidRequest, 'params.app.geo');
deepSetValue(requestTemplate, 'device.geo', geo);
}
if (!deepAccess(requestTemplate, 'device.ifa')) {
const ifa = deepAccess(bidRequest, 'params.app.ifa');
deepSetValue(requestTemplate, 'device.ifa', ifa);
}
}

const eids = deepAccess(bidRequest, 'userIdAsEids');
Expand Down
32 changes: 32 additions & 0 deletions test/spec/modules/smaatoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,13 @@ describe('smaatoBidAdapterTest', () => {
keywords: 'a,b',
gender: 'M',
yob: 1984
},
device: {
ifa: 'ifa',
geo: {
lat: 53.5488,
lon: 9.9872
}
}
};

Expand All @@ -368,6 +375,9 @@ describe('smaatoBidAdapterTest', () => {
expect(req.user.ext.consent).to.equal(CONSENT_STRING);
expect(req.site.keywords).to.eql('power tools,drills');
expect(req.site.publisher.id).to.equal('publisherId');
expect(req.device.ifa).to.equal('ifa');
expect(req.device.geo.lat).to.equal(53.5488);
expect(req.device.geo.lon).to.equal(9.9872);
});

it('has no user ids', () => {
Expand Down Expand Up @@ -1007,6 +1017,28 @@ describe('smaatoBidAdapterTest', () => {
expect(req.device.ifa).to.equal(DEVICE_ID);
});

it('when geo and ifa info present and fpd present, then prefer fpd', () => {
const ortb2 = {
device: {
ifa: 'ifa',
geo: {
lat: 53.5488,
lon: 9.9872
}
}
};

const inAppBidRequest = utils.deepClone(inAppBidRequestWithoutAppParams);
inAppBidRequest.params.app = {ifa: DEVICE_ID, geo: LOCATION};

const reqs = spec.buildRequests([inAppBidRequest], {...defaultBidderRequest, ortb2});

const req = extractPayloadOfFirstAndOnlyRequest(reqs);
expect(req.device.geo.lat).to.equal(53.5488);
expect(req.device.geo.lon).to.equal(9.9872);
expect(req.device.ifa).to.equal('ifa');
});

it('when ifa is present but geo is missing, then add only ifa to device object', () => {
const inAppBidRequest = utils.deepClone(inAppBidRequestWithoutAppParams);
inAppBidRequest.params.app = {ifa: DEVICE_ID};
Expand Down

0 comments on commit 81fd111

Please sign in to comment.