Skip to content

Commit 9fef481

Browse files
authored
Merge pull request prebid#24 from Pubx-ai/bug/PUB-2794
send BidRejected Events to capture floored bids
2 parents 0c6b844 + 5bfc260 commit 9fef481

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

modules/pubxaiAnalyticsAdapter.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,19 @@ const track = ({ eventType, args }) => {
157157
// handle invalid bids, and remove them from the adUnit cache
158158
case EVENTS.BID_TIMEOUT:
159159
args.map(extractBid).forEach((bid) => {
160-
bid.renderStatus = 3;
160+
bid.bidType = 3;
161161
auctionCache[bid.auctionId].bids.push(bid);
162162
});
163163
break;
164164
// handle valid bid responses and record them as part of an auction
165165
case EVENTS.BID_RESPONSE:
166-
const bid = Object.assign(extractBid(args), { renderStatus: 2 });
166+
const bid = Object.assign(extractBid(args), { bidType: 2 });
167167
auctionCache[bid.auctionId].bids.push(bid);
168168
break;
169+
case EVENTS.BID_REJECTED:
170+
const rejectedBid = Object.assign(extractBid(args), { bidType: 1 });
171+
auctionCache[rejectedBid.auctionId].bids.push(rejectedBid);
172+
break;
169173
// capture extra information from the auction, and if there were no bids
170174
// (and so no chance of a win) send the auction
171175
case EVENTS.AUCTION_END:
@@ -183,7 +187,7 @@ const track = ({ eventType, args }) => {
183187
timestamp: args.timestamp,
184188
});
185189
if (
186-
auctionCache[args.auctionId].bids.every((bid) => bid.renderStatus === 3)
190+
auctionCache[args.auctionId].bids.every((bid) => bid.bidType === 3)
187191
) {
188192
prepareSend(args.auctionId);
189193
}
@@ -201,7 +205,7 @@ const track = ({ eventType, args }) => {
201205
isFloorSkipped: floorDetail?.skipped || false,
202206
isWinningBid: true,
203207
renderedSize: args.size,
204-
renderStatus: 4,
208+
bidType: 4,
205209
});
206210
winningBid.adServerData = getAdServerDataForBid(winningBid);
207211
auctionCache[winningBid.auctionId].winningBid = winningBid;
@@ -283,6 +287,7 @@ const prepareSend = (auctionId) => {
283287
auctionTimestamp: auctionData.auctionDetail.timestamp,
284288
pubxaiAnalyticsVersion: pubxaiAnalyticsVersion,
285289
prebidVersion: '$prebid.version$',
290+
pubxId: initOptions.pubxId,
286291
},
287292
});
288293
sendCache[pubxaiAnalyticsRequestUrl].push(data);

test/spec/modules/pubxaiAnalyticsAdapter_spec.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ describe('pubxai analytics adapter', () => {
3131
});
3232

3333
describe('track', () => {
34+
const pubxId = '6c415fc0-8b0e-4cf5-be73-01526a4db625';
3435
let initOptions = {
3536
samplingRate: '1',
36-
pubxId: '6c415fc0-8b0e-4cf5-be73-01526a4db625',
37+
pubxId: pubxId,
3738
};
3839

3940
let originalVS;
@@ -148,7 +149,7 @@ describe('pubxai analytics adapter', () => {
148149
timeout: 1000,
149150
config: {
150151
samplingRate: '1',
151-
pubxId: '6c415fc0-8b0e-4cf5-be73-01526a4db625',
152+
pubxId: pubxId,
152153
},
153154
},
154155
bidRequested: {
@@ -529,7 +530,7 @@ describe('pubxai analytics adapter', () => {
529530
null,
530531
auctionId: 'bc3806e4-873e-453c-8ae5-204f35e923b4',
531532
sizes: '300x250',
532-
renderStatus: 2,
533+
bidType: 2,
533534
requestTimestamp: 1616654312804,
534535
creativeId: 96846035,
535536
currency: 'USD',
@@ -651,7 +652,7 @@ describe('pubxai analytics adapter', () => {
651652
placementId: 13144370,
652653
renderedSize: '300x250',
653654
sizes: '300x250',
654-
renderStatus: 4,
655+
bidType: 4,
655656
responseTimestamp: 1616654313071,
656657
requestTimestamp: 1616654312804,
657658
status: 'rendered',
@@ -764,6 +765,7 @@ describe('pubxai analytics adapter', () => {
764765
auctionTimestamp: '1616654312804',
765766
pubxaiAnalyticsVersion: 'v2.0.0',
766767
prebidVersion: '$prebid.version$',
768+
pubxId: pubxId,
767769
});
768770
expect(expectedData.type).to.equal('text/json');
769771
expect(JSON.parse(await readBlobSafariCompat(expectedData))).to.deep.equal([
@@ -807,6 +809,7 @@ describe('pubxai analytics adapter', () => {
807809
auctionTimestamp: '1616654312804',
808810
pubxaiAnalyticsVersion: 'v2.0.0',
809811
prebidVersion: '$prebid.version$',
812+
pubxId: pubxId,
810813
});
811814

812815
// Step 9: check that the data sent in the request is correct
@@ -932,6 +935,7 @@ describe('pubxai analytics adapter', () => {
932935
auctionTimestamp: '1616654312804',
933936
pubxaiAnalyticsVersion: 'v2.0.0',
934937
prebidVersion: '$prebid.version$',
938+
pubxId: pubxId,
935939
});
936940
expect(expectedData.type).to.equal('text/json');
937941
expect(JSON.parse(await readBlobSafariCompat(expectedData))).to.deep.equal([
@@ -1048,6 +1052,7 @@ describe('pubxai analytics adapter', () => {
10481052
auctionTimestamp: '1616654312804',
10491053
pubxaiAnalyticsVersion: 'v2.0.0',
10501054
prebidVersion: '$prebid.version$',
1055+
pubxId: pubxId,
10511056
});
10521057
expect(expectedData.type).to.equal('text/json');
10531058
expect(JSON.parse(await readBlobSafariCompat(expectedData))).to.deep.equal([

0 commit comments

Comments
 (0)