Version that does at least send some traces
This commit is contained in:
@@ -31,11 +31,12 @@ import { MatrixEvent, IContent } from "matrix-js-sdk/src/models/event";
|
||||
import { GroupCall } from "matrix-js-sdk/src/webrtc/groupCall";
|
||||
import { ClientEvent, MatrixClient } from "matrix-js-sdk/src/client";
|
||||
import { RoomStateEvent } from "matrix-js-sdk/src/models/room-state";
|
||||
import { CallEvent } from "matrix-js-sdk/src/webrtc/call";
|
||||
import { CallEvent, VoipEvent } from "matrix-js-sdk/src/webrtc/call";
|
||||
|
||||
import styles from "./GroupCallInspector.module.css";
|
||||
import { SelectInput } from "../input/SelectInput";
|
||||
import { PosthogAnalytics } from "../analytics/PosthogAnalytics";
|
||||
import { OTelGroupCallMembership } from "../otel/OTelGroupCallMembership";
|
||||
|
||||
interface InspectorContextState {
|
||||
eventsByUserId?: { [userId: string]: SequenceDiagramMatrixEvent[] };
|
||||
@@ -235,7 +236,7 @@ function reducer(
|
||||
action: {
|
||||
type?: CallEvent | ClientEvent | RoomStateEvent;
|
||||
event?: MatrixEvent;
|
||||
rawEvent?: Record<string, unknown>;
|
||||
rawEvent?: VoipEvent;
|
||||
callStateEvent?: MatrixEvent;
|
||||
memberStateEvents?: MatrixEvent[];
|
||||
}
|
||||
@@ -355,6 +356,18 @@ function useGroupCallState(
|
||||
groupCall: GroupCall,
|
||||
showPollCallStats: boolean
|
||||
): InspectorContextState {
|
||||
const [otelMembership] = useState(
|
||||
() => new OTelGroupCallMembership(groupCall)
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
otelMembership.onJoinCall();
|
||||
|
||||
return () => {
|
||||
otelMembership.onLeaveCall();
|
||||
};
|
||||
}, [otelMembership]);
|
||||
|
||||
const [state, dispatch] = useReducer(reducer, {
|
||||
localUserId: client.getUserId(),
|
||||
localSessionId: client.getSessionId(),
|
||||
@@ -387,8 +400,10 @@ function useGroupCallState(
|
||||
dispatch({ type: ClientEvent.ReceivedVoipEvent, event });
|
||||
}
|
||||
|
||||
function onSendVoipEvent(event: Record<string, unknown>) {
|
||||
function onSendVoipEvent(event: VoipEvent) {
|
||||
dispatch({ type: CallEvent.SendVoipEvent, rawEvent: event });
|
||||
|
||||
otelMembership.onSendEvent(event);
|
||||
}
|
||||
|
||||
function onUndecryptableToDevice(event: MatrixEvent) {
|
||||
@@ -422,7 +437,7 @@ function useGroupCallState(
|
||||
onUndecryptableToDevice
|
||||
);
|
||||
};
|
||||
}, [client, groupCall]);
|
||||
}, [client, groupCall, otelMembership]);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import { useLocationNavigation } from "../useLocationNavigation";
|
||||
import { PosthogAnalytics } from "../analytics/PosthogAnalytics";
|
||||
import { useMediaHandler } from "../settings/useMediaHandler";
|
||||
import { findDeviceByName, getDevices } from "../media-utils";
|
||||
import { callTracer } from "../telemetry/otel";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@@ -144,7 +143,6 @@ export function GroupCallView({
|
||||
]);
|
||||
|
||||
await groupCall.enter();
|
||||
callTracer.startCall(groupCall.groupCallId);
|
||||
PosthogAnalytics.instance.eventCallEnded.cacheStartCall(new Date());
|
||||
PosthogAnalytics.instance.eventCallStarted.track(groupCall.groupCallId);
|
||||
|
||||
@@ -165,7 +163,6 @@ export function GroupCallView({
|
||||
if (isEmbedded && !preload) {
|
||||
// In embedded mode, bypass the lobby and just enter the call straight away
|
||||
groupCall.enter();
|
||||
callTracer.startCall(groupCall.groupCallId);
|
||||
|
||||
PosthogAnalytics.instance.eventCallEnded.cacheStartCall(new Date());
|
||||
PosthogAnalytics.instance.eventCallStarted.track(groupCall.groupCallId);
|
||||
@@ -189,7 +186,6 @@ export function GroupCallView({
|
||||
|
||||
// In embedded/widget mode the iFrame will be killed right after the call ended prohibiting the posthog event from getting sent,
|
||||
// therefore we want the event to be sent instantly without getting queued/batched.
|
||||
callTracer.endCall();
|
||||
const sendInstantly = !!widget;
|
||||
PosthogAnalytics.instance.eventCallEnded.track(
|
||||
groupCall.groupCallId,
|
||||
|
||||
@@ -32,7 +32,6 @@ import { usePageUnload } from "./usePageUnload";
|
||||
import { PosthogAnalytics } from "../analytics/PosthogAnalytics";
|
||||
import { TranslatedError, translatedError } from "../TranslatedError";
|
||||
import { ElementWidgetActions, ScreenshareStartData, widget } from "../widget";
|
||||
import { callTracer } from "../telemetry/otel";
|
||||
|
||||
export enum ConnectionState {
|
||||
EstablishingCall = "establishing call", // call hasn't been established yet
|
||||
@@ -376,7 +375,6 @@ export function useGroupCall(groupCall: GroupCall): UseGroupCallReturnType {
|
||||
) {
|
||||
return;
|
||||
}
|
||||
callTracer.startCall(groupCall.groupCallId);
|
||||
|
||||
PosthogAnalytics.instance.eventCallEnded.cacheStartCall(new Date());
|
||||
PosthogAnalytics.instance.eventCallStarted.track(groupCall.groupCallId);
|
||||
@@ -401,7 +399,6 @@ export function useGroupCall(groupCall: GroupCall): UseGroupCallReturnType {
|
||||
const setMicrophoneMuted = useCallback(
|
||||
(setMuted) => {
|
||||
groupCall.setMicrophoneMuted(setMuted);
|
||||
callTracer.muteMic(setMuted);
|
||||
PosthogAnalytics.instance.eventMuteMicrophone.track(
|
||||
setMuted,
|
||||
groupCall.groupCallId
|
||||
|
||||
Reference in New Issue
Block a user