chore: refactoring

This commit is contained in:
LAKHAN BAHETI 2024-03-08 18:57:12 +05:30
parent b98e0fef2b
commit f90e3172e6
33 changed files with 190 additions and 182 deletions

View File

@ -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,
},

View File

@ -86,7 +86,7 @@ export const GlobalIssuesHeader: React.FC<Props> = 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<Props> = 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<Props> = 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<Props> = observer((props) => {
captureIssuesFilterEvent({
eventName: FILTER_SEARCHED,
payload: {
path: router.asPath,
routePath: router.asPath,
current_filters: issueFilters?.filters,
layout: issueFilters?.displayFilters?.layout,
},

View File

@ -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,
},

View File

@ -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,
},

View File

@ -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,
},

View File

@ -99,7 +99,7 @@ export const CreateInboxIssueModal: React.FC<Props> = observer((props) => {
state: "SUCCESS",
element: "Inbox page",
},
path: router.pathname,
routePath: router.pathname,
});
})
.catch((error) => {
@ -111,7 +111,7 @@ export const CreateInboxIssueModal: React.FC<Props> = observer((props) => {
state: "FAILED",
element: "Inbox page",
},
path: router.pathname,
routePath: router.pathname,
});
});
};

View File

@ -57,7 +57,7 @@ export const InboxIssueDetailRoot: FC<TInboxIssueDetailRoot> = (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<TInboxIssueDetailRoot> = (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<TInboxIssueDetailRoot> = (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",

View File

@ -95,7 +95,7 @@ export const IssueDetailRoot: FC<TIssueDetailRoot> = 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<TIssueDetailRoot> = 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<TIssueDetailRoot> = 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<TIssueDetailRoot> = 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<TIssueDetailRoot> = 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<TIssueDetailRoot> = 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<TIssueDetailRoot> = 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<TIssueDetailRoot> = observer((props) => {
changed_property: "cycle_id",
change_details: cycleId,
},
path: router.asPath,
routePath: router.asPath,
});
}
},
@ -225,7 +225,7 @@ export const IssueDetailRoot: FC<TIssueDetailRoot> = 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<TIssueDetailRoot> = observer((props) => {
changed_property: "cycle_id",
change_details: "",
},
path: router.asPath,
routePath: router.asPath,
});
}
},
@ -261,7 +261,7 @@ export const IssueDetailRoot: FC<TIssueDetailRoot> = 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<TIssueDetailRoot> = observer((props) => {
changed_property: "module_id",
change_details: moduleIds,
},
path: router.asPath,
routePath: router.asPath,
});
}
},
@ -297,7 +297,7 @@ export const IssueDetailRoot: FC<TIssueDetailRoot> = 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<TIssueDetailRoot> = observer((props) => {
changed_property: "module_id",
change_details: "",
},
path: router.asPath,
routePath: router.asPath,
});
}
},

View File

@ -155,14 +155,14 @@ export const CalendarQuickAddIssueForm: React.FC<Props> = 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,
});
});
}

View File

@ -129,14 +129,14 @@ export const GanttQuickAddIssueForm: React.FC<IGanttQuickAddIssueForm> = 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,
});
});
}

View File

@ -188,7 +188,7 @@ export const BaseKanBanRoot: React.FC<IBaseKanBanLayout> = observer((props: IBas
captureIssueEvent({
eventName: ISSUE_DELETED,
payload: { id: dragState.draggedIssueId!, state: "FAILED", element: "Kanban layout drag & drop" },
path: router.asPath,
routePath: router.asPath,
});
});
};

View File

@ -123,14 +123,14 @@ export const KanBanQuickAddIssueForm: React.FC<IKanBanQuickAddIssueForm> = 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,
});
});
}

View File

@ -120,14 +120,14 @@ export const ListQuickAddIssueForm: FC<IListQuickAddIssueForm> = 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,
});
});
}

View File

@ -85,7 +85,7 @@ export const IssueProperties: React.FC<IIssueProperties> = 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<IIssueProperties> = 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<IIssueProperties> = 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<IIssueProperties> = 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<IIssueProperties> = 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<IIssueProperties> = 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<IIssueProperties> = 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<IIssueProperties> = 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<IIssueProperties> = 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,

View File

@ -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();

View File

@ -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(

View File

@ -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(

View File

@ -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(

View File

@ -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(

View File

@ -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(

View File

@ -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(

View File

@ -41,7 +41,7 @@ export const SpreadsheetCycleColumn: React.FC<Props> = 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]

View File

@ -52,7 +52,7 @@ export const SpreadsheetModuleColumn: React.FC<Props> = 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]

View File

@ -53,7 +53,7 @@ export const IssueColumn = observer((props: Props) => {
element: "Spreadsheet layout",
},
updates: updates,
path: router.asPath,
routePath: router.asPath,
});
})
}

View File

@ -183,14 +183,14 @@ export const SpreadsheetQuickAddIssueForm: React.FC<Props> = 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);
});

View File

@ -68,7 +68,7 @@ export const DraftIssueLayout: React.FC<DraftIssueProps> = 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<DraftIssueProps> = observer((props) => {
captureIssueEvent({
eventName: "Draft issue created",
payload: { ...payload, state: "FAILED" },
path: router.asPath,
routePath: router.asPath,
});
});
};

View File

@ -166,7 +166,7 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = 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<IssuesModalProps> = 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<IssuesModalProps> = 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<IssuesModalProps> = observer((prop
captureIssueEvent({
eventName: ISSUE_UPDATED,
payload: { ...payload, state: "FAILED" },
path: router.asPath,
routePath: router.asPath,
});
}
};

View File

@ -99,14 +99,14 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = 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<IIssuePeekOverview> = 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<IIssuePeekOverview> = 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<IIssuePeekOverview> = 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<IIssuePeekOverview> = 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<IIssuePeekOverview> = 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<IIssuePeekOverview> = 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<IIssuePeekOverview> = 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<IIssuePeekOverview> = observer((props) => {
changed_property: "cycle_id",
change_details: cycleId,
},
path: router.asPath,
routePath: router.asPath,
});
}
},
@ -251,7 +251,7 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = 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<IIssuePeekOverview> = observer((props) => {
changed_property: "cycle_id",
change_details: "",
},
path: router.asPath,
routePath: router.asPath,
});
}
},
@ -287,7 +287,7 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = 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<IIssuePeekOverview> = observer((props) => {
changed_property: "module_id",
change_details: moduleIds,
},
path: router.asPath,
routePath: router.asPath,
});
}
},
@ -323,7 +323,7 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = 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<IIssuePeekOverview> = observer((props) => {
changed_property: "module_id",
change_details: "",
},
path: router.asPath,
routePath: router.asPath,
});
}
},

View File

@ -179,7 +179,7 @@ export const SubIssuesRoot: FC<ISubIssuesRoot> = 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<ISubIssuesRoot> = 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<ISubIssuesRoot> = 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<ISubIssuesRoot> = 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<ISubIssuesRoot> = 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,

View File

@ -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 (

View File

@ -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<Props> = 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<Props> = 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({

View File

@ -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),
};
};

View File

@ -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,
});
}
}
};
}