Skip to content

Commit

Permalink
Prebid 8: set pubmatic source.tid to auctionId (#9954)
Browse files Browse the repository at this point in the history
* set source.tid to auctionId
* removed changes to test page
* added support for setting ext.wrapper.transactionId as well
  • Loading branch information
jlquaccia authored May 17, 2023
1 parent 99c9869 commit c46e38c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
10 changes: 8 additions & 2 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,11 @@ export const spec = {
payload.ext.wrapper.wiid = conf.wiid || bidderRequest.auctionId;
// eslint-disable-next-line no-undef
payload.ext.wrapper.wv = $$REPO_AND_VERSION$$;
payload.ext.wrapper.transactionId = conf.transactionId;

if (bidderRequest) {
payload.ext.wrapper.transactionId = bidderRequest.auctionId;
}

payload.ext.wrapper.wp = 'pbjs';
const allowAlternateBidder = bidderRequest ? bidderSettings.get(bidderRequest.bidderCode, 'allowAlternateBidderCodes') : undefined;
if (allowAlternateBidder !== undefined) {
Expand Down Expand Up @@ -1151,7 +1155,9 @@ export const spec = {
// update device.language to ISO-639-1-alpha-2 (2 character language)
payload.device.language = payload.device.language && payload.device.language.split('-')[0];

// passing nothing in source.tid -- Pubmatic can correct in a future PR
// passing auctionId in source.tid
if (bidderRequest) deepSetValue(payload, 'source.tid', bidderRequest.auctionId);

// test bids
if (window.location.href.indexOf('pubmaticTest=true') !== -1) {
payload.test = 1;
Expand Down
19 changes: 11 additions & 8 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,8 @@ describe('PubMatic adapter', function () {
expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version
expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId
expect(data.ext.wrapper.transactionId).to.equal('new-auction-id'); // Prebid TransactionId
expect(data.source.tid).to.equal('new-auction-id'); // Prebid TransactionId
expect(data.ext.wrapper.wiid).to.equal(bidRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID
expect(data.ext.wrapper.profile).to.equal(parseInt(bidRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID
expect(data.ext.wrapper.version).to.equal(parseInt(bidRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID
Expand Down Expand Up @@ -1387,7 +1388,7 @@ describe('PubMatic adapter', function () {
expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version
expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId
expect(data.ext.wrapper.transactionId).to.equal('new-auction-id'); // Prebid TransactionId
expect(data.ext.wrapper.wiid).to.equal(bidRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID
expect(data.ext.wrapper.profile).to.equal(parseInt(bidRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID
expect(data.ext.wrapper.version).to.equal(parseInt(bidRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID
Expand Down Expand Up @@ -1598,7 +1599,7 @@ describe('PubMatic adapter', function () {
expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version
expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId
expect(data.ext.wrapper.transactionId).to.equal('new-auction-id'); // Prebid TransactionId
expect(data.ext.wrapper.wiid).to.equal('new-auction-id'); // OpenWrap: Wrapper Impression ID
expect(data.ext.wrapper.profile).to.equal(parseInt(bidRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID
expect(data.ext.wrapper.version).to.equal(parseInt(bidRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID
Expand All @@ -1616,7 +1617,8 @@ describe('PubMatic adapter', function () {
gdprConsent: {
consentString: 'kjfdniwjnifwenrif3',
gdprApplies: true
}
},
auctionId: 'new-auction-id'
};
let request = spec.buildRequests(bidRequests, bidRequest);
let data = JSON.parse(request.data);
Expand All @@ -1634,7 +1636,7 @@ describe('PubMatic adapter', function () {
expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version
expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId
expect(data.ext.wrapper.transactionId).to.equal('new-auction-id'); // Prebid TransactionId
expect(data.ext.wrapper.wiid).to.equal(bidRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID
expect(data.ext.wrapper.profile).to.equal(parseInt(bidRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID
expect(data.ext.wrapper.version).to.equal(parseInt(bidRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID
Expand All @@ -1649,7 +1651,8 @@ describe('PubMatic adapter', function () {

it('Request params check with USP/CCPA Consent', function () {
let bidRequest = {
uspConsent: '1NYN'
uspConsent: '1NYN',
auctionId: 'new-auction-id'
};
let request = spec.buildRequests(bidRequests, bidRequest);
let data = JSON.parse(request.data);
Expand All @@ -1666,7 +1669,7 @@ describe('PubMatic adapter', function () {
expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version
expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId
expect(data.ext.wrapper.transactionId).to.equal('new-auction-id'); // Prebid TransactionId
expect(data.ext.wrapper.wiid).to.equal(bidRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID
expect(data.ext.wrapper.profile).to.equal(parseInt(bidRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID
expect(data.ext.wrapper.version).to.equal(parseInt(bidRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID
Expand Down Expand Up @@ -2696,7 +2699,7 @@ describe('PubMatic adapter', function () {
expect(data.user.geo.lat).to.equal(parseFloat(multipleMediaRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.equal(parseFloat(multipleMediaRequests[0].params.lon)); // Lognitude
expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version
expect(data.ext.wrapper.transactionId).to.equal(multipleMediaRequests[0].transactionId); // Prebid TransactionId
expect(data.ext.wrapper.transactionId).to.equal('new-auction-id'); // Prebid TransactionId
expect(data.ext.wrapper.wiid).to.equal(multipleMediaRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID
expect(data.ext.wrapper.profile).to.equal(parseInt(multipleMediaRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID
expect(data.ext.wrapper.version).to.equal(parseInt(multipleMediaRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID
Expand Down

0 comments on commit c46e38c

Please sign in to comment.