mirror of
https://github.com/vector-im/element-call.git
synced 2026-09-19 22:19:30 +00:00
Prototyping for to-device key distribution
Show participant ID and some encryption status message Allow encryption system to be chosen at point of room creation Send cryptoVersion platform data to Posthog Send key distribution stats to posthog Send encryption type for CallStarted and CallEnded events Update js-sdk
This commit is contained in:
@@ -16,19 +16,40 @@ limitations under the License.
|
||||
|
||||
import { DisconnectReason } from "livekit-client";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc";
|
||||
|
||||
import {
|
||||
IPosthogEvent,
|
||||
PosthogAnalytics,
|
||||
RegistrationType,
|
||||
} from "./PosthogAnalytics";
|
||||
import { E2eeType } from "../e2ee/e2eeType";
|
||||
|
||||
type EncryptionScheme = "none" | "shared" | "per_sender";
|
||||
|
||||
function mapE2eeType(type: E2eeType): EncryptionScheme {
|
||||
switch (type) {
|
||||
case E2eeType.NONE:
|
||||
return "none";
|
||||
case E2eeType.SHARED_KEY:
|
||||
return "shared";
|
||||
case E2eeType.PER_PARTICIPANT:
|
||||
return "per_sender";
|
||||
}
|
||||
}
|
||||
interface CallEnded extends IPosthogEvent {
|
||||
eventName: "CallEnded";
|
||||
callId: string;
|
||||
callParticipantsOnLeave: number;
|
||||
callParticipantsMax: number;
|
||||
callDuration: number;
|
||||
encryption: EncryptionScheme;
|
||||
toDeviceEncryptionKeysSent: number;
|
||||
toDeviceEncryptionKeysReceived: number;
|
||||
toDeviceEncryptionKeysReceivedAverageAge: number;
|
||||
roomEventEncryptionKeysSent: number;
|
||||
roomEventEncryptionKeysReceived: number;
|
||||
roomEventEncryptionKeysReceivedAverageAge: number;
|
||||
}
|
||||
|
||||
export class CallEndedTracker {
|
||||
@@ -51,6 +72,8 @@ export class CallEndedTracker {
|
||||
public track(
|
||||
callId: string,
|
||||
callParticipantsNow: number,
|
||||
e2eeType: E2eeType,
|
||||
rtcSession: MatrixRTCSession,
|
||||
sendInstantly: boolean,
|
||||
): void {
|
||||
PosthogAnalytics.instance.trackEvent<CallEnded>(
|
||||
@@ -60,6 +83,27 @@ export class CallEndedTracker {
|
||||
callParticipantsMax: this.cache.maxParticipantsCount,
|
||||
callParticipantsOnLeave: callParticipantsNow,
|
||||
callDuration: (Date.now() - this.cache.startTime.getTime()) / 1000,
|
||||
encryption: mapE2eeType(e2eeType),
|
||||
toDeviceEncryptionKeysSent:
|
||||
rtcSession.statistics.counters.toDeviceEncryptionKeysSent,
|
||||
toDeviceEncryptionKeysReceived:
|
||||
rtcSession.statistics.counters.toDeviceEncryptionKeysReceived,
|
||||
toDeviceEncryptionKeysReceivedAverageAge:
|
||||
rtcSession.statistics.counters.toDeviceEncryptionKeysReceived > 0
|
||||
? rtcSession.statistics.totals
|
||||
.toDeviceEncryptionKeysReceivedTotalAge /
|
||||
rtcSession.statistics.counters.toDeviceEncryptionKeysReceived
|
||||
: 0,
|
||||
roomEventEncryptionKeysSent:
|
||||
rtcSession.statistics.counters.roomEventEncryptionKeysSent,
|
||||
roomEventEncryptionKeysReceived:
|
||||
rtcSession.statistics.counters.roomEventEncryptionKeysReceived,
|
||||
roomEventEncryptionKeysReceivedAverageAge:
|
||||
rtcSession.statistics.counters.roomEventEncryptionKeysReceived > 0
|
||||
? rtcSession.statistics.totals
|
||||
.roomEventEncryptionKeysReceivedTotalAge /
|
||||
rtcSession.statistics.counters.roomEventEncryptionKeysReceived
|
||||
: 0,
|
||||
},
|
||||
{ send_instantly: sendInstantly },
|
||||
);
|
||||
@@ -69,13 +113,15 @@ export class CallEndedTracker {
|
||||
interface CallStarted extends IPosthogEvent {
|
||||
eventName: "CallStarted";
|
||||
callId: string;
|
||||
encryption: EncryptionScheme;
|
||||
}
|
||||
|
||||
export class CallStartedTracker {
|
||||
public track(callId: string): void {
|
||||
public track(callId: string, e2eeType: E2eeType): void {
|
||||
PosthogAnalytics.instance.trackEvent<CallStarted>({
|
||||
eventName: "CallStarted",
|
||||
callId: callId,
|
||||
encryption: mapE2eeType(e2eeType),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user