diff --git a/web/store/application/event-tracker.store.ts b/web/store/application/event-tracker.store.ts index c30a8ee40..80f3ca01b 100644 --- a/web/store/application/event-tracker.store.ts +++ b/web/store/application/event-tracker.store.ts @@ -9,7 +9,7 @@ export interface IEventTrackerStore { postHogEventTracker: ( eventName: string, payload: object | [] | null, - group?: { isGrouping: boolean | null; groupType: string | null; gorupId: string | null } | null + group?: { isGrouping: boolean | null; groupType: string | null; groupId: string | null } | null ) => void; } @@ -32,16 +32,19 @@ export class EventTrackerStore implements IEventTrackerStore { postHogEventTracker = ( eventName: string, payload: object | [] | null, - group?: { isGrouping: boolean | null; groupType: string | null; gorupId: string | null } | null + group?: { isGrouping: boolean | null; groupType: string | null; groupId: string | null } | null ) => { try { + const currentWorkspaceDetails = this.rootStore.workspace.currentWorkspace; + const currentProjectDetails = this.rootStore.project.projects.currentProjectDetails; + let extras: any = { - workspace_name: this.rootStore.workspace.currentWorkspace?.name ?? "", - workspace_id: this.rootStore.workspace.currentWorkspace?.id ?? "", - workspace_slug: this.rootStore.workspace.currentWorkspace?.slug ?? "", - project_name: this.rootStore.project.currentProjectDetails?.name ?? "", - project_id: this.rootStore.project.currentProjectDetails?.id ?? "", - project_identifier: this.rootStore.project.currentProjectDetails?.identifier ?? "", + workspace_name: currentWorkspaceDetails?.name ?? "", + workspace_id: currentWorkspaceDetails?.id ?? "", + workspace_slug: currentWorkspaceDetails?.slug ?? "", + project_name: currentProjectDetails?.name ?? "", + project_id: currentProjectDetails?.id ?? "", + project_identifier: currentProjectDetails?.identifier ?? "", }; if (["PROJECT_CREATED", "PROJECT_UPDATED"].includes(eventName)) { const project_details: any = payload as object; @@ -54,9 +57,9 @@ export class EventTrackerStore implements IEventTrackerStore { } if (group && group!.isGrouping === true) { - posthog?.group(group!.groupType!, group!.gorupId!, { + posthog?.group(group!.groupType!, group!.groupId!, { date: new Date(), - workspace_id: group!.gorupId, + workspace_id: group!.groupId, }); posthog?.capture(eventName, { ...payload, diff --git a/web/store/project/index.ts b/web/store/project/index.ts index f99736ae8..ceaa026e0 100644 --- a/web/store/project/index.ts +++ b/web/store/project/index.ts @@ -1,10 +1,15 @@ -import { ProjectsStore } from "./projects.store"; -import { ProjectPublishStore } from "./project-publish.store"; +import { IProjectsStore, ProjectsStore } from "./projects.store"; +import { IProjectPublishStore, ProjectPublishStore } from "./project-publish.store"; import { RootStore } from "store/root.store"; +export interface IProjectRootStore { + projects: IProjectsStore; + publish: IProjectPublishStore; +} + export class ProjectRootStore { - projects: ProjectsStore; - publish: ProjectPublishStore; + projects: IProjectsStore; + publish: IProjectPublishStore; constructor(_root: RootStore) { this.projects = new ProjectsStore(_root); diff --git a/web/store/root.store.ts b/web/store/root.store.ts index 792a5d2d0..a69d3427e 100644 --- a/web/store/root.store.ts +++ b/web/store/root.store.ts @@ -1,29 +1,30 @@ import { enableStaticRendering } from "mobx-react-lite"; // root stores import { AppRootStore, IAppRootStore } from "./application"; -import { ProjectRootStore } from "./project"; -import { CycleStore } from "./cycle.store"; -import { ProjectViewsStore } from "./project-view.store"; -import { ModulesStore } from "./module.store"; -import { UserStore, IUserStore } from "./user"; -import { LabelStore, ILabelStore } from "./label.store"; +import { IProjectRootStore, ProjectRootStore } from "./project"; +import { CycleStore, ICycleStore } from "./cycle.store"; +import { IProjectViewsStore, ProjectViewsStore } from "./project-view.store"; +import { IModuleStore, ModulesStore } from "./module.store"; +import { IUserStore, UserStore } from "./user"; +import { ILabelStore, LabelStore } from "./label.store"; +import { IWorkspaceRootStore, WorkspaceRootStore } from "./workspace"; enableStaticRendering(typeof window === "undefined"); export class RootStore { app: IAppRootStore; user: IUserStore; - // workspace; - project; - cycle; - module; - projectView; + workspace: IWorkspaceRootStore; + project: IProjectRootStore; + cycle: ICycleStore; + module: IModuleStore; + projectView: IProjectViewsStore; label: ILabelStore; constructor() { this.app = new AppRootStore(this); this.user = new UserStore(this); - // this.workspace = new WorkspaceRootStore(); + this.workspace = new WorkspaceRootStore(this); this.project = new ProjectRootStore(this); this.cycle = new CycleStore(this); this.module = new ModulesStore(this); diff --git a/web/store/user/index.ts b/web/store/user/index.ts index 79ccd69e8..b82b56d68 100644 --- a/web/store/user/index.ts +++ b/web/store/user/index.ts @@ -1,4 +1,4 @@ -import { action, observable, runInAction, makeObservable, computed } from "mobx"; +import { action, observable, runInAction, makeObservable } from "mobx"; // services import { UserService } from "services/user.service"; import { AuthService } from "services/auth.service"; @@ -6,7 +6,7 @@ import { AuthService } from "services/auth.service"; import { IUser, IUserSettings } from "types/users"; // store import { RootStore } from "../root.store"; -import { UserMembershipStore } from "./user-membership.store"; +import { IUserMembershipStore, UserMembershipStore } from "./user-membership.store"; export interface IUserStore { loader: boolean; @@ -33,7 +33,7 @@ export interface IUserStore { deactivateAccount: () => Promise; signOut: () => Promise; - membership: UserMembershipStore; + membership: IUserMembershipStore; } export class UserStore implements IUserStore { diff --git a/web/store/workspace/index.ts b/web/store/workspace/index.ts index 7f5fbc449..0738a60ba 100644 --- a/web/store/workspace/index.ts +++ b/web/store/workspace/index.ts @@ -5,10 +5,10 @@ import { IWorkspace } from "types"; // services import { WorkspaceService } from "services/workspace.service"; // sub-stores -import { WebhookStore } from "./webhook.store"; -import { ApiTokenStore } from "./api-token.store"; +import { IWebhookStore, WebhookStore } from "./webhook.store"; +import { ApiTokenStore, IApiTokenStore } from "./api-token.store"; -export interface IWorkspaceStore { +export interface IWorkspaceRootStore { // states loader: boolean; error: any | null; @@ -31,11 +31,11 @@ export interface IWorkspaceStore { deleteWorkspace: (workspaceSlug: string) => Promise; // sub-stores - webhook: WebhookStore; - apiToken: ApiTokenStore; + webhook: IWebhookStore; + apiToken: IApiTokenStore; } -export class WorkspaceStore implements IWorkspaceStore { +export class WorkspaceRootStore implements IWorkspaceRootStore { // states loader: boolean = false; error: any | null = null;