From 238d4376920a9b9a4738609186d3bfdab52cf89c Mon Sep 17 00:00:00 2001 From: LAKHAN BAHETI Date: Thu, 22 Feb 2024 15:42:01 +0530 Subject: [PATCH] chore: issues-list open event refactored --- .../roots/archived-issue-layout-root.tsx | 6 +++++- .../issue-layouts/roots/cycle-layout-root.tsx | 6 +++++- .../roots/draft-issue-layout-root.tsx | 6 +++++- .../issue-layouts/roots/module-layout-root.tsx | 6 +++++- .../issue-layouts/roots/project-layout-root.tsx | 6 +++++- .../roots/project-view-layout-root.tsx | 6 +++++- web/constants/event-tracker.ts | 14 ++++++++++++++ web/store/event-tracker.store.ts | 9 +++------ 8 files changed, 47 insertions(+), 12 deletions(-) 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 2e40d4792..d927d5e0b 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 @@ -28,7 +28,11 @@ export const ArchivedIssueLayoutRoot: React.FC = observer(() => { async () => { if (workspaceSlug && projectId) { await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString()); - captureIssuesListOpenedEvent(router.asPath, issuesFilter?.issueFilters?.filters); + captureIssuesListOpenedEvent({ + path: router.asPath, + filters: issuesFilter?.issueFilters?.filters, + element_id: projectId, + }); await issues?.fetchIssues( workspaceSlug.toString(), projectId.toString(), 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 2b72d121f..f3c824b0d 100644 --- a/web/components/issues/issue-layouts/roots/cycle-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/cycle-layout-root.tsx @@ -40,7 +40,11 @@ export const CycleLayoutRoot: React.FC = observer(() => { async () => { if (workspaceSlug && projectId && cycleId) { await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString(), cycleId.toString()); - captureIssuesListOpenedEvent(router.asPath, issuesFilter?.issueFilters?.filters); + captureIssuesListOpenedEvent({ + path: router.asPath, + filters: issuesFilter?.issueFilters?.filters, + element_id: cycleId, + }); await issues?.fetchIssues( workspaceSlug.toString(), projectId.toString(), 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 aed208cf0..e9af8b178 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 @@ -28,7 +28,11 @@ export const DraftIssueLayoutRoot: React.FC = observer(() => { async () => { if (workspaceSlug && projectId) { await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString()); - captureIssuesListOpenedEvent(router.asPath, issuesFilter?.issueFilters?.filters); + captureIssuesListOpenedEvent({ + path: router.asPath, + filters: issuesFilter?.issueFilters?.filters, + element_id: projectId, + }); await issues?.fetchIssues( workspaceSlug.toString(), projectId.toString(), 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 4ca0bf35b..e2b64f893 100644 --- a/web/components/issues/issue-layouts/roots/module-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/module-layout-root.tsx @@ -37,7 +37,11 @@ export const ModuleLayoutRoot: React.FC = observer(() => { async () => { if (workspaceSlug && projectId && moduleId) { await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString(), moduleId.toString()); - captureIssuesListOpenedEvent(router.asPath, issuesFilter?.issueFilters?.filters); + captureIssuesListOpenedEvent({ + path: router.asPath, + filters: issuesFilter?.issueFilters?.filters, + element_id: moduleId, + }) await issues?.fetchIssues( workspaceSlug.toString(), projectId.toString(), 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 c0fdb343c..f952909c3 100644 --- a/web/components/issues/issue-layouts/roots/project-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/project-layout-root.tsx @@ -33,7 +33,11 @@ export const ProjectLayoutRoot: FC = observer(() => { useSWR(workspaceSlug && projectId ? `PROJECT_ISSUES_${workspaceSlug}_${projectId}` : null, async () => { if (workspaceSlug && projectId) { await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString()); - captureIssuesListOpenedEvent(router.asPath, issuesFilter?.issueFilters?.filters); + captureIssuesListOpenedEvent({ + path: router.asPath, + filters: issuesFilter?.issueFilters?.filters, + element_id: projectId, + }); await issues?.fetchIssues( workspaceSlug.toString(), projectId.toString(), 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 20fa43fc1..c4b68a5b0 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 @@ -35,7 +35,11 @@ export const ProjectViewLayoutRoot: React.FC = observer(() => { async () => { if (workspaceSlug && projectId && viewId) { await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString(), viewId.toString()); - captureIssuesListOpenedEvent(router.asPath, issuesFilter?.issueFilters?.filters); + captureIssuesListOpenedEvent({ + path: router.asPath, + filters: issuesFilter?.issueFilters?.filters, + element_id: viewId, + }); await issues?.fetchIssues( workspaceSlug.toString(), projectId.toString(), diff --git a/web/constants/event-tracker.ts b/web/constants/event-tracker.ts index ecca3e5cc..889093609 100644 --- a/web/constants/event-tracker.ts +++ b/web/constants/event-tracker.ts @@ -123,6 +123,16 @@ export const getProjectStateEventPayload = (payload: any) => { export const getIssuesListOpenedPayload = (payload: any) => ({ element: elementFromPath(payload.path), + element_id: payload.element_id, + type: payload.project_id ? "Project" : "Workspace", + layout: payload?.displayFilters?.layout, + filters: payload?.filters, + display_properties: payload?.displayProperties, +}); + +export const getIssuesFilterEventPayload = (payload: any) => ({ + element: elementFromPath(payload.path), + element_id: payload.element_id, type: payload.project_id ? "Project" : "Workspace", layout: payload?.displayFilters?.layout, filters: payload?.filters, @@ -176,6 +186,10 @@ export const ISSUE_DELETED = "Issue deleted"; // Issue Checkout Events export const ISSUES_LIST_OPENED = "Issues list opened"; export const ISSUE_OPENED = "Issue opened"; +// Issues Filter Events +export const FILTER_APPLIED = "Filter applied"; +export const FILTER_REMOVED = "Filter removed"; +export const FILTER_SEARCHED = "Filter searched"; // Project State Events export const STATE_CREATED = "State created"; export const STATE_UPDATED = "State updated"; diff --git a/web/store/event-tracker.store.ts b/web/store/event-tracker.store.ts index ce3a5585c..4697180c7 100644 --- a/web/store/event-tracker.store.ts +++ b/web/store/event-tracker.store.ts @@ -39,7 +39,7 @@ export interface IEventTrackerStore { capturePageEvent: (props: EventProps) => void; captureIssueEvent: (props: IssueEventProps) => void; captureProjectStateEvent: (props: EventProps) => void; - captureIssuesListOpenedEvent: (path: string, filters: any) => void; + captureIssuesListOpenedEvent: (payload: any) => void; } export class EventTrackerStore implements IEventTrackerStore { @@ -248,12 +248,9 @@ export class EventTrackerStore implements IEventTrackerStore { * @param {string} path * @param {any} filters */ - captureIssuesListOpenedEvent = (path: string, filters: any) => { + captureIssuesListOpenedEvent = (payload: any) => { const eventPayload = { - ...getIssuesListOpenedPayload({ - path: path, - filters: filters, - }), + ...getIssuesListOpenedPayload(payload), ...this.getRequiredProperties, }; posthog?.capture(ISSUES_LIST_OPENED, eventPayload);