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

Zeta Global SSP Bid Adapter : pass user.geo and device.geo to payload #11723

Merged
merged 1 commit into from
Jun 6, 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
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