send roomID with all events

This commit is contained in:
David Colburn
2021-11-29 16:41:55 -08:00
parent 27a80aa801
commit 6cf662cbe9
+17
View File
@@ -82,6 +82,7 @@ func (t *telemetryService) ParticipantLeft(ctx context.Context, room *livekit.Ro
t.analytics.SendEvent(ctx, &livekit.AnalyticsEvent{ t.analytics.SendEvent(ctx, &livekit.AnalyticsEvent{
Type: livekit.AnalyticsEventType_PARTICIPANT_LEFT, Type: livekit.AnalyticsEventType_PARTICIPANT_LEFT,
Timestamp: timestamppb.Now(), Timestamp: timestamppb.Now(),
RoomSid: room.Sid,
ParticipantId: participant.Sid, ParticipantId: participant.Sid,
}) })
} }
@@ -92,16 +93,19 @@ func (t *telemetryService) TrackPublished(ctx context.Context, participantID str
t.analytics.SendEvent(ctx, &livekit.AnalyticsEvent{ t.analytics.SendEvent(ctx, &livekit.AnalyticsEvent{
Type: livekit.AnalyticsEventType_TRACK_PUBLISHED, Type: livekit.AnalyticsEventType_TRACK_PUBLISHED,
Timestamp: timestamppb.Now(), Timestamp: timestamppb.Now(),
RoomSid: t.getRoomID(participantID),
ParticipantId: participantID, ParticipantId: participantID,
Track: track, Track: track,
}) })
} }
func (t *telemetryService) TrackUnpublished(ctx context.Context, participantID string, track *livekit.TrackInfo, ssrc uint32) { func (t *telemetryService) TrackUnpublished(ctx context.Context, participantID string, track *livekit.TrackInfo, ssrc uint32) {
roomID := ""
t.RLock() t.RLock()
w := t.workers[participantID] w := t.workers[participantID]
t.RUnlock() t.RUnlock()
if w != nil { if w != nil {
roomID = w.roomID
w.RemoveBuffer(ssrc) w.RemoveBuffer(ssrc)
} }
@@ -110,6 +114,7 @@ func (t *telemetryService) TrackUnpublished(ctx context.Context, participantID s
t.analytics.SendEvent(ctx, &livekit.AnalyticsEvent{ t.analytics.SendEvent(ctx, &livekit.AnalyticsEvent{
Type: livekit.AnalyticsEventType_TRACK_UNPUBLISHED, Type: livekit.AnalyticsEventType_TRACK_UNPUBLISHED,
Timestamp: timestamppb.Now(), Timestamp: timestamppb.Now(),
RoomSid: roomID,
ParticipantId: participantID, ParticipantId: participantID,
TrackId: track.Sid, TrackId: track.Sid,
}) })
@@ -121,6 +126,7 @@ func (t *telemetryService) TrackSubscribed(ctx context.Context, participantID st
t.analytics.SendEvent(ctx, &livekit.AnalyticsEvent{ t.analytics.SendEvent(ctx, &livekit.AnalyticsEvent{
Type: livekit.AnalyticsEventType_TRACK_SUBSCRIBED, Type: livekit.AnalyticsEventType_TRACK_SUBSCRIBED,
Timestamp: timestamppb.Now(), Timestamp: timestamppb.Now(),
RoomSid: t.getRoomID(participantID),
ParticipantId: participantID, ParticipantId: participantID,
TrackId: track.Sid, TrackId: track.Sid,
}) })
@@ -132,6 +138,7 @@ func (t *telemetryService) TrackUnsubscribed(ctx context.Context, participantID
t.analytics.SendEvent(ctx, &livekit.AnalyticsEvent{ t.analytics.SendEvent(ctx, &livekit.AnalyticsEvent{
Type: livekit.AnalyticsEventType_TRACK_UNSUBSCRIBED, Type: livekit.AnalyticsEventType_TRACK_UNSUBSCRIBED,
Timestamp: timestamppb.Now(), Timestamp: timestamppb.Now(),
RoomSid: t.getRoomID(participantID),
ParticipantId: participantID, ParticipantId: participantID,
TrackId: track.Sid, TrackId: track.Sid,
}) })
@@ -166,6 +173,16 @@ func (t *telemetryService) RecordingEnded(ctx context.Context, res *livekit.Reco
}) })
} }
func (t *telemetryService) getRoomID(participantID string) string {
t.RLock()
w := t.workers[participantID]
t.RUnlock()
if w != nil {
return w.roomID
}
return ""
}
func (t *telemetryService) notifyEvent(ctx context.Context, event *livekit.WebhookEvent) { func (t *telemetryService) notifyEvent(ctx context.Context, event *livekit.WebhookEvent) {
if t.notifier == nil { if t.notifier == nil {
return return