From 1ee5428882650b25bc8142edde964f70eb9787c5 Mon Sep 17 00:00:00 2001 From: aslagle Date: Thu, 13 Apr 2023 11:05:35 -0600 Subject: [PATCH 1/4] Add context to emitted seatnonbid event --- modules/prebidServerBidAdapter/index.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index ffb02204ed0..3ceca9f3d2b 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -474,7 +474,13 @@ export function PrebidServer() { bidRequests.forEach(bidderRequest => events.emit(CONSTANTS.EVENTS.BIDDER_DONE, bidderRequest)); } if (shouldEmitNonbids(s2sBidRequest.s2sConfig, response)) { - emitNonBids(response.ext.seatnonbid, bidRequests[0].auctionId); + emitNonBids({ + seatnonbid: response.ext.seatnonbid, + auctionId: bidRequests[0].auctionId, + requestedBidders, + response, + adapterMetrics + }); } done(); doClientSideSyncs(requestedBidders, gdprConsent, uspConsent, gppConsent); @@ -580,10 +586,14 @@ function shouldEmitNonbids(s2sConfig, response) { return s2sConfig?.extPrebid?.returnallbidstatus && response?.ext?.seatnonbid; } -function emitNonBids(seatnonbid, auctionId) { +function emitNonBids(context) { + const {seatnonbid, auctionId, response, requestedBidders, adapterMetrics} = context; events.emit(CONSTANTS.EVENTS.SEAT_NON_BID, { seatnonbid, - auctionId + auctionId, + response, + requestedBidders, + adapterMetrics }); } From f7a2fd81551ac40b94aac1e4cbe61e19127baf70 Mon Sep 17 00:00:00 2001 From: aslagle Date: Thu, 13 Apr 2023 16:20:08 -0600 Subject: [PATCH 2/4] Add unit test coverage --- test/spec/modules/prebidServerBidAdapter_spec.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index 9516f0402c1..755d348c67d 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -2934,7 +2934,7 @@ describe('S2S Adapter', function () { expect(response).to.have.property('ttl', 60); }); - it('handles seatnonbid responses and calls SEAT_NON_BID', function () { + it('handles seatnonbid responses and emits SEAT_NON_BID', function () { const original = CONFIG; CONFIG.extPrebid = { returnallbidstatus: true }; const nonbidResponse = {...RESPONSE_OPENRTB, ext: {seatnonbid: [{}]}}; @@ -2947,6 +2947,8 @@ describe('S2S Adapter', function () { const event = events.emit.secondCall.args; expect(event[0]).to.equal(CONSTANTS.EVENTS.SEAT_NON_BID); expect(event[1].seatnonbid[0]).to.have.property('auctionId', 2); + expect(event[1].requestedBidders).to.deep.equal(['appnexus']); + expect(event[1].response).to.deep.equal(responding); }); it('respects defaultTtl', function () { From 06d60e135e6213d1732b80d1ca6abd84e8069155 Mon Sep 17 00:00:00 2001 From: aslagle Date: Mon, 17 Apr 2023 12:39:32 -0600 Subject: [PATCH 3/4] Sanitize and emit context --- modules/prebidServerBidAdapter/index.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index 3ceca9f3d2b..17ac35c63b9 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -587,14 +587,9 @@ function shouldEmitNonbids(s2sConfig, response) { } function emitNonBids(context) { - const {seatnonbid, auctionId, response, requestedBidders, adapterMetrics} = context; - events.emit(CONSTANTS.EVENTS.SEAT_NON_BID, { - seatnonbid, - auctionId, - response, - requestedBidders, - adapterMetrics - }); + // parse/stringify to prevent manipulation of original data through the event + const sanitizedData = JSON.parse(JSON.stringify({...context})) + events.emit(CONSTANTS.EVENTS.SEAT_NON_BID, sanitizedData); } /** From e8dd230e089f29b4295f4db4a7cf4a57dd26056d Mon Sep 17 00:00:00 2001 From: aslagle Date: Tue, 18 Apr 2023 13:35:09 -0600 Subject: [PATCH 4/4] Remove sanitize step for emitted data --- modules/prebidServerBidAdapter/index.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index 17ac35c63b9..b09a8688dd0 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -474,7 +474,7 @@ export function PrebidServer() { bidRequests.forEach(bidderRequest => events.emit(CONSTANTS.EVENTS.BIDDER_DONE, bidderRequest)); } if (shouldEmitNonbids(s2sBidRequest.s2sConfig, response)) { - emitNonBids({ + events.emit(CONSTANTS.EVENTS.SEAT_NON_BID, { seatnonbid: response.ext.seatnonbid, auctionId: bidRequests[0].auctionId, requestedBidders, @@ -586,12 +586,6 @@ function shouldEmitNonbids(s2sConfig, response) { return s2sConfig?.extPrebid?.returnallbidstatus && response?.ext?.seatnonbid; } -function emitNonBids(context) { - // parse/stringify to prevent manipulation of original data through the event - const sanitizedData = JSON.parse(JSON.stringify({...context})) - events.emit(CONSTANTS.EVENTS.SEAT_NON_BID, sanitizedData); -} - /** * Global setter that sets eids permissions for bidders * This setter is to be used by userId module when included