From ab35867545188a29f42531c96ca9c76436ed74ef Mon Sep 17 00:00:00 2001 From: asurovenko-zeta <80847074+asurovenko-zeta@users.noreply.github.com> Date: Wed, 20 Sep 2023 19:00:03 +0200 Subject: [PATCH] ZetaGlobalSsp Analytics Adapter: update deepCopy of analytics object (#10507) * ZetaGlobalSspAnalytics adapter: bugfix in deepClone * checkstyle fix --------- Co-authored-by: Surovenko Alexey Co-authored-by: Alexey Surovenko --- modules/zeta_global_sspAnalyticsAdapter.js | 37 ++++--------------- .../zeta_global_sspAnalyticsAdapter_spec.js | 5 --- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/modules/zeta_global_sspAnalyticsAdapter.js b/modules/zeta_global_sspAnalyticsAdapter.js index 9609a047656..3d5466dd906 100644 --- a/modules/zeta_global_sspAnalyticsAdapter.js +++ b/modules/zeta_global_sspAnalyticsAdapter.js @@ -1,4 +1,4 @@ -import {logInfo, logError, deepClone} from '../src/utils.js'; +import {logInfo, logError} from '../src/utils.js'; import { ajax } from '../src/ajax.js'; import adapterManager from '../src/adapterManager.js'; import CONSTANTS from '../src/constants.json'; @@ -47,46 +47,25 @@ function getZetaParams(event) { /// /////////// ADAPTER EVENT HANDLER FUNCTIONS ////////////// -function adRenderSucceededHandler(originalArgs) { - const args = deepClone(originalArgs); +function adRenderSucceededHandler(args) { let eventType = CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED logInfo(LOG_PREFIX + 'handle ' + eventType + ' event'); - if (args.bid) { - // cleanup object - delete args.bid.metrics; - delete args.bid.ad; - - // set zetaParams from cache - if (args.bid.auctionId) { - const zetaParams = cache.auctions[args.bid.auctionId]; - if (zetaParams) { - args.bid.params = [ zetaParams ]; - } + // set zetaParams from cache + if (args.bid && args.bid.auctionId) { + const zetaParams = cache.auctions[args.bid.auctionId]; + if (zetaParams) { + args.bid.params = [ zetaParams ]; } } sendEvent(eventType, args); } -function auctionEndHandler(originalArgs) { - const args = deepClone(originalArgs); +function auctionEndHandler(args) { let eventType = CONSTANTS.EVENTS.AUCTION_END; logInfo(LOG_PREFIX + 'handle ' + eventType + ' event'); - // cleanup object - delete args.metrics; - if (args.bidderRequests) { - args.bidderRequests.forEach(requests => { - delete requests.metrics; - if (requests.bids) { - requests.bids.forEach(bid => { - delete bid.metrics; - }) - } - }) - } - // save zetaParams to cache const zetaParams = getZetaParams(args); if (zetaParams && args.auctionId) { diff --git a/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js b/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js index 962d135cd6d..0796736a162 100644 --- a/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js +++ b/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js @@ -395,11 +395,6 @@ describe('Zeta Global SSP Analytics Adapter', function() { const auctionEnd = JSON.parse(requests[0].requestBody); const auctionSucceeded = JSON.parse(requests[1].requestBody); - expect(auctionEnd.metrics).to.be.undefined; - - expect(auctionSucceeded.bid.ad).to.be.undefined; - expect(auctionSucceeded.bid.metrics).to.be.undefined; - expect(auctionSucceeded.bid.params[0]).to.be.deep.equal(EVENTS.AUCTION_END.adUnits[0].bids[0].params); expect(EVENTS.AUCTION_END.adUnits[0].bids[0].bidder).to.be.equal('zeta_global_ssp'); });