Skip to content

Commit

Permalink
IX Bid Adapter: Add support for impression level transactionId (imp[]…
Browse files Browse the repository at this point in the history
….ext.tid) (#8641)

* IX Bid Adapter: add imp ext tid support

* fix tid level in imp ext object

Co-authored-by: shahin.rahbariasl <[email protected]>
  • Loading branch information
shahinrahbariasl and shahin-rahbariasl authored Jul 8, 2022
1 parent a29cafd commit be0e69b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,7 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) {

const gpid = impressions[transactionIds[adUnitIndex]].gpid;
const dfpAdUnitCode = impressions[transactionIds[adUnitIndex]].dfp_ad_unit_code;
const tid = impressions[transactionIds[adUnitIndex]].tid
if (impressionObjects.length && BANNER in impressionObjects[0]) {
const { id, banner: { topframe } } = impressionObjects[0];
const _bannerImpression = {
Expand All @@ -1060,10 +1061,11 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) {
},
}

if (dfpAdUnitCode || gpid) {
if (dfpAdUnitCode || gpid || tid) {
_bannerImpression.ext = {};
_bannerImpression.ext.dfp_ad_unit_code = dfpAdUnitCode;
_bannerImpression.ext.gpid = gpid;
_bannerImpression.ext.tid = tid;
}

if ('bidfloor' in impressionObjects[0]) {
Expand Down Expand Up @@ -1272,6 +1274,7 @@ function createVideoImps(validBidRequest, videoImps) {
videoImps[validBidRequest.transactionId].ixImps = [];
videoImps[validBidRequest.transactionId].ixImps.push(imp);
videoImps[validBidRequest.transactionId].gpid = deepAccess(validBidRequest, 'ortb2Imp.ext.gpid');
videoImps[validBidRequest.transactionId].tid = deepAccess(validBidRequest, 'ortb2Imp.ext.tid');
}
}

Expand All @@ -1298,6 +1301,7 @@ function createBannerImps(validBidRequest, missingBannerSizes, bannerImps) {

bannerImps[validBidRequest.transactionId].gpid = deepAccess(validBidRequest, 'ortb2Imp.ext.gpid');
bannerImps[validBidRequest.transactionId].dfp_ad_unit_code = deepAccess(validBidRequest, 'ortb2Imp.ext.data.adserver.adslot');
bannerImps[validBidRequest.transactionId].tid = deepAccess(validBidRequest, 'ortb2Imp.ext.tid');

// Create IX imps from params.size
if (bannerSizeDefined) {
Expand Down
41 changes: 41 additions & 0 deletions test/spec/modules/ixBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ describe('IndexexchangeAdapter', function () {
playerSize: [[400, 100]]
}
},
ortb2Imp: {
ext: {
tid: '173f49a8-7549-4218-a23c-e7ba59b47230'
}
},
adUnitCode: 'div-gpt-ad-1460505748562-0',
transactionId: '173f49a8-7549-4218-a23c-e7ba59b47230',
bidId: '1a2b3c4e',
Expand All @@ -143,6 +148,11 @@ describe('IndexexchangeAdapter', function () {
sizes: [[300, 250]]
}
},
ortb2Imp: {
ext: {
tid: '173f49a8-7549-4218-a23c-e7ba59b47229'
}
},
adUnitCode: 'div-gpt-ad-1460505748561-0',
transactionId: '173f49a8-7549-4218-a23c-e7ba59b47229',
bidId: '1a2b3c4d',
Expand All @@ -165,6 +175,11 @@ describe('IndexexchangeAdapter', function () {
sizes: [[300, 250], [300, 600]]
}
},
ortb2Imp: {
ext: {
tid: '173f49a8-7549-4218-a23c-e7ba59b47229'
}
},
adUnitCode: 'div-gpt-ad-1460505748561-0',
transactionId: '173f49a8-7549-4218-a23c-e7ba59b47229',
bidId: '1a2b3c4d',
Expand All @@ -185,6 +200,11 @@ describe('IndexexchangeAdapter', function () {
sizes: [[300, 250], [300, 600]]
}
},
ortb2Imp: {
ext: {
tid: '173f49a8-7549-4218-a23c-e7ba59b47229'
}
},
adUnitCode: 'div-gpt-ad-1460505748561-0',
transactionId: '173f49a8-7549-4218-a23c-e7ba59b47229',
bidId: '1a2b3c4d',
Expand Down Expand Up @@ -214,6 +234,11 @@ describe('IndexexchangeAdapter', function () {
protocols: [2]
}
},
ortb2Imp: {
ext: {
tid: '173f49a8-7549-4218-a23c-e7ba59b47230'
}
},
adUnitCode: 'div-gpt-ad-1460505748562-0',
transactionId: '173f49a8-7549-4218-a23c-e7ba59b47230',
bidId: '1a2b3c4e',
Expand Down Expand Up @@ -247,6 +272,11 @@ describe('IndexexchangeAdapter', function () {
playerSize: [[400, 100], [200, 400]]
}
},
ortb2Imp: {
ext: {
tid: '173f49a8-7549-4218-a23c-e7ba59b47230'
}
},
adUnitCode: 'div-gpt-ad-1460505748562-0',
transactionId: '173f49a8-7549-4218-a23c-e7ba59b47230',
bidId: '1a2b3c4e',
Expand All @@ -272,6 +302,11 @@ describe('IndexexchangeAdapter', function () {
sizes: [[300, 250], [300, 600], [400, 500]]
}
},
ortb2Imp: {
ext: {
tid: '173f49a8-7549-4218-a23c-e7ba59b47230'
}
},
adUnitCode: 'div-gpt-ad-1460505748562-0',
transactionId: '173f49a8-7549-4218-a23c-e7ba59b47230',
bidId: '1a2b3c4e',
Expand Down Expand Up @@ -307,6 +342,11 @@ describe('IndexexchangeAdapter', function () {
sizes: [[300, 250], [300, 600]]
}
},
ortb2Imp: {
ext: {
tid: '173f49a8-7549-4218-a23c-e7ba59b47230'
}
},
adUnitCode: 'div-gpt-ad-1460505748562-0',
transactionId: '273f49a8-7549-4218-a23c-e7ba59b47230',
bidId: '1a2b3c4e',
Expand Down Expand Up @@ -1720,6 +1760,7 @@ describe('IndexexchangeAdapter', function () {
expect(impression.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidId);
expect(impression.banner.format).to.be.length(2);
expect(impression.banner.topframe).to.be.oneOf([0, 1]);
expect(impression.ext.tid).to.equal(DEFAULT_BANNER_VALID_BID[0].transactionId);

impression.banner.format.map(({ w, h, ext }, index) => {
const size = DEFAULT_BANNER_VALID_BID[0].mediaTypes.banner.sizes[index];
Expand Down

0 comments on commit be0e69b

Please sign in to comment.