Skip to content

Commit

Permalink
PubMatic Bid Adapter : passing a unique wiid to pubmatic ssp and logg…
Browse files Browse the repository at this point in the history
…er call (#10821)

* Added wiid as UUID

* Handled undefined wiid in logger and tracker

* updated test cases

* updated test cases

---------

Co-authored-by: pm-azhar-mulla <azhar@L1119.local>
  • Loading branch information
pm-azhar-mulla and pm-azhar-mulla authored Dec 13, 2023
1 parent 75cb166 commit dc530cf
Show file tree
Hide file tree
Showing 3 changed files with 18 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 @@ -337,6 +337,7 @@ function executeBidsLoggerCall(e, highestCpmBids) {
let auctionId = e.auctionId;
let referrer = config.getConfig('pageUrl') || cache.auctions[auctionId].referer || '';
let auctionCache = cache.auctions[auctionId];
let wiid = auctionCache?.wiid || auctionId;
let floorData = auctionCache?.floorData;
let floorFetchStatus = getFloorFetchStatus(auctionCache?.floorData);
let outputObj = { s: [] };
Expand All @@ -352,7 +353,7 @@ function executeBidsLoggerCall(e, highestCpmBids) {

pixelURL += 'pubid=' + publisherId;
outputObj['pubid'] = '' + publisherId;
outputObj['iid'] = '' + auctionId;
outputObj['iid'] = '' + wiid;
outputObj['to'] = '' + auctionCache.timeout;
outputObj['purl'] = referrer;
outputObj['orig'] = getDomainFromUrl(referrer);
Expand Down Expand Up @@ -428,6 +429,7 @@ function executeBidWonLoggerCall(auctionId, adUnitId) {
let origAdUnit = getAdUnit(cache.auctions[auctionId].origAdUnits, adUnitId) || {};
let auctionCache = cache.auctions[auctionId];
let floorData = auctionCache.floorData;
let wiid = cache.auctions[auctionId]?.wiid || auctionId;
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;
Expand All @@ -436,7 +438,7 @@ function executeBidWonLoggerCall(auctionId, adUnitId) {
pixelURL += 'pubid=' + publisherId;
pixelURL += '&purl=' + enc(config.getConfig('pageUrl') || cache.auctions[auctionId].referer || '');
pixelURL += '&tst=' + Math.round((new window.Date()).getTime() / 1000);
pixelURL += '&iid=' + enc(auctionId);
pixelURL += '&iid=' + enc(wiid);
pixelURL += '&bidid=' + enc(winningBidId);
pixelURL += '&pid=' + enc(profileId);
pixelURL += '&pdvid=' + enc(profileVersionId);
Expand Down Expand Up @@ -500,6 +502,9 @@ function bidRequestedHandler(args) {
dimensions: bid.sizes
};
}
if (bid.bidder === 'pubmatic' && !!bid?.params?.wiid) {
cache.auctions[args.auctionId].wiid = bid.params.wiid;
}
cache.auctions[args.auctionId].adUnitCodes[bid.adUnitCode].bids[bid.bidId] = [copyRequiredBidDetails(bid)];
if (bid.floorData) {
cache.auctions[args.auctionId].floorData['floorRequestData'] = bid.floorData;
Expand Down
4 changes: 3 additions & 1 deletion modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getBidRequest, logWarn, isBoolean, isStr, isArray, inIframe, mergeDeep, deepAccess, isNumber, deepSetValue, logInfo, logError, deepClone, uniques, isPlainObject, isInteger } from '../src/utils.js';
import { getBidRequest, logWarn, isBoolean, isStr, isArray, inIframe, mergeDeep, deepAccess, isNumber, deepSetValue, logInfo, logError, deepClone, uniques, isPlainObject, isInteger, generateUUID } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO, NATIVE, ADPOD } from '../src/mediaTypes.js';
import { config } from '../src/config.js';
Expand Down Expand Up @@ -1081,8 +1081,10 @@ export const spec = {
var bid;
var blockedIabCategories = [];
var allowedIabCategories = [];
var wiid = generateUUID();

validBidRequests.forEach(originalBid => {
originalBid.params.wiid = originalBid.params.wiid || bidderRequest.auctionId || wiid;
bid = deepClone(originalBid);
bid.params.adSlot = bid.params.adSlot || '';
_parseAdSlot(bid);
Expand Down
8 changes: 8 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ describe('PubMatic adapter', function () {
params: {
publisherId: '5890',
adSlot: 'Div1@0x0', // ad_id or tagid
wiid: 'new-unique-wiid',
video: {
mimes: ['video/mp4', 'video/x-flv'],
skippable: true,
Expand Down Expand Up @@ -154,6 +155,7 @@ describe('PubMatic adapter', function () {
params: {
publisherId: '5890',
adSlot: 'Div1@640x480', // ad_id or tagid
wiid: '1234567890',
video: {
mimes: ['video/mp4', 'video/x-flv'],
skippable: true,
Expand Down Expand Up @@ -213,6 +215,7 @@ describe('PubMatic adapter', function () {
params: {
publisherId: '5670',
adSlot: '/43743431/NativeAutomationPrebid@1x1',
wiid: 'new-unique-wiid'
},
bidId: '2a5571261281d4',
requestId: 'B68287E1-DC39-4B38-9790-FE4F179739D6',
Expand Down Expand Up @@ -278,6 +281,7 @@ describe('PubMatic adapter', function () {
params: {
publisherId: '5670',
adSlot: '/43743431/NativeAutomationPrebid@1x1',
wiid: 'new-unique-wiid'
},
bidId: '2a5571261281d4',
requestId: 'B68287E1-DC39-4B38-9790-FE4F179739D6',
Expand All @@ -304,6 +308,7 @@ describe('PubMatic adapter', function () {
params: {
publisherId: '5670',
adSlot: '/43743431/NativeAutomationPrebid@1x1',
wiid: 'new-unique-wiid'
}
}];

Expand Down Expand Up @@ -344,6 +349,7 @@ describe('PubMatic adapter', function () {
params: {
publisherId: '5670',
adSlot: '/43743431/NativeAutomationPrebid@1x1',
wiid: 'new-unique-wiid'
}
}];

Expand Down Expand Up @@ -502,6 +508,7 @@ describe('PubMatic adapter', function () {
params: {
publisherId: '301',
adSlot: '/15671365/DMDemo@300x250:0',
wiid: 'new-unique-wiid',
video: {
mimes: ['video/mp4', 'video/x-flv'],
skippable: true,
Expand Down Expand Up @@ -572,6 +579,7 @@ describe('PubMatic adapter', function () {
params: {
publisherId: '301',
adSlot: '/15671365/DMDemo@300x250:0',
wiid: 'new-unique-wiid',
video: {
mimes: ['video/mp4', 'video/x-flv'],
skippable: true,
Expand Down

0 comments on commit dc530cf

Please sign in to comment.