Skip to content

Commit 1ccbdb2

Browse files
authored
Wire up analytics for Legacy/EC/Jitsi voip options (#28348)
* Wire up analytics for Legacy/EC/Jitsi voip options Signed-off-by: Michael Telatynski <[email protected]> * Update @matrix-org/analytics-events Signed-off-by: Michael Telatynski <[email protected]> --------- Signed-off-by: Michael Telatynski <[email protected]>
1 parent b1ef099 commit 1ccbdb2

File tree

5 files changed

+49
-31
lines changed

5 files changed

+49
-31
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"dependencies": {
8585
"@babel/runtime": "^7.12.5",
8686
"@formatjs/intl-segmenter": "^11.5.7",
87-
"@matrix-org/analytics-events": "^0.28.0",
87+
"@matrix-org/analytics-events": "^0.29.0",
8888
"@matrix-org/emojibase-bindings": "^1.3.3",
8989
"@vector-im/matrix-wysiwyg": "2.37.13",
9090
"@matrix-org/react-sdk-module-api": "^2.4.0",

src/components/views/rooms/RoomHeader.tsx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { useRoomMemberCount, useRoomMembers } from "../../../hooks/useRoomMember
2727
import { _t } from "../../../languageHandler";
2828
import { Flex } from "../../utils/Flex";
2929
import { Box } from "../../utils/Box";
30-
import { getPlatformCallTypeChildren, getPlatformCallTypeLabel, useRoomCall } from "../../../hooks/room/useRoomCall";
30+
import { getPlatformCallTypeProps, useRoomCall } from "../../../hooks/room/useRoomCall";
3131
import { useRoomThreadNotifications } from "../../../hooks/room/useRoomThreadNotifications";
3232
import { useGlobalNotificationState } from "../../../hooks/useGlobalNotificationState";
3333
import SdkConfig from "../../../SdkConfig";
@@ -167,18 +167,21 @@ export default function RoomHeader({
167167
side="left"
168168
align="start"
169169
>
170-
{callOptions.map((option) => (
171-
<MenuItem
172-
key={option}
173-
label={getPlatformCallTypeLabel(option)}
174-
aria-label={getPlatformCallTypeLabel(option)}
175-
children={getPlatformCallTypeChildren(option)}
176-
className="mx_RoomHeader_videoCallOption"
177-
onClick={(ev) => videoCallClick(ev, option)}
178-
Icon={VideoCallIcon}
179-
onSelect={() => {} /* Dummy handler since we want the click event.*/}
180-
/>
181-
))}
170+
{callOptions.map((option) => {
171+
const { label, children } = getPlatformCallTypeProps(option);
172+
return (
173+
<MenuItem
174+
key={option}
175+
label={label}
176+
aria-label={label}
177+
children={children}
178+
className="mx_RoomHeader_videoCallOption"
179+
onClick={(ev) => videoCallClick(ev, option)}
180+
Icon={VideoCallIcon}
181+
onSelect={() => {} /* Dummy handler since we want the click event.*/}
182+
/>
183+
);
184+
})}
182185
</Menu>
183186
) : (
184187
<IconButton

src/hooks/room/useRoomCall.tsx

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,41 @@ import { useGuestAccessInformation } from "./useGuestAccessInformation";
3636
import SettingsStore from "../../settings/SettingsStore";
3737
import { UIFeature } from "../../settings/UIFeature";
3838
import { BetaPill } from "../../components/views/beta/BetaCard";
39+
import { InteractionName } from "../../PosthogTrackers";
3940

4041
export enum PlatformCallType {
4142
ElementCall,
4243
JitsiCall,
4344
LegacyCall,
4445
}
45-
export const getPlatformCallTypeLabel = (platformCallType: PlatformCallType): string => {
46+
47+
export const getPlatformCallTypeProps = (
48+
platformCallType: PlatformCallType,
49+
): {
50+
label: string;
51+
children?: ReactNode;
52+
analyticsName: InteractionName;
53+
} => {
4654
switch (platformCallType) {
4755
case PlatformCallType.ElementCall:
48-
return _t("voip|element_call");
56+
return {
57+
label: _t("voip|element_call"),
58+
analyticsName: "WebVoipOptionElementCall",
59+
children: <BetaPill />,
60+
};
4961
case PlatformCallType.JitsiCall:
50-
return _t("voip|jitsi_call");
62+
return {
63+
label: _t("voip|jitsi_call"),
64+
analyticsName: "WebVoipOptionJitsi",
65+
};
5166
case PlatformCallType.LegacyCall:
52-
return _t("voip|legacy_call");
53-
}
54-
};
55-
export const getPlatformCallTypeChildren = (platformCallType: PlatformCallType): ReactNode => {
56-
switch (platformCallType) {
57-
case PlatformCallType.ElementCall:
58-
return <BetaPill />;
59-
default:
60-
return null;
67+
return {
68+
label: _t("voip|legacy_call"),
69+
analyticsName: "WebVoipOptionLegacy",
70+
};
6171
}
6272
};
73+
6374
const enum State {
6475
NoCall,
6576
NoOneHere,

src/utils/room/placeCall.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import { CallType } from "matrix-js-sdk/src/webrtc/call";
1010
import { Room } from "matrix-js-sdk/src/matrix";
1111

1212
import LegacyCallHandler from "../../LegacyCallHandler";
13-
import { PlatformCallType } from "../../hooks/room/useRoomCall";
13+
import { getPlatformCallTypeProps, PlatformCallType } from "../../hooks/room/useRoomCall";
1414
import defaultDispatcher from "../../dispatcher/dispatcher";
1515
import { ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload";
1616
import { Action } from "../../dispatcher/actions";
17+
import PosthogTrackers from "../../PosthogTrackers";
1718

1819
/**
1920
* Helper to place a call in a room that works with all the legacy modes
@@ -27,6 +28,9 @@ export const placeCall = async (
2728
platformCallType: PlatformCallType,
2829
skipLobby: boolean,
2930
): Promise<void> => {
31+
const { analyticsName } = getPlatformCallTypeProps(platformCallType);
32+
PosthogTrackers.trackInteraction(analyticsName);
33+
3034
if (platformCallType == PlatformCallType.LegacyCall || platformCallType == PlatformCallType.JitsiCall) {
3135
await LegacyCallHandler.instance.placeCall(room.roomId, callType);
3236
} else if (platformCallType == PlatformCallType.ElementCall) {

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,10 +1931,10 @@
19311931
resolved "https://registry.yarnpkg.com/@mapbox/whoots-js/-/whoots-js-3.1.0.tgz#497c67a1cef50d1a2459ba60f315e448d2ad87fe"
19321932
integrity sha512-Es6WcD0nO5l+2BOQS4uLfNPYQaNDfbot3X1XUoloz+x0mPDS3eeORZJl06HXjwBG1fOGwCRnzK88LMdxKRrd6Q==
19331933

1934-
"@matrix-org/analytics-events@^0.28.0":
1935-
version "0.28.0"
1936-
resolved "https://registry.yarnpkg.com/@matrix-org/analytics-events/-/analytics-events-0.28.0.tgz#91f501bb25435b9418f785ca850ca858aa6efc76"
1937-
integrity sha512-RvvGBYzgJrk2wTRVGk2fWhGM1f69f6nBraRqTiuqlqE2eQd2hZ2onHyRhvhxJeKVC/oNBsvrupObqrrWowXsnQ==
1934+
"@matrix-org/analytics-events@^0.29.0":
1935+
version "0.29.0"
1936+
resolved "https://registry.yarnpkg.com/@matrix-org/analytics-events/-/analytics-events-0.29.0.tgz#ebadd922f50c0932a5c6af8b5e156f8f839f3236"
1937+
integrity sha512-7L+dQJuFt2iIhxhWwvJVp89/UdOfl2P455Ki9Krw0LGCMazPOwo5bc9GUjj/OKXO+eNHq+Qml1+RkYW+8LCk2Q==
19381938

19391939
"@matrix-org/emojibase-bindings@^1.3.3":
19401940
version "1.3.3"

0 commit comments

Comments
 (0)