From 342aa93828986c4278d4e2598485b473e2706a39 Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski Date: Mon, 25 Apr 2022 13:44:43 +0200 Subject: [PATCH 1/3] feat: add click tracking to onboarding tasks Adds interaction tracking to explore room, send DM and create room events in onboarding view and elsewhere --- src/components/structures/HomePage.tsx | 6 ++++-- src/components/structures/LeftPanel.tsx | 5 ++++- src/components/views/rooms/RoomList.tsx | 11 +++++++++-- src/components/views/rooms/RoomListHeader.tsx | 2 ++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/components/structures/HomePage.tsx b/src/components/structures/HomePage.tsx index fdcb52a6878..ddba1c81d71 100644 --- a/src/components/structures/HomePage.tsx +++ b/src/components/structures/HomePage.tsx @@ -34,13 +34,15 @@ import Analytics from "../../Analytics"; import PosthogTrackers from "../../PosthogTrackers"; import EmbeddedPage from "./EmbeddedPage"; -const onClickSendDm = () => { +const onClickSendDm = (ev: ButtonEvent) => { Analytics.trackEvent('home_page', 'button', 'dm'); + PosthogTrackers.trackInteraction("WebHomeCreateChatButton", ev); dis.dispatch({ action: 'view_create_chat' }); }; -const onClickExplore = () => { +const onClickExplore = (ev: ButtonEvent) => { Analytics.trackEvent('home_page', 'button', 'room_directory'); + PosthogTrackers.trackInteraction("WebHomeExploreRoomsButton", ev); dis.fire(Action.ViewRoomDirectory); }; diff --git a/src/components/structures/LeftPanel.tsx b/src/components/structures/LeftPanel.tsx index 9b4e98e66cb..5897f371a84 100644 --- a/src/components/structures/LeftPanel.tsx +++ b/src/components/structures/LeftPanel.tsx @@ -43,6 +43,8 @@ import SettingsStore from "../../settings/SettingsStore"; import { KeyBindingAction } from "../../accessibility/KeyboardShortcuts"; import { shouldShowComponent } from "../../customisations/helpers/UIComponents"; import { UIComponent } from "../../settings/UIFeature"; +import { ButtonEvent } from "../views/elements/AccessibleButton"; +import PosthogTrackers from "../../PosthogTrackers"; interface IProps { isMinimized: boolean; @@ -116,8 +118,9 @@ export default class LeftPanel extends React.Component { dis.fire(Action.OpenDialPad); }; - private onExplore = () => { + private onExplore = (ev: ButtonEvent) => { dis.fire(Action.ViewRoomDirectory); + PosthogTrackers.trackInteraction("WebLeftPanelExploreRoomsItem", ev); }; private refreshStickyHeaders = () => { diff --git a/src/components/views/rooms/RoomList.tsx b/src/components/views/rooms/RoomList.tsx index 9251cfc2ba6..a7bc539a304 100644 --- a/src/components/views/rooms/RoomList.tsx +++ b/src/components/views/rooms/RoomList.tsx @@ -142,6 +142,7 @@ const DmAuxButton = ({ tabIndex, dispatcher = defaultDispatcher }: IAuxButtonPro e.stopPropagation(); closeMenu(); defaultDispatcher.dispatch({ action: "view_create_chat" }); + PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuCreateChatItem", e); }} /> } { showInviteUsers && dispatcher.dispatch({ action: 'view_create_chat' })} + onClick={(e) => { + dispatcher.dispatch({ action: 'view_create_chat' }); + PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuCreateChatItem", e); + }} className="mx_RoomSublist_auxButton" tooltipClassName="mx_RoomSublist_addRoomTooltip" aria-label={_t("Start chat")} @@ -300,6 +304,7 @@ const UntaggedAuxButton = ({ tabIndex }: IAuxButtonProps) => { e.preventDefault(); e.stopPropagation(); closeMenu(); + PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuExploreRoomsItem", e); defaultDispatcher.fire(Action.ViewRoomDirectory); }} /> @@ -496,9 +501,10 @@ export default class RoomList extends React.PureComponent { } }; - private onStartChat = () => { + private onStartChat = (ev: ButtonEvent) => { const initialText = RoomListStore.instance.getFirstNameFilterCondition()?.search; defaultDispatcher.dispatch({ action: "view_create_chat", initialText }); + PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuCreateChatItem", ev); }; private onExplore = (ev: ButtonEvent) => { @@ -512,6 +518,7 @@ export default class RoomList extends React.PureComponent { } else { const initialText = RoomListStore.instance.getFirstNameFilterCondition()?.search; defaultDispatcher.dispatch({ action: Action.ViewRoomDirectory, initialText }); + PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuExploreRoomsItem", ev); } }; diff --git a/src/components/views/rooms/RoomListHeader.tsx b/src/components/views/rooms/RoomListHeader.tsx index 6a892df2386..b8ac024b918 100644 --- a/src/components/views/rooms/RoomListHeader.tsx +++ b/src/components/views/rooms/RoomListHeader.tsx @@ -297,6 +297,7 @@ const RoomListHeader = ({ onVisibilityChange }: IProps) => { e.preventDefault(); e.stopPropagation(); defaultDispatcher.dispatch({ action: "view_create_chat" }); + PosthogTrackers.trackInteraction("WebRoomListHeaderPlusMenuCreateChatItem", e); closePlusMenu(); }} /> @@ -335,6 +336,7 @@ const RoomListHeader = ({ onVisibilityChange }: IProps) => { e.preventDefault(); e.stopPropagation(); defaultDispatcher.dispatch({ action: Action.ViewRoomDirectory }); + PosthogTrackers.trackInteraction("WebRoomListHeaderPlusMenuExploreRoomsItem", e); closePlusMenu(); }} /> From d61aa67094511cfd7cc8d8cc3795dba5b0e5f2a2 Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski Date: Tue, 26 Apr 2022 11:42:13 +0200 Subject: [PATCH 2/3] fix: correct naming for WebLeftPanelExploreRoomsButton --- src/components/structures/LeftPanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/LeftPanel.tsx b/src/components/structures/LeftPanel.tsx index 5897f371a84..ed1f990c3f8 100644 --- a/src/components/structures/LeftPanel.tsx +++ b/src/components/structures/LeftPanel.tsx @@ -120,7 +120,7 @@ export default class LeftPanel extends React.Component { private onExplore = (ev: ButtonEvent) => { dis.fire(Action.ViewRoomDirectory); - PosthogTrackers.trackInteraction("WebLeftPanelExploreRoomsItem", ev); + PosthogTrackers.trackInteraction("WebLeftPanelExploreRoomsButton", ev); }; private refreshStickyHeaders = () => { From e287b1cca1f23aaa6a805d44779e8cfa3ec7d20f Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski Date: Tue, 26 Apr 2022 12:59:07 +0200 Subject: [PATCH 3/3] Update matrix analytics events dependency --- package.json | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d1321890545..33376d12d0c 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "linkifyjs": "^4.0.0-beta.4", "lodash": "^4.17.20", "maplibre-gl": "^1.15.2", - "matrix-analytics-events": "github:matrix-org/matrix-analytics-events.git#daad3faed54f0b1f1e026a7498b4653e4d01cd90", + "matrix-analytics-events": "github:matrix-org/matrix-analytics-events.git#4aef17b56798639906f26a8739043a3c5c5fde7e", "matrix-encrypt-attachment": "^1.0.3", "matrix-events-sdk": "^0.0.1-beta.7", "matrix-js-sdk": "17.1.0", diff --git a/yarn.lock b/yarn.lock index b5ee3782a78..efd298fd22a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6629,9 +6629,9 @@ mathml-tag-names@^2.1.3: resolved "https://registry.yarnpkg.com/mathml-tag-names/-/mathml-tag-names-2.1.3.tgz#4ddadd67308e780cf16a47685878ee27b736a0a3" integrity sha512-APMBEanjybaPzUrfqU0IMU5I0AswKMH7k8OTLs0vvV4KZpExkTkY87nR/zpbuTPj+gARop7aGUbl11pnDfW6xg== -"matrix-analytics-events@github:matrix-org/matrix-analytics-events.git#daad3faed54f0b1f1e026a7498b4653e4d01cd90": +"matrix-analytics-events@github:matrix-org/matrix-analytics-events.git#4aef17b56798639906f26a8739043a3c5c5fde7e": version "0.0.1" - resolved "https://codeload.github.com/matrix-org/matrix-analytics-events/tar.gz/daad3faed54f0b1f1e026a7498b4653e4d01cd90" + resolved "https://codeload.github.com/matrix-org/matrix-analytics-events/tar.gz/4aef17b56798639906f26a8739043a3c5c5fde7e" matrix-encrypt-attachment@^1.0.3: version "1.0.3"