Skip to content

Commit

Permalink
ZetaGlobalSsp Analytics Adapter : provide device object (#11607)
Browse files Browse the repository at this point in the history
* ZetaGlobalSpp Analytics adapter: provide device object

* ZetaGlobalSpp Analytics adapter: provide ua in adRenderSucceeded event

* provide domain and page in timeout event

---------

Co-authored-by: Surovenko Alexey <surovenko.alexey@gmail.com>
Co-authored-by: Alexey Surovenko <ASurovenko@vdhk6ddf9m.home>
  • Loading branch information
3 people authored Jun 4, 2024
1 parent 16263f3 commit 5b7df85
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 22 deletions.
8 changes: 7 additions & 1 deletion modules/zeta_global_sspAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ function adRenderSucceededHandler(args) {
adomain: args.bid?.adserverTargeting?.hb_adomain,
timeToRespond: args.bid?.timeToRespond,
cpm: args.bid?.cpm
},
device: {
ua: navigator.userAgent
}
}
sendEvent(EVENTS.AD_RENDER_SUCCEEDED, event);
Expand All @@ -59,7 +62,8 @@ function auctionEndHandler(args) {
auctionId: b?.auctionId,
bidder: b?.bidder,
mediaType: b?.mediaTypes?.video ? 'VIDEO' : (b?.mediaTypes?.banner ? 'BANNER' : undefined),
size: b?.sizes?.filter(s => s && s.length === 2).filter(s => Number.isInteger(s[0]) && Number.isInteger(s[1])).map(s => s[0] + 'x' + s[1]).find(s => s)
size: b?.sizes?.filter(s => s && s.length === 2).filter(s => Number.isInteger(s[0]) && Number.isInteger(s[1])).map(s => s[0] + 'x' + s[1]).find(s => s),
device: b?.ortb2?.device
}))
})),
bidsReceived: args.bidsReceived?.map(br => ({
Expand All @@ -80,6 +84,8 @@ function auctionEndHandler(args) {
function bidTimeoutHandler(args) {
const event = {
zetaParams: zetaParams,
domain: args.find(t => t?.ortb2?.site?.domain),
page: args.find(t => t?.ortb2?.site?.page),
timeouts: args.map(t => ({
bidId: t?.bidId,
auctionId: t?.auctionId,
Expand Down
62 changes: 41 additions & 21 deletions test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ const SAMPLE_EVENTS = {
'src': 'client',
'bidRequestsCount': 1,
'bidderRequestsCount': 1,
'bidderWinsCount': 0
'bidderWinsCount': 0,
'ortb2': {
'device': {
'mobile': 1
}
}
}
],
'auctionStart': 1638441234544,
Expand Down Expand Up @@ -168,7 +173,12 @@ const SAMPLE_EVENTS = {
'src': 'client',
'bidRequestsCount': 1,
'bidderRequestsCount': 1,
'bidderWinsCount': 0
'bidderWinsCount': 0,
'ortb2': {
'device': {
'mobile': 1
}
}
}
],
'auctionStart': 1638441234544,
Expand Down Expand Up @@ -395,8 +405,6 @@ describe('Zeta Global SSP Analytics Adapter', function () {

expect(requests.length).to.equal(2);
const auctionEnd = JSON.parse(requests[0].requestBody);
const auctionSucceeded = JSON.parse(requests[1].requestBody);

expect(auctionEnd).to.be.deep.equal({
zetaParams: {sid: 111, tags: {position: 'top', shortname: 'name'}},
bidderRequests: [{
Expand All @@ -408,7 +416,10 @@ describe('Zeta Global SSP Analytics Adapter', function () {
auctionId: '75e394d9',
bidder: 'zeta_global_ssp',
mediaType: 'BANNER',
size: '300x250'
size: '300x250',
device: {
mobile: 1
}
}]
}, {
bidderCode: 'appnexus',
Expand All @@ -419,7 +430,10 @@ describe('Zeta Global SSP Analytics Adapter', function () {
auctionId: '75e394d9',
bidder: 'appnexus',
mediaType: 'BANNER',
size: '300x250'
size: '300x250',
device: {
mobile: 1
}
}]
}],
bidsReceived: [{
Expand All @@ -434,23 +448,29 @@ describe('Zeta Global SSP Analytics Adapter', function () {
cpm: 2.258302852806723
}]
});
expect(auctionSucceeded).to.be.deep.equal({
zetaParams: {sid: 111, tags: {position: 'top', shortname: 'name'}},
domain: 'test-zeta-ssp.net',
page: 'test-zeta-ssp.net/zeta-ssp/ssp/_dev/examples/page_banner.html',
bid: {
adId: '5759bb3ef7be1e8',
requestId: '206be9a13236af',
auctionId: '75e394d9',
creativeId: '456456456',
bidder: 'zeta_global_ssp',
mediaType: 'banner',
size: '480x320',
adomain: 'example.adomain',
timeToRespond: 123,
cpm: 2.258302852806723
const auctionSucceeded = JSON.parse(requests[1].requestBody);
expect(auctionSucceeded.zetaParams).to.be.deep.equal({
sid: 111,
tags: {
position: 'top',
shortname: 'name'
}
});
expect(auctionSucceeded.domain).to.eql('test-zeta-ssp.net');
expect(auctionSucceeded.page).to.eql('test-zeta-ssp.net/zeta-ssp/ssp/_dev/examples/page_banner.html');
expect(auctionSucceeded.bid).to.be.deep.equal({
adId: '5759bb3ef7be1e8',
requestId: '206be9a13236af',
auctionId: '75e394d9',
creativeId: '456456456',
bidder: 'zeta_global_ssp',
mediaType: 'banner',
size: '480x320',
adomain: 'example.adomain',
timeToRespond: 123,
cpm: 2.258302852806723
});
expect(auctionSucceeded.device.ua).to.not.be.empty;
});
});
});

0 comments on commit 5b7df85

Please sign in to comment.