Add analytics for the ViewRoom action (#7666)
This commit is contained in:
parent
20e9d0c159
commit
0d6ef76605
53 changed files with 332 additions and 159 deletions
|
@ -119,6 +119,7 @@ import { ActionPayload } from "../../dispatcher/payloads";
|
|||
import { SummarizedNotificationState } from "../../stores/notifications/SummarizedNotificationState";
|
||||
import GenericToast from '../views/toasts/GenericToast';
|
||||
import Views from '../../Views';
|
||||
import { ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload";
|
||||
|
||||
// legacy export
|
||||
export { default as Views } from "../../Views";
|
||||
|
@ -140,25 +141,6 @@ interface IScreen {
|
|||
params?: QueryDict;
|
||||
}
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
interface IRoomInfo {
|
||||
room_id?: string;
|
||||
room_alias?: string;
|
||||
event_id?: string;
|
||||
|
||||
auto_join?: boolean;
|
||||
highlighted?: boolean;
|
||||
oob_data?: object;
|
||||
via_servers?: string[];
|
||||
threepid_invite?: IThreepidInvite;
|
||||
|
||||
justCreatedOpts?: IOpts;
|
||||
|
||||
// Whether or not to override default behaviour to end up at a timeline
|
||||
forceTimeline?: boolean;
|
||||
}
|
||||
/* eslint-enable camelcase */
|
||||
|
||||
interface IProps { // TODO type things better
|
||||
config: {
|
||||
piwik: {
|
||||
|
@ -675,7 +657,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
// known to be in (eg. user clicks on a room in the recents panel), supply the ID
|
||||
// If the user is clicking on a room in the context of the alias being presented
|
||||
// to them, supply the room alias. If both are supplied, the room ID will be ignored.
|
||||
const promise = this.viewRoom(payload as any);
|
||||
const promise = this.viewRoom(payload as ViewRoomPayload);
|
||||
if (payload.deferred_action) {
|
||||
promise.then(() => {
|
||||
dis.dispatch(payload.deferred_action);
|
||||
|
@ -894,21 +876,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
}
|
||||
|
||||
// switch view to the given room
|
||||
//
|
||||
// @param {Object} roomInfo Object containing data about the room to be joined
|
||||
// @param {string=} roomInfo.room_id ID of the room to join. One of room_id or room_alias must be given.
|
||||
// @param {string=} roomInfo.room_alias Alias of the room to join. One of room_id or room_alias must be given.
|
||||
// @param {boolean=} roomInfo.auto_join If true, automatically attempt to join the room if not already a member.
|
||||
// @param {string=} roomInfo.event_id ID of the event in this room to show: this will cause a switch to the
|
||||
// context of that particular event.
|
||||
// @param {boolean=} roomInfo.highlighted If true, add event_id to the hash of the URL
|
||||
// and alter the EventTile to appear highlighted.
|
||||
// @param {Object=} roomInfo.threepid_invite Object containing data about the third party
|
||||
// we received to join the room, if any.
|
||||
// @param {Object=} roomInfo.oob_data Object of additional data about the room
|
||||
// that has been passed out-of-band (eg.
|
||||
// room name and avatar from an invite email)
|
||||
private async viewRoom(roomInfo: IRoomInfo) {
|
||||
private async viewRoom(roomInfo: ViewRoomPayload) {
|
||||
this.focusComposer = true;
|
||||
|
||||
if (roomInfo.room_alias) {
|
||||
|
@ -1120,9 +1088,10 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
const dmRooms = dmRoomMap.getDMRoomsForUserId(userId);
|
||||
|
||||
if (dmRooms.length > 0) {
|
||||
dis.dispatch({
|
||||
dis.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
room_id: dmRooms[0],
|
||||
_trigger: "MessageUser",
|
||||
});
|
||||
} else {
|
||||
dis.dispatch({
|
||||
|
@ -1395,9 +1364,10 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
}
|
||||
|
||||
private viewLastRoom() {
|
||||
dis.dispatch({
|
||||
dis.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
room_id: localStorage.getItem('mx_last_room_id'),
|
||||
_trigger: undefined, // other
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1823,7 +1793,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
else via = params.via;
|
||||
}
|
||||
|
||||
const payload = {
|
||||
const payload: ViewRoomPayload = {
|
||||
action: Action.ViewRoom,
|
||||
event_id: eventId,
|
||||
via_servers: via,
|
||||
|
@ -1842,6 +1812,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
},
|
||||
room_alias: undefined,
|
||||
room_id: undefined,
|
||||
_trigger: undefined, // unknown or external trigger
|
||||
};
|
||||
if (roomString[0] === '#') {
|
||||
payload.room_alias = roomString;
|
||||
|
|
|
@ -46,10 +46,10 @@ import BaseDialog from "../views/dialogs/BaseDialog";
|
|||
import DirectorySearchBox from "../views/elements/DirectorySearchBox";
|
||||
import ScrollPanel from "./ScrollPanel";
|
||||
import Spinner from "../views/elements/Spinner";
|
||||
import { ActionPayload } from "../../dispatcher/payloads";
|
||||
import { getDisplayAliasForAliasSet } from "../../Rooms";
|
||||
import { Action } from "../../dispatcher/actions";
|
||||
import PosthogTrackers from "../../PosthogTrackers";
|
||||
import { ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload";
|
||||
|
||||
const MAX_NAME_LENGTH = 80;
|
||||
const MAX_TOPIC_LENGTH = 800;
|
||||
|
@ -494,11 +494,11 @@ export default class RoomDirectory extends React.Component<IProps, IState> {
|
|||
|
||||
private showRoom(room: IPublicRoomsChunkRoom, roomAlias?: string, autoJoin = false, shouldPeek = false) {
|
||||
this.onFinished();
|
||||
const payload: ActionPayload = {
|
||||
const payload: ViewRoomPayload = {
|
||||
action: Action.ViewRoom,
|
||||
auto_join: autoJoin,
|
||||
should_peek: shouldPeek,
|
||||
_type: "room_directory", // instrumentation
|
||||
_trigger: "RoomDirectory",
|
||||
};
|
||||
if (room) {
|
||||
// Don't let the user view a room they won't be able to either
|
||||
|
@ -524,9 +524,6 @@ export default class RoomDirectory extends React.Component<IProps, IState> {
|
|||
|
||||
if (this.state.roomServer) {
|
||||
payload.via_servers = [this.state.roomServer];
|
||||
payload.opts = {
|
||||
viaServers: [this.state.roomServer],
|
||||
};
|
||||
}
|
||||
}
|
||||
// It's not really possible to join Matrix rooms by ID because the HS has no way to know
|
||||
|
|
|
@ -101,6 +101,7 @@ import AppsDrawer from '../views/rooms/AppsDrawer';
|
|||
import { RightPanelPhases } from '../../stores/right-panel/RightPanelStorePhases';
|
||||
import { ActionPayload } from "../../dispatcher/payloads";
|
||||
import { KeyBindingAction } from "../../accessibility/KeyboardShortcuts";
|
||||
import { ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload";
|
||||
|
||||
const DEBUG = false;
|
||||
let debuglog = function(msg: string) {};
|
||||
|
@ -767,12 +768,13 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
|||
|
||||
private onUserScroll = () => {
|
||||
if (this.state.initialEventId && this.state.isInitialEventHighlighted) {
|
||||
dis.dispatch({
|
||||
dis.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
room_id: this.state.room.roomId,
|
||||
event_id: this.state.initialEventId,
|
||||
highlighted: false,
|
||||
replyingToEvent: this.state.replyToEvent,
|
||||
_trigger: undefined, // room doesn't change
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -871,10 +873,11 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
|||
}
|
||||
|
||||
setImmediate(() => {
|
||||
dis.dispatch({
|
||||
dis.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
room_id: roomId,
|
||||
deferred_action: payload,
|
||||
_trigger: "MessageSearch",
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -1171,9 +1174,10 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
|||
|
||||
if (ev.getType() === EventType.RoomCanonicalAlias) {
|
||||
// re-view the room so MatrixChat can manage the alias in the URL properly
|
||||
dis.dispatch({
|
||||
dis.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
room_id: this.state.room.roomId,
|
||||
_trigger: undefined, // room doesn't change
|
||||
});
|
||||
return; // this event cannot affect permissions so bail
|
||||
}
|
||||
|
@ -1643,9 +1647,10 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
|||
// If we were viewing a highlighted event, firing view_room without
|
||||
// an event will take care of both clearing the URL fragment and
|
||||
// jumping to the bottom
|
||||
dis.dispatch({
|
||||
dis.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
room_id: this.state.room.roomId,
|
||||
_trigger: undefined, // room doesn't change
|
||||
});
|
||||
} else {
|
||||
// Otherwise we have to jump manually
|
||||
|
@ -1778,9 +1783,10 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
|||
onHiddenHighlightsClick = () => {
|
||||
const oldRoom = this.getOldRoom();
|
||||
if (!oldRoom) return;
|
||||
dis.dispatch({
|
||||
dis.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
room_id: oldRoom.roomId,
|
||||
_trigger: "Predecessor",
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ import { useEventEmitterState } from "../../hooks/useEventEmitter";
|
|||
import { IOOBData } from "../../stores/ThreepidInviteStore";
|
||||
import { awaitRoomDownSync } from "../../utils/RoomUpgrade";
|
||||
import RoomViewStore from "../../stores/RoomViewStore";
|
||||
import { ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload";
|
||||
|
||||
interface IProps {
|
||||
space: Room;
|
||||
|
@ -326,10 +327,9 @@ export const showRoom = (cli: MatrixClient, hierarchy: RoomHierarchy, roomId: st
|
|||
}
|
||||
|
||||
const roomAlias = getDisplayAliasForRoom(room) || undefined;
|
||||
dis.dispatch({
|
||||
dis.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
should_peek: true,
|
||||
_type: "room_directory", // instrumentation
|
||||
room_alias: roomAlias,
|
||||
room_id: room.room_id,
|
||||
via_servers: Array.from(hierarchy.viaMap.get(roomId) || []),
|
||||
|
@ -339,6 +339,7 @@ export const showRoom = (cli: MatrixClient, hierarchy: RoomHierarchy, roomId: st
|
|||
name: room.name || roomAlias || _t("Unnamed room"),
|
||||
roomType,
|
||||
} as IOOBData,
|
||||
_trigger: "RoomDirectory",
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ import { shouldShowComponent } from "../../customisations/helpers/UIComponents";
|
|||
import { UIComponent } from "../../settings/UIFeature";
|
||||
import { UPDATE_EVENT } from "../../stores/AsyncStore";
|
||||
import PosthogTrackers from "../../PosthogTrackers";
|
||||
import { ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload";
|
||||
|
||||
interface IProps {
|
||||
space: Room;
|
||||
|
@ -865,9 +866,10 @@ export default class SpaceRoomView extends React.PureComponent<IProps, IState> {
|
|||
|
||||
private goToFirstRoom = async () => {
|
||||
if (this.state.firstRoomId) {
|
||||
defaultDispatcher.dispatch({
|
||||
defaultDispatcher.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
room_id: this.state.firstRoomId,
|
||||
_trigger: undefined, // other
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import { _t } from '../../languageHandler';
|
|||
import ThreadListContextMenu from '../views/context_menus/ThreadListContextMenu';
|
||||
import RightPanelStore from '../../stores/right-panel/RightPanelStore';
|
||||
import SettingsStore from "../../settings/SettingsStore";
|
||||
import { ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload";
|
||||
|
||||
interface IProps {
|
||||
room: Room;
|
||||
|
@ -195,12 +196,13 @@ export default class ThreadView extends React.Component<IProps, IState> {
|
|||
|
||||
private onScroll = (): void => {
|
||||
if (this.props.initialEvent && this.props.isInitialEventHighlighted) {
|
||||
dis.dispatch({
|
||||
dis.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
room_id: this.props.room.roomId,
|
||||
event_id: this.props.initialEvent?.getId(),
|
||||
highlighted: false,
|
||||
replyingToEvent: this.state.replyToEvent,
|
||||
_trigger: undefined, // room doesn't change
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -52,6 +52,7 @@ import Spinner from "../views/elements/Spinner";
|
|||
import EditorStateTransfer from '../../utils/EditorStateTransfer';
|
||||
import ErrorDialog from '../views/dialogs/ErrorDialog';
|
||||
import CallEventGrouper from "./CallEventGrouper";
|
||||
import { ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload";
|
||||
|
||||
const PAGINATE_SIZE = 20;
|
||||
const INITIAL_SIZE = 20;
|
||||
|
@ -1191,9 +1192,10 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
|||
if (eventId) {
|
||||
onFinished = () => {
|
||||
// go via the dispatcher so that the URL is updated
|
||||
dis.dispatch({
|
||||
dis.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
room_id: this.props.timelineSet.room.roomId,
|
||||
_trigger: undefined, // room doesn't change
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue