mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: user properties update
This commit is contained in:
parent
8cd651f1a5
commit
64fe785722
@ -33,10 +33,7 @@ export interface IAppProvider {
|
||||
export const AppProvider: FC<IAppProvider> = observer((props) => {
|
||||
const { children } = props;
|
||||
// store hooks
|
||||
const {
|
||||
currentUser,
|
||||
membership: { currentWorkspaceRole },
|
||||
} = useUser();
|
||||
const { currentUser } = useUser();
|
||||
const { currentWorkspace, workspaces } = useWorkspace();
|
||||
const {
|
||||
config: { envConfig },
|
||||
@ -50,8 +47,7 @@ export const AppProvider: FC<IAppProvider> = observer((props) => {
|
||||
<CrispWrapper user={currentUser}>
|
||||
<PostHogProvider
|
||||
user={currentUser}
|
||||
currentWorkspaceId= {currentWorkspace?.id}
|
||||
workspaceRole={currentWorkspaceRole}
|
||||
currentWorkspaceId={currentWorkspace?.id}
|
||||
workspaces={workspaces}
|
||||
posthogAPIKey={envConfig?.posthog_api_key || null}
|
||||
posthogHost={envConfig?.posthog_host || null}
|
||||
|
@ -3,24 +3,21 @@ import { useRouter } from "next/router";
|
||||
import posthog from "posthog-js";
|
||||
import { PostHogProvider as PHProvider } from "posthog-js/react";
|
||||
// mobx store provider
|
||||
import { IUser } from "@plane/types";
|
||||
// helpers
|
||||
import { getUserRole } from "helpers/user.helper";
|
||||
import { IUser, IWorkspace } from "@plane/types";
|
||||
// constants
|
||||
import { GROUP_WORKSPACE } from "constants/event-tracker";
|
||||
|
||||
export interface IPosthogWrapper {
|
||||
children: ReactNode;
|
||||
user: IUser | null;
|
||||
workspaces: Record<string, IWorkspace>;
|
||||
currentWorkspaceId: string | undefined;
|
||||
workspaceRole: number | undefined;
|
||||
projectRole: number | undefined;
|
||||
posthogAPIKey: string | null;
|
||||
posthogHost: string | null;
|
||||
}
|
||||
|
||||
const PostHogProvider: FC<IPosthogWrapper> = (props) => {
|
||||
const { children, user, workspaceRole, currentWorkspaceId, projectRole, posthogAPIKey, posthogHost } = props;
|
||||
const { children, user, workspaces, currentWorkspaceId, posthogAPIKey, posthogHost } = props;
|
||||
// states
|
||||
const [lastWorkspaceId, setLastWorkspaceId] = useState(currentWorkspaceId);
|
||||
// router
|
||||
@ -35,11 +32,10 @@ const PostHogProvider: FC<IPosthogWrapper> = (props) => {
|
||||
last_name: user.last_name,
|
||||
email: user.email,
|
||||
use_case: user.use_case,
|
||||
workspace_role: workspaceRole ? getUserRole(workspaceRole) : undefined,
|
||||
project_role: projectRole ? getUserRole(projectRole) : undefined,
|
||||
workspaces: Object.keys(workspaces),
|
||||
});
|
||||
}
|
||||
}, [user, workspaceRole, projectRole]);
|
||||
}, [user, workspaces]);
|
||||
|
||||
useEffect(() => {
|
||||
if (posthogAPIKey && posthogHost) {
|
||||
|
@ -62,12 +62,14 @@ export class EventTrackerStore implements IEventTrackerStore {
|
||||
* @description: Returns the necessary property for the event tracking
|
||||
*/
|
||||
get getRequiredProperties() {
|
||||
const currentWorkspaceRole = this.rootStore.user.membership.currentWorkspaceRole;
|
||||
const currentWorkspaceDetails = this.rootStore.workspaceRoot.currentWorkspace;
|
||||
const currentProjectDetails = this.rootStore.projectRoot.project.currentProjectDetails;
|
||||
return {
|
||||
workspace_id: currentWorkspaceDetails?.id,
|
||||
project_id: currentProjectDetails?.id,
|
||||
user_project_role: getUserRole(currentProjectDetails?.member_role as number),
|
||||
user_workspace_role: getUserRole(currentWorkspaceRole as number),
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user