Add analytics for the ViewRoom action (#7666)

This commit is contained in:
Michael Telatynski 2022-02-10 14:29:55 +00:00 committed by GitHub
parent 20e9d0c159
commit 0d6ef76605
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 332 additions and 159 deletions

View file

@ -54,6 +54,7 @@ import {
import { getCachedRoomIDForAlias } from "../../RoomAliasCache";
import { EffectiveMembership, getEffectiveMembership } from "../../utils/membership";
import { PosthogAnalytics } from "../../PosthogAnalytics";
import { ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload";
interface IState {}
@ -157,10 +158,11 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
if (space) {
const roomId = this.getNotificationState(space).getFirstRoomWithNotifications();
defaultDispatcher.dispatch({
defaultDispatcher.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
room_id: roomId,
context_switch: true,
_trigger: "WebSpaceContextSwitch",
});
} else {
const lists = RoomListStore.instance.unfilteredLists;
@ -174,10 +176,11 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
}
});
if (unreadRoom) {
defaultDispatcher.dispatch({
defaultDispatcher.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
room_id: unreadRoom.roomId,
context_switch: true,
_trigger: "WebSpaceContextSwitch",
});
break;
}
@ -222,16 +225,18 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
this.matrixClient.getRoom(roomId)?.getMyMembership() === "join" &&
this.isRoomInSpace(space, roomId)
) {
defaultDispatcher.dispatch({
defaultDispatcher.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
room_id: roomId,
context_switch: true,
_trigger: "WebSpaceContextSwitch",
});
} else if (cliSpace) {
defaultDispatcher.dispatch({
defaultDispatcher.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
room_id: space,
context_switch: true,
_trigger: "WebSpaceContextSwitch",
});
} else {
defaultDispatcher.dispatch({