From 75197e03359c9e68ea05b307544cb2125dcd2262 Mon Sep 17 00:00:00 2001 From: "Donny.Chang" Date: Thu, 8 Jan 2026 17:54:39 +0800 Subject: [PATCH 1/2] enhance adapter with additional bid parameters --- modules/bridgewellBidAdapter.js | 105 +++++++++++++++++++++++--------- 1 file changed, 75 insertions(+), 30 deletions(-) diff --git a/modules/bridgewellBidAdapter.js b/modules/bridgewellBidAdapter.js index 9b7ff2fd0c9..3aac340a285 100644 --- a/modules/bridgewellBidAdapter.js +++ b/modules/bridgewellBidAdapter.js @@ -45,44 +45,76 @@ export const spec = { validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); const adUnits = []; - var bidderUrl = REQUEST_ENDPOINT + Math.random(); - var userIds; + const bidderUrl = REQUEST_ENDPOINT + Math.random(); _each(validBidRequests, function (bid) { - userIds = bid.userId; - - if (bid.params.cid) { - adUnits.push({ - cid: bid.params.cid, - adUnitCode: bid.adUnitCode, - requestId: bid.bidId, - mediaTypes: bid.mediaTypes || { - banner: { - sizes: bid.sizes - } - }, - userIds: userIds || {} - }); - } else { - adUnits.push({ - ChannelID: bid.params.ChannelID, - adUnitCode: bid.adUnitCode, - requestId: bid.bidId, - mediaTypes: bid.mediaTypes || { - banner: { - sizes: bid.sizes - } + const passthrough = bid.ortb2Imp?.ext?.prebid?.passthrough; + const filteredPassthrough = passthrough ? Object.fromEntries( + Object.entries({ + bucket: passthrough.bucket, + client: passthrough.client, + gamAdCode: passthrough.gamAdCode, + gamLoc: passthrough.gamLoc, + colo: passthrough.colo, + device: passthrough.device, + lang: passthrough.lang, + pt: passthrough.pt, + region: passthrough.region, + site: passthrough.site, + ver: passthrough.ver + }).filter(([_, value]) => value !== undefined) + ) : undefined; + + const adUnit = { + adUnitCode: bid.adUnitCode, + requestId: bid.bidId, + transactionId: bid.transactionId, + adUnitId: bid.adUnitId, + sizes: bid.sizes, + mediaTypes: bid.mediaTypes || { + banner: { + sizes: bid.sizes + } + }, + ortb2Imp: { + ext: { + prebid: { + passthrough: filteredPassthrough + }, + data: { + adserver: { + name: bid.ortb2Imp?.ext?.data?.adserver?.name, + adslot: bid.ortb2Imp?.ext?.data?.adserver?.adslot + }, + pbadslot: bid.ortb2Imp?.ext?.data?.pbadslot + }, + gpid: bid.ortb2Imp?.ext?.gpid }, - userIds: userIds || {} - }); + banner: { + pos: bid.ortb2Imp?.banner?.pos + } + } + }; + + if (bid.params?.cid) { + adUnit.cid = bid.params.cid; + } else if (bid.params?.ChannelID) { + adUnit.ChannelID = bid.params.ChannelID; } + + const floorInfo = bid.getFloor?.() || {}; + adUnit.floor = floorInfo.floor; + adUnit.currency = floorInfo.currency; + adUnits.push(adUnit); }); let topUrl = ''; - if (bidderRequest && bidderRequest.refererInfo) { + if (bidderRequest?.refererInfo?.page) { topUrl = bidderRequest.refererInfo.page; } + const firstBid = validBidRequests[0] || {}; + return { method: 'POST', url: bidderUrl, @@ -93,10 +125,23 @@ export const spec = { }, inIframe: inIframe(), url: topUrl, - referrer: bidderRequest.refererInfo.ref, + referrer: bidderRequest?.refererInfo?.ref, + auctionId: firstBid?.auctionId, + bidderRequestId: firstBid?.bidderRequestId, + src: firstBid?.src, + userIds: firstBid?.userId || {}, + userIdAsEids: firstBid?.userIdAsEids || [], + auctionsCount: firstBid?.auctionsCount, + bidRequestsCount: firstBid?.bidRequestsCount, + bidderRequestsCount: firstBid?.bidderRequestsCount, + bidderWinsCount: firstBid?.bidderWinsCount, + deferBilling: firstBid?.deferBilling, + metrics: firstBid?.metrics || {}, adUnits: adUnits, // TODO: please do not send internal data structures over the network - refererInfo: bidderRequest.refererInfo.legacy}, + refererInfo: bidderRequest?.refererInfo?.legacy, + ortb2: bidderRequest?.ortb2 + }, validBidRequests: validBidRequests }; }, From 8bb5ae3d34d736d067d7eb9e63143bb2b496a303 Mon Sep 17 00:00:00 2001 From: "Donny.Chang" Date: Thu, 8 Jan 2026 17:54:51 +0800 Subject: [PATCH 2/2] Add additional bid parameters to tests of bridgewellBidAdapter --- .../spec/modules/bridgewellBidAdapter_spec.js | 207 +++++++++++++++++- 1 file changed, 202 insertions(+), 5 deletions(-) diff --git a/test/spec/modules/bridgewellBidAdapter_spec.js b/test/spec/modules/bridgewellBidAdapter_spec.js index 629cf6b62c5..edb8286f931 100644 --- a/test/spec/modules/bridgewellBidAdapter_spec.js +++ b/test/spec/modules/bridgewellBidAdapter_spec.js @@ -8,6 +8,16 @@ const userId = { 'sharedid': {'id': '01F61MX53D786DSB2WYD38ZVM7', 'third': '01F61MX53D786DSB2WYD38ZVM7'}, 'uid2': {'id': 'eb33b0cb-8d35-1234-b9c0-1a31d4064777'}, } +const userIdAsEids = [{ + source: 'test.org', + uids: [{ + id: '01**********', + atype: 1, + ext: { + third: '01***********' + } + }] +}]; describe('bridgewellBidAdapter', function () { const adapter = newBidder(spec); @@ -95,6 +105,7 @@ describe('bridgewellBidAdapter', function () { 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', 'userId': userId, + 'userIdAsEids': userIdAsEids, }, { 'bidder': 'bridgewell', @@ -135,6 +146,7 @@ describe('bridgewellBidAdapter', function () { 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', 'userId': userId, + 'userIdAsEids': userIdAsEids, } ]; @@ -153,14 +165,20 @@ describe('bridgewellBidAdapter', function () { expect(payload).to.be.an('object'); expect(payload.adUnits).to.be.an('array'); expect(payload.url).to.exist.and.to.equal('https://www.bridgewell.com/'); + expect(payload.userIds).to.deep.equal(userId); + expect(payload.userIdAsEids).to.deep.equal(userIdAsEids); + expect(payload.auctionId).to.equal('1d1a030790a475'); + expect(payload.bidderRequestId).to.equal('22edbae2733bf6'); for (let i = 0, max_i = payload.adUnits.length; i < max_i; i++) { const u = payload.adUnits[i]; expect(u).to.have.property('ChannelID').that.is.a('string'); expect(u).to.not.have.property('cid'); expect(u).to.have.property('adUnitCode').and.to.equal('adunit-code-2'); expect(u).to.have.property('requestId').and.to.equal('3150ccb55da321'); - expect(u).to.have.property('userIds'); - expect(u.userIds).to.deep.equal(userId); + expect(u).to.have.property('transactionId'); + expect(u).to.have.property('sizes'); + expect(u).to.have.property('mediaTypes'); + expect(u).to.have.property('ortb2Imp'); } }); @@ -188,7 +206,8 @@ describe('bridgewellBidAdapter', function () { 'bidId': '3150ccb55da321', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', - 'userId': userId + 'userId': userId, + 'userIdAsEids': userIdAsEids, }, ]; @@ -198,14 +217,20 @@ describe('bridgewellBidAdapter', function () { expect(payload).to.be.an('object'); expect(payload.adUnits).to.be.an('array'); expect(payload.url).to.exist.and.to.equal('https://www.bridgewell.com/'); + expect(payload.userIds).to.deep.equal(userId); + expect(payload.userIdAsEids).to.deep.equal(userIdAsEids); + expect(payload.auctionId).to.equal('1d1a030790a475'); + expect(payload.bidderRequestId).to.equal('22edbae2733bf6'); for (let i = 0, max_i = payload.adUnits.length; i < max_i; i++) { const u = payload.adUnits[i]; expect(u).to.have.property('cid').that.is.a('number'); expect(u).to.not.have.property('ChannelID'); expect(u).to.have.property('adUnitCode').and.to.equal('adunit-code-2'); expect(u).to.have.property('requestId').and.to.equal('3150ccb55da321'); - expect(u).to.have.property('userIds'); - expect(u.userIds).to.deep.equal(userId); + expect(u).to.have.property('transactionId'); + expect(u).to.have.property('sizes'); + expect(u).to.have.property('mediaTypes'); + expect(u).to.have.property('ortb2Imp'); } }); @@ -223,6 +248,178 @@ describe('bridgewellBidAdapter', function () { const validBidRequests = request.validBidRequests; expect(validBidRequests).to.deep.equal(bidRequests); }); + + it('should include ortb2Imp fields in adUnit', function () { + const bidderRequest = { + refererInfo: { + page: 'https://www.bridgewell.com/', + legacy: { + referer: 'https://www.bridgewell.com/', + } + } + } + const bidRequestsWithOrtb2 = [ + { + 'bidder': 'bridgewell', + 'params': { + 'cid': 1234, + }, + 'adUnitCode': 'adunit-code-1', + 'transactionId': 'trans-123', + 'adUnitId': 'adunit-123', + 'sizes': [[300, 250]], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]] + } + }, + 'bidId': 'bid-123', + 'ortb2Imp': { + 'ext': { + 'data': { + 'adserver': { + 'name': 'gam', + 'adslot': '/1234/test' + }, + 'pbadslot': '/1234/test-pbadslot' + }, + 'gpid': 'test-gpid', + 'prebid': { + 'passthrough': { + 'bucket': 'test-bucket', + 'client': 'test-client', + 'gamAdCode': 'test-gam', + 'undefinedField': undefined + } + } + }, + 'banner': { + 'pos': 1 + } + }, + 'userId': userId, + 'userIdAsEids': userIdAsEids, + } + ]; + + const request = spec.buildRequests(bidRequestsWithOrtb2, bidderRequest); + const adUnit = request.data.adUnits[0]; + + expect(adUnit.transactionId).to.equal('trans-123'); + expect(adUnit.adUnitId).to.equal('adunit-123'); + expect(adUnit.sizes).to.deep.equal([[300, 250]]); + expect(adUnit.ortb2Imp.ext.data.adserver.name).to.equal('gam'); + expect(adUnit.ortb2Imp.ext.data.adserver.adslot).to.equal('/1234/test'); + expect(adUnit.ortb2Imp.ext.data.pbadslot).to.equal('/1234/test-pbadslot'); + expect(adUnit.ortb2Imp.ext.gpid).to.equal('test-gpid'); + expect(adUnit.ortb2Imp.banner.pos).to.equal(1); + expect(adUnit.ortb2Imp.ext.prebid.passthrough).to.deep.equal({ + bucket: 'test-bucket', + client: 'test-client', + gamAdCode: 'test-gam' + }); + expect(adUnit.ortb2Imp.ext.prebid.passthrough).to.not.have.property('undefinedField'); + }); + + it('should include floor information when getFloor is available', function () { + const bidderRequest = { + refererInfo: { + page: 'https://www.bridgewell.com/', + legacy: { + referer: 'https://www.bridgewell.com/', + } + } + } + const bidRequestsWithFloor = [ + { + 'bidder': 'bridgewell', + 'params': { + 'cid': 1234, + }, + 'adUnitCode': 'adunit-code-1', + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]] + } + }, + 'bidId': 'bid-123', + 'getFloor': function() { + return { + floor: 1.5, + currency: 'USD' + }; + }, + 'userId': userId, + 'userIdAsEids': userIdAsEids, + } + ]; + + const request = spec.buildRequests(bidRequestsWithFloor, bidderRequest); + const adUnit = request.data.adUnits[0]; + + expect(adUnit.floor).to.equal(1.5); + expect(adUnit.currency).to.equal('USD'); + }); + + it('should include additional bid request fields in payload', function () { + const bidderRequest = { + refererInfo: { + page: 'https://www.bridgewell.com/', + ref: 'https://www.referrer.com/', + legacy: { + referer: 'https://www.bridgewell.com/', + } + }, + ortb2: { + site: { + name: 'test-site' + } + } + } + const bidRequestsWithMetrics = [ + { + 'bidder': 'bridgewell', + 'params': { + 'cid': 1234, + }, + 'adUnitCode': 'adunit-code-1', + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]] + } + }, + 'bidId': 'bid-123', + 'bidderRequestId': 'bidder-req-123', + 'auctionId': 'auction-123', + 'src': 's2s', + 'auctionsCount': 5, + 'bidRequestsCount': 10, + 'bidderRequestsCount': 3, + 'bidderWinsCount': 2, + 'deferBilling': true, + 'metrics': { + 'test': 'metric' + }, + 'userId': userId, + 'userIdAsEids': userIdAsEids, + } + ]; + + const request = spec.buildRequests(bidRequestsWithMetrics, bidderRequest); + const payload = request.data; + + expect(payload.auctionId).to.equal('auction-123'); + expect(payload.bidderRequestId).to.equal('bidder-req-123'); + expect(payload.src).to.equal('s2s'); + expect(payload.auctionsCount).to.equal(5); + expect(payload.bidRequestsCount).to.equal(10); + expect(payload.bidderRequestsCount).to.equal(3); + expect(payload.bidderWinsCount).to.equal(2); + expect(payload.deferBilling).to.equal(true); + expect(payload.metrics).to.deep.equal({test: 'metric'}); + expect(payload.referrer).to.equal('https://www.referrer.com/'); + expect(payload.ortb2).to.deep.equal({site: {name: 'test-site'}}); + }); }); describe('interpretResponse', function () {