Skip to content

Commit

Permalink
pass user.geo and device.geo to payload (#11723)
Browse files Browse the repository at this point in the history
  • Loading branch information
aivanov-zeta committed Jun 6, 2024
1 parent f4c0b7b commit 2853602
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
12 changes: 12 additions & 0 deletions modules/zeta_global_sspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@ export const spec = {
payload.device.w = screen.width;
payload.device.h = screen.height;

if (bidderRequest.ortb2?.user?.geo && bidderRequest.ortb2?.device?.geo) {
payload.device.geo = { ...payload.device.geo, ...bidderRequest.ortb2?.device.geo };
payload.user.geo = { ...payload.user.geo, ...bidderRequest.ortb2?.user.geo };
} else {
if (bidderRequest.ortb2?.user?.geo) {
payload.user.geo = payload.device.geo = { ...payload.user.geo, ...bidderRequest.ortb2?.user.geo };
}
if (bidderRequest.ortb2?.device?.geo) {
payload.user.geo = payload.device.geo = { ...payload.user.geo, ...bidderRequest.ortb2?.device.geo };
}
}

if (bidderRequest?.ortb2?.device?.sua) {
payload.device.sua = bidderRequest.ortb2.device.sua;
}
Expand Down
37 changes: 36 additions & 1 deletion test/spec/modules/zeta_global_sspBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,17 @@ describe('Zeta Ssp Bid Adapter', function () {
{ id: '59' }
]
}
]
],
geo: {
lat: 40.0,
lon: -80.0,
type: 2,
country: 'USA',
region: 'NY',
metro: '501',
city: 'New York',
zip: '10001',
}
}
}
}];
Expand Down Expand Up @@ -658,12 +668,37 @@ describe('Zeta Ssp Bid Adapter', function () {
expect(payload.device.sua.platform.brand).to.eql('Chrome');
expect(payload.device.sua.platform.version[0]).to.eql('102');

// expecting the same values for user.geo and device.geo
expect(payload.device.geo.type).to.eql(2);
expect(payload.device.geo.lat).to.eql(40.0);
expect(payload.device.geo.lon).to.eql(-80.0);
expect(payload.device.geo.country).to.eql('USA');
expect(payload.device.geo.region).to.eql('NY');
expect(payload.device.geo.metro).to.eql('501');
expect(payload.device.geo.city).to.eql('New York');
expect(payload.device.geo.zip).to.eql('10001');

expect(payload.device.ua).to.not.be.undefined;
expect(payload.device.language).to.not.be.undefined;
expect(payload.device.w).to.not.be.undefined;
expect(payload.device.h).to.not.be.undefined;
});

it('Test provide user params', function () {
const request = spec.buildRequests(bannerRequest, bannerRequest[0]);
const payload = JSON.parse(request.data);

// expecting the same values for user.geo and device.geo
expect(payload.user.geo.type).to.eql(2);
expect(payload.user.geo.lat).to.eql(40.0);
expect(payload.user.geo.lon).to.eql(-80.0);
expect(payload.user.geo.country).to.eql('USA');
expect(payload.user.geo.region).to.eql('NY');
expect(payload.user.geo.metro).to.eql('501');
expect(payload.user.geo.city).to.eql('New York');
expect(payload.user.geo.zip).to.eql('10001');
});

it('Test that all empties are removed', function () {
const request = spec.buildRequests(bannerRequest, bannerRequest[0]);
const payload = JSON.parse(request.data);
Expand Down

0 comments on commit 2853602

Please sign in to comment.