Skip to content

Commit

Permalink
pass along the order which bidders were called (#7947)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrmartinez authored Jan 21, 2022
1 parent b3ee5da commit c6d6c29
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
5 changes: 5 additions & 0 deletions modules/rubiconAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ function sendMessage(auctionId, bidWonId, trigger) {

let auction = {
clientTimeoutMillis: auctionCache.timeout,
auctionStart: auctionCache.timestamp,
auctionEnd: auctionCache.endTs,
bidderOrder: auctionCache.bidderOrder,
samplingFactor,
accountId,
adUnits: Object.keys(adUnitMap).map(i => adUnitMap[i]),
Expand Down Expand Up @@ -583,6 +586,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
cacheEntry.bids = {};
cacheEntry.bidsWon = {};
cacheEntry.gamHasRendered = {};
cacheEntry.bidderOrder = [];
cacheEntry.referrer = deepAccess(args, 'bidderRequests.0.refererInfo.referer');
const floorData = deepAccess(args, 'bidderRequests.0.bids.0.floorData');
if (floorData) {
Expand All @@ -608,6 +612,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
}
break;
case BID_REQUESTED:
cache.auctions[args.auctionId].bidderOrder.push(args.bidderCode);
Object.assign(cache.auctions[args.auctionId].bids, args.bids.reduce((memo, bid) => {
// mark adUnits we expect bidWon events for
cache.auctions[args.auctionId].bidsWon[bid.adUnitCode] = false;
Expand Down
32 changes: 31 additions & 1 deletion test/spec/modules/rubiconAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ const MOCK = {
}
},
BID_REQUESTED: {
'bidder': 'rubicon',
'bidderCode': 'rubicon',
'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa',
'bidderRequestId': '1be65d7958826a',
'bids': [
Expand Down Expand Up @@ -384,6 +384,10 @@ const ANALYTICS_MESSAGE = {
'referrerHostname': 'www.test.com',
'auctions': [
{

'auctionEnd': 1519767013781,
'auctionStart': 1519767010567,
'bidderOrder': ['rubicon'],
'requestId': '25c6d7f5-699a-4bfc-87c9-996f915341fa',
'clientTimeoutMillis': 3000,
'serverTimeoutMillis': 1000,
Expand Down Expand Up @@ -853,6 +857,32 @@ describe('rubicon analytics adapter', function () {
expect(message).to.deep.equal(ANALYTICS_MESSAGE);
});

it('should pass along bidderOrder correctly', function () {
const appnexusBid = utils.deepClone(MOCK.BID_REQUESTED);
appnexusBid.bidderCode = 'appnexus';
const pubmaticBid = utils.deepClone(MOCK.BID_REQUESTED);
pubmaticBid.bidderCode = 'pubmatic';
const indexBid = utils.deepClone(MOCK.BID_REQUESTED);
indexBid.bidderCode = 'ix';
events.emit(AUCTION_INIT, MOCK.AUCTION_INIT);
events.emit(BID_REQUESTED, pubmaticBid);
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);
events.emit(BID_REQUESTED, indexBid);
events.emit(BID_REQUESTED, appnexusBid);
events.emit(BIDDER_DONE, MOCK.BIDDER_DONE);
events.emit(AUCTION_END, MOCK.AUCTION_END);
events.emit(SET_TARGETING, MOCK.SET_TARGETING);
clock.tick(SEND_TIMEOUT + 1000);

let message = JSON.parse(server.requests[0].requestBody);
expect(message.auctions[0].bidderOrder).to.deep.equal([
'pubmatic',
'rubicon',
'ix',
'appnexus'
]);
});

it('should pass along user ids', function () {
let auctionInit = utils.deepClone(MOCK.AUCTION_INIT);
auctionInit.bidderRequests[0].bids[0].userId = {
Expand Down

0 comments on commit c6d6c29

Please sign in to comment.