Skip to content

Commit

Permalink
ZetaGlobalSsp Analytics Adapter: keep only needed fields in event (pr…
Browse files Browse the repository at this point in the history
…ebid#11107)

* ZetaGlobalSspAnalyticsAdapter: keep only needed fields in event

* -

---------

Co-authored-by: Surovenko Alexey <surovenko.alexey@gmail.com>
Co-authored-by: Alexey Surovenko <ASurovenko@vdhk6ddf9m.home>
  • Loading branch information
3 people authored Feb 18, 2024
1 parent 11c77af commit a0194cf
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 28 deletions.
44 changes: 37 additions & 7 deletions modules/zeta_global_sspAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,44 @@ function auctionEndHandler(args) {
logInfo(LOG_PREFIX + 'handle ' + eventType + ' event');

const event = {
adUnitCodes: args.adUnitCodes,
adUnits: args.adUnits,
auctionEnd: args.auctionEnd,
auctionId: args.auctionId,
bidderRequests: args.bidderRequests,
bidsReceived: args.bidsReceived,
noBids: args.noBids,
winningBids: args.winningBids
adUnits: args.adUnits,
bidderRequests: args.bidderRequests?.map(br => ({
bidderCode: br?.bidderCode,
refererInfo: br?.refererInfo,
bids: br?.bids?.map(b => ({
adUnitCode: b?.adUnitCode,
auctionId: b?.auctionId,
bidId: b?.bidId,
requestId: b?.requestId,
bidderCode: b?.bidderCode,
mediaTypes: b?.mediaTypes,
sizes: b?.sizes,
bidder: b?.bidder,
params: b?.params
}))
})),
bidsReceived: args.bidsReceived?.map(br => ({
adId: br?.adId,
adserverTargeting: {
hb_adomain: br?.adserverTargeting?.hb_adomain
},
cpm: br?.cpm,
creativeId: br?.creativeId,
mediaType: br?.mediaType,
renderer: br?.renderer,
size: br?.size,
timeToRespond: br?.timeToRespond,
adUnitCode: br?.adUnitCode,
auctionId: br?.auctionId,
bidId: br?.bidId,
requestId: br?.requestId,
bidderCode: br?.bidderCode,
mediaTypes: br?.mediaTypes,
sizes: br?.sizes,
bidder: br?.bidder,
params: br?.params
}))
}

// save zetaParams to cache
Expand Down
45 changes: 24 additions & 21 deletions test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let events = require('src/events');

const EVENTS = {
AUCTION_END: {
'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1',
'auctionId': '75e394d9',
'timestamp': 1638441234544,
'auctionEnd': 1638441234784,
'auctionStatus': 'completed',
Expand Down Expand Up @@ -61,7 +61,7 @@ const EVENTS = {
600
]
],
'transactionId': '6b29369c-0c2e-414e-be1f-5867aec18d83'
'transactionId': '6b29369c'
}
],
'adUnitCodes': [
Expand All @@ -70,7 +70,7 @@ const EVENTS = {
'bidderRequests': [
{
'bidderCode': 'zeta_global_ssp',
'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1',
'auctionId': '75e394d9',
'bidderRequestId': '1207cb49191887',
'bids': [
{
Expand All @@ -90,7 +90,7 @@ const EVENTS = {
}
},
'adUnitCode': '/19968336/header-bid-tag-0',
'transactionId': '6b29369c-0c2e-414e-be1f-5867aec18d83',
'transactionId': '6b29369c',
'sizes': [
[
300,
Expand All @@ -103,7 +103,7 @@ const EVENTS = {
],
'bidId': '206be9a13236af',
'bidderRequestId': '1207cb49191887',
'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1',
'auctionId': '75e394d9',
'src': 'client',
'bidRequestsCount': 1,
'bidderRequestsCount': 1,
Expand All @@ -126,7 +126,7 @@ const EVENTS = {
},
{
'bidderCode': 'appnexus',
'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1',
'auctionId': '75e394d9',
'bidderRequestId': '32b97f0a935422',
'bids': [
{
Expand All @@ -149,7 +149,7 @@ const EVENTS = {
}
},
'adUnitCode': '/19968336/header-bid-tag-0',
'transactionId': '6b29369c-0c2e-414e-be1f-5867aec18d83',
'transactionId': '6b29369c',
'sizes': [
[
300,
Expand All @@ -162,7 +162,7 @@ const EVENTS = {
],
'bidId': '41badc0e164c758',
'bidderRequestId': '32b97f0a935422',
'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1',
'auctionId': '75e394d9',
'src': 'client',
'bidRequestsCount': 1,
'bidderRequestsCount': 1,
Expand Down Expand Up @@ -205,7 +205,7 @@ const EVENTS = {
}
},
'adUnitCode': '/19968336/header-bid-tag-0',
'transactionId': '6b29369c-0c2e-414e-be1f-5867aec18d83',
'transactionId': '6b29369c',
'sizes': [
[
300,
Expand All @@ -218,7 +218,7 @@ const EVENTS = {
],
'bidId': '41badc0e164c758',
'bidderRequestId': '32b97f0a935422',
'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1',
'auctionId': '75e394d9',
'src': 'client',
'bidRequestsCount': 1,
'bidderRequestsCount': 1,
Expand All @@ -243,12 +243,12 @@ const EVENTS = {
'netRevenue': true,
'meta': {
'advertiserDomains': [
'viaplay.fi'
'example.adomain'
]
},
'originalCpm': 2.258302852806723,
'originalCurrency': 'USD',
'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1',
'auctionId': '75e394d9',
'responseTimestamp': 1638441234670,
'requestTimestamp': 1638441234547,
'bidder': 'zeta_global_ssp',
Expand All @@ -268,7 +268,7 @@ const EVENTS = {
'hb_size': '480x320',
'hb_source': 'client',
'hb_format': 'banner',
'hb_adomain': 'viaplay.fi'
'hb_adomain': 'example.adomain'
}
}
],
Expand Down Expand Up @@ -311,12 +311,12 @@ const EVENTS = {
'netRevenue': true,
'meta': {
'advertiserDomains': [
'viaplay.fi'
'example.adomain'
]
},
'originalCpm': 2.258302852806723,
'originalCurrency': 'USD',
'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1',
'auctionId': '75e394d9',
'responseTimestamp': 1638441234670,
'requestTimestamp': 1638441234547,
'bidder': 'zeta_global_ssp',
Expand All @@ -336,7 +336,7 @@ const EVENTS = {
'hb_size': '480x320',
'hb_source': 'client',
'hb_format': 'banner',
'hb_adomain': 'viaplay.fi'
'hb_adomain': 'example.adomain'
},
'status': 'rendered',
'params': [
Expand Down Expand Up @@ -409,16 +409,19 @@ describe('Zeta Global SSP Analytics Adapter', function() {
const auctionEnd = JSON.parse(requests[0].requestBody);
const auctionSucceeded = JSON.parse(requests[1].requestBody);

expect(auctionEnd.adUnitCodes[0]).to.be.equal('/19968336/header-bid-tag-0');
expect(auctionEnd.adUnitCodes).to.be.undefined;
expect(auctionEnd.adUnits[0].bids[0].bidder).to.be.equal('zeta_global_ssp');
expect(auctionEnd.auctionEnd).to.be.equal(1638441234784);
expect(auctionEnd.auctionId).to.be.equal('75e394d9-ccce-4978-9238-91e6a1ac88a1');
expect(auctionEnd.auctionEnd).to.be.undefined;
expect(auctionEnd.auctionId).to.be.equal('75e394d9');
expect(auctionEnd.bidderRequests[0].bidderCode).to.be.equal('zeta_global_ssp');
expect(auctionEnd.bidderRequests[0].bids[0].bidId).to.be.equal('206be9a13236af');
expect(auctionEnd.bidderRequests[0].bids[0].adUnitCode).to.be.equal('/19968336/header-bid-tag-0');
expect(auctionEnd.bidsReceived[0].bidderCode).to.be.equal('zeta_global_ssp');
expect(auctionEnd.noBids[0].bidder).to.be.equal('appnexus');
expect(auctionEnd.bidsReceived[0].adserverTargeting.hb_adomain).to.be.equal('example.adomain');
expect(auctionEnd.bidsReceived[0].auctionId).to.be.equal('75e394d9');

expect(auctionSucceeded.adId).to.be.equal('5759bb3ef7be1e8');
expect(auctionSucceeded.bid.auctionId).to.be.equal('75e394d9-ccce-4978-9238-91e6a1ac88a1');
expect(auctionSucceeded.bid.auctionId).to.be.equal('75e394d9');
expect(auctionSucceeded.bid.requestId).to.be.equal('206be9a13236af');
expect(auctionSucceeded.bid.bidderCode).to.be.equal('zeta_global_ssp');
expect(auctionSucceeded.bid.creativeId).to.be.equal('456456456');
Expand Down

0 comments on commit a0194cf

Please sign in to comment.