From f90e3172e62a55e6cf43986d776d647b67c75f74 Mon Sep 17 00:00:00 2001 From: LAKHAN BAHETI Date: Fri, 8 Mar 2024 18:57:12 +0530 Subject: [PATCH] chore: refactoring --- web/components/headers/cycle-issues.tsx | 8 +-- web/components/headers/global-issues.tsx | 8 +-- web/components/headers/module-issues.tsx | 8 +-- web/components/headers/project-issues.tsx | 8 +-- .../headers/project-view-issues.tsx | 8 +-- .../inbox/modals/create-issue-modal.tsx | 4 +- .../issues/issue-detail/inbox/root.tsx | 8 +-- web/components/issues/issue-detail/root.tsx | 28 ++++---- .../calendar/quick-add-issue-form.tsx | 4 +- .../gantt/quick-add-issue-form.tsx | 4 +- .../issue-layouts/kanban/base-kanban-root.tsx | 2 +- .../kanban/quick-add-issue-form.tsx | 4 +- .../list/quick-add-issue-form.tsx | 4 +- .../properties/all-properties.tsx | 18 ++--- .../roots/all-issue-layout-root.tsx | 2 +- .../roots/archived-issue-layout-root.tsx | 2 +- .../issue-layouts/roots/cycle-layout-root.tsx | 2 +- .../roots/draft-issue-layout-root.tsx | 2 +- .../roots/module-layout-root.tsx | 2 +- .../roots/project-layout-root.tsx | 2 +- .../roots/project-view-layout-root.tsx | 2 +- .../spreadsheet/columns/cycle-column.tsx | 2 +- .../spreadsheet/columns/module-column.tsx | 2 +- .../spreadsheet/issue-column.tsx | 2 +- .../spreadsheet/quick-add-issue-form.tsx | 4 +- .../issues/issue-modal/draft-issue-layout.tsx | 4 +- web/components/issues/issue-modal/modal.tsx | 8 +-- web/components/issues/peek-overview/root.tsx | 32 ++++----- web/components/issues/sub-issues/root.tsx | 12 ++-- .../labels/project-setting-label-list.tsx | 47 ++++--------- web/components/views/modal.tsx | 16 ++--- web/constants/event-tracker.ts | 66 +++++++++---------- web/store/event-tracker.store.ts | 47 ++++++++++++- 33 files changed, 190 insertions(+), 182 deletions(-) diff --git a/web/components/headers/cycle-issues.tsx b/web/components/headers/cycle-issues.tsx index e5f5c64e2..7e4a27999 100644 --- a/web/components/headers/cycle-issues.tsx +++ b/web/components/headers/cycle-issues.tsx @@ -139,7 +139,7 @@ export const CycleIssuesHeader: React.FC = observer(() => { captureIssuesFilterEvent({ eventName: isFilterRemoved ? FILTER_REMOVED : FILTER_APPLIED, payload: { - path: router.asPath, + routePath: router.asPath, filters: issueFilters, filter_property: value, filter_type: key, @@ -160,7 +160,7 @@ export const CycleIssuesHeader: React.FC = observer(() => { payload: { property_type: Object.keys(updatedDisplayFilter).join(","), property: Object.values(updatedDisplayFilter)?.[0], - path: router.asPath, + routePath: router.asPath, filters: issueFilters, }, }) @@ -177,7 +177,7 @@ export const CycleIssuesHeader: React.FC = observer(() => { eventName: Object.values(property)?.[0] === true ? DP_APPLIED : DP_REMOVED, payload: { display_property: Object.keys(property).join(","), - path: router.asPath, + routePath: router.asPath, filters: issueFilters, }, }) @@ -280,7 +280,7 @@ export const CycleIssuesHeader: React.FC = observer(() => { captureIssuesFilterEvent({ eventName: FILTER_SEARCHED, payload: { - path: router.asPath, + routePath: router.asPath, current_filters: issueFilters?.filters, layout: issueFilters?.displayFilters?.layout, }, diff --git a/web/components/headers/global-issues.tsx b/web/components/headers/global-issues.tsx index ff7d2f053..3c70b4dc6 100644 --- a/web/components/headers/global-issues.tsx +++ b/web/components/headers/global-issues.tsx @@ -86,7 +86,7 @@ export const GlobalIssuesHeader: React.FC = observer((props) => { captureIssuesFilterEvent({ eventName: isFilterRemoved ? FILTER_REMOVED : FILTER_APPLIED, payload: { - path: router.asPath, + routePath: router.asPath, filters: issueFilters, filter_property: value, filter_type: key, @@ -112,7 +112,7 @@ export const GlobalIssuesHeader: React.FC = observer((props) => { payload: { property_type: Object.keys(updatedDisplayFilter).join(","), property: Object.values(updatedDisplayFilter)?.[0], - path: router.asPath, + routePath: router.asPath, filters: issueFilters, }, }) @@ -135,7 +135,7 @@ export const GlobalIssuesHeader: React.FC = observer((props) => { eventName: Object.values(property)?.[0] === true ? DP_APPLIED : DP_REMOVED, payload: { display_property: Object.keys(property).join(","), - path: router.asPath, + routePath: router.asPath, filters: issueFilters, }, }) @@ -206,7 +206,7 @@ export const GlobalIssuesHeader: React.FC = observer((props) => { captureIssuesFilterEvent({ eventName: FILTER_SEARCHED, payload: { - path: router.asPath, + routePath: router.asPath, current_filters: issueFilters?.filters, layout: issueFilters?.displayFilters?.layout, }, diff --git a/web/components/headers/module-issues.tsx b/web/components/headers/module-issues.tsx index 582397a5e..71f0d9de8 100644 --- a/web/components/headers/module-issues.tsx +++ b/web/components/headers/module-issues.tsx @@ -140,7 +140,7 @@ export const ModuleIssuesHeader: React.FC = observer(() => { captureIssuesFilterEvent({ eventName: isFilterRemoved ? FILTER_REMOVED : FILTER_APPLIED, payload: { - path: router.asPath, + routePath: router.asPath, filters: issueFilters, filter_property: value, filter_type: key, @@ -160,7 +160,7 @@ export const ModuleIssuesHeader: React.FC = observer(() => { payload: { property_type: Object.keys(updatedDisplayFilter).join(","), property: Object.values(updatedDisplayFilter)?.[0], - path: router.asPath, + routePath: router.asPath, filters: issueFilters, }, }) @@ -177,7 +177,7 @@ export const ModuleIssuesHeader: React.FC = observer(() => { eventName: Object.values(property)?.[0] === true ? DP_APPLIED : DP_REMOVED, payload: { display_property: Object.keys(property).join(","), - path: router.asPath, + routePath: router.asPath, filters: issueFilters, }, }) @@ -283,7 +283,7 @@ export const ModuleIssuesHeader: React.FC = observer(() => { captureIssuesFilterEvent({ eventName: FILTER_SEARCHED, payload: { - path: router.asPath, + routePath: router.asPath, current_filters: issueFilters?.filters, layout: issueFilters?.displayFilters?.layout, }, diff --git a/web/components/headers/project-issues.tsx b/web/components/headers/project-issues.tsx index f79462d3a..f42dcf089 100644 --- a/web/components/headers/project-issues.tsx +++ b/web/components/headers/project-issues.tsx @@ -87,7 +87,7 @@ export const ProjectIssuesHeader: React.FC = observer(() => { captureIssuesFilterEvent({ eventName: isFilterRemoved ? FILTER_REMOVED : FILTER_APPLIED, payload: { - path: router.asPath, + routePath: router.asPath, filters: issueFilters, filter_property: value, filter_type: key, @@ -120,7 +120,7 @@ export const ProjectIssuesHeader: React.FC = observer(() => { payload: { property_type: Object.keys(updatedDisplayFilter).join(","), property: Object.values(updatedDisplayFilter)?.[0], - path: router.asPath, + routePath: router.asPath, filters: issueFilters, }, }) @@ -137,7 +137,7 @@ export const ProjectIssuesHeader: React.FC = observer(() => { eventName: Object.values(property)?.[0] === true ? DP_APPLIED : DP_REMOVED, payload: { display_property: Object.keys(property).join(","), - path: router.asPath, + routePath: router.asPath, filters: issueFilters, }, }); @@ -227,7 +227,7 @@ export const ProjectIssuesHeader: React.FC = observer(() => { captureIssuesFilterEvent({ eventName: FILTER_SEARCHED, payload: { - path: router.asPath, + routePath: router.asPath, current_filters: issueFilters?.filters, layout: issueFilters?.displayFilters?.layout, }, diff --git a/web/components/headers/project-view-issues.tsx b/web/components/headers/project-view-issues.tsx index 79f2b97b4..8a747c651 100644 --- a/web/components/headers/project-view-issues.tsx +++ b/web/components/headers/project-view-issues.tsx @@ -113,7 +113,7 @@ export const ProjectViewIssuesHeader: React.FC = observer(() => { captureIssuesFilterEvent({ eventName: isFilterRemoved ? FILTER_REMOVED : FILTER_APPLIED, payload: { - path: router.asPath, + routePath: router.asPath, filters: issueFilters, filter_property: value, filter_type: key, @@ -139,7 +139,7 @@ export const ProjectViewIssuesHeader: React.FC = observer(() => { payload: { property_type: Object.keys(updatedDisplayFilter).join(","), property: Object.values(updatedDisplayFilter)?.[0], - path: router.asPath, + routePath: router.asPath, filters: issueFilters, }, }) @@ -162,7 +162,7 @@ export const ProjectViewIssuesHeader: React.FC = observer(() => { eventName: Object.values(property)?.[0] === true ? DP_APPLIED : DP_REMOVED, payload: { display_property: Object.keys(property).join(","), - path: router.asPath, + routePath: router.asPath, filters: issueFilters, }, }) @@ -263,7 +263,7 @@ export const ProjectViewIssuesHeader: React.FC = observer(() => { captureIssuesFilterEvent({ eventName: FILTER_SEARCHED, payload: { - path: router.asPath, + routePath: router.asPath, current_filters: issueFilters?.filters, layout: issueFilters?.displayFilters?.layout, }, diff --git a/web/components/inbox/modals/create-issue-modal.tsx b/web/components/inbox/modals/create-issue-modal.tsx index 2603b712e..2ba4fd323 100644 --- a/web/components/inbox/modals/create-issue-modal.tsx +++ b/web/components/inbox/modals/create-issue-modal.tsx @@ -99,7 +99,7 @@ export const CreateInboxIssueModal: React.FC = observer((props) => { state: "SUCCESS", element: "Inbox page", }, - path: router.pathname, + routePath: router.pathname, }); }) .catch((error) => { @@ -111,7 +111,7 @@ export const CreateInboxIssueModal: React.FC = observer((props) => { state: "FAILED", element: "Inbox page", }, - path: router.pathname, + routePath: router.pathname, }); }); }; diff --git a/web/components/issues/issue-detail/inbox/root.tsx b/web/components/issues/issue-detail/inbox/root.tsx index f1cb1b9ff..999eb76f6 100644 --- a/web/components/issues/issue-detail/inbox/root.tsx +++ b/web/components/issues/issue-detail/inbox/root.tsx @@ -57,7 +57,7 @@ export const InboxIssueDetailRoot: FC = (props) => { changed_property: Object.keys(data).join(","), change_details: !data.name && !data.description_html ? Object.values(data).join(",") : undefined, }, - path: router.asPath, + routePath: router.asPath, }); } catch (error) { setToast({ @@ -72,7 +72,7 @@ export const InboxIssueDetailRoot: FC = (props) => { changed_property: Object.keys(data).join(","), change_details: !data.name && !data.description_html ? Object.values(data).join(",") : undefined, }, - path: router.asPath, + routePath: router.asPath, }); } }, @@ -87,13 +87,13 @@ export const InboxIssueDetailRoot: FC = (props) => { captureIssueEvent({ eventName: "Inbox issue deleted", payload: { id: issueId, state: "SUCCESS", element: "Inbox" }, - path: router.asPath, + routePath: router.asPath, }); } catch (error) { captureIssueEvent({ eventName: "Inbox issue deleted", payload: { id: issueId, state: "FAILED", element: "Inbox" }, - path: router.asPath, + routePath: router.asPath, }); setToast({ title: "Issue delete failed", diff --git a/web/components/issues/issue-detail/root.tsx b/web/components/issues/issue-detail/root.tsx index 1c8cc95b8..b1bd22ee8 100644 --- a/web/components/issues/issue-detail/root.tsx +++ b/web/components/issues/issue-detail/root.tsx @@ -95,7 +95,7 @@ export const IssueDetailRoot: FC = observer((props) => { changed_property: Object.keys(data).join(","), change_details: !data.name && !data.description_html ? Object.values(data).join(",") : undefined, }, - path: router.asPath, + routePath: router.asPath, }); } catch (error) { captureIssueEvent({ @@ -105,7 +105,7 @@ export const IssueDetailRoot: FC = observer((props) => { changed_property: Object.keys(data).join(","), change_details: !data.name && !data.description_html ? Object.values(data).join(",") : undefined, }, - path: router.asPath, + routePath: router.asPath, }); setToast({ title: "Issue update failed", @@ -126,7 +126,7 @@ export const IssueDetailRoot: FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_DELETED, payload: { id: issueId, state: "SUCCESS", element: "Issue detail page" }, - path: router.asPath, + routePath: router.asPath, }); } catch (error) { setToast({ @@ -137,7 +137,7 @@ export const IssueDetailRoot: FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_DELETED, payload: { id: issueId, state: "FAILED", element: "Issue detail page" }, - path: router.asPath, + routePath: router.asPath, }); } }, @@ -152,7 +152,7 @@ export const IssueDetailRoot: FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_ARCHIVED, payload: { id: issueId, state: "SUCCESS", element: "Issue details page" }, - path: router.asPath, + routePath: router.asPath, }); } catch (error) { setToast({ @@ -163,7 +163,7 @@ export const IssueDetailRoot: FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_ARCHIVED, payload: { id: issueId, state: "FAILED", element: "Issue details page" }, - path: router.asPath, + routePath: router.asPath, }); } }, @@ -189,7 +189,7 @@ export const IssueDetailRoot: FC = observer((props) => { changed_property: "cycle_id", change_details: cycleId, }, - path: router.asPath, + routePath: router.asPath, }); } catch (error) { captureIssueEvent({ @@ -199,7 +199,7 @@ export const IssueDetailRoot: FC = observer((props) => { changed_property: "cycle_id", change_details: cycleId, }, - path: router.asPath, + routePath: router.asPath, }); } }, @@ -225,7 +225,7 @@ export const IssueDetailRoot: FC = observer((props) => { changed_property: "cycle_id", change_details: "", }, - path: router.asPath, + routePath: router.asPath, }); } catch (error) { captureIssueEvent({ @@ -235,7 +235,7 @@ export const IssueDetailRoot: FC = observer((props) => { changed_property: "cycle_id", change_details: "", }, - path: router.asPath, + routePath: router.asPath, }); } }, @@ -261,7 +261,7 @@ export const IssueDetailRoot: FC = observer((props) => { changed_property: "module_id", change_details: moduleIds, }, - path: router.asPath, + routePath: router.asPath, }); } catch (error) { captureIssueEvent({ @@ -271,7 +271,7 @@ export const IssueDetailRoot: FC = observer((props) => { changed_property: "module_id", change_details: moduleIds, }, - path: router.asPath, + routePath: router.asPath, }); } }, @@ -297,7 +297,7 @@ export const IssueDetailRoot: FC = observer((props) => { changed_property: "module_id", change_details: "", }, - path: router.asPath, + routePath: router.asPath, }); } catch (error) { captureIssueEvent({ @@ -307,7 +307,7 @@ export const IssueDetailRoot: FC = observer((props) => { changed_property: "module_id", change_details: "", }, - path: router.asPath, + routePath: router.asPath, }); } }, diff --git a/web/components/issues/issue-layouts/calendar/quick-add-issue-form.tsx b/web/components/issues/issue-layouts/calendar/quick-add-issue-form.tsx index 5f62706dc..b2fc5402f 100644 --- a/web/components/issues/issue-layouts/calendar/quick-add-issue-form.tsx +++ b/web/components/issues/issue-layouts/calendar/quick-add-issue-form.tsx @@ -155,14 +155,14 @@ export const CalendarQuickAddIssueForm: React.FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_CREATED, payload: { ...res, state: "SUCCESS", element: "Calendar quick add" }, - path: router.asPath, + routePath: router.asPath, }); }) .catch(() => { captureIssueEvent({ eventName: ISSUE_CREATED, payload: { ...payload, state: "FAILED", element: "Calendar quick add" }, - path: router.asPath, + routePath: router.asPath, }); }); } diff --git a/web/components/issues/issue-layouts/gantt/quick-add-issue-form.tsx b/web/components/issues/issue-layouts/gantt/quick-add-issue-form.tsx index b2d3ac9d4..685cccb32 100644 --- a/web/components/issues/issue-layouts/gantt/quick-add-issue-form.tsx +++ b/web/components/issues/issue-layouts/gantt/quick-add-issue-form.tsx @@ -129,14 +129,14 @@ export const GanttQuickAddIssueForm: React.FC = observe captureIssueEvent({ eventName: ISSUE_CREATED, payload: { ...res, state: "SUCCESS", element: "Gantt quick add" }, - path: router.asPath, + routePath: router.asPath, }); }) .catch(() => { captureIssueEvent({ eventName: ISSUE_CREATED, payload: { ...payload, state: "FAILED", element: "Gantt quick add" }, - path: router.asPath, + routePath: router.asPath, }); }); } diff --git a/web/components/issues/issue-layouts/kanban/base-kanban-root.tsx b/web/components/issues/issue-layouts/kanban/base-kanban-root.tsx index e90823c5b..184816b2a 100644 --- a/web/components/issues/issue-layouts/kanban/base-kanban-root.tsx +++ b/web/components/issues/issue-layouts/kanban/base-kanban-root.tsx @@ -188,7 +188,7 @@ export const BaseKanBanRoot: React.FC = observer((props: IBas captureIssueEvent({ eventName: ISSUE_DELETED, payload: { id: dragState.draggedIssueId!, state: "FAILED", element: "Kanban layout drag & drop" }, - path: router.asPath, + routePath: router.asPath, }); }); }; diff --git a/web/components/issues/issue-layouts/kanban/quick-add-issue-form.tsx b/web/components/issues/issue-layouts/kanban/quick-add-issue-form.tsx index 71a0e661c..90e65fdb1 100644 --- a/web/components/issues/issue-layouts/kanban/quick-add-issue-form.tsx +++ b/web/components/issues/issue-layouts/kanban/quick-add-issue-form.tsx @@ -123,14 +123,14 @@ export const KanBanQuickAddIssueForm: React.FC = obser captureIssueEvent({ eventName: ISSUE_CREATED, payload: { ...res, state: "SUCCESS", element: "Kanban quick add" }, - path: router.asPath, + routePath: router.asPath, }); }) .catch(() => { captureIssueEvent({ eventName: ISSUE_CREATED, payload: { ...payload, state: "FAILED", element: "Kanban quick add" }, - path: router.asPath, + routePath: router.asPath, }); }); } diff --git a/web/components/issues/issue-layouts/list/quick-add-issue-form.tsx b/web/components/issues/issue-layouts/list/quick-add-issue-form.tsx index 7bae7ecff..025dabd33 100644 --- a/web/components/issues/issue-layouts/list/quick-add-issue-form.tsx +++ b/web/components/issues/issue-layouts/list/quick-add-issue-form.tsx @@ -120,14 +120,14 @@ export const ListQuickAddIssueForm: FC = observer((props captureIssueEvent({ eventName: ISSUE_CREATED, payload: { ...res, state: "SUCCESS", element: "List quick add" }, - path: router.asPath, + routePath: router.asPath, }); }) .catch(() => { captureIssueEvent({ eventName: ISSUE_CREATED, payload: { ...payload, state: "FAILED", element: "List quick add" }, - path: router.asPath, + routePath: router.asPath, }); }); } diff --git a/web/components/issues/issue-layouts/properties/all-properties.tsx b/web/components/issues/issue-layouts/properties/all-properties.tsx index 8c1e33b8c..73ca652c4 100644 --- a/web/components/issues/issue-layouts/properties/all-properties.tsx +++ b/web/components/issues/issue-layouts/properties/all-properties.tsx @@ -85,7 +85,7 @@ export const IssueProperties: React.FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_UPDATED, payload: { ...issue, state: "SUCCESS", element: currentLayout }, - path: router.asPath, + routePath: router.asPath, updates: { changed_property: "state", change_details: stateId, @@ -100,7 +100,7 @@ export const IssueProperties: React.FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_UPDATED, payload: { ...issue, state: "SUCCESS", element: currentLayout }, - path: router.asPath, + routePath: router.asPath, updates: { changed_property: "priority", change_details: value, @@ -115,7 +115,7 @@ export const IssueProperties: React.FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_UPDATED, payload: { ...issue, state: "SUCCESS", element: currentLayout }, - path: router.asPath, + routePath: router.asPath, updates: { changed_property: "labels", change_details: ids, @@ -130,7 +130,7 @@ export const IssueProperties: React.FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_UPDATED, payload: { ...issue, state: "SUCCESS", element: currentLayout }, - path: router.asPath, + routePath: router.asPath, updates: { changed_property: "assignees", change_details: ids, @@ -155,7 +155,7 @@ export const IssueProperties: React.FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_UPDATED, payload: { ...issue, state: "SUCCESS", element: currentLayout }, - path: router.asPath, + routePath: router.asPath, updates: { changed_property: "module_ids", change_details: { module_ids: moduleIds } }, }); }, @@ -171,7 +171,7 @@ export const IssueProperties: React.FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_UPDATED, payload: { ...issue, state: "SUCCESS", element: currentLayout }, - path: router.asPath, + routePath: router.asPath, updates: { changed_property: "cycle", change_details: { cycle_id: cycleId } }, }); }, @@ -185,7 +185,7 @@ export const IssueProperties: React.FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_UPDATED, payload: { ...issue, state: "SUCCESS", element: currentLayout }, - path: router.asPath, + routePath: router.asPath, updates: { changed_property: "start_date", change_details: date ? renderFormattedPayloadDate(date) : null, @@ -202,7 +202,7 @@ export const IssueProperties: React.FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_UPDATED, payload: { ...issue, state: "SUCCESS", element: currentLayout }, - path: router.asPath, + routePath: router.asPath, updates: { changed_property: "target_date", change_details: date ? renderFormattedPayloadDate(date) : null, @@ -218,7 +218,7 @@ export const IssueProperties: React.FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_UPDATED, payload: { ...issue, state: "SUCCESS", element: currentLayout }, - path: router.asPath, + routePath: router.asPath, updates: { changed_property: "estimate_point", change_details: value, diff --git a/web/components/issues/issue-layouts/roots/all-issue-layout-root.tsx b/web/components/issues/issue-layouts/roots/all-issue-layout-root.tsx index eefe4c82b..6f7c8f586 100644 --- a/web/components/issues/issue-layouts/roots/all-issue-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/all-issue-layout-root.tsx @@ -93,7 +93,7 @@ export const AllIssueLayoutRoot: React.FC = observer(() => { await fetchAllGlobalViews(workspaceSlug.toString()); await fetchFilters(workspaceSlug.toString(), globalViewId.toString()); captureIssuesListOpenedEvent({ - path: router.asPath, + routePath: router.asPath, }); await fetchIssues(workspaceSlug.toString(), globalViewId.toString(), issueIds ? "mutation" : "init-loader"); routerFilterParams(); diff --git a/web/components/issues/issue-layouts/roots/archived-issue-layout-root.tsx b/web/components/issues/issue-layouts/roots/archived-issue-layout-root.tsx index fdb0cd0a7..e00da4636 100644 --- a/web/components/issues/issue-layouts/roots/archived-issue-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/archived-issue-layout-root.tsx @@ -29,7 +29,7 @@ export const ArchivedIssueLayoutRoot: React.FC = observer(() => { if (workspaceSlug && projectId) { await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString()); captureIssuesListOpenedEvent({ - path: router.asPath, + routePath: router.asPath, filters: issuesFilter?.issueFilters?.filters, }); await issues?.fetchIssues( diff --git a/web/components/issues/issue-layouts/roots/cycle-layout-root.tsx b/web/components/issues/issue-layouts/roots/cycle-layout-root.tsx index 6c4f853b2..ecedcf3c4 100644 --- a/web/components/issues/issue-layouts/roots/cycle-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/cycle-layout-root.tsx @@ -42,7 +42,7 @@ export const CycleLayoutRoot: React.FC = observer(() => { if (workspaceSlug && projectId && cycleId) { await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString(), cycleId.toString()); captureIssuesListOpenedEvent({ - path: router.asPath, + routePath: router.asPath, filters: issuesFilter?.issueFilters?.filters, }); await issues?.fetchIssues( diff --git a/web/components/issues/issue-layouts/roots/draft-issue-layout-root.tsx b/web/components/issues/issue-layouts/roots/draft-issue-layout-root.tsx index 4487d94f7..835e496ed 100644 --- a/web/components/issues/issue-layouts/roots/draft-issue-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/draft-issue-layout-root.tsx @@ -29,7 +29,7 @@ export const DraftIssueLayoutRoot: React.FC = observer(() => { if (workspaceSlug && projectId) { await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString()); captureIssuesListOpenedEvent({ - path: router.asPath, + routePath: router.asPath, filters: issuesFilter?.issueFilters?.filters, }); await issues?.fetchIssues( diff --git a/web/components/issues/issue-layouts/roots/module-layout-root.tsx b/web/components/issues/issue-layouts/roots/module-layout-root.tsx index 597a66575..182cb3737 100644 --- a/web/components/issues/issue-layouts/roots/module-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/module-layout-root.tsx @@ -38,7 +38,7 @@ export const ModuleLayoutRoot: React.FC = observer(() => { if (workspaceSlug && projectId && moduleId) { await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString(), moduleId.toString()); captureIssuesListOpenedEvent({ - path: router.asPath, + routePath: router.asPath, filters: issuesFilter?.issueFilters?.filters, }) await issues?.fetchIssues( diff --git a/web/components/issues/issue-layouts/roots/project-layout-root.tsx b/web/components/issues/issue-layouts/roots/project-layout-root.tsx index 92156bced..0eb5f5c48 100644 --- a/web/components/issues/issue-layouts/roots/project-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/project-layout-root.tsx @@ -36,7 +36,7 @@ export const ProjectLayoutRoot: FC = observer(() => { if (workspaceSlug && projectId) { await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString()); captureIssuesListOpenedEvent({ - path: router.asPath, + routePath: router.asPath, filters: issuesFilter?.issueFilters?.filters, }); await issues?.fetchIssues( diff --git a/web/components/issues/issue-layouts/roots/project-view-layout-root.tsx b/web/components/issues/issue-layouts/roots/project-view-layout-root.tsx index 9f2c43910..227d0490a 100644 --- a/web/components/issues/issue-layouts/roots/project-view-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/project-view-layout-root.tsx @@ -34,7 +34,7 @@ export const ProjectViewLayoutRoot: React.FC = observer(() => { if (workspaceSlug && projectId && viewId) { await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString(), viewId.toString()); captureIssuesListOpenedEvent({ - path: router.asPath, + routePath: router.asPath, filters: issuesFilter?.issueFilters?.filters, }); await issues?.fetchIssues( diff --git a/web/components/issues/issue-layouts/spreadsheet/columns/cycle-column.tsx b/web/components/issues/issue-layouts/spreadsheet/columns/cycle-column.tsx index 658e9c79b..ab302c73b 100644 --- a/web/components/issues/issue-layouts/spreadsheet/columns/cycle-column.tsx +++ b/web/components/issues/issue-layouts/spreadsheet/columns/cycle-column.tsx @@ -41,7 +41,7 @@ export const SpreadsheetCycleColumn: React.FC = observer((props) => { element: "Spreadsheet layout", }, updates: { changed_property: "cycle", change_details: { cycle_id: cycleId } }, - path: router.asPath, + routePath: router.asPath, }); }, [workspaceSlug, issue, addIssueToCycle, removeIssueFromCycle, captureIssueEvent, router.asPath] diff --git a/web/components/issues/issue-layouts/spreadsheet/columns/module-column.tsx b/web/components/issues/issue-layouts/spreadsheet/columns/module-column.tsx index 67c72d2a8..e68c3675b 100644 --- a/web/components/issues/issue-layouts/spreadsheet/columns/module-column.tsx +++ b/web/components/issues/issue-layouts/spreadsheet/columns/module-column.tsx @@ -52,7 +52,7 @@ export const SpreadsheetModuleColumn: React.FC = observer((props) => { element: "Spreadsheet layout", }, updates: { changed_property: "module_ids", change_details: { module_ids: moduleIds } }, - path: router.asPath, + routePath: router.asPath, }); }, [workspaceSlug, issue, addModulesToIssue, removeModulesFromIssue, captureIssueEvent, router.asPath] diff --git a/web/components/issues/issue-layouts/spreadsheet/issue-column.tsx b/web/components/issues/issue-layouts/spreadsheet/issue-column.tsx index 825c2b31c..a2bb34ce1 100644 --- a/web/components/issues/issue-layouts/spreadsheet/issue-column.tsx +++ b/web/components/issues/issue-layouts/spreadsheet/issue-column.tsx @@ -53,7 +53,7 @@ export const IssueColumn = observer((props: Props) => { element: "Spreadsheet layout", }, updates: updates, - path: router.asPath, + routePath: router.asPath, }); }) } diff --git a/web/components/issues/issue-layouts/spreadsheet/quick-add-issue-form.tsx b/web/components/issues/issue-layouts/spreadsheet/quick-add-issue-form.tsx index 6b886ffa9..e69ae7177 100644 --- a/web/components/issues/issue-layouts/spreadsheet/quick-add-issue-form.tsx +++ b/web/components/issues/issue-layouts/spreadsheet/quick-add-issue-form.tsx @@ -183,14 +183,14 @@ export const SpreadsheetQuickAddIssueForm: React.FC = observer((props) => captureIssueEvent({ eventName: ISSUE_CREATED, payload: { ...res, state: "SUCCESS", element: "Spreadsheet quick add" }, - path: router.asPath, + routePath: router.asPath, }); }) .catch((err) => { captureIssueEvent({ eventName: ISSUE_CREATED, payload: { ...payload, state: "FAILED", element: "Spreadsheet quick add" }, - path: router.asPath, + routePath: router.asPath, }); console.error(err); }); diff --git a/web/components/issues/issue-modal/draft-issue-layout.tsx b/web/components/issues/issue-modal/draft-issue-layout.tsx index 785ccb0bb..e1326f2d9 100644 --- a/web/components/issues/issue-modal/draft-issue-layout.tsx +++ b/web/components/issues/issue-modal/draft-issue-layout.tsx @@ -68,7 +68,7 @@ export const DraftIssueLayout: React.FC = observer((props) => { captureIssueEvent({ eventName: "Draft issue created", payload: { ...res, state: "SUCCESS" }, - path: router.asPath, + routePath: router.asPath, }); onChange(null); setIssueDiscardModal(false); @@ -83,7 +83,7 @@ export const DraftIssueLayout: React.FC = observer((props) => { captureIssueEvent({ eventName: "Draft issue created", payload: { ...payload, state: "FAILED" }, - path: router.asPath, + routePath: router.asPath, }); }); }; diff --git a/web/components/issues/issue-modal/modal.tsx b/web/components/issues/issue-modal/modal.tsx index b4cf05fc8..17d6b97df 100644 --- a/web/components/issues/issue-modal/modal.tsx +++ b/web/components/issues/issue-modal/modal.tsx @@ -166,7 +166,7 @@ export const CreateUpdateIssueModal: React.FC = observer((prop captureIssueEvent({ eventName: ISSUE_CREATED, payload: { ...response, state: "SUCCESS" }, - path: router.asPath, + routePath: router.asPath, }); !createMore && handleClose(); return response; @@ -179,7 +179,7 @@ export const CreateUpdateIssueModal: React.FC = observer((prop captureIssueEvent({ eventName: ISSUE_CREATED, payload: { ...payload, state: "FAILED" }, - path: router.asPath, + routePath: router.asPath, }); } }; @@ -200,7 +200,7 @@ export const CreateUpdateIssueModal: React.FC = observer((prop captureIssueEvent({ eventName: ISSUE_UPDATED, payload: { ...payload, issueId: data.id, state: "SUCCESS" }, - path: router.asPath, + routePath: router.asPath, }); handleClose(); } catch (error) { @@ -212,7 +212,7 @@ export const CreateUpdateIssueModal: React.FC = observer((prop captureIssueEvent({ eventName: ISSUE_UPDATED, payload: { ...payload, state: "FAILED" }, - path: router.asPath, + routePath: router.asPath, }); } }; diff --git a/web/components/issues/peek-overview/root.tsx b/web/components/issues/peek-overview/root.tsx index ab9799fda..b59aa7e37 100644 --- a/web/components/issues/peek-overview/root.tsx +++ b/web/components/issues/peek-overview/root.tsx @@ -99,14 +99,14 @@ export const IssuePeekOverview: FC = observer((props) => { changed_property: Object.keys(data).join(","), change_details: Object.values(data).join(","), }, - path: router.asPath, + routePath: router.asPath, }); }) .catch(() => { captureIssueEvent({ eventName: ISSUE_UPDATED, payload: { state: "FAILED", element: "Issue peek-overview" }, - path: router.asPath, + routePath: router.asPath, }); setToast({ title: "Issue update failed", @@ -126,7 +126,7 @@ export const IssuePeekOverview: FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_DELETED, payload: { id: issueId, state: "SUCCESS", element: "Issue peek-overview" }, - path: router.asPath, + routePath: router.asPath, }); } catch (error) { setToast({ @@ -137,7 +137,7 @@ export const IssuePeekOverview: FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_DELETED, payload: { id: issueId, state: "FAILED", element: "Issue peek-overview" }, - path: router.asPath, + routePath: router.asPath, }); } }, @@ -152,7 +152,7 @@ export const IssuePeekOverview: FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_ARCHIVED, payload: { id: issueId, state: "SUCCESS", element: "Issue peek-overview" }, - path: router.asPath, + routePath: router.asPath, }); } catch (error) { setToast({ @@ -163,7 +163,7 @@ export const IssuePeekOverview: FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_ARCHIVED, payload: { id: issueId, state: "FAILED", element: "Issue peek-overview" }, - path: router.asPath, + routePath: router.asPath, }); } }, @@ -178,7 +178,7 @@ export const IssuePeekOverview: FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_RESTORED, payload: { id: issueId, state: "SUCCESS", element: "Issue peek-overview" }, - path: router.asPath, + routePath: router.asPath, }); } catch (error) { setToast({ @@ -189,7 +189,7 @@ export const IssuePeekOverview: FC = observer((props) => { captureIssueEvent({ eventName: ISSUE_RESTORED, payload: { id: issueId, state: "FAILED", element: "Issue peek-overview" }, - path: router.asPath, + routePath: router.asPath, }); } }, @@ -215,7 +215,7 @@ export const IssuePeekOverview: FC = observer((props) => { changed_property: "cycle_id", change_details: cycleId, }, - path: router.asPath, + routePath: router.asPath, }); } catch (error) { captureIssueEvent({ @@ -225,7 +225,7 @@ export const IssuePeekOverview: FC = observer((props) => { changed_property: "cycle_id", change_details: cycleId, }, - path: router.asPath, + routePath: router.asPath, }); } }, @@ -251,7 +251,7 @@ export const IssuePeekOverview: FC = observer((props) => { changed_property: "cycle_id", change_details: "", }, - path: router.asPath, + routePath: router.asPath, }); } catch (error) { captureIssueEvent({ @@ -261,7 +261,7 @@ export const IssuePeekOverview: FC = observer((props) => { changed_property: "cycle_id", change_details: "", }, - path: router.asPath, + routePath: router.asPath, }); } }, @@ -287,7 +287,7 @@ export const IssuePeekOverview: FC = observer((props) => { changed_property: "module_id", change_details: moduleIds, }, - path: router.asPath, + routePath: router.asPath, }); } catch (error) { captureIssueEvent({ @@ -297,7 +297,7 @@ export const IssuePeekOverview: FC = observer((props) => { changed_property: "module_id", change_details: moduleIds, }, - path: router.asPath, + routePath: router.asPath, }); } }, @@ -323,7 +323,7 @@ export const IssuePeekOverview: FC = observer((props) => { changed_property: "module_id", change_details: "", }, - path: router.asPath, + routePath: router.asPath, }); } catch (error) { captureIssueEvent({ @@ -333,7 +333,7 @@ export const IssuePeekOverview: FC = observer((props) => { changed_property: "module_id", change_details: "", }, - path: router.asPath, + routePath: router.asPath, }); } }, diff --git a/web/components/issues/sub-issues/root.tsx b/web/components/issues/sub-issues/root.tsx index 36c999640..1c2f6d68f 100644 --- a/web/components/issues/sub-issues/root.tsx +++ b/web/components/issues/sub-issues/root.tsx @@ -179,7 +179,7 @@ export const SubIssuesRoot: FC = observer((props) => { change_details: !issueData.name && !issueData.description_html ? Object.values(issueData).join(",") : undefined, }, - path: router.asPath, + routePath: router.asPath, }); setToast({ type: TOAST_TYPE.SUCCESS, @@ -196,7 +196,7 @@ export const SubIssuesRoot: FC = observer((props) => { change_details: !issueData.name && !issueData.description_html ? Object.values(issueData).join(",") : undefined, }, - path: router.asPath, + routePath: router.asPath, }); setToast({ type: TOAST_TYPE.ERROR, @@ -221,7 +221,7 @@ export const SubIssuesRoot: FC = observer((props) => { changed_property: "parent_id", change_details: parentIssueId, }, - path: router.asPath, + routePath: router.asPath, }); setSubIssueHelpers(parentIssueId, "issue_loader", issueId); } catch (error) { @@ -232,7 +232,7 @@ export const SubIssuesRoot: FC = observer((props) => { changed_property: "parent_id", change_details: parentIssueId, }, - path: router.asPath, + routePath: router.asPath, }); setToast({ type: TOAST_TYPE.ERROR, @@ -253,14 +253,14 @@ export const SubIssuesRoot: FC = observer((props) => { captureIssueEvent({ eventName: "Sub-issue deleted", payload: { id: issueId, state: "SUCCESS", element: "Issue detail page" }, - path: router.asPath, + routePath: router.asPath, }); setSubIssueHelpers(parentIssueId, "issue_loader", issueId); } catch (error) { captureIssueEvent({ eventName: "Sub-issue removed", payload: { id: issueId, state: "FAILED", element: "Issue detail page" }, - path: router.asPath, + routePath: router.asPath, }); setToast({ type: TOAST_TYPE.ERROR, diff --git a/web/components/labels/project-setting-label-list.tsx b/web/components/labels/project-setting-label-list.tsx index 8829592f0..99c2a0d76 100644 --- a/web/components/labels/project-setting-label-list.tsx +++ b/web/components/labels/project-setting-label-list.tsx @@ -25,7 +25,6 @@ import { Button, Loader } from "@plane/ui"; // types import { IIssueLabel } from "@plane/types"; // constants -import { LABEL_ADDED_G, LABEL_REMOVED_G } from "constants/event-tracker"; import { EmptyStateType } from "constants/empty-state"; const LABELS_ROOT = "labels.root"; @@ -43,7 +42,7 @@ export const ProjectSettingsLabelList: React.FC = observer(() => { const { workspaceSlug, projectId } = router.query; // store hooks const { projectLabels, updateLabelPosition, projectLabelsTree, getLabelById } = useLabel(); - const { captureEvent } = useEventTracker(); + const { captureLabelDragNDropEvent } = useEventTracker(); // portal const renderDraggable = useDraggableInPortal(); @@ -71,40 +70,18 @@ export const ProjectSettingsLabelList: React.FC = observer(() => { if (result.reason == "DROP" && childLabel != parentLabel) { const childLabelData = getLabelById(childLabel); - if (childLabelData?.parent != parentLabel) { - if (childLabelData?.parent) { - captureEvent(LABEL_REMOVED_G, { - group_id: childLabelData?.parent, - child_id: childLabel, - child_count: - (projectLabelsTree?.find((label) => label.id === childLabelData?.parent)?.children?.length ?? 0) - 1, - }); - parentLabel && - captureEvent(LABEL_ADDED_G, { - group_id: parentLabel, - child_id: childLabel, - child_count: (projectLabelsTree?.find((label) => label.id === parentLabel)?.children?.length ?? 0) + 1, - }); - } else { - captureEvent(LABEL_ADDED_G, { - group_id: parentLabel, - child_id: childLabel, - child_count: (projectLabelsTree?.find((label) => label.id === parentLabel)?.children?.length ?? 0) + 1, - }); - } - } - - updateLabelPosition( - workspaceSlug?.toString()!, - projectId?.toString()!, - childLabel, - parentLabel, - index, - prevParentLabel == parentLabel, - prevIndex - ); - return; + captureLabelDragNDropEvent(childLabelData?.parent, parentLabel, childLabel, projectLabelsTree); } + updateLabelPosition( + workspaceSlug?.toString()!, + projectId?.toString()!, + childLabel, + parentLabel, + index, + prevParentLabel == parentLabel, + prevIndex + ); + return; }; return ( diff --git a/web/components/views/modal.tsx b/web/components/views/modal.tsx index 969859cb6..81ccb497b 100644 --- a/web/components/views/modal.tsx +++ b/web/components/views/modal.tsx @@ -11,7 +11,7 @@ import { useEventTracker, useProjectView } from "hooks/store"; // types import { IProjectView } from "@plane/types"; // constants -import { VIEW_CREATED, VIEW_UPDATED } from "constants/event-tracker"; +import { VIEW_CREATED, VIEW_UPDATED, elementFromPath } from "constants/event-tracker"; type Props = { data?: IProjectView | null; @@ -26,7 +26,6 @@ export const CreateUpdateProjectViewModal: FC = observer((props) => { const { data, isOpen, onClose, preLoadedData, workspaceSlug, projectId } = props; // router const router = useRouter(); - const { cycleId, moduleId, viewId } = router.query; // store hooks const { createView, updateView } = useProjectView(); const { captureEvent, getTrackElement } = useEventTracker(); @@ -39,19 +38,12 @@ export const CreateUpdateProjectViewModal: FC = observer((props) => { await createView(workspaceSlug, projectId, payload) .then((res) => { handleClose(); + const element = elementFromPath(router.asPath); captureEvent(VIEW_CREATED, { view_id: res.id, filters: res.filters, - element_id: cycleId ?? moduleId ?? viewId ?? projectId, - element: getTrackElement - ? getTrackElement - : cycleId - ? "Cycle issues page" - : moduleId - ? "Module issues page" - : viewId - ? "View issues page" - : "Project issues page", + element: getTrackElement ?? element?.element, + element_id: element?.element_id, state: "SUCCESS", }); setToast({ diff --git a/web/constants/event-tracker.ts b/web/constants/event-tracker.ts index 047b73407..c289d95b0 100644 --- a/web/constants/event-tracker.ts +++ b/web/constants/event-tracker.ts @@ -4,7 +4,7 @@ export type IssueEventProps = { eventName: string; payload: any; updates?: any; - path?: string; + routePath?: string; }; export type EventProps = { @@ -72,7 +72,7 @@ export const getPageEventPayload = (payload: any) => ({ }); export const getIssueEventPayload = (props: IssueEventProps) => { - const { eventName, payload, updates, path } = props; + const { eventName, payload, updates, routePath } = props; let eventPayload: any = { issue_id: payload.id, estimate_point: payload.estimate_point, @@ -97,35 +97,33 @@ export const getIssueEventPayload = (props: IssueEventProps) => { module_id: payload.module_id, archived_at: payload.archived_at, state: payload.state, - view_id: path?.includes("workspace-views") || path?.includes("views") ? path.split("/").pop() : "", + view_id: routePath?.includes("workspace-views") || routePath?.includes("views") ? routePath.split("/").pop() : "", }; if (eventName === ISSUE_UPDATED) { eventPayload = { ...eventPayload, ...updates, - updated_from: elementFromPath(path), + updated_from: elementFromPath(routePath), }; } return eventPayload; }; -export const getProjectStateEventPayload = (payload: any) => { - return { - state_id: payload.id, - created_at: payload.created_at, - updated_at: payload.updated_at, - group: payload.group, - color: payload.color, - default: payload.default, - state: payload.state, - element: payload.element, - change_details: payload.change_details, - }; -}; +export const getProjectStateEventPayload = (payload: any) => ({ + state_id: payload.id, + created_at: payload.created_at, + updated_at: payload.updated_at, + group: payload.group, + color: payload.color, + default: payload.default, + state: payload.state, + element: payload.element, + change_details: payload.change_details, +}); export const getIssuesListOpenedPayload = (payload: any) => ({ - ...elementFromPath(payload?.path), + ...elementFromPath(payload?.routePath), layout: payload?.displayFilters?.layout, filters: payload?.filters, display_properties: payload?.displayProperties, @@ -136,7 +134,7 @@ export const getIssuesFilterEventPayload = (payload: any) => ({ filter_property: payload?.filter_property, layout: payload?.filters?.displayFilters?.layout, current_filters: payload?.filters?.filters, - ...elementFromPath(payload?.path), + ...elementFromPath(payload?.routePath), }); export const getIssuesDisplayFilterPayload = (payload: any) => { @@ -149,32 +147,32 @@ export const getIssuesDisplayFilterPayload = (payload: any) => { return { layout: payload?.filters?.displayFilters?.layout, current_display_properties: payload?.filters?.displayProperties, - ...elementFromPath(payload?.path), + ...elementFromPath(payload?.routePath), display_property: payload.display_property, property: property, property_type: payload.property_type, }; }; -export const elementFromPath = (path?: string) => { - path = path?.split("?")?.[0]; - if (!path) return; +export const elementFromPath = (routePath?: string) => { + routePath = routePath?.split("?")?.[0]; + if (!routePath) return; let element = "Dashboard"; - if (path.includes("workspace-views")) element = "Global view"; - else if (path.includes("cycles")) element = "Cycle"; - else if (path.includes("modules")) element = "Module"; - else if (path.includes("pages")) element = "Project page"; - else if (path.includes("views")) element = "Project view"; - else if (path.includes("profile")) element = "Profile"; - else if (path.includes("inbox")) element = "Inbox"; - else if (path.includes("draft")) element = "Draft"; - else if (path.includes("archived")) element = "Archive"; - else if (path.includes("projects")) element = "Project"; + if (routePath.includes("workspace-views")) element = "Global view"; + else if (routePath.includes("cycles")) element = "Cycle"; + else if (routePath.includes("modules")) element = "Module"; + else if (routePath.includes("pages")) element = "Project page"; + else if (routePath.includes("views")) element = "Project view"; + else if (routePath.includes("profile")) element = "Profile"; + else if (routePath.includes("inbox")) element = "Inbox"; + else if (routePath.includes("draft")) element = "Draft"; + else if (routePath.includes("archived")) element = "Archive"; + else if (routePath.includes("projects")) element = "Project"; return { element: element, - element_id: ["Project", "Draft", "Archive"].includes(element) ? path.split("/").at(-2) : path.split("/").at(-1), + element_id: ["Project", "Draft", "Archive"].includes(element) ? routePath.split("/")?.at(-2) : routePath.split("/")?.at(-1), }; }; diff --git a/web/store/event-tracker.store.ts b/web/store/event-tracker.store.ts index 0239e41a2..6054494ff 100644 --- a/web/store/event-tracker.store.ts +++ b/web/store/event-tracker.store.ts @@ -6,8 +6,6 @@ import { RootStore } from "./root.store"; import { getUserRole } from "helpers/user.helper"; // constants import { - GROUP_WORKSPACE, - WORKSPACE_CREATED, EventProps, IssueEventProps, getCycleEventPayload, @@ -17,12 +15,17 @@ import { getProjectStateEventPayload, getWorkspaceEventPayload, getPageEventPayload, - ISSUES_LIST_OPENED, getIssuesListOpenedPayload, getIssuesFilterEventPayload, getIssuesDisplayFilterPayload, LP_UPDATED, + ISSUES_LIST_OPENED, + GROUP_WORKSPACE, + WORKSPACE_CREATED, + LABEL_REMOVED_G, + LABEL_ADDED_G, } from "constants/event-tracker"; +import { IIssueLabelTree } from "@plane/types"; export interface IEventTrackerStore { // properties @@ -45,6 +48,12 @@ export interface IEventTrackerStore { captureIssuesListOpenedEvent: (payload: any) => void; captureIssuesFilterEvent: (props: EventProps) => void; captureIssuesDisplayFilterEvent: (props: EventProps) => void; + captureLabelDragNDropEvent: ( + childLabelParent: string | null | undefined, + parentLabel: string | null | undefined, + childLabel: string | null | undefined, + projectLabelsTree: IIssueLabelTree[] | undefined + ) => void; } export class EventTrackerStore implements IEventTrackerStore { @@ -69,6 +78,7 @@ export class EventTrackerStore implements IEventTrackerStore { captureProjectStateEvent: action, captureIssuesListOpenedEvent: action, joinWorkspaceMetricGroup: action, + captureWorkspaceEvent: action, }); // store this.rootStore = _rootStore; @@ -292,4 +302,35 @@ export class EventTrackerStore implements IEventTrackerStore { posthog?.capture(eventName, eventPayload); this.setTrackElement(undefined); }; + + captureLabelDragNDropEvent = ( + childLabelParent: string | null | undefined, + parentLabel: string | null | undefined, + childLabel: string | null | undefined, + projectLabelsTree: IIssueLabelTree[] | undefined + ) => { + if (childLabelParent != parentLabel) { + // if the child label has a parent, then remove it from the parent and add it to a new parent. + if (childLabelParent) { + this.captureEvent(LABEL_REMOVED_G, { + group_id: childLabelParent, + child_id: childLabel, + child_count: (projectLabelsTree?.find((label) => label.id === childLabelParent)?.children?.length ?? 0) - 1, + }); + parentLabel && + this.captureEvent(LABEL_ADDED_G, { + group_id: parentLabel, + child_id: childLabel, + child_count: (projectLabelsTree?.find((label) => label.id === parentLabel)?.children?.length ?? 0) + 1, + }); + } else { + // if the child label has no parent, then add it to a new parent. + this.captureEvent(LABEL_ADDED_G, { + group_id: parentLabel, + child_id: childLabel, + child_count: (projectLabelsTree?.find((label) => label.id === parentLabel)?.children?.length ?? 0) + 1, + }); + } + } + }; }