From 45d639d963dc36e7fe911126679828d26bad7699 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 19 Oct 2020 14:56:15 +0100 Subject: [PATCH 1/2] Add analytics to VoIP --- src/CallHandler.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/CallHandler.tsx b/src/CallHandler.tsx index d1ebb15c26..a5b6b20720 100644 --- a/src/CallHandler.tsx +++ b/src/CallHandler.tsx @@ -78,6 +78,7 @@ import WidgetStore from "./stores/WidgetStore"; import { WidgetMessagingStore } from "./stores/widgets/WidgetMessagingStore"; import { ElementWidgetActions } from "./stores/widgets/ElementWidgetActions"; import { MatrixCall, CallErrorCode, CallState, CallEvent, CallParty } from "matrix-js-sdk/lib/webrtc/call"; +import Analytics from './Analytics'; enum AudioID { Ring = 'ringAudio', @@ -191,6 +192,7 @@ export default class CallHandler { call.on(CallEvent.Error, (err) => { if (!this.matchesCallForThisRoom(call)) return; + Analytics.trackEvent('voip', 'callError', 'error', err); console.error("Call error:", err); if ( MatrixClientPeg.get().getTurnServers().length === 0 && @@ -208,6 +210,8 @@ export default class CallHandler { call.on(CallEvent.Hangup, () => { if (!this.matchesCallForThisRoom(call)) return; + Analytics.trackEvent('voip', 'callHangup'); + this.removeCallForRoom(call.roomId); }); call.on(CallEvent.State, (newState: CallState, oldState: CallState) => { @@ -232,6 +236,7 @@ export default class CallHandler { this.play(AudioID.Ringback); break; case CallState.Ended: + Analytics.trackEvent('voip', 'callEnded', "hangupReason", call.hangupReason); this.removeCallForRoom(call.roomId); if (oldState === CallState.InviteSent && ( call.hangupParty === CallParty.Remote || @@ -329,6 +334,7 @@ export default class CallHandler { roomId: string, type: PlaceCallType, localElement: HTMLVideoElement, remoteElement: HTMLVideoElement, ) { + Analytics.trackEvent('voip', 'placeCall', 'type', type); const call = Matrix.createNewMatrixCall(MatrixClientPeg.get(), roomId); this.calls.set(roomId, call); this.setCallListeners(call); @@ -406,6 +412,7 @@ export default class CallHandler { break; case 'place_conference_call': console.info("Place conference call in %s", payload.room_id); + Analytics.trackEvent('voip', 'placeConferenceCall'); this.startCallApp(payload.room_id, payload.type); break; case 'end_conference': @@ -432,6 +439,7 @@ export default class CallHandler { } const call = payload.call as MatrixCall; + Analytics.trackEvent('voip', 'receiveCall', 'type', call.type); this.calls.set(call.roomId, call) this.setCallListeners(call); } From 88b7210f5ca3ffab56553ccfbbaef675e94de582 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 19 Oct 2020 15:04:57 +0100 Subject: [PATCH 2/2] consistent quotes --- src/CallHandler.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CallHandler.tsx b/src/CallHandler.tsx index a5b6b20720..b788ec7da1 100644 --- a/src/CallHandler.tsx +++ b/src/CallHandler.tsx @@ -236,7 +236,7 @@ export default class CallHandler { this.play(AudioID.Ringback); break; case CallState.Ended: - Analytics.trackEvent('voip', 'callEnded', "hangupReason", call.hangupReason); + Analytics.trackEvent('voip', 'callEnded', 'hangupReason', call.hangupReason); this.removeCallForRoom(call.roomId); if (oldState === CallState.InviteSent && ( call.hangupParty === CallParty.Remote ||