Send how many favorited rooms a user has to Posthog (#7772)

pull/21833/head
Michael Telatynski 2022-02-10 10:02:34 +00:00 committed by GitHub
parent 871032e1bc
commit f6565bfbc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 47 additions and 15 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#035d02303996c1fa7119bd8a09f2e00db9a4c648",
"matrix-analytics-events": "github:matrix-org/matrix-analytics-events.git#3c9ca927f68300a6d2589dfd802161c737ff59c2",
"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

@ -23,6 +23,7 @@ import Views from "./Views";
import { PosthogAnalytics } from "./PosthogAnalytics";
export type ScreenName = ScreenEvent["screenName"];
export type InteractionName = InteractionEvent["name"];
const notLoggedInMap: Record<Exclude<Views, Views.LOGGED_IN>, ScreenName> = {
[Views.LOADING]: "WebLoading",
@ -90,7 +91,7 @@ export default class PosthogTrackers {
this.trackPage();
}
public static trackInteraction(name: InteractionEvent["name"], ev?: SyntheticEvent): void {
public static trackInteraction(name: InteractionName, ev?: SyntheticEvent): void {
let interactionType: InteractionEvent["interactionType"];
if (ev?.type === "click") {
interactionType = "Pointer";

View File

@ -26,13 +26,14 @@ import dis from "../../dispatcher/dispatcher";
import { Action } from "../../dispatcher/actions";
import BaseAvatar from "../views/avatars/BaseAvatar";
import { OwnProfileStore } from "../../stores/OwnProfileStore";
import AccessibleButton from "../views/elements/AccessibleButton";
import AccessibleButton, { ButtonEvent } from "../views/elements/AccessibleButton";
import { UPDATE_EVENT } from "../../stores/AsyncStore";
import { useEventEmitter } from "../../hooks/useEventEmitter";
import MatrixClientContext from "../../contexts/MatrixClientContext";
import MiniAvatarUploader, { AVATAR_SIZE } from "../views/elements/MiniAvatarUploader";
import Analytics from "../../Analytics";
import CountlyAnalytics from "../../CountlyAnalytics";
import PosthogTrackers from "../../PosthogTrackers";
const onClickSendDm = () => {
Analytics.trackEvent('home_page', 'button', 'dm');
@ -46,9 +47,10 @@ const onClickExplore = () => {
dis.fire(Action.ViewRoomDirectory);
};
const onClickNewRoom = () => {
const onClickNewRoom = (ev: ButtonEvent) => {
Analytics.trackEvent('home_page', 'button', 'create_room');
CountlyAnalytics.instance.track("home_page_button", { button: "create_room" });
PosthogTrackers.trackInteraction("WebHomeCreateRoomButton", ev);
dis.dispatch({ action: 'view_create_room' });
};

View File

@ -49,6 +49,7 @@ import Spinner from "../views/elements/Spinner";
import { ActionPayload } from "../../dispatcher/payloads";
import { getDisplayAliasForAliasSet } from "../../Rooms";
import { Action } from "../../dispatcher/actions";
import PosthogTrackers from "../../PosthogTrackers";
const MAX_NAME_LENGTH = 80;
const MAX_TOPIC_LENGTH = 800;
@ -477,13 +478,14 @@ export default class RoomDirectory extends React.Component<IProps, IState> {
ev.stopPropagation();
};
private onCreateRoomClick = () => {
private onCreateRoomClick = (ev: ButtonEvent) => {
this.onFinished();
dis.dispatch({
action: 'view_create_room',
public: true,
defaultName: this.state.filterString.trim(),
});
PosthogTrackers.trackInteraction("WebRoomDirectoryCreateRoomButton", ev);
};
private showRoomAlias(alias: string, autoJoin = false) {

View File

@ -84,6 +84,7 @@ import { useRoomState } from "../../hooks/useRoomState";
import { shouldShowComponent } from "../../customisations/helpers/UIComponents";
import { UIComponent } from "../../settings/UIFeature";
import { UPDATE_EVENT } from "../../stores/AsyncStore";
import PosthogTrackers from "../../PosthogTrackers";
interface IProps {
space: Room;
@ -386,6 +387,7 @@ const SpaceLandingAddButton = ({ space }) => {
e.stopPropagation();
closeMenu();
PosthogTrackers.trackInteraction("WebSpaceHomeCreateRoomButton", e);
if (await showCreateNewRoom(space)) {
defaultDispatcher.fire(Action.UpdateSpaceHierarchy);
}

View File

@ -38,6 +38,7 @@ import SettingsStore from "../../../settings/SettingsStore";
import { Action } from "../../../dispatcher/actions";
import { shouldShowComponent } from "../../../customisations/helpers/UIComponents";
import { UIComponent } from "../../../settings/UIFeature";
import PosthogTrackers from "../../../PosthogTrackers";
interface IProps extends IContextMenuProps {
space: Room;
@ -141,6 +142,7 @@ const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) =
ev.preventDefault();
ev.stopPropagation();
PosthogTrackers.trackInteraction("WebSpaceContextMenuNewRoomItem", ev);
showCreateNewRoom(space);
onFinished();
};

View File

@ -28,7 +28,7 @@ import SearchBox from "../../structures/SearchBox";
import SpaceStore from "../../../stores/spaces/SpaceStore";
import RoomAvatar from "../avatars/RoomAvatar";
import { getDisplayAliasForRoom } from "../../../Rooms";
import AccessibleButton from "../elements/AccessibleButton";
import AccessibleButton, { ButtonEvent } from "../elements/AccessibleButton";
import AutoHideScrollbar from "../../structures/AutoHideScrollbar";
import DMRoomMap from "../../../utils/DMRoomMap";
import { calculateRoomVia } from "../../../utils/permalinks/Permalinks";
@ -47,7 +47,7 @@ const GROUP_MARGIN = 24;
interface IProps {
space: Room;
onCreateRoomClick(): void;
onCreateRoomClick(ev: ButtonEvent): void;
onAddSubspaceClick(): void;
onFinished(added?: boolean): void;
}
@ -439,8 +439,8 @@ const AddExistingToSpaceDialog: React.FC<IProps> = ({ space, onCreateRoomClick,
<div>{ _t("Want to add a new room instead?") }</div>
<AccessibleButton
kind="link"
onClick={() => {
onCreateRoomClick();
onClick={(ev: ButtonEvent) => {
onCreateRoomClick(ev);
onFinished();
}}
>

View File

@ -64,6 +64,7 @@ import { useEventEmitterState } from "../../../hooks/useEventEmitter";
import { ChevronFace, ContextMenuTooltipButton, useContextMenu } from "../../structures/ContextMenu";
import MatrixClientContext from "../../../contexts/MatrixClientContext";
import SettingsStore from "../../../settings/SettingsStore";
import PosthogTrackers from "../../../PosthogTrackers";
interface IProps {
onKeyDown: (ev: React.KeyboardEvent, state: IRovingTabIndexState) => void;
@ -233,6 +234,7 @@ const UntaggedAuxButton = ({ tabIndex }: IAuxButtonProps) => {
e.stopPropagation();
closeMenu();
showCreateNewRoom(activeSpace);
PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuCreateRoomItem", e);
}}
disabled={!canAddRooms}
tooltip={canAddRooms ? undefined
@ -265,6 +267,7 @@ const UntaggedAuxButton = ({ tabIndex }: IAuxButtonProps) => {
e.stopPropagation();
closeMenu();
defaultDispatcher.dispatch({ action: "view_create_room" });
PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuCreateRoomItem", e);
}}
/> }
<IconizedContextMenuOption

View File

@ -59,6 +59,7 @@ import {
import RightPanelStore from "../../../stores/right-panel/RightPanelStore";
import TooltipTarget from "../elements/TooltipTarget";
import { BetaPill } from "../beta/BetaCard";
import PosthogTrackers from "../../../PosthogTrackers";
const contextMenuBelow = (elementRect: DOMRect) => {
// align the context menu's icons with the icon which opened the context menu
@ -253,6 +254,7 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
e.preventDefault();
e.stopPropagation();
showCreateNewRoom(activeSpace);
PosthogTrackers.trackInteraction("WebRoomListHeaderPlusMenuCreateRoomItem", e);
closePlusMenu();
}}
/>;
@ -331,6 +333,7 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
e.preventDefault();
e.stopPropagation();
defaultDispatcher.dispatch({ action: "view_create_room" });
PosthogTrackers.trackInteraction("WebRoomListHeaderPlusMenuCreateRoomItem", e);
closePlusMenu();
}}
/>

View File

@ -38,6 +38,7 @@ import JoinRuleSettings from "../../JoinRuleSettings";
import ErrorDialog from "../../../dialogs/ErrorDialog";
import SettingsFieldset from '../../SettingsFieldset';
import ExternalLink from '../../../elements/ExternalLink';
import PosthogTrackers from "../../../../../PosthogTrackers";
interface IProps {
roomId: string;
@ -212,6 +213,9 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
CreateRoomDialog,
{ defaultPublic, defaultEncrypted },
);
PosthogTrackers.trackInteraction("WebRoomSettingsSecurityTabCreateNewRoomButton");
const [shouldCreate, opts] = await modal.finished;
if (shouldCreate) {
await createRoom(opts);

View File

@ -26,6 +26,7 @@ import { RoomNotificationState } from "./RoomNotificationState";
import { SummarizedNotificationState } from "./SummarizedNotificationState";
import { ThreadsRoomNotificationState } from "./ThreadsRoomNotificationState";
import { VisibilityProvider } from "../room-list/filters/VisibilityProvider";
import { PosthogAnalytics } from "../../PosthogAnalytics";
interface IState {}
@ -105,12 +106,19 @@ export class RoomNotificationStateStore extends AsyncStoreWithClient<IState> {
// Only count visible rooms to not torment the user with notification counts in rooms they can't see.
// This will include highlights from the previous version of the room internally
const globalState = new SummarizedNotificationState();
for (const room of this.matrixClient.getVisibleRooms()) {
const visibleRooms = this.matrixClient.getVisibleRooms();
let numFavourites = 0;
for (const room of visibleRooms) {
if (VisibilityProvider.instance.isRoomVisible(room)) {
globalState.add(this.getRoomState(room));
if (room.tags[DefaultTagID.Favourite] && !room.getType()) numFavourites++;
}
}
PosthogAnalytics.instance.setProperty("numFavouriteRooms", numFavourites);
if (this.globalState.symbol !== globalState.symbol ||
this.globalState.count !== globalState.count ||
this.globalState.color !== globalState.color ||

View File

@ -33,14 +33,16 @@ import { showRoomInviteDialog } from "../RoomInvite";
import CreateSubspaceDialog from "../components/views/dialogs/CreateSubspaceDialog";
import AddExistingSubspaceDialog from "../components/views/dialogs/AddExistingSubspaceDialog";
import defaultDispatcher from "../dispatcher/dispatcher";
import dis from "../dispatcher/dispatcher";
import RoomViewStore from "../stores/RoomViewStore";
import { Action } from "../dispatcher/actions";
import { leaveRoomBehaviour } from "./membership";
import Spinner from "../components/views/elements/Spinner";
import dis from "../dispatcher/dispatcher";
import LeaveSpaceDialog from "../components/views/dialogs/LeaveSpaceDialog";
import CreateSpaceFromCommunityDialog from "../components/views/dialogs/CreateSpaceFromCommunityDialog";
import SpacePreferencesDialog, { SpacePreferenceTab } from "../components/views/dialogs/SpacePreferencesDialog";
import PosthogTrackers from "../PosthogTrackers";
import { ButtonEvent } from "../components/views/elements/AccessibleButton";
export const shouldShowSpaceSettings = (space: Room) => {
const userId = space.client.getUserId();
@ -73,7 +75,10 @@ export const showAddExistingRooms = (space: Room): void => {
"Add Existing",
AddExistingToSpaceDialog,
{
onCreateRoomClick: () => showCreateNewRoom(space),
onCreateRoomClick: (ev: ButtonEvent) => {
showCreateNewRoom(space);
PosthogTrackers.trackInteraction("WebAddExistingToSpaceDialogCreateRoomButton", ev);
},
onAddSubspaceClick: () => showAddExistingSubspace(space),
space,
onFinished: (added: boolean) => {
@ -92,7 +97,7 @@ export const showCreateNewRoom = async (space: Room): Promise<boolean> => {
"Create Room",
CreateRoomDialog,
{
defaultPublic: space.getJoinRule() === "public",
defaultPublic: space.getJoinRule() === JoinRule.Public,
parentSpace: space,
},
);

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#035d02303996c1fa7119bd8a09f2e00db9a4c648":
"matrix-analytics-events@github:matrix-org/matrix-analytics-events.git#3c9ca927f68300a6d2589dfd802161c737ff59c2":
version "0.0.1"
resolved "https://codeload.github.com/matrix-org/matrix-analytics-events/tar.gz/035d02303996c1fa7119bd8a09f2e00db9a4c648"
resolved "https://codeload.github.com/matrix-org/matrix-analytics-events/tar.gz/3c9ca927f68300a6d2589dfd802161c737ff59c2"
matrix-events-sdk@^0.0.1-beta.6:
version "0.0.1-beta.6"