Skip to content

Commit c54871c

Browse files
Robert Ray Martinez IIIPedro López Jiménez
Robert Ray Martinez III
authored and
Pedro López Jiménez
committed
Rubicon analytics fix bid response mapping (prebid#3411)
* Changing to requestId in order to align with prebid cores mapping of bidId to responseId * Need to update in other events as well * Catching and logging no bid found * Lint error fix
1 parent 09d2517 commit c54871c

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

modules/rubiconAnalyticsAdapter.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,11 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
406406
}, {}));
407407
break;
408408
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+
}
410414
bid.source = formatSource(bid.source || args.source);
411415
switch (args.getStatusCode()) {
412416
case GOOD:
@@ -428,7 +432,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
428432
break;
429433
case BIDDER_DONE:
430434
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];
432436
if (typeof bid.serverResponseTimeMs !== 'undefined') {
433437
cachedBid.serverLatencyMillis = bid.serverResponseTimeMs;
434438
}
@@ -445,11 +449,11 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
445449
break;
446450
case BID_WON:
447451
let auctionCache = cache.auctions[args.auctionId];
448-
auctionCache.bidsWon[args.adUnitCode] = args.adId;
452+
auctionCache.bidsWon[args.adUnitCode] = args.requestId;
449453

450454
// check if this BID_WON missed the boat, if so send by itself
451455
if (auctionCache.sent === true) {
452-
sendMessage.call(this, args.auctionId, args.adId);
456+
sendMessage.call(this, args.auctionId, args.requestId);
453457
} else if (Object.keys(auctionCache.bidsWon).reduce((memo, adUnitCode) => {
454458
// only send if we've received bidWon events for all adUnits in auction
455459
memo = memo && auctionCache.bidsWon[adUnitCode];
@@ -470,7 +474,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
470474
case BID_TIMEOUT:
471475
args.forEach(badBid => {
472476
let auctionCache = cache.auctions[badBid.auctionId];
473-
let bid = auctionCache.bids[badBid.bidId || badBid.adId];
477+
let bid = auctionCache.bids[badBid.bidId || badBid.requestId];
474478
bid.status = 'error';
475479
bid.error = {
476480
code: 'timeout-error'

test/spec/modules/rubiconAnalyticsAdapter_spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const BID = {
4040
'mediaType': 'video',
4141
'statusMessage': 'Bid available',
4242
'bidId': '2ecff0db240757',
43-
'adId': '2ecff0db240757',
43+
'adId': 'fake_ad_id',
4444
'source': 'client',
4545
'requestId': '2ecff0db240757',
4646
'currency': 'USD',
@@ -80,7 +80,7 @@ const BID = {
8080
const BID2 = Object.assign({}, BID, {
8181
adUnitCode: '/19968336/header-bid-tag1',
8282
bidId: '3bd4ebb1c900e2',
83-
adId: '3bd4ebb1c900e2',
83+
adId: 'fake_ad_id',
8484
requestId: '3bd4ebb1c900e2',
8585
width: 728,
8686
height: 90,

0 commit comments

Comments
 (0)