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