Skip to content

Commit c354f86

Browse files
Merge pull request #5 from kapil-tuptewar/UOE-9825
Uoe 9825
2 parents b7744ec + 022c473 commit c354f86

File tree

3 files changed

+57
-7
lines changed

3 files changed

+57
-7
lines changed

modules/pubmaticAnalyticsAdapter.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ function gatherPartnerBidsForAdUnitForLogger(adUnit, adUnitId, highestBid) {
286286
'ocpm': bid.bidResponse ? (bid.bidResponse.originalCpm || 0) : 0,
287287
'ocry': bid.bidResponse ? (bid.bidResponse.originalCurrency || CURRENCY_USD) : CURRENCY_USD,
288288
'piid': bid.bidResponse ? (bid.bidResponse.partnerImpId || EMPTY_STRING) : EMPTY_STRING,
289-
'frv': (bid.bidResponse ? (bid.bidResponse.floorData ? bid.bidResponse.floorData.floorRuleValue : undefined) : undefined),
289+
'frv': bid.bidResponse ? bid.bidResponse.floorData?.floorRuleValue : undefined,
290290
'md': bid.bidResponse ? getMetadata(bid.bidResponse.meta) : undefined
291291
});
292292
});
@@ -337,11 +337,10 @@ function executeBidsLoggerCall(e, highestCpmBids) {
337337
let auctionId = e.auctionId;
338338
let referrer = config.getConfig('pageUrl') || cache.auctions[auctionId].referer || '';
339339
let auctionCache = cache.auctions[auctionId];
340-
let floorData = auctionCache.floorData;
340+
let floorData = auctionCache?.floorData;
341+
let floorFetchStatus = getFloorFetchStatus(auctionCache?.floorData);
341342
let outputObj = { s: [] };
342343
let pixelURL = END_POINT_BID_LOGGER;
343-
// will return true if floor data is present.
344-
let fetchStatus = getFloorFetchStatus(auctionCache.floorData);
345344

346345
if (!auctionCache) {
347346
return;
@@ -364,7 +363,7 @@ function executeBidsLoggerCall(e, highestCpmBids) {
364363
outputObj['tgid'] = getTgId();
365364
outputObj['pbv'] = getGlobal()?.version || '-1';
366365

367-
if (floorData && fetchStatus) {
366+
if (floorData && floorFetchStatus) {
368367
outputObj['fmv'] = floorData.floorRequestData ? floorData.floorRequestData.modelVersion || undefined : undefined;
369368
outputObj['ft'] = floorData.floorResponseData ? (floorData.floorResponseData.enforcements.enforceJS == false ? 0 : 1) : undefined;
370369
}
@@ -379,8 +378,24 @@ function executeBidsLoggerCall(e, highestCpmBids) {
379378
'mt': getAdUnitAdFormats(origAdUnit),
380379
'sz': getSizesForAdUnit(adUnit, adUnitId),
381380
'ps': gatherPartnerBidsForAdUnitForLogger(adUnit, adUnitId, highestCpmBids.filter(bid => bid.adUnitCode === adUnitId)),
382-
'fskp': (floorData && fetchStatus) ? (floorData.floorRequestData ? (floorData.floorRequestData.skipped == false ? 0 : 1) : undefined) : undefined,
381+
'fskp': floorData && floorFetchStatus ? (floorData.floorRequestData ? (floorData.floorRequestData.skipped == false ? 0 : 1) : undefined) : undefined,
383382
};
383+
if (floorData?.floorRequestData) {
384+
const { location, fetchStatus, floorProvider } = floorData?.floorRequestData;
385+
slotObject.ffs = {
386+
[CONSTANTS.FLOOR_VALUES.SUCCESS]: 1,
387+
[CONSTANTS.FLOOR_VALUES.ERROR]: 2,
388+
[CONSTANTS.FLOOR_VALUES.TIMEOUT]: 4,
389+
undefined: 0
390+
}[fetchStatus];
391+
slotObject.fsrc = {
392+
[CONSTANTS.FLOOR_VALUES.FETCH]: 2,
393+
[CONSTANTS.FLOOR_VALUES.NO_DATA]: 2,
394+
[CONSTANTS.FLOOR_VALUES.AD_UNIT]: 1,
395+
[CONSTANTS.FLOOR_VALUES.SET_CONFIG]: 1
396+
}[location];
397+
slotObject.fp = floorProvider;
398+
}
384399
slotsArray.push(slotObject);
385400
return slotsArray;
386401
}, []);

src/constants.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@
176176
"AD_UNIT": "adUnit",
177177
"SET_CONFIG": "setConfig",
178178
"FETCH": "fetch",
179-
"SUCCESS": "success"
179+
"SUCCESS": "success",
180+
"ERROR": "error",
181+
"TIMEOUT": "timeout"
180182
}
181183
}

test/spec/modules/pubmaticAnalyticsAdapter_spec.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ describe('pubmatic analytics adapter', function () {
374374
// slot 1
375375
expect(data.s[0].sn).to.equal('/19968336/header-bid-tag-0');
376376
expect(data.s[0].fskp).to.equal(0);
377+
expect(data.s[0].ffs).to.equal(1);
378+
expect(data.s[0].fsrc).to.equal(2);
379+
expect(data.s[0].fp).to.equal('pubmatic');
377380
expect(data.s[0].sz).to.deep.equal(['640x480']);
378381
expect(data.s[0].ps).to.be.an('array');
379382
expect(data.s[0].au).to.equal('/19968336/header-bid-tag-0');
@@ -403,6 +406,9 @@ describe('pubmatic analytics adapter', function () {
403406
// slot 2
404407
expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1');
405408
expect(data.s[1].fskp).to.equal(0);
409+
expect(data.s[1].ffs).to.equal(1);
410+
expect(data.s[1].fsrc).to.equal(2);
411+
expect(data.s[1].fp).to.equal('pubmatic');
406412
expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']);
407413
expect(data.s[1].ps).to.be.an('array');
408414
expect(data.s[1].ps.length).to.equal(1);
@@ -583,6 +589,9 @@ describe('pubmatic analytics adapter', function () {
583589
// slot 1
584590
expect(data.s[0].sn).to.equal('/19968336/header-bid-tag-0');
585591
expect(data.s[0].fskp).to.equal(0);
592+
expect(data.s[0].ffs).to.equal(1);
593+
expect(data.s[0].fsrc).to.equal(2);
594+
expect(data.s[0].fp).to.equal('pubmatic');
586595
expect(data.s[0].sz).to.deep.equal(['640x480']);
587596
expect(data.s[0].ps).to.be.an('array');
588597
expect(data.s[0].au).to.equal('/19968336/header-bid-tag-0');
@@ -702,6 +711,9 @@ describe('pubmatic analytics adapter', function () {
702711
expect(data.tgid).to.equal(0);// test group id should be an INT between 0-15 else set to 0
703712
expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1');
704713
expect(data.s[1].fskp).to.equal(0);
714+
expect(data.s[1].ffs).to.equal(1);
715+
expect(data.s[1].fsrc).to.equal(2);
716+
expect(data.s[1].fp).to.equal('pubmatic');
705717
expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']);
706718
expect(data.s[1].ps).to.be.an('array');
707719
expect(data.s[1].ps.length).to.equal(1);
@@ -784,6 +796,9 @@ describe('pubmatic analytics adapter', function () {
784796
let data = getLoggerJsonFromRequest(request.requestBody);
785797
expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1');
786798
expect(data.s[1].fskp).to.equal(0);
799+
expect(data.s[1].ffs).to.equal(1);
800+
expect(data.s[1].fsrc).to.equal(2);
801+
expect(data.s[1].fp).to.equal('pubmatic');
787802
expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']);
788803
expect(data.s[1].ps).to.be.an('array');
789804
expect(data.s[1].ps.length).to.equal(1);
@@ -893,6 +908,9 @@ describe('pubmatic analytics adapter', function () {
893908
let data = getLoggerJsonFromRequest(request.requestBody);
894909
expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1');
895910
expect(data.s[1].fskp).to.equal(0);
911+
expect(data.s[1].ffs).to.equal(1);
912+
expect(data.s[1].fsrc).to.equal(2);
913+
expect(data.s[1].fp).to.equal('pubmatic');
896914
expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']);
897915
expect(data.s[1].ps).to.be.an('array');
898916
expect(data.s[1].ps.length).to.equal(1);
@@ -1006,6 +1024,9 @@ describe('pubmatic analytics adapter', function () {
10061024
let data = getLoggerJsonFromRequest(request.requestBody);
10071025
expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1');
10081026
expect(data.s[1].fskp).to.equal(0);
1027+
expect(data.s[1].ffs).to.equal(1);
1028+
expect(data.s[1].fsrc).to.equal(2);
1029+
expect(data.s[1].fp).to.equal('pubmatic');
10091030
expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']);
10101031
expect(data.s[1].ps).to.be.an('array');
10111032
expect(data.s[1].ps.length).to.equal(1);
@@ -1121,6 +1142,9 @@ describe('pubmatic analytics adapter', function () {
11211142
// Testing only for rejected bid as other scenarios will be covered under other TCs
11221143
expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1');
11231144
expect(data.s[1].fskp).to.equal(0);
1145+
expect(data.s[1].ffs).to.equal(1);
1146+
expect(data.s[1].fsrc).to.equal(2);
1147+
expect(data.s[1].fp).to.equal('pubmatic');
11241148
expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']);
11251149
expect(data.s[1].ps).to.be.an('array');
11261150
expect(data.s[1].ps.length).to.equal(1);
@@ -1196,6 +1220,9 @@ describe('pubmatic analytics adapter', function () {
11961220
// slot 1
11971221
expect(data.s[0].sn).to.equal('/19968336/header-bid-tag-0');
11981222
expect(data.s[0].fskp).to.equal(0);
1223+
expect(data.s[0].ffs).to.equal(1);
1224+
expect(data.s[0].fsrc).to.equal(2);
1225+
expect(data.s[0].fp).to.equal('pubmatic');
11991226
expect(data.s[0].sz).to.deep.equal(['640x480']);
12001227
expect(data.s[0].ps).to.be.an('array');
12011228
expect(data.s[0].au).to.equal('/19968336/header-bid-tag-0');
@@ -1226,6 +1253,9 @@ describe('pubmatic analytics adapter', function () {
12261253
// slot 2
12271254
expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1');
12281255
expect(data.s[1].fskp).to.equal(0);
1256+
expect(data.s[1].ffs).to.equal(1);
1257+
expect(data.s[1].fsrc).to.equal(2);
1258+
expect(data.s[1].fp).to.equal('pubmatic');
12291259
expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']);
12301260
expect(data.s[1].ps).to.be.an('array');
12311261
expect(data.s[1].ps.length).to.equal(1);
@@ -1318,6 +1348,9 @@ describe('pubmatic analytics adapter', function () {
13181348
// slot 1
13191349
expect(data.s[0].sn).to.equal('/19968336/header-bid-tag-0');
13201350
expect(data.s[0].fskp).to.equal(0);
1351+
expect(data.s[0].ffs).to.equal(1);
1352+
expect(data.s[0].fsrc).to.equal(2);
1353+
expect(data.s[0].fp).to.equal('pubmatic');
13211354
expect(data.s[0].sz).to.deep.equal(['640x480']);
13221355
expect(data.s[0].ps).to.be.an('array');
13231356
expect(data.s[0].au).to.equal('/19968336/header-bid-tag-0');

0 commit comments

Comments
 (0)