Skip to content

Commit

Permalink
PubMatic Analytics Adapter : Logging price bucket value of the bid (#…
Browse files Browse the repository at this point in the history
…11197)

* Logging price bucket value for the bid

* Converting data type for logging

* Dummy Commit

---------

Co-authored-by: pm-azhar-mulla <[email protected]>
  • Loading branch information
pm-azhar-mulla and pm-azhar-mulla authored Mar 13, 2024
1 parent 6bd8ba6 commit 22d10dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
9 changes: 7 additions & 2 deletions modules/pubmaticAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ function parseBidResponse(bid) {
'cpm', () => window.parseFloat(Number(bid.cpm).toFixed(BID_PRECISION)),
'originalCpm', () => window.parseFloat(Number(bid.originalCpm).toFixed(BID_PRECISION)),
'originalCurrency',
'adserverTargeting',
'dealChannel',
'meta',
'status',
Expand Down Expand Up @@ -278,6 +279,7 @@ function gatherPartnerBidsForAdUnitForLogger(adUnit, adUnitId, highestBid) {
if (isOWPubmaticBid(adapterName) && isS2SBidder(bid.bidder)) {
return;
}
const pg = window.parseFloat(Number(bid.bidResponse?.adserverTargeting?.hb_pb || bid.bidResponse?.adserverTargeting?.pwtpb).toFixed(BID_PRECISION));
partnerBids.push({
'pn': adapterName,
'bc': bid.bidderCode || bid.bidder,
Expand All @@ -303,7 +305,8 @@ function gatherPartnerBidsForAdUnitForLogger(adUnit, adUnitId, highestBid) {
'ocry': bid.bidResponse ? (bid.bidResponse.originalCurrency || CURRENCY_USD) : CURRENCY_USD,
'piid': bid.bidResponse ? (bid.bidResponse.partnerImpId || EMPTY_STRING) : EMPTY_STRING,
'frv': bid.bidResponse ? bid.bidResponse.floorData?.floorRuleValue : undefined,
'md': bid.bidResponse ? getMetadata(bid.bidResponse.meta) : undefined
'md': bid.bidResponse ? getMetadata(bid.bidResponse.meta) : undefined,
'pb': pg || undefined
});
});
return partnerBids;
Expand Down Expand Up @@ -457,8 +460,9 @@ function executeBidWonLoggerCall(auctionId, adUnitId) {
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 pg = window.parseFloat(Number(winningBid?.bidResponse?.adserverTargeting?.hb_pb || winningBid?.bidResponse?.adserverTargeting?.pwtpb)) || undefined;
let pixelURL = END_POINT_WIN_BID_LOGGER;

pixelURL += 'pubid=' + publisherId;
pixelURL += '&purl=' + enc(config.getConfig('pageUrl') || cache.auctions[auctionId].referer || '');
pixelURL += '&tst=' + Math.round((new window.Date()).getTime() / 1000);
Expand All @@ -475,6 +479,7 @@ function executeBidWonLoggerCall(auctionId, adUnitId) {
pixelURL += '&kgpv=' + enc(getValueForKgpv(winningBid, adUnitId));
pixelURL += '&piid=' + enc(winningBid.bidResponse.partnerImpId || EMPTY_STRING);
pixelURL += '&di=' + enc(winningBid?.bidResponse?.dealId || OPEN_AUCTION_DEAL_ID);
pixelURL += '&pb=' + enc(pg);

pixelURL += '&plt=' + enc(getDevicePlatform());
pixelURL += '&psz=' + enc((winningBid?.bidResponse?.dimensions?.width || '0') + 'x' +
Expand Down
13 changes: 12 additions & 1 deletion test/spec/modules/pubmaticAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const BID2 = Object.assign({}, BID, {
adserverTargeting: {
'hb_bidder': 'pubmatic',
'hb_adid': '3bd4ebb1c900e2',
'hb_pb': '1.500',
'hb_pb': 1.50,
'hb_size': '728x90',
'hb_source': 'server'
},
Expand Down Expand Up @@ -606,6 +606,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[0].ps[0].ocpm).to.equal(1.23);
expect(data.s[0].ps[0].ocry).to.equal('USD');
expect(data.s[0].ps[0].frv).to.equal(1.1);
expect(data.s[0].ps[0].pb).to.equal(1.2);
// slot 2
expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1');
expect(data.s[1].fskp).to.equal(0);
Expand Down Expand Up @@ -640,6 +641,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[1].ps[0].ocpm).to.equal(1.52);
expect(data.s[1].ps[0].ocry).to.equal('USD');
expect(data.s[1].ps[0].frv).to.equal(1.1);
expect(data.s[1].ps[0].pb).to.equal(1.50);

// tracker slot1
let firstTracker = requests[0].url;
Expand Down Expand Up @@ -812,6 +814,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[0].ps[0].ocpm).to.equal(1.23);
expect(data.s[0].ps[0].ocry).to.equal('USD');
expect(data.s[1].ps[0].frv).to.equal(1.1);
expect(data.s[1].ps[0].pb).to.equal(1.50);
// tracker slot1
let firstTracker = requests[0].url;
expect(firstTracker.split('?')[0]).to.equal('https://t.pubmatic.com/wt');
Expand Down Expand Up @@ -1035,6 +1038,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[1].ps[0].ocpm).to.equal(1.52);
expect(data.s[1].ps[0].ocry).to.equal('USD');
expect(data.s[1].ps[0].frv).to.equal(1.1);
expect(data.s[1].ps[0].pb).to.equal(1.50);
});

it('Logger: currency conversion check', function() {
Expand Down Expand Up @@ -1149,6 +1153,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[1].ps[0].ocpm).to.equal(1.52);
expect(data.s[1].ps[0].ocry).to.equal('USD');
expect(data.s[1].ps[0].frv).to.equal(1.1);
expect(data.s[1].ps[0].pb).to.equal(1.50);
expect(data.dvc).to.deep.equal({'plt': 2});
// respective tracker slot
let firstTracker = requests[1].url;
Expand Down Expand Up @@ -1209,6 +1214,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[1].ps[0].ocry).to.equal('USD');
expect(data.dvc).to.deep.equal({'plt': 1});
expect(data.s[1].ps[0].frv).to.equal(1.1);
expect(data.s[1].ps[0].pb).to.equal(1.50);
// respective tracker slot
let firstTracker = requests[1].url;
expect(firstTracker.split('?')[0]).to.equal('https://t.pubmatic.com/wt');
Expand Down Expand Up @@ -1267,6 +1273,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[1].ps[0].ocpm).to.equal(1.52);
expect(data.s[1].ps[0].ocry).to.equal('USD');
expect(data.s[1].ps[0].frv).to.equal(1.1);
expect(data.s[1].ps[0].pb).to.equal(1.50);
// respective tracker slot
let firstTracker = requests[1].url;
expect(firstTracker.split('?')[0]).to.equal('https://t.pubmatic.com/wt');
Expand Down Expand Up @@ -1388,6 +1395,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[1].ps[0].ocpm).to.equal(1.52);
expect(data.s[1].ps[0].ocry).to.equal('USD');
expect(data.s[1].ps[0].frv).to.equal(1.1);
expect(data.s[1].ps[0].pb).to.equal(1.50);
});

it('Logger: best case + win tracker in case of Bidder Aliases', function() {
Expand Down Expand Up @@ -1466,6 +1474,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[0].ps[0].ocpm).to.equal(1.23);
expect(data.s[0].ps[0].ocry).to.equal('USD');
expect(data.s[0].ps[0].frv).to.equal(1.1);
expect(data.s[0].ps[0].pb).to.equal(1.2);

// slot 2
expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1');
Expand Down Expand Up @@ -1501,6 +1510,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[1].ps[0].ocpm).to.equal(1.52);
expect(data.s[1].ps[0].ocry).to.equal('USD');
expect(data.s[1].ps[0].frv).to.equal(1.1);
expect(data.s[1].ps[0].pb).to.equal(1.50);

// tracker slot1
let firstTracker = requests[0].url;
Expand Down Expand Up @@ -1596,6 +1606,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[0].ps[0].ocpm).to.equal(1.23);
expect(data.s[0].ps[0].ocry).to.equal('USD');
expect(data.s[0].ps[0].frv).to.equal(1.1);
expect(data.s[0].ps[0].pb).to.equal(1.2);

// slot 2
expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1');
Expand Down

0 comments on commit 22d10dd

Please sign in to comment.