Fix incorrect unsubscribed track telemetry (#1350)

- only log unsubscribe on close if Track was actually bound
- update subscribed counters even if a failure had been logged before
This commit is contained in:
David Zhao
2023-01-30 10:16:21 -08:00
committed by GitHub
parent 2671493870
commit b023c531c2
5 changed files with 42 additions and 23 deletions
+4 -2
View File
@@ -207,10 +207,12 @@ func Test_OnTrackSubscribed_EventIsSent(t *testing.T) {
require.Equal(t, room, event.Room)
// do
fixture.sut.TrackSubscribed(context.Background(), livekit.ParticipantID(partSID), trackInfo, publisherInfo)
fixture.sut.TrackSubscribed(context.Background(), livekit.ParticipantID(partSID), trackInfo, publisherInfo, true)
time.Sleep(time.Millisecond * 500)
require.Equal(t, 2, fixture.analytics.SendEventCallCount())
require.Eventually(t, func() bool {
return fixture.analytics.SendEventCallCount() == 2
}, time.Second, time.Millisecond*50, "expected send event to be called twice")
_, eventTrackSubscribed := fixture.analytics.SendEventArgsForCall(1)
require.Equal(t, livekit.AnalyticsEventType_TRACK_SUBSCRIBED, eventTrackSubscribed.Type)
require.Equal(t, partSID, eventTrackSubscribed.ParticipantId)