mirror of
https://github.com/vector-im/element-call.git
synced 2026-05-10 10:24:44 +00:00
Expose single trackCallReconnecting() entry point on PosthogAnalytics
This commit is contained in:
@@ -27,6 +27,7 @@ import {
|
||||
CallDisconnectedEventTracker,
|
||||
CallConnectDurationTracker,
|
||||
CallReconnectingTracker,
|
||||
type CallReconnectingReason,
|
||||
} from "./PosthogEvents";
|
||||
import { Config } from "../config/Config";
|
||||
import { getUrlParams } from "../UrlParams";
|
||||
@@ -422,5 +423,13 @@ export class PosthogAnalytics {
|
||||
public eventQualitySurvey = new QualitySurveyEventTracker();
|
||||
public eventCallDisconnected = new CallDisconnectedEventTracker();
|
||||
public eventCallConnectDuration = new CallConnectDurationTracker();
|
||||
public eventCallReconnecting = new CallReconnectingTracker();
|
||||
private readonly _eventCallReconnecting = new CallReconnectingTracker();
|
||||
|
||||
public trackCallReconnecting(
|
||||
callId: string,
|
||||
reason: CallReconnectingReason,
|
||||
): void {
|
||||
this._eventCallReconnecting.track(callId, reason);
|
||||
this.eventCallEnded.cacheReconnecting(reason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,12 +696,8 @@ describe("LocalMembership", () => {
|
||||
it("fires CallReconnecting with the homeserver reason when homeserver disconnects", async () => {
|
||||
const scope = new ObservableScope();
|
||||
const trackSpy = vi.spyOn(
|
||||
PosthogAnalytics.instance.eventCallReconnecting,
|
||||
"track",
|
||||
);
|
||||
const cacheSpy = vi.spyOn(
|
||||
PosthogAnalytics.instance.eventCallEnded,
|
||||
"cacheReconnecting",
|
||||
PosthogAnalytics.instance,
|
||||
"trackCallReconnecting",
|
||||
);
|
||||
|
||||
const hsConnected$ = new BehaviorSubject<boolean>(true);
|
||||
@@ -738,7 +734,6 @@ describe("LocalMembership", () => {
|
||||
defaultCreateLocalMemberValues.callId,
|
||||
"syncing",
|
||||
);
|
||||
expect(cacheSpy).toHaveBeenCalledWith("syncing");
|
||||
|
||||
scope.end();
|
||||
});
|
||||
@@ -746,8 +741,8 @@ describe("LocalMembership", () => {
|
||||
it("reports livekit reason when livekit disconnects but homeserver is fine", async () => {
|
||||
const scope = new ObservableScope();
|
||||
const trackSpy = vi.spyOn(
|
||||
PosthogAnalytics.instance.eventCallReconnecting,
|
||||
"track",
|
||||
PosthogAnalytics.instance,
|
||||
"trackCallReconnecting",
|
||||
);
|
||||
|
||||
const connectionState$ = new BehaviorSubject<ConnectionState>(
|
||||
@@ -795,8 +790,8 @@ describe("LocalMembership", () => {
|
||||
it("fires one event per reconnection, not once per condition change", async () => {
|
||||
const scope = new ObservableScope();
|
||||
const trackSpy = vi.spyOn(
|
||||
PosthogAnalytics.instance.eventCallReconnecting,
|
||||
"track",
|
||||
PosthogAnalytics.instance,
|
||||
"trackCallReconnecting",
|
||||
);
|
||||
|
||||
const hsConnected$ = new BehaviorSubject<boolean>(true);
|
||||
|
||||
@@ -536,8 +536,7 @@ export const createLocalMembership$ = ({
|
||||
)
|
||||
.subscribe(([_, homeserverReason]) => {
|
||||
const reason = homeserverReason !== null ? homeserverReason : "livekit";
|
||||
PosthogAnalytics.instance.eventCallReconnecting.track(callId, reason);
|
||||
PosthogAnalytics.instance.eventCallEnded.cacheReconnecting(reason);
|
||||
PosthogAnalytics.instance.trackCallReconnecting(callId, reason);
|
||||
});
|
||||
|
||||
// inform the widget about the connect and disconnect intent from the user.
|
||||
|
||||
Reference in New Issue
Block a user