Skip to content

Commit a908cc9

Browse files
timing analysis data added
1 parent 5729c8c commit a908cc9

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

modules/rubiconAnalyticsAdapter.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function formatSource(src) {
115115
return src.toLowerCase();
116116
}
117117

118-
function sendMessage(auctionId, bidWonId) {
118+
function sendMessage(auctionId, bidWonId, trigger) {
119119
function formatBid(bid) {
120120
return utils.pick(bid, [
121121
'bidder',
@@ -163,6 +163,7 @@ function sendMessage(auctionId, bidWonId) {
163163
let auctionCache = cache.auctions[auctionId];
164164
let referrer = config.getConfig('pageUrl') || (auctionCache && auctionCache.referrer);
165165
let message = {
166+
trigger,
166167
eventTimeMillis: Date.now(),
167168
integration: rubiConf.int_type || DEFAULT_INTEGRATION,
168169
version: '$prebid.version$',
@@ -301,8 +302,10 @@ function sendMessage(auctionId, bidWonId) {
301302
message.bidsWon = bidsWon;
302303
}
303304

305+
message.eventTiming = Math.round(utils.getPerformanceNow() - auctionCache.endTs);
304306
auctionCache.sent = true;
305307
} else if (bidWonId && auctionCache && auctionCache.bids[bidWonId]) {
308+
message.eventTiming = Math.round(utils.getPerformanceNow() - auctionCache.endTs);
306309
message.bidsWon = [
307310
formatBidWon(auctionCache.bids[bidWonId])
308311
];
@@ -497,9 +500,9 @@ function subscribeToGamSlots() {
497500
clearTimeout(cache.timeouts[auctionId]);
498501
delete cache.timeouts[auctionId];
499502
if (rubiConf.analyticsEventDelay > 0) {
500-
setTimeout(() => sendMessage.call(rubiconAdapter, auctionId), rubiConf.analyticsEventDelay)
503+
setTimeout(() => sendMessage.call(rubiconAdapter, auctionId, undefined, 'delayedGam'), rubiConf.analyticsEventDelay)
501504
} else {
502-
sendMessage.call(rubiconAdapter, auctionId)
505+
sendMessage.call(rubiconAdapter, auctionId, undefined, 'gam')
503506
}
504507
}
505508
});
@@ -749,7 +752,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
749752

750753
// check if this BID_WON missed the boat, if so send by itself
751754
if (auctionCache.sent === true) {
752-
sendMessage.call(this, args.auctionId, args.requestId);
755+
sendMessage.call(this, args.auctionId, args.requestId, 'soloBidWon');
753756
} else if (!rubiConf.waitForGamSlots && Object.keys(auctionCache.bidsWon).reduce((memo, adUnitCode) => {
754757
// only send if we've received bidWon events for all adUnits in auction
755758
memo = memo && auctionCache.bidsWon[adUnitCode];
@@ -758,13 +761,15 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
758761
clearTimeout(cache.timeouts[args.auctionId]);
759762
delete cache.timeouts[args.auctionId];
760763

761-
sendMessage.call(this, args.auctionId);
764+
sendMessage.call(this, args.auctionId, undefined, 'allBidWons');
762765
}
763766
break;
764767
case AUCTION_END:
768+
// see how long it takes for the payload to come fire
769+
cache.auctions[args.auctionId].endTs = utils.getPerformanceNow();
765770
// start timer to send batched payload just in case we don't hear any BID_WON events
766771
cache.timeouts[args.auctionId] = setTimeout(() => {
767-
sendMessage.call(this, args.auctionId);
772+
sendMessage.call(this, args.auctionId, undefined, 'auctionEnd');
768773
}, rubiConf.analyticsBatchTimeout || SEND_TIMEOUT);
769774
break;
770775
case BID_TIMEOUT:

0 commit comments

Comments
 (0)