Wire up new fields on the ViewRoom posthog event and more interactions (#7787)

This commit is contained in:
Michael Telatynski 2022-02-14 19:31:13 +00:00 committed by GitHub
parent 9141225a79
commit cfa6e266cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 54 additions and 11 deletions

View file

@ -91,7 +91,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#bdabdd63280f052cedeeb0c25443f3d55f7c7108",
"matrix-analytics-events": "github:matrix-org/matrix-analytics-events.git#df9c0312f51911a7364810466d041f2b79e7e080",
"matrix-events-sdk": "^0.0.1-beta.6",
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop",
"matrix-widget-api": "^0.1.0-beta.18",

View file

@ -190,7 +190,7 @@ const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) =
onFinished();
};
const onExploreRoomsClick = (ev: ButtonEvent) => {
const openSpace = (ev: ButtonEvent) => {
ev.preventDefault();
ev.stopPropagation();
@ -202,6 +202,16 @@ const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) =
onFinished();
};
const onExploreRoomsClick = (ev: ButtonEvent) => {
PosthogTrackers.trackInteraction("WebSpaceContextMenuExploreRoomsItem", ev);
openSpace(ev);
};
const onHomeClick = (ev: ButtonEvent) => {
PosthogTrackers.trackInteraction("WebSpaceContextMenuHomeItem", ev);
openSpace(ev);
};
return <IconizedContextMenu
{...props}
onFinished={onFinished}
@ -215,7 +225,7 @@ const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) =
<IconizedContextMenuOption
iconClassName="mx_SpacePanel_iconHome"
label={_t("Space home")}
onClick={onExploreRoomsClick}
onClick={onHomeClick}
/>
{ inviteOption }
<IconizedContextMenuOption

View file

@ -43,7 +43,7 @@ import IconizedContextMenu, {
IconizedContextMenuOption,
IconizedContextMenuOptionList,
} from "../context_menus/IconizedContextMenu";
import AccessibleButton from "../elements/AccessibleButton";
import AccessibleButton, { ButtonEvent } from "../elements/AccessibleButton";
import { CommunityPrototypeStore } from "../../../stores/CommunityPrototypeStore";
import SpaceStore from "../../../stores/spaces/SpaceStore";
import {
@ -223,6 +223,7 @@ const UntaggedAuxButton = ({ tabIndex }: IAuxButtonProps) => {
room_id: activeSpace.roomId,
_trigger: undefined, // other
});
PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuExploreRoomsItem", e);
}}
/>
{
@ -503,13 +504,14 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
defaultDispatcher.dispatch({ action: "view_create_chat", initialText });
};
private onExplore = () => {
private onExplore = (ev: ButtonEvent) => {
if (!isMetaSpace(this.props.activeSpace)) {
defaultDispatcher.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
room_id: this.props.activeSpace,
_trigger: undefined, // other
});
PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuExploreRoomsItem", ev);
} else {
const initialText = RoomListStore.instance.getFirstNameFilterCondition()?.search;
defaultDispatcher.dispatch({ action: Action.ViewRoomDirectory, initialText });

View file

@ -282,6 +282,7 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
_trigger: undefined, // other
});
closePlusMenu();
PosthogTrackers.trackInteraction("WebRoomListHeaderPlusMenuExploreRoomsItem", e);
}}
/>
<IconizedContextMenuOption

View file

@ -21,6 +21,7 @@ import { Store } from 'flux/utils';
import { MatrixError } from "matrix-js-sdk/src/http-api";
import { logger } from "matrix-js-sdk/src/logger";
import { ViewRoom as ViewRoomEvent } from "matrix-analytics-events/types/typescript/ViewRoom";
import { JoinRule } from "matrix-js-sdk/src/@types/partials";
import dis from '../dispatcher/dispatcher';
import { MatrixClientPeg } from '../MatrixClientPeg';
@ -35,6 +36,9 @@ import CountlyAnalytics, { IJoinRoomEvent } from "../CountlyAnalytics";
import { TimelineRenderingType } from "../contexts/RoomContext";
import { PosthogAnalytics } from "../PosthogAnalytics";
import { ViewRoomPayload } from "../dispatcher/payloads/ViewRoomPayload";
import DMRoomMap from "../utils/DMRoomMap";
import SpaceStore from "./spaces/SpaceStore";
import { isMetaSpace, MetaSpace } from "./spaces";
const NUM_JOIN_RETRY = 5;
@ -189,10 +193,24 @@ class RoomViewStore extends Store<ActionPayload> {
private async viewRoom(payload: ViewRoomPayload): Promise<void> {
if (payload.room_id) {
if (payload._trigger !== null && payload.room_id !== this.state.roomId) {
let activeSpace: ViewRoomEvent["activeSpace"];
if (SpaceStore.instance.activeSpace === MetaSpace.Home) {
activeSpace = "Home";
} else if (isMetaSpace(SpaceStore.instance.activeSpace)) {
activeSpace = "Meta";
} else {
activeSpace = SpaceStore.instance.activeSpaceRoom.getJoinRule() === JoinRule.Public
? "Public"
: "Private";
}
PosthogAnalytics.instance.trackEvent<ViewRoomEvent>({
eventName: "ViewRoom",
trigger: payload._trigger,
viaKeyboard: payload._viaKeyboard,
isDM: !!DMRoomMap.shared().getUserIdForRoomId(payload.room_id),
isSpace: MatrixClientPeg.get().getRoom(payload.room_id)?.isSpaceRoom(),
activeSpace,
});
}

View file

@ -16,6 +16,7 @@ limitations under the License.
import { MatrixEvent } from 'matrix-js-sdk';
import './skinned-sdk'; // Must be first for skinning to work
import { DecryptionFailureTracker } from '../src/DecryptionFailureTracker';
class MockDecryptionError extends Error {

View file

@ -17,10 +17,10 @@ limitations under the License.
import React from 'react';
import { mount } from 'enzyme';
import { mocked } from 'jest-mock';
import '../../../skinned-sdk';
import { act } from "react-dom/test-utils";
import { Room } from 'matrix-js-sdk';
import '../../../skinned-sdk';
import ExportDialog from '../../../../src/components/views/dialogs/ExportDialog';
import { ExportType, ExportFormat } from '../../../../src/utils/exportUtils/exportUtils';
import { createTestClient, mkStubRoom } from '../../../test-utils';

View file

@ -14,13 +14,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import '../../../skinned-sdk'; // Must be first for skinning to work
import React from "react";
import { act } from "react-dom/test-utils";
import { sleep } from "matrix-js-sdk/src/utils";
import { mount } from 'enzyme';
import { RelationType } from 'matrix-js-sdk/src/@types/event';
import '../../../skinned-sdk'; // Must be first for skinning to work
import SendMessageComposer, {
createMessageContent,
isQuickReaction,
@ -38,8 +38,6 @@ import defaultDispatcher from "../../../../src/dispatcher/dispatcher";
import DocumentOffset from '../../../../src/editor/offset';
import { Layout } from '../../../../src/settings/enums/Layout';
jest.mock("../../../../src/stores/RoomViewStore");
describe('<SendMessageComposer/>', () => {
const roomContext = {
roomLoading: true,

View file

@ -1,3 +1,4 @@
import '../skinned-sdk'; // Must be first for skinning to work
import RoomViewStore from '../../src/stores/RoomViewStore';
import { Action } from '../../src/dispatcher/actions';
import { MatrixClientPeg as peg } from '../../src/MatrixClientPeg';
@ -5,6 +6,18 @@ import * as testUtils from '../test-utils';
const dispatch = testUtils.getDispatchForStore(RoomViewStore);
jest.mock('../../src/utils/DMRoomMap', () => {
const mock = {
getUserIdForRoomId: jest.fn(),
getDMRoomsForUserId: jest.fn(),
};
return {
shared: jest.fn().mockReturnValue(mock),
sharedInstance: mock,
};
});
describe('RoomViewStore', function() {
beforeEach(function() {
testUtils.stubClient();

View file

@ -6249,9 +6249,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#bdabdd63280f052cedeeb0c25443f3d55f7c7108":
"matrix-analytics-events@github:matrix-org/matrix-analytics-events.git#df9c0312f51911a7364810466d041f2b79e7e080":
version "0.0.1"
resolved "https://codeload.github.com/matrix-org/matrix-analytics-events/tar.gz/bdabdd63280f052cedeeb0c25443f3d55f7c7108"
resolved "https://codeload.github.com/matrix-org/matrix-analytics-events/tar.gz/df9c0312f51911a7364810466d041f2b79e7e080"
matrix-events-sdk@^0.0.1-beta.6:
version "0.0.1-beta.6"