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 updates - Pass additional data through adapter #6134

Merged
merged 13 commits into from
Dec 22, 2020
64 changes: 39 additions & 25 deletions modules/zetaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,37 @@ export const spec = {
*/
isBidRequestValid: function(bid) {
// check for all required bid fields
let isValid = !!(
bid &&
bid.bidId &&
bid.params &&
bid.params.ip &&
bid.params.user &&
bid.params.user.buyeruid &&
bid.params.definerId
);
if (!isValid) {
utils.logWarn('Invalid bid request');
if (!(bid &&
bid.bidId &&
bid.params)) {
utils.logWarn('Invalid bid request - missing required bid data');
return false;
}
return isValid;

if (!(bid.params.user &&
bid.params.user.buyeruid)) {
utils.logWarn('Invalid bid request - missing required user data');
return false;
}

if (!(bid.params.device &&
bid.params.device.ip)) {
utils.logWarn('Invalid bid request - missing required device data');
return false;
}

if (!(bid.params.device.geo &&
bid.params.device.geo.country)) {
utils.logWarn('Invalid bid request - missing required geo data');
return false;
}

if (!bid.params.definerId) {
utils.logWarn('Invalid bid request - missing required definer data');
return false;
}

return true;
},

/**
Expand All @@ -51,27 +69,23 @@ export const spec = {
secure: secure,
banner: buildBanner(request)
};
let isMobile = /(ios|ipod|ipad|iphone|android)/i.test(navigator.userAgent) ? 1 : 0;
let payload = {
id: bidderRequest.auctionId,
cur: [DEFAULT_CUR],
imp: [impData],
site: {
mobile: isMobile,
page: bidderRequest.refererInfo.referer
},
device: {
ua: navigator.userAgent,
ip: params.ip
},
user: {
buyeruid: params.user.buyeruid,
uid: params.user.uid
},
site: params.site ? params.site : {},
device: params.device ? params.device : {},
user: params.user ? params.user : {},
app: params.app ? params.app : {},
ext: {
definerId: params.definerId
}
};

payload.device.ua = navigator.userAgent;
payload.site.page = bidderRequest.refererInfo.referer;
payload.site.mobile = /(ios|ipod|ipad|iphone|android)/i.test(navigator.userAgent) ? 1 : 0;

if (params.test) {
payload.test = params.test;
}
Expand Down
7 changes: 6 additions & 1 deletion modules/zetaBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ Module that connects to Zeta's demand sources
uid: 12345,
buyeruid: 12345
},
ip: '111.222.33.44',
device: {
ip: '111.222.33.44',
geo: {
country: "USA"
}
},
definerId: 1,
test: 1
}
Expand Down
7 changes: 6 additions & 1 deletion test/spec/modules/zetaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ describe('Zeta Bid Adapter', function() {
uid: 12345,
buyeruid: 12345
},
ip: '111.222.33.44',
device: {
ip: '111.222.33.44',
geo: {
country: 'USA'
}
},
definerId: 1,
test: 1
}
Expand Down