chore: added sign-up/in, onboarding, dashboard, all-issues related events (#3595)
* chore: added event constants * chore: added workspace events * chore: added workspace group for events * chore: member invitation event added * chore: added project pages related events. * fix: member integer role to string * chore: added sign-up & sign-in events * chore: added global-view related events * chore: added notification related events * chore: project, cycle property change added * chore: cycle favourite, and change-properties added * chore: module davorite, and sidebar property changes added * fix: build errors * chore: all events defined in constants
This commit is contained in:
parent
8d730e6680
commit
4f72ebded9
80 changed files with 1276 additions and 507 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { FC, ReactNode, useEffect } from "react";
|
||||
import { FC, ReactNode, useEffect, useState } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import posthog from "posthog-js";
|
||||
import { PostHogProvider as PHProvider } from "posthog-js/react";
|
||||
|
|
@ -6,10 +6,13 @@ import { PostHogProvider as PHProvider } from "posthog-js/react";
|
|||
import { IUser } from "@plane/types";
|
||||
// helpers
|
||||
import { getUserRole } from "helpers/user.helper";
|
||||
// constants
|
||||
import { GROUP_WORKSPACE } from "constants/event-tracker";
|
||||
|
||||
export interface IPosthogWrapper {
|
||||
children: ReactNode;
|
||||
user: IUser | null;
|
||||
currentWorkspaceId: string | undefined;
|
||||
workspaceRole: number | undefined;
|
||||
projectRole: number | undefined;
|
||||
posthogAPIKey: string | null;
|
||||
|
|
@ -17,7 +20,9 @@ export interface IPosthogWrapper {
|
|||
}
|
||||
|
||||
const PostHogProvider: FC<IPosthogWrapper> = (props) => {
|
||||
const { children, user, workspaceRole, projectRole, posthogAPIKey, posthogHost } = props;
|
||||
const { children, user, workspaceRole, currentWorkspaceId, projectRole, posthogAPIKey, posthogHost } = props;
|
||||
// states
|
||||
const [lastWorkspaceId, setLastWorkspaceId] = useState(currentWorkspaceId);
|
||||
// router
|
||||
const router = useRouter();
|
||||
|
||||
|
|
@ -25,10 +30,11 @@ const PostHogProvider: FC<IPosthogWrapper> = (props) => {
|
|||
if (user) {
|
||||
// Identify sends an event, so you want may want to limit how often you call it
|
||||
posthog?.identify(user.email, {
|
||||
email: user.email,
|
||||
id: user.id,
|
||||
first_name: user.first_name,
|
||||
last_name: user.last_name,
|
||||
id: user.id,
|
||||
email: user.email,
|
||||
use_case: user.use_case,
|
||||
workspace_role: workspaceRole ? getUserRole(workspaceRole) : undefined,
|
||||
project_role: projectRole ? getUserRole(projectRole) : undefined,
|
||||
});
|
||||
|
|
@ -45,6 +51,15 @@ const PostHogProvider: FC<IPosthogWrapper> = (props) => {
|
|||
}
|
||||
}, [posthogAPIKey, posthogHost]);
|
||||
|
||||
useEffect(() => {
|
||||
// Join workspace group on workspace change
|
||||
if (lastWorkspaceId !== currentWorkspaceId && currentWorkspaceId && user) {
|
||||
setLastWorkspaceId(currentWorkspaceId);
|
||||
posthog?.identify(user.email);
|
||||
posthog?.group(GROUP_WORKSPACE, currentWorkspaceId);
|
||||
}
|
||||
}, [currentWorkspaceId, user]);
|
||||
|
||||
useEffect(() => {
|
||||
// Track page views
|
||||
const handleRouteChange = () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue