Skip to content

Commit

Permalink
ZetaGlobalSsp Analytics Adapter: update deepCopy of analytics object (#…
Browse files Browse the repository at this point in the history
…10507)

* ZetaGlobalSspAnalytics adapter: bugfix in deepClone

* checkstyle fix

---------

Co-authored-by: Surovenko Alexey <[email protected]>
Co-authored-by: Alexey Surovenko <[email protected]>
  • Loading branch information
3 people authored Sep 20, 2023
1 parent 2213365 commit ab35867
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 34 deletions.
37 changes: 8 additions & 29 deletions modules/zeta_global_sspAnalyticsAdapter.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 0 additions & 5 deletions test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand Down

0 comments on commit ab35867

Please sign in to comment.