Skip to content

Commit d50fed9

Browse files
committed
Some updates to the heartbeat plugin
1 parent de848c1 commit d50fed9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Source/Shared/Plugins/Default/110 _HeartbeatPlugin.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,24 @@ public HeartbeatPlugin(IEventQueue eventQueue, IExceptionlessLog log) {
2020
public void Run(EventPluginContext context) {
2121
var sessionIdentifier = context.Event.SessionId ?? context.Event.GetUserIdentity()?.Identity;
2222
if (String.IsNullOrEmpty(sessionIdentifier) || context.Event.IsSessionEnd()) {
23-
_timer?.Change(Timeout.Infinite, Timeout.Infinite);
2423
_lastEvent = null;
24+
_timer?.Change(Timeout.Infinite, Timeout.Infinite);
2525
return;
2626
}
27-
27+
28+
_lastEvent = context.Event;
2829
if (_timer == null)
2930
_timer = new Timer(OnEnqueueHeartbeat, null, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30));
3031
else
3132
_timer.Change(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30));
32-
33-
_lastEvent = context.Event;
3433
}
3534

3635
private void OnEnqueueHeartbeat(object state) {
3736
var heartbeatEvent = CreateHeartbeatEvent(_lastEvent);
3837
if (heartbeatEvent == null)
3938
return;
4039

41-
_log.Trace(nameof(HeartbeatPlugin), $"Enqueuing heartbeat for session: {_lastEvent.SessionId}");
40+
_log.Trace(nameof(HeartbeatPlugin), $"Enqueuing heartbeat for session: {heartbeatEvent.SessionId}");
4241
_eventQueue.Enqueue(heartbeatEvent);
4342
}
4443

0 commit comments

Comments
 (0)