More posthog tracking around joining rooms and room search (#7807)

This commit is contained in:
Michael Telatynski 2022-02-17 18:03:27 +00:00 committed by GitHub
parent e997676ae2
commit 658590e5bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
59 changed files with 276 additions and 116 deletions

View file

@ -720,7 +720,7 @@ export default class EventTile extends React.Component<IProps, IState> {
event_id: this.props.mxEvent.getId(),
highlighted: true,
room_id: this.props.mxEvent.getRoomId(),
_trigger: undefined, // room doesn't change
metricsTrigger: undefined, // room doesn't change
});
};
@ -1023,7 +1023,9 @@ export default class EventTile extends React.Component<IProps, IState> {
event_id: this.props.mxEvent.getId(),
highlighted: true,
room_id: this.props.mxEvent.getRoomId(),
_trigger: this.props.timelineRenderingType === TimelineRenderingType.Search ? "MessageSearch" : undefined,
metricsTrigger: this.props.timelineRenderingType === TimelineRenderingType.Search
? "MessageSearch"
: undefined,
});
};

View file

@ -237,8 +237,8 @@ export default class MessageComposer extends React.Component<IProps, IState> {
// Try to join via the server that sent the event. This converts @something:example.org
// into a server domain by splitting on colons and ignoring the first entry ("@something").
via_servers: viaServers,
_trigger: "Tombstone",
_viaKeyboard: ev.type !== "click",
metricsTrigger: "Tombstone",
metricsViaKeyboard: ev.type !== "click",
});
};

View file

@ -51,7 +51,7 @@ export default class PinnedEventTile extends React.Component<IProps> {
event_id: this.props.event.getId(),
highlighted: true,
room_id: this.props.event.getRoomId(),
_trigger: undefined, // room doesn't change
metricsTrigger: undefined, // room doesn't change
});
};

View file

@ -44,8 +44,8 @@ const RecentlyViewedButton = () => {
dis.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
room_id: crumb.roomId,
_trigger: "WebVerticalBreadcrumbs",
_viaKeyboard: ev.type !== "click",
metricsTrigger: "WebVerticalBreadcrumbs",
metricsViaKeyboard: ev.type !== "click",
});
tooltipRef.current?.hideTooltip();
}}

View file

@ -100,7 +100,7 @@ export default class ReplyTile extends React.PureComponent<IProps> {
event_id: this.props.mxEvent.getId(),
highlighted: true,
room_id: this.props.mxEvent.getRoomId(),
_trigger: undefined, // room doesn't change
metricsTrigger: undefined, // room doesn't change
});
}
}

View file

@ -110,8 +110,8 @@ export default class RoomBreadcrumbs extends React.PureComponent<IProps, IState>
defaultDispatcher.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
room_id: room.roomId,
_trigger: "WebHorizontalBreadcrumbs",
_viaKeyboard: viaKeyboard,
metricsTrigger: "WebHorizontalBreadcrumbs",
metricsViaKeyboard: viaKeyboard,
});
};

View file

@ -44,7 +44,7 @@ export default class RoomDetailList extends React.Component<IProps> {
action: Action.ViewRoom,
room_id: room.roomId,
room_alias: room.getCanonicalAlias() || (room.getAltAliases() || [])[0],
_trigger: undefined, // Deprecated groups
metricsTrigger: undefined, // Deprecated groups
});
};

View file

@ -221,7 +221,7 @@ const UntaggedAuxButton = ({ tabIndex }: IAuxButtonProps) => {
defaultDispatcher.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
room_id: activeSpace.roomId,
_trigger: undefined, // other
metricsTrigger: undefined, // other
});
PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuExploreRoomsItem", e);
}}
@ -424,8 +424,8 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
action: Action.ViewRoom,
room_id: room.roomId,
show_room_tile: true, // to make sure the room gets scrolled into view
_trigger: "WebKeyboardShortcut",
_viaKeyboard: true,
metricsTrigger: "WebKeyboardShortcut",
metricsViaKeyboard: true,
});
}
} else if (payload.action === Action.PstnSupportUpdated) {
@ -509,7 +509,7 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
defaultDispatcher.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
room_id: this.props.activeSpace,
_trigger: undefined, // other
metricsTrigger: undefined, // other
});
PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuExploreRoomsItem", ev);
} else {
@ -542,8 +542,8 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
avatarUrl: room.avatar_url,
name,
},
_trigger: "RoomList",
_viaKeyboard: ev.type !== "click",
metricsTrigger: "RoomList",
metricsViaKeyboard: ev.type !== "click",
});
};
return (

View file

@ -61,6 +61,7 @@ import TooltipTarget from "../elements/TooltipTarget";
import { BetaPill } from "../beta/BetaCard";
import PosthogTrackers from "../../../PosthogTrackers";
import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload";
import { useWebSearchMetrics } from "../dialogs/SpotlightDialog";
const contextMenuBelow = (elementRect: DOMRect) => {
// align the context menu's icons with the icon which opened the context menu
@ -108,7 +109,7 @@ const PrototypeCommunityContextMenu = (props: ComponentProps<typeof SpaceContext
dis.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
room_id: chat.roomId,
_trigger: undefined, // Deprecated groups
metricsTrigger: undefined, // Deprecated groups
}, true);
RightPanelStore.instance.setCard({ phase: RightPanelPhases.RoomMemberList }, undefined, chat.roomId);
} else {
@ -177,14 +178,18 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
});
const joiningRooms = useJoiningRooms();
const filterCondition = RoomListStore.instance.getFirstNameFilterCondition();
const count = useEventEmitterState(RoomListStore.instance, LISTS_UPDATE_EVENT, () => {
if (RoomListStore.instance.getFirstNameFilterCondition()) {
if (filterCondition) {
return Object.values(RoomListStore.instance.orderedLists).flat(1).length;
} else {
return null;
}
});
// we pass null for the queryLength to inhibit the metrics hook for when there is no filterCondition
useWebSearchMetrics(count, filterCondition ? filterCondition.search.length : null, false);
const spaceName = useEventEmitterState(activeSpace, "Room.name", () => activeSpace?.name);
useEffect(() => {
@ -279,7 +284,7 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
defaultDispatcher.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
room_id: activeSpace.roomId,
_trigger: undefined, // other
metricsTrigger: undefined, // other
});
closePlusMenu();
PosthogTrackers.trackInteraction("WebRoomListHeaderPlusMenuExploreRoomsItem", e);

View file

@ -433,8 +433,8 @@ export default class RoomSublist extends React.Component<IProps, IState> {
action: Action.ViewRoom,
room_id: room.roomId,
show_room_tile: true, // to make sure the room gets scrolled into view
_trigger: "WebRoomListNotificationBadge",
_viaKeyboard: ev.type !== "click",
metricsTrigger: "WebRoomListNotificationBadge",
metricsViaKeyboard: ev.type !== "click",
});
}
};

View file

@ -245,8 +245,8 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
show_room_tile: true, // make sure the room is visible in the list
room_id: this.props.room.roomId,
clear_search: (ev && (ev.key === Key.ENTER || ev.key === Key.SPACE)),
_trigger: "RoomList",
_viaKeyboard: ev.type !== "click",
metricsTrigger: "RoomList",
metricsViaKeyboard: ev.type !== "click",
});
};