Skip to content

Commit

Permalink
PubmaticAnalyticsAdapter - Passing GPT slot name for "au" field. (#9912)
Browse files Browse the repository at this point in the history
* Get gptslot and push it in au field

* Code review changes

* Added comment for better understanding
  • Loading branch information
kapil-tuptewar authored May 8, 2023
1 parent b6d949f commit 9f1dd22
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions modules/pubmaticAnalyticsAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { _each, pick, logWarn, isStr, isArray, logError } from '../src/utils.js';
import { _each, pick, logWarn, isStr, isArray, logError, getGptSlotInfoForAdUnitCode } from '../src/utils.js';
import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js';
import adapterManager from '../src/adapterManager.js';
import CONSTANTS from '../src/constants.json';
Expand Down Expand Up @@ -353,9 +353,10 @@ function executeBidsLoggerCall(e, highestCpmBids) {
outputObj.s = Object.keys(auctionCache.adUnitCodes).reduce(function(slotsArray, adUnitId) {
let adUnit = auctionCache.adUnitCodes[adUnitId];
let origAdUnit = getAdUnit(auctionCache.origAdUnits, adUnitId) || {};
// getGptSlotInfoForAdUnitCode returns gptslot corresponding to adunit provided as input.
let slotObject = {
'sn': adUnitId,
'au': origAdUnit.adUnitId || adUnitId,
'au': origAdUnit.adUnitId || getGptSlotInfoForAdUnitCode(adUnitId)?.gptSlot || adUnitId,
'mt': getAdUnitAdFormats(origAdUnit),
'sz': getSizesForAdUnit(adUnit, adUnitId),
'ps': gatherPartnerBidsForAdUnitForLogger(adUnit, adUnitId, highestCpmBids.filter(bid => bid.adUnitCode === adUnitId)),
Expand Down
7 changes: 6 additions & 1 deletion test/spec/modules/pubmaticAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[0].fskp).to.equal(0);
expect(data.s[0].sz).to.deep.equal(['640x480']);
expect(data.s[0].ps).to.be.an('array');
expect(data.s[0].ps.length).to.equal(1);
expect(data.s[0].au).to.equal('/19968336/header-bid-tag-0');
expect(data.s[0].ps.length).to.equal(1);
expect(data.s[0].ps[0].pn).to.equal('pubmatic');
expect(data.s[0].ps[0].bc).to.equal('pubmatic');
expect(data.s[0].ps[0].bidid).to.equal('2ecff0db240757');
Expand Down Expand Up @@ -481,6 +482,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[0].fskp).to.equal(0);
expect(data.s[0].sz).to.deep.equal(['640x480']);
expect(data.s[0].ps).to.be.an('array');
expect(data.s[0].au).to.equal('/19968336/header-bid-tag-0');
expect(data.s[0].ps.length).to.equal(1);
expect(data.s[0].ps[0].pn).to.equal('pubmatic');
expect(data.s[0].ps[0].bc).to.equal('pubmatic');
Expand Down Expand Up @@ -553,6 +555,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[0].sz).to.deep.equal(['640x480']);
expect(data.s[0].ps).to.be.an('array');
expect(data.s[0].ps.length).to.equal(1);
expect(data.s[0].au).to.equal('/19968336/header-bid-tag-0');
expect(data.s[0].ps[0].pn).to.equal('pubmatic');
expect(data.s[0].ps[0].bc).to.equal('pubmatic');
expect(data.s[0].ps[0].bidid).to.equal('2ecff0db240757');
Expand Down Expand Up @@ -1029,6 +1032,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[0].fskp).to.equal(0);
expect(data.s[0].sz).to.deep.equal(['640x480']);
expect(data.s[0].ps).to.be.an('array');
expect(data.s[0].au).to.equal('/19968336/header-bid-tag-0');
expect(data.s[0].ps.length).to.equal(1);
expect(data.s[0].ps[0].pn).to.equal('pubmatic');
expect(data.s[0].ps[0].bc).to.equal('pubmatic_alias');
Expand Down Expand Up @@ -1147,6 +1151,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[0].fskp).to.equal(0);
expect(data.s[0].sz).to.deep.equal(['640x480']);
expect(data.s[0].ps).to.be.an('array');
expect(data.s[0].au).to.equal('/19968336/header-bid-tag-0');
expect(data.s[0].ps.length).to.equal(1);
expect(data.s[0].ps[0].pn).to.equal('pubmatic');
expect(data.s[0].ps[0].bc).to.equal('groupm');
Expand Down

0 comments on commit 9f1dd22

Please sign in to comment.