Add ParticipantActive telemetry method (#411)
* Add ParticipantActive telemetry method Signed-off-by: shishir gowda <shishir@livekit.io> * fix test Signed-off-by: shishir gowda <shishir@livekit.io> * Update go mod Signed-off-by: shishir gowda <shishir@livekit.io>
This commit is contained in:
@@ -109,3 +109,50 @@ func Test_OnTrackUpdate_EventIsSent(t *testing.T) {
|
||||
require.Equal(t, height, event.Track.Height)
|
||||
|
||||
}
|
||||
|
||||
func Test_OnParticipantActive_EventIsSent(t *testing.T) {
|
||||
fixture := createFixture()
|
||||
|
||||
// prepare participant to change status
|
||||
room := &livekit.Room{Sid: "RoomSid", Name: "RoomName"}
|
||||
partSID := "part1"
|
||||
|
||||
clientInfo := &livekit.ClientInfo{
|
||||
Sdk: 2,
|
||||
Version: "v1",
|
||||
Os: "mac",
|
||||
OsVersion: "v1",
|
||||
DeviceModel: "DM1",
|
||||
Browser: "chrome",
|
||||
BrowserVersion: "97.0.1",
|
||||
}
|
||||
clientMeta := &livekit.AnalyticsClientMeta{
|
||||
Region: "dark-side",
|
||||
Node: "moon",
|
||||
ClientAddr: "127.0.0.1",
|
||||
}
|
||||
participantInfo := &livekit.ParticipantInfo{Sid: partSID}
|
||||
|
||||
// do
|
||||
fixture.sut.ParticipantJoined(context.Background(), room, participantInfo, clientInfo, clientMeta)
|
||||
|
||||
// test
|
||||
require.Equal(t, 1, fixture.analytics.SendEventCallCount())
|
||||
_, event := fixture.analytics.SendEventArgsForCall(0)
|
||||
|
||||
// test
|
||||
// do
|
||||
clientMetaConnect := &livekit.AnalyticsClientMeta{
|
||||
ClientConnectTime: 420,
|
||||
}
|
||||
fixture.sut.ParticipantActive(context.Background(), livekit.ParticipantID(partSID), clientMetaConnect)
|
||||
|
||||
require.Equal(t, 2, fixture.analytics.SendEventCallCount())
|
||||
_, eventActive := fixture.analytics.SendEventArgsForCall(1)
|
||||
require.Equal(t, livekit.AnalyticsEventType_PARTICIPANT_ACTIVE, eventActive.Type)
|
||||
require.Equal(t, partSID, eventActive.ParticipantId)
|
||||
require.Equal(t, room.Sid, eventActive.RoomId)
|
||||
require.Equal(t, room, event.Room)
|
||||
|
||||
require.Equal(t, clientMetaConnect.ClientConnectTime, eventActive.ClientMeta.ClientConnectTime)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user