From 64fe7857227321475dbc5542e315ef49411cbb02 Mon Sep 17 00:00:00 2001 From: LAKHAN BAHETI Date: Wed, 21 Feb 2024 14:12:18 +0530 Subject: [PATCH] chore: user properties update --- web/lib/app-provider.tsx | 8 ++------ web/lib/posthog-provider.tsx | 14 +++++--------- web/store/event-tracker.store.ts | 2 ++ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/web/lib/app-provider.tsx b/web/lib/app-provider.tsx index 18cca8899..84b1df769 100644 --- a/web/lib/app-provider.tsx +++ b/web/lib/app-provider.tsx @@ -33,10 +33,7 @@ export interface IAppProvider { export const AppProvider: FC = 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 = observer((props) => { ; currentWorkspaceId: string | undefined; - workspaceRole: number | undefined; - projectRole: number | undefined; posthogAPIKey: string | null; posthogHost: string | null; } const PostHogProvider: FC = (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 = (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) { diff --git a/web/store/event-tracker.store.ts b/web/store/event-tracker.store.ts index 144c46d79..f277d5495 100644 --- a/web/store/event-tracker.store.ts +++ b/web/store/event-tracker.store.ts @@ -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), }; }