@@ -406,7 +406,11 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
406
406
} , { } ) ) ;
407
407
break ;
408
408
case BID_RESPONSE :
409
- let bid = cache . auctions [ args . auctionId ] . bids [ args . adId ] ;
409
+ let bid = cache . auctions [ args . auctionId ] . bids [ args . requestId ] ;
410
+ if ( ! bid ) {
411
+ utils . logError ( 'Rubicon Anlytics Adapter Error: Could not find associated bid request for bid response with requestId: ' , args . requestId ) ;
412
+ break ;
413
+ }
410
414
bid . source = formatSource ( bid . source || args . source ) ;
411
415
switch ( args . getStatusCode ( ) ) {
412
416
case GOOD :
@@ -428,7 +432,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
428
432
break ;
429
433
case BIDDER_DONE :
430
434
args . bids . forEach ( bid => {
431
- let cachedBid = cache . auctions [ bid . auctionId ] . bids [ bid . bidId || bid . adId ] ;
435
+ let cachedBid = cache . auctions [ bid . auctionId ] . bids [ bid . bidId || bid . requestId ] ;
432
436
if ( typeof bid . serverResponseTimeMs !== 'undefined' ) {
433
437
cachedBid . serverLatencyMillis = bid . serverResponseTimeMs ;
434
438
}
@@ -445,11 +449,11 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
445
449
break ;
446
450
case BID_WON :
447
451
let auctionCache = cache . auctions [ args . auctionId ] ;
448
- auctionCache . bidsWon [ args . adUnitCode ] = args . adId ;
452
+ auctionCache . bidsWon [ args . adUnitCode ] = args . requestId ;
449
453
450
454
// check if this BID_WON missed the boat, if so send by itself
451
455
if ( auctionCache . sent === true ) {
452
- sendMessage . call ( this , args . auctionId , args . adId ) ;
456
+ sendMessage . call ( this , args . auctionId , args . requestId ) ;
453
457
} else if ( Object . keys ( auctionCache . bidsWon ) . reduce ( ( memo , adUnitCode ) => {
454
458
// only send if we've received bidWon events for all adUnits in auction
455
459
memo = memo && auctionCache . bidsWon [ adUnitCode ] ;
@@ -470,7 +474,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
470
474
case BID_TIMEOUT :
471
475
args . forEach ( badBid => {
472
476
let auctionCache = cache . auctions [ badBid . auctionId ] ;
473
- let bid = auctionCache . bids [ badBid . bidId || badBid . adId ] ;
477
+ let bid = auctionCache . bids [ badBid . bidId || badBid . requestId ] ;
474
478
bid . status = 'error' ;
475
479
bid . error = {
476
480
code : 'timeout-error'
0 commit comments