Skip to content

Commit

Permalink
Revert "Track connection time on posthog (#2313)" (#2315)
Browse files Browse the repository at this point in the history
This reverts commit 5e2b652.
  • Loading branch information
toger5 authored Apr 16, 2024
1 parent 5e2b652 commit 9f4a107
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 48 deletions.
2 changes: 0 additions & 2 deletions src/analytics/PosthogAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
UndecryptableToDeviceEventTracker,
QualitySurveyEventTracker,
CallDisconnectedEventTracker,
CallConnectDurationTracker,
} from "./PosthogEvents";
import { Config } from "../config/Config";
import { getUrlParams } from "../UrlParams";
Expand Down Expand Up @@ -445,5 +444,4 @@ export class PosthogAnalytics {
public eventUndecryptableToDevice = new UndecryptableToDeviceEventTracker();
public eventQualitySurvey = new QualitySurveyEventTracker();
public eventCallDisconnected = new CallDisconnectedEventTracker();
public eventCallConnectDuration = new CallConnectDurationTracker();
}
36 changes: 0 additions & 36 deletions src/analytics/PosthogEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ limitations under the License.
*/

import { DisconnectReason } from "livekit-client";
import { logger } from "matrix-js-sdk/src/logger";

import {
IPosthogEvent,
Expand Down Expand Up @@ -202,38 +201,3 @@ export class CallDisconnectedEventTracker {
});
}
}

interface CallConnectDuration extends IPosthogEvent {
eventName: "CallConnectDuration";
totalDuration: number;
websocketDuration: number;
peerConnectionDuration: number;
}

export class CallConnectDurationTracker {
private connectStart = 0;
private websocketConnected = 0;
public cacheConnectStart(): void {
this.connectStart = Date.now();
}
public cacheWsConnect(): void {
this.websocketConnected = Date.now();
}

public track(options = { log: false }): void {
const now = Date.now();
const totalDuration = now - this.connectStart;
const websocketDuration = this.websocketConnected - this.connectStart;
const peerConnectionDuration = now - this.websocketConnected;
PosthogAnalytics.instance.trackEvent<CallConnectDuration>({
eventName: "CallConnectDuration",
totalDuration,
websocketDuration,
peerConnectionDuration,
});
if (options.log)
logger.log(
`Time to connect:\ntotal: ${totalDuration}ms\npeerConnection: ${websocketDuration}ms\nwebsocket: ${peerConnectionDuration}ms`,
);
}
}
10 changes: 0 additions & 10 deletions src/livekit/useECConnectionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { logger } from "matrix-js-sdk/src/logger";
import * as Sentry from "@sentry/react";

import { SFUConfig, sfuConfigEquals } from "./openIDSFU";
import { PosthogAnalytics } from "../analytics/PosthogAnalytics";

declare global {
interface Window {
Expand Down Expand Up @@ -132,22 +131,13 @@ async function connectAndPublish(
micTrack: LocalTrack | undefined,
screenshareTracks: MediaStreamTrack[],
): Promise<void> {
const tracker = PosthogAnalytics.instance.eventCallConnectDuration;
// Track call connect duration
tracker.cacheConnectStart();
livekitRoom.once(RoomEvent.SignalConnected, () => tracker.cacheWsConnect());

await livekitRoom!.connect(sfuConfig!.url, sfuConfig!.jwt, {
// Due to stability issues on Firefox we are testing the effect of different
// timeouts, and allow these values to be set through the console
peerConnectionTimeout: window.peerConnectionTimeout ?? 45000,
websocketTimeout: window.websocketTimeout ?? 45000,
});

// remove listener in case the connect promise rejects before `SignalConnected` is emitted.
livekitRoom.off(RoomEvent.SignalConnected, tracker.cacheWsConnect);
tracker.track({ log: true });

if (micTrack) {
logger.info(`Publishing precreated mic track`);
await livekitRoom.localParticipant.publishTrack(micTrack, {
Expand Down

0 comments on commit 9f4a107

Please sign in to comment.