public override SummaryData GetEventSummaryData(PersistentEvent ev) {
            if (!ShouldHandle(ev))
                return null;
            
            dynamic data = new ExpandoObject();
            data.SessionId = ev.GetSessionId();
            data.Type = ev.Type;

            if (ev.IsSessionStart()) {
                data.Value = ev.Value.GetValueOrDefault();

                DateTime? endTime = ev.GetSessionEndTime();
                if (endTime.HasValue)
                    data.SessionEnd = endTime;
            }

            var identity = ev.GetUserIdentity();
            if (identity != null) {
                if (!String.IsNullOrEmpty(identity.Identity))
                    data.Identity = identity.Identity;
                
                if (!String.IsNullOrEmpty(identity.Name))
                    data.Name = identity.Name;
            }

            return new SummaryData { TemplateKey = "event-session-summary", Data = data };
        }
        private async Task<HeartbeatResult> GetHeartbeatAsync(PersistentEvent sessionStart) {
            string sessionId = sessionStart.GetSessionId();
            if (!String.IsNullOrWhiteSpace(sessionId)) {
                var result = await GetLastHeartbeatActivityUtcAsync($"project:{sessionStart.ProjectId}:heartbeat:{sessionId.ToSHA1()}");
                if (result != null)
                    return result;
            }

            var user = sessionStart.GetUserIdentity();
            if (String.IsNullOrWhiteSpace(user?.Identity))
                return null;

            return await GetLastHeartbeatActivityUtcAsync($"project:{sessionStart.ProjectId}:heartbeat:{user.Identity.ToSHA1()}");
        }
        public override SummaryData GetEventSummaryData(PersistentEvent ev)
        {
            if (!ShouldHandle(ev))
                return null;

            var data = new Dictionary<string, object> { { "SessionId", ev.GetSessionId() }, { "Type", ev.Type } };
            AddUserIdentitySummaryData(data, ev.GetUserIdentity());

            if (ev.IsSessionStart()) {
                data.Add("Value", ev.Value.GetValueOrDefault());

                DateTime? endTime = ev.GetSessionEndTime();
                if (endTime.HasValue)
                    data.Add("SessionEnd", endTime);
            }

            return new SummaryData { TemplateKey = "event-session-summary", Data = data };
        }