use roomId as long as possible

This commit is contained in:
fkwp
2026-05-13 17:45:32 +02:00
parent 6c987eb0d4
commit be6e9110cb
4 changed files with 17 additions and 10 deletions

View File

@@ -17,6 +17,7 @@ import {
interface CallEnded extends IPosthogEvent { interface CallEnded extends IPosthogEvent {
eventName: "CallEnded"; eventName: "CallEnded";
// the callId posthog key is essentially a Matrix roomId
callId: string; callId: string;
callParticipantsOnLeave: number; callParticipantsOnLeave: number;
callParticipantsMax: number; callParticipantsMax: number;
@@ -120,6 +121,7 @@ export class CallEndedTracker {
interface CallStarted extends IPosthogEvent { interface CallStarted extends IPosthogEvent {
eventName: "CallStarted"; eventName: "CallStarted";
// the callId posthog key is essentially a Matrix roomId
callId: string; callId: string;
} }
@@ -180,6 +182,7 @@ export class LoginTracker {
interface MuteMicrophone { interface MuteMicrophone {
eventName: "MuteMicrophone"; eventName: "MuteMicrophone";
targetMuteState: "mute" | "unmute"; targetMuteState: "mute" | "unmute";
// the callId posthog key is essentially a Matrix roomId
callId: string; callId: string;
} }
@@ -196,6 +199,7 @@ export class MuteMicrophoneTracker {
interface MuteCamera { interface MuteCamera {
eventName: "MuteCamera"; eventName: "MuteCamera";
targetMuteState: "mute" | "unmute"; targetMuteState: "mute" | "unmute";
// the callId posthog key is essentially a Matrix roomId
callId: string; callId: string;
} }
@@ -211,6 +215,7 @@ export class MuteCameraTracker {
interface UndecryptableToDeviceEvent { interface UndecryptableToDeviceEvent {
eventName: "UndecryptableToDeviceEvent"; eventName: "UndecryptableToDeviceEvent";
// the callId posthog key is essentially a Matrix roomId
callId: string; callId: string;
} }
@@ -225,6 +230,7 @@ export class UndecryptableToDeviceEventTracker {
interface QualitySurveyEvent { interface QualitySurveyEvent {
eventName: "QualitySurvey"; eventName: "QualitySurvey";
// the callId posthog key is essentially a Matrix roomId
callId: string; callId: string;
feedbackText: string; feedbackText: string;
stars: number; stars: number;
@@ -298,6 +304,7 @@ export type CallReconnectingReason =
interface CallReconnecting extends IPosthogEvent { interface CallReconnecting extends IPosthogEvent {
eventName: "CallReconnecting"; eventName: "CallReconnecting";
// the callId posthog key is essentially a Matrix roomId
callId: string; callId: string;
reason: CallReconnectingReason; reason: CallReconnectingReason;
reconnectDuration: number; reconnectDuration: number;

View File

@@ -560,7 +560,7 @@ export function createCallViewModel$(
connectionManager, connectionManager,
matrixRTCSession, matrixRTCSession,
localTransport$, localTransport$,
callId: matrixRoom.roomId, roomId: matrixRoom.roomId,
logger: logger.getChild(`[${Date.now()}]`), logger: logger.getChild(`[${Date.now()}]`),
}); });

View File

@@ -231,7 +231,7 @@ describe("LocalMembership", () => {
]), ]),
rtsSession$: constant(RTCMemberStatus.Connected), rtsSession$: constant(RTCMemberStatus.Connected),
}, },
callId: "!test-room-id:example.org", roomId: "!test-room-id:example.org",
}; };
it("throws error on missing RTC config error", () => { it("throws error on missing RTC config error", () => {
@@ -772,7 +772,7 @@ describe("LocalMembership", () => {
hsReason$.next([true, null]); hsReason$.next([true, null]);
expect(trackSpy).toHaveBeenCalledWith( expect(trackSpy).toHaveBeenCalledWith(
defaultCreateLocalMemberValues.callId, defaultCreateLocalMemberValues.roomId,
"sync", "sync",
expect.any(Number), expect.any(Number),
); );
@@ -822,7 +822,7 @@ describe("LocalMembership", () => {
connectionState$.next(ConnectionState.LivekitConnected); connectionState$.next(ConnectionState.LivekitConnected);
expect(trackSpy).toHaveBeenCalledWith( expect(trackSpy).toHaveBeenCalledWith(
defaultCreateLocalMemberValues.callId, defaultCreateLocalMemberValues.roomId,
"livekit", "livekit",
expect.any(Number), expect.any(Number),
); );
@@ -873,13 +873,13 @@ describe("LocalMembership", () => {
expect(trackSpy).toHaveBeenCalledTimes(2); expect(trackSpy).toHaveBeenCalledTimes(2);
expect(trackSpy).toHaveBeenNthCalledWith( expect(trackSpy).toHaveBeenNthCalledWith(
1, 1,
defaultCreateLocalMemberValues.callId, defaultCreateLocalMemberValues.roomId,
"membership", "membership",
expect.any(Number), expect.any(Number),
); );
expect(trackSpy).toHaveBeenNthCalledWith( expect(trackSpy).toHaveBeenNthCalledWith(
2, 2,
defaultCreateLocalMemberValues.callId, defaultCreateLocalMemberValues.roomId,
"probablyLeft", "probablyLeft",
expect.any(Number), expect.any(Number),
); );

View File

@@ -128,7 +128,7 @@ interface Props {
createPublisherFactory: (connection: Connection) => Publisher; createPublisherFactory: (connection: Connection) => Publisher;
joinMatrixRTC: (transport: LivekitTransportConfig) => void; joinMatrixRTC: (transport: LivekitTransportConfig) => void;
homeserverConnected: HomeserverConnected; homeserverConnected: HomeserverConnected;
callId: string; roomId: string;
localTransport$: Behavior<LocalTransport>; localTransport$: Behavior<LocalTransport>;
matrixRTCSession: Pick< matrixRTCSession: Pick<
MatrixRTCSession, MatrixRTCSession,
@@ -152,7 +152,7 @@ interface Props {
* @param props.logger The logger to use. * @param props.logger The logger to use.
* @param props.muteStates The mute states for video and audio. * @param props.muteStates The mute states for video and audio.
* @param props.matrixRTCSession The matrix RTC session to join. * @param props.matrixRTCSession The matrix RTC session to join.
* @param props.callId The room ID used as the call identifier in analytics events. * @param props.roomId The room ID used as the call identifier in analytics events.
* @returns * @returns
* - publisher: The handle to create tracks and publish them to the room. * - publisher: The handle to create tracks and publish them to the room.
* - connected$: the current connection state. Including matrix server and livekit server connection. (only considering the livekit server we are using for our own media publication) * - connected$: the current connection state. Including matrix server and livekit server connection. (only considering the livekit server we are using for our own media publication)
@@ -170,7 +170,7 @@ export const createLocalMembership$ = ({
logger: parentLogger, logger: parentLogger,
muteStates, muteStates,
matrixRTCSession, matrixRTCSession,
callId, roomId: roomId,
}: Props): { }: Props): {
/** /**
* This request to start audio and video tracks. * This request to start audio and video tracks.
@@ -552,7 +552,7 @@ export const createLocalMembership$ = ({
} }
} else if (reconnectStart !== null) { } else if (reconnectStart !== null) {
PosthogAnalytics.instance.eventCallReconnecting.track( PosthogAnalytics.instance.eventCallReconnecting.track(
callId, roomId,
reconnectStart.reason, reconnectStart.reason,
(Date.now() - reconnectStart.time) / 1000, (Date.now() - reconnectStart.time) / 1000,
); );