From fa447390578055c65f8b8dfbeb49e29797adef91 Mon Sep 17 00:00:00 2001 From: pm-priyanka-deshmane Date: Wed, 31 May 2023 19:24:35 +0530 Subject: [PATCH 1/2] Additional fields in tracker call for Analytics reporting --- modules/pubmaticAnalyticsAdapter.js | 39 +++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/modules/pubmaticAnalyticsAdapter.js b/modules/pubmaticAnalyticsAdapter.js index 71a5bfef25b..ad62e8db217 100755 --- a/modules/pubmaticAnalyticsAdapter.js +++ b/modules/pubmaticAnalyticsAdapter.js @@ -256,6 +256,10 @@ export function getMetadata(meta) { return metaObj; } +function isS2SBidder(bidder) { + return (s2sBidders.indexOf(bidder) > -1) ? 1 : 0 +} + function gatherPartnerBidsForAdUnitForLogger(adUnit, adUnitId, highestBid) { highestBid = (highestBid && highestBid.length > 0) ? highestBid[0] : null; return Object.keys(adUnit.bids).reduce(function(partnerBids, bidId) { @@ -275,7 +279,7 @@ function gatherPartnerBidsForAdUnitForLogger(adUnit, adUnitId, highestBid) { 'l1': bid.bidResponse ? bid.clientLatencyTimeMs : 0, 'l2': 0, 'adv': bid.bidResponse ? getAdDomain(bid.bidResponse) || undefined : undefined, - 'ss': (s2sBidders.indexOf(bid.bidder) > -1) ? 1 : 0, + 'ss': isS2SBidder(bid.bidder), 't': (bid.status == ERROR && bid.error.code == TIMEOUT_ERROR) ? 1 : 0, 'wb': (highestBid && highestBid.adId === bid.adId ? 1 : 0), 'mi': bid.bidResponse ? (bid.bidResponse.mi || undefined) : undefined, @@ -311,6 +315,14 @@ function getAdUnit(adUnits, adUnitId) { return adUnits.filter(adUnit => (adUnit.divID && adUnit.divID == adUnitId) || (adUnit.code == adUnitId))[0]; } +function getTgId() { + var testGroupId = parseInt(config.getConfig('testGroupId') || 0); + if (testGroupId <= 15 && testGroupId >= 0) { + return testGroupId; + } + return 0; +} + function executeBidsLoggerCall(e, highestCpmBids) { let auctionId = e.auctionId; let referrer = config.getConfig('pageUrl') || cache.auctions[auctionId].referer || ''; @@ -337,13 +349,7 @@ function executeBidsLoggerCall(e, highestCpmBids) { outputObj['pid'] = '' + profileId; outputObj['pdvid'] = '' + profileVersionId; outputObj['dvc'] = {'plt': getDevicePlatform()}; - outputObj['tgid'] = (function() { - var testGroupId = parseInt(config.getConfig('testGroupId') || 0); - if (testGroupId <= 15 && testGroupId >= 0) { - return testGroupId; - } - return 0; - })(); + outputObj['tgid'] = getTgId(); if (floorData) { outputObj['fmv'] = floorData.floorRequestData ? floorData.floorRequestData.modelVersion || undefined : undefined; @@ -391,6 +397,12 @@ function executeBidWonLoggerCall(auctionId, adUnitId) { const adapterName = getAdapterNameForAlias(winningBid.adapterCode || winningBid.bidder); let origAdUnit = getAdUnit(cache.auctions[auctionId].origAdUnits, adUnitId) || {}; + let auctionCache = cache.auctions[auctionId]; + let floorData = auctionCache.floorData; + let referrer = config.getConfig('pageUrl') || cache.auctions[auctionId].referer || ''; + let adv = winningBid.bidResponse ? getAdDomain(winningBid.bidResponse) || undefined : undefined; + let fskp = floorData ? (floorData.floorRequestData ? (floorData.floorRequestData.skipped == false ? 0 : 1) : undefined) : undefined; + let pixelURL = END_POINT_WIN_BID_LOGGER; pixelURL += 'pubid=' + publisherId; pixelURL += '&purl=' + enc(config.getConfig('pageUrl') || cache.auctions[auctionId].referer || ''); @@ -407,6 +419,17 @@ function executeBidWonLoggerCall(auctionId, adUnitId) { pixelURL += '&eg=' + enc(winningBid.bidResponse.bidGrossCpmUSD); pixelURL += '&kgpv=' + enc(getValueForKgpv(winningBid, adUnitId)); pixelURL += '&piid=' + enc(winningBid.bidResponse.partnerImpId || EMPTY_STRING); + + pixelURL += '&plt=' + enc(getDevicePlatform()); + pixelURL += '&psz=' + enc((winningBid?.bidResponse?.dimensions?.width || '0') + 'x' + + (winningBid?.bidResponse?.dimensions?.height || '0')); + pixelURL += '&tgid=' + enc(getTgId()); + adv && (pixelURL += '&adv=' + enc(adv)); + pixelURL += '&orig=' + enc(getDomainFromUrl(referrer)); + pixelURL += '&ss=' + enc(isS2SBidder(winningBid.bidder)); + (fskp != undefined) && (pixelURL += '&fskp=' + enc(fskp)); + pixelURL += '&af=' + enc(winningBid.bidResponse ? (winningBid.bidResponse.mediaType || undefined) : undefined); + ajax( pixelURL, null, From 97f5426ebb02ad91b556489e90480106e5589c9d Mon Sep 17 00:00:00 2001 From: pm-priyanka-deshmane Date: Mon, 5 Jun 2023 12:36:53 +0530 Subject: [PATCH 2/2] Test cases change --- test/spec/modules/pubmaticAnalyticsAdapter_spec.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/spec/modules/pubmaticAnalyticsAdapter_spec.js b/test/spec/modules/pubmaticAnalyticsAdapter_spec.js index 048244ee4fb..c56ed565c43 100755 --- a/test/spec/modules/pubmaticAnalyticsAdapter_spec.js +++ b/test/spec/modules/pubmaticAnalyticsAdapter_spec.js @@ -443,6 +443,13 @@ describe('pubmatic analytics adapter', function () { expect(data.eg).to.equal('1.23'); expect(data.en).to.equal('1.23'); expect(data.piid).to.equal('partnerImpressionID-1'); + expect(data.plt).to.equal('1'); + expect(data.psz).to.equal('640x480'); + expect(data.tgid).to.equal('15'); + expect(data.orig).to.equal('www.test.com'); + expect(data.ss).to.equal('1'); + expect(data.fskp).to.equal('0'); + expect(data.af).to.equal('video'); }); it('bidCpmAdjustment: USD: Logger: best case + win tracker', function() {