Skip to content

Commit

Permalink
📈 Add presence.broadcast timing event
Browse files Browse the repository at this point in the history
This change adds a `presence.broadcast` `timing` event, which can be
used to monitor Presence broadcast performance.
  • Loading branch information
alecgibson committed Oct 9, 2023
1 parent 62e4ec5 commit 1c703f4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -776,13 +776,15 @@ Agent.prototype._broadcastPresence = function(presence, callback) {
presence: presence,
collection: presence.c
};
var start = Date.now();
backend.trigger(backend.MIDDLEWARE_ACTIONS.receivePresence, this, context, function(error) {
if (error) return callback(error);
backend.transformPresenceToLatestVersion(agent, presence, function(error, presence) {
if (error) return callback(error);
var channel = agent._getPresenceChannel(presence.ch);
agent.backend.pubsub.publish([channel], presence, function(error) {
if (error) return callback(error);
backend.emit('timing', 'presence.broadcast', Date.now() - start);
callback(null, presence);
});
});
Expand Down

0 comments on commit 1c703f4

Please sign in to comment.