Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PubMatic Bid Adapter : passing a unique wiid to pubmatic ssp and logger call #10821

Merged
merged 7 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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