Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rubicon analytics fix bid response mapping #3411

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
14 changes: 9 additions & 5 deletions modules/rubiconAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,11 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
}, {}));
break;
case BID_RESPONSE:
let bid = cache.auctions[args.auctionId].bids[args.adId];
let bid = cache.auctions[args.auctionId].bids[args.requestId];
if (!bid) {
utils.logError('Rubicon Anlytics Adapter Error: Could not find associated bid request for bid response with requestId: ', args.requestId);
break;
}
bid.source = formatSource(bid.source || args.source);
switch (args.getStatusCode()) {
case GOOD:
Expand All @@ -428,7 +432,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
break;
case BIDDER_DONE:
args.bids.forEach(bid => {
let cachedBid = cache.auctions[bid.auctionId].bids[bid.bidId || bid.adId];
let cachedBid = cache.auctions[bid.auctionId].bids[bid.bidId || bid.requestId];
if (typeof bid.serverResponseTimeMs !== 'undefined') {
cachedBid.serverLatencyMillis = bid.serverResponseTimeMs;
}
Expand All @@ -445,11 +449,11 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
break;
case BID_WON:
let auctionCache = cache.auctions[args.auctionId];
auctionCache.bidsWon[args.adUnitCode] = args.adId;
auctionCache.bidsWon[args.adUnitCode] = args.requestId;

// check if this BID_WON missed the boat, if so send by itself
if (auctionCache.sent === true) {
sendMessage.call(this, args.auctionId, args.adId);
sendMessage.call(this, args.auctionId, args.requestId);
} else if (Object.keys(auctionCache.bidsWon).reduce((memo, adUnitCode) => {
// only send if we've received bidWon events for all adUnits in auction
memo = memo && auctionCache.bidsWon[adUnitCode];
Expand All @@ -470,7 +474,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
case BID_TIMEOUT:
args.forEach(badBid => {
let auctionCache = cache.auctions[badBid.auctionId];
let bid = auctionCache.bids[badBid.bidId || badBid.adId];
let bid = auctionCache.bids[badBid.bidId || badBid.requestId];
bid.status = 'error';
bid.error = {
code: 'timeout-error'
Expand Down
4 changes: 2 additions & 2 deletions test/spec/modules/rubiconAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const BID = {
'mediaType': 'video',
'statusMessage': 'Bid available',
'bidId': '2ecff0db240757',
'adId': '2ecff0db240757',
'adId': 'fake_ad_id',
'source': 'client',
'requestId': '2ecff0db240757',
'currency': 'USD',
Expand Down Expand Up @@ -80,7 +80,7 @@ const BID = {
const BID2 = Object.assign({}, BID, {
adUnitCode: '/19968336/header-bid-tag1',
bidId: '3bd4ebb1c900e2',
adId: '3bd4ebb1c900e2',
adId: 'fake_ad_id',
requestId: '3bd4ebb1c900e2',
width: 728,
height: 90,
Expand Down