Skip to content

Commit

Permalink
Zeta updates - Pass additional data through adapter (prebid#6134)
Browse files Browse the repository at this point in the history
* Submit Zeta Adapter to Prebid

* comments addressed

* demo changes

* additional polishing

* additional polishing

* Update hello_world.html

* remove extraneous changes to hello_world.html

* no, really this time

* additional polishing

* add unit test

* Update Zeta bid adapter to pass more data
  • Loading branch information
mwehr-zeta authored and stsepelin committed May 28, 2021
1 parent f1b7602 commit c5a1816
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 27 deletions.
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

0 comments on commit c5a1816

Please sign in to comment.