Skip to content
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
3 changes: 2 additions & 1 deletion modules/previousAuctionInfo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ export const onAuctionEndHandler = (auctionDetails) => {
source: 'pbjs',
adUnitCode: bid.adUnitCode,
highestBidCpm: highestBidsByAdUnitCode[bid.adUnitCode]?.cpm || null,
highestBidCurrency: highestBidsByAdUnitCode[bid.adUnitCode]?.currency || null,
bidderCpm: receivedBidsMap[bid.bidId]?.cpm || null,
bidderOriginalCpm: receivedBidsMap[bid.bidId]?.originalCpm || null,
bidderCurrency: receivedBidsMap[bid.bidId]?.currency || null,
bidderOriginalCurrency: receivedBidsMap[bid.bidId]?.originalCurrency || null,
bidderErrorCode: rejectedBidsMap[bid.bidId]?.rejectionReason || null,
rejectionReason: rejectedBidsMap[bid.bidId]?.rejectionReason || null,
timestamp: auctionDetails.timestamp,
transactionId: bid.transactionId, // this field gets removed before injecting previous auction info into the bid stream
}
Expand Down
43 changes: 40 additions & 3 deletions test/spec/modules/previousAuctionInfo_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { expect } from 'chai';
import { config } from 'src/config.js';
import * as events from 'src/events.js';
import {CONFIG_NS, resetPreviousAuctionInfo, startAuctionHook} from '../../../modules/previousAuctionInfo';
import { REJECTION_REASON } from '../../../src/constants.js';

describe('previous auction info', () => {
let sandbox;
Expand Down Expand Up @@ -90,11 +91,12 @@ describe('previous auction info', () => {
source: 'pbjs',
adUnitCode: 'adUnit1',
highestBidCpm: 2,
highestBidCurrency: 'EUR',
bidderCpm: 2,
bidderOriginalCpm: 2.1,
bidderCurrency: 'EUR',
bidderOriginalCurrency: 'EUR',
bidderErrorCode: null,
rejectionReason: null,
timestamp: auctionDetails.timestamp
});
});
Expand All @@ -109,17 +111,21 @@ describe('previous auction info', () => {
expect(previousAuctionInfo.auctionState['testBidder1'][0]).to.include({
bidId: 'bid123',
highestBidCpm: 2,
highestBidCurrency: 'EUR',
adUnitCode: 'adUnit1',
bidderCpm: 1,
bidderCurrency: 'USD'
bidderCurrency: 'USD',
rejectionReason: null,
});

expect(previousAuctionInfo.auctionState['testBidder3'][0]).to.include({
bidId: 'bidxyz',
highestBidCpm: 3,
highestBidCurrency: 'USD',
adUnitCode: 'adUnit2',
bidderCpm: 3,
bidderCurrency: 'USD'
bidderCurrency: 'USD',
rejectionReason: null,
});
});

Expand All @@ -130,6 +136,37 @@ describe('previous auction info', () => {
expect(previousAuctionInfo.auctionState).to.have.property('testBidder1');
expect(previousAuctionInfo.auctionState).to.not.have.property('testBidder2');
});

it('should include rejectionReason string if the bid was rejected', () => {
const auctionDetailsWithRejectedBid = {
auctionId: 'auctionXYZ',
bidsReceived: [],
bidsRejected: [
{ requestId: 'bid456', rejectionReason: REJECTION_REASON.FLOOR_NOT_MET } // string from REJECTION_REASON
],
bidderRequests: [
{
bidderCode: 'testBidder1',
bidderRequestId: 'req1',
bids: [
{ bidId: 'bid456', adUnitCode: 'adUnit1' }
]
}
],
timestamp: Date.now(),
};

config.setConfig({ [CONFIG_NS]: { enabled: true, bidders: ['testBidder1'] } });
previousAuctionInfo.onAuctionEndHandler(auctionDetailsWithRejectedBid);

const stored = previousAuctionInfo.auctionState['testBidder1'][0];
expect(stored).to.include({
bidId: 'bid456',
rejectionReason: REJECTION_REASON.FLOOR_NOT_MET,
bidderCpm: null,
highestBidCpm: null
});
});
});

describe('startAuctionHook', () => {
Expand Down