Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit fe96420

Browse files
committed
feat: add click tracking to onboarding tasks
Adds interaction tracking to explore room, send DM and create room events in onboarding view and elsewhere
1 parent b2bebda commit fe96420

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

src/components/structures/HomePage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ import Analytics from "../../Analytics";
3434
import PosthogTrackers from "../../PosthogTrackers";
3535
import EmbeddedPage from "./EmbeddedPage";
3636

37-
const onClickSendDm = () => {
37+
const onClickSendDm = (ev: ButtonEvent) => {
3838
Analytics.trackEvent('home_page', 'button', 'dm');
39+
PosthogTrackers.trackInteraction("WebHomeCreateChatButton", ev);
3940
dis.dispatch({ action: 'view_create_chat' });
4041
};
4142

42-
const onClickExplore = () => {
43+
const onClickExplore = (ev: ButtonEvent) => {
4344
Analytics.trackEvent('home_page', 'button', 'room_directory');
45+
PosthogTrackers.trackInteraction("WebHomeExploreRoomsButton", ev);
4446
dis.fire(Action.ViewRoomDirectory);
4547
};
4648

src/components/structures/LeftPanel.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ import SettingsStore from "../../settings/SettingsStore";
4343
import { KeyBindingAction } from "../../accessibility/KeyboardShortcuts";
4444
import { shouldShowComponent } from "../../customisations/helpers/UIComponents";
4545
import { UIComponent } from "../../settings/UIFeature";
46+
import { ButtonEvent } from "../views/elements/AccessibleButton";
47+
import PosthogTrackers from "../../PosthogTrackers";
4648

4749
interface IProps {
4850
isMinimized: boolean;
@@ -116,8 +118,9 @@ export default class LeftPanel extends React.Component<IProps, IState> {
116118
dis.fire(Action.OpenDialPad);
117119
};
118120

119-
private onExplore = () => {
121+
private onExplore = (ev: ButtonEvent) => {
120122
dis.fire(Action.ViewRoomDirectory);
123+
PosthogTrackers.trackInteraction("WebLeftPanelExploreRoomsItem", ev);
121124
};
122125

123126
private refreshStickyHeaders = () => {

src/components/views/rooms/RoomList.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ const DmAuxButton = ({ tabIndex, dispatcher = defaultDispatcher }: IAuxButtonPro
142142
e.stopPropagation();
143143
closeMenu();
144144
defaultDispatcher.dispatch({ action: "view_create_chat" });
145+
PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuCreateChatItem", e);
145146
}}
146147
/> }
147148
{ showInviteUsers && <IconizedContextMenuOption
@@ -178,7 +179,10 @@ const DmAuxButton = ({ tabIndex, dispatcher = defaultDispatcher }: IAuxButtonPro
178179
} else if (!activeSpace && showCreateRooms) {
179180
return <AccessibleTooltipButton
180181
tabIndex={tabIndex}
181-
onClick={() => dispatcher.dispatch({ action: 'view_create_chat' })}
182+
onClick={(e) => {
183+
dispatcher.dispatch({ action: 'view_create_chat' });
184+
PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuCreateChatItem", e);
185+
}}
182186
className="mx_RoomSublist_auxButton"
183187
tooltipClassName="mx_RoomSublist_addRoomTooltip"
184188
aria-label={_t("Start chat")}
@@ -300,6 +304,7 @@ const UntaggedAuxButton = ({ tabIndex }: IAuxButtonProps) => {
300304
e.preventDefault();
301305
e.stopPropagation();
302306
closeMenu();
307+
PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuExploreRoomsItem", e);
303308
defaultDispatcher.fire(Action.ViewRoomDirectory);
304309
}}
305310
/>
@@ -496,9 +501,10 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
496501
}
497502
};
498503

499-
private onStartChat = () => {
504+
private onStartChat = (ev: ButtonEvent) => {
500505
const initialText = RoomListStore.instance.getFirstNameFilterCondition()?.search;
501506
defaultDispatcher.dispatch({ action: "view_create_chat", initialText });
507+
PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuCreateChatItem", ev);
502508
};
503509

504510
private onExplore = (ev: ButtonEvent) => {
@@ -512,6 +518,7 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
512518
} else {
513519
const initialText = RoomListStore.instance.getFirstNameFilterCondition()?.search;
514520
defaultDispatcher.dispatch({ action: Action.ViewRoomDirectory, initialText });
521+
PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuExploreRoomsItem", ev);
515522
}
516523
};
517524

src/components/views/rooms/RoomListHeader.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ const RoomListHeader = ({ onVisibilityChange }: IProps) => {
297297
e.preventDefault();
298298
e.stopPropagation();
299299
defaultDispatcher.dispatch({ action: "view_create_chat" });
300+
PosthogTrackers.trackInteraction("WebRoomListHeaderPlusMenuCreateChatItem", e);
300301
closePlusMenu();
301302
}}
302303
/>
@@ -335,6 +336,7 @@ const RoomListHeader = ({ onVisibilityChange }: IProps) => {
335336
e.preventDefault();
336337
e.stopPropagation();
337338
defaultDispatcher.dispatch({ action: Action.ViewRoomDirectory });
339+
PosthogTrackers.trackInteraction("WebRoomListHeaderPlusMenuExploreRoomsItem", e);
338340
closePlusMenu();
339341
}}
340342
/>

0 commit comments

Comments
 (0)