From cf662f6e6cd64fccb7c7afb9323722b9ea09ece9 Mon Sep 17 00:00:00 2001 From: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Date: Thu, 6 Apr 2023 12:08:52 +0530 Subject: [PATCH] chore: new analytic events (#699) * feat: tracking events for issues marked as DONE, issue property update, issue moved to cycle, issue moved to modules * fix: changed events names * chore: sync analytic * chore: new analytic events --- .../core/board-view/single-issue.tsx | 1 - apps/app/components/core/issues-view.tsx | 19 +- .../issues/view-select/assignee.tsx | 13 ++ .../issues/view-select/due-date.tsx | 19 +- .../issues/view-select/priority.tsx | 19 +- .../components/issues/view-select/state.tsx | 32 +++- .../[projectId]/settings/features.tsx | 57 +++++- apps/app/services/issues.service.ts | 95 +++++++++- apps/app/services/modules.service.ts | 17 +- apps/app/services/project.service.ts | 15 +- apps/app/services/track-event.service.ts | 168 +++++++++++++++++- apps/app/types/issues.d.ts | 4 + 12 files changed, 428 insertions(+), 31 deletions(-) diff --git a/apps/app/components/core/board-view/single-issue.tsx b/apps/app/components/core/board-view/single-issue.tsx index 3b28ef428..6c965a737 100644 --- a/apps/app/components/core/board-view/single-issue.tsx +++ b/apps/app/components/core/board-view/single-issue.tsx @@ -34,7 +34,6 @@ import { TrashIcon, XMarkIcon, ArrowTopRightOnSquareIcon, - } from "@heroicons/react/24/outline"; // helpers import { handleIssuesMutation } from "constants/issue"; diff --git a/apps/app/components/core/issues-view.tsx b/apps/app/components/core/issues-view.tsx index 5ce930dda..be78d6c0a 100644 --- a/apps/app/components/core/issues-view.tsx +++ b/apps/app/components/core/issues-view.tsx @@ -10,6 +10,7 @@ import { DragDropContext, DropResult } from "react-beautiful-dnd"; import issuesService from "services/issues.service"; import stateService from "services/state.service"; import modulesService from "services/modules.service"; +import trackEventServices from "services/track-event.service"; // hooks import useToast from "hooks/use-toast"; import useIssuesView from "hooks/use-issues-view"; @@ -259,7 +260,22 @@ export const IssuesView: React.FC = ({ state: draggedItem.state, sort_order: draggedItem.sort_order, }) - .then(() => { + .then((response) => { + const sourceStateBeforeDrag = states.find((state) => state.name === source.droppableId); + + if ( + sourceStateBeforeDrag?.group !== "completed" && + response?.state_detail?.group === "completed" + ) + trackEventServices.trackIssueMarkedAsDoneEvent({ + workspaceSlug, + workspaceId: draggedItem.workspace_detail.id, + projectName: draggedItem.project_detail.name, + projectIdentifier: draggedItem.project_detail.identifier, + projectId, + issueId: draggedItem.id, + }); + if (cycleId) { mutate(CYCLE_ISSUES_WITH_PARAMS(cycleId as string, params)); mutate(CYCLE_DETAILS(cycleId as string)); @@ -282,6 +298,7 @@ export const IssuesView: React.FC = ({ orderBy, handleDeleteIssue, params, + states, ] ); diff --git a/apps/app/components/issues/view-select/assignee.tsx b/apps/app/components/issues/view-select/assignee.tsx index 6e9c900fd..819b7b696 100644 --- a/apps/app/components/issues/view-select/assignee.tsx +++ b/apps/app/components/issues/view-select/assignee.tsx @@ -6,6 +6,7 @@ import useSWR from "swr"; // services import projectService from "services/project.service"; +import trackEventServices from "services/track-event.service"; // ui import { AssigneesList, Avatar, CustomSearchSelect, Tooltip } from "components/ui"; // icons @@ -71,6 +72,18 @@ export const ViewAssigneeSelect: React.FC = ({ else newData.push(data); partialUpdateIssue({ assignees_list: data }); + + trackEventServices.trackIssuePartialPropertyUpdateEvent( + { + workspaceSlug: issue.workspace_detail.slug, + workspaceId: issue.workspace_detail.id, + projectId: issue.project_detail.id, + projectIdentifier: issue.project_detail.identifier, + projectName: issue.project_detail.name, + issueId: issue.id, + }, + "ISSUE_PROPERTY_UPDATE_ASSIGNEE" + ); }} options={options} label={ diff --git a/apps/app/components/issues/view-select/due-date.tsx b/apps/app/components/issues/view-select/due-date.tsx index f897eaad9..dd6d3302e 100644 --- a/apps/app/components/issues/view-select/due-date.tsx +++ b/apps/app/components/issues/view-select/due-date.tsx @@ -2,6 +2,8 @@ import { CustomDatePicker, Tooltip } from "components/ui"; // helpers import { findHowManyDaysLeft } from "helpers/date-time.helper"; +// services +import trackEventServices from "services/track-event.service"; // types import { IIssue } from "types"; @@ -25,13 +27,24 @@ export const ViewDueDateSelect: React.FC = ({ issue, partialUpdateIssue, + onChange={(val) => { partialUpdateIssue({ target_date: val, priority: issue.priority, state: issue.state, - }) - } + }); + trackEventServices.trackIssuePartialPropertyUpdateEvent( + { + workspaceSlug: issue.workspace_detail.slug, + workspaceId: issue.workspace_detail.id, + projectId: issue.project_detail.id, + projectIdentifier: issue.project_detail.identifier, + projectName: issue.project_detail.name, + issueId: issue.id, + }, + "ISSUE_PROPERTY_UPDATE_DUE_DATE" + ); + }} className={issue?.target_date ? "w-[6.5rem]" : "w-[3rem] text-center"} disabled={isNotAllowed} /> diff --git a/apps/app/components/issues/view-select/priority.tsx b/apps/app/components/issues/view-select/priority.tsx index e5078e71d..47847f658 100644 --- a/apps/app/components/issues/view-select/priority.tsx +++ b/apps/app/components/issues/view-select/priority.tsx @@ -8,6 +8,8 @@ import { getPriorityIcon } from "components/icons/priority-icon"; import { IIssue } from "types"; // constants import { PRIORITIES } from "constants/project"; +// services +import trackEventServices from "services/track-event.service"; type Props = { issue: IIssue; @@ -26,9 +28,20 @@ export const ViewPrioritySelect: React.FC = ({ }) => ( - partialUpdateIssue({ priority: data, state: issue.state, target_date: issue.target_date }) - } + onChange={(data: string) => { + partialUpdateIssue({ priority: data, state: issue.state, target_date: issue.target_date }); + trackEventServices.trackIssuePartialPropertyUpdateEvent( + { + workspaceSlug: issue.workspace_detail.slug, + workspaceId: issue.workspace_detail.id, + projectId: issue.project_detail.id, + projectIdentifier: issue.project_detail.identifier, + projectName: issue.project_detail.name, + issueId: issue.id, + }, + "ISSUE_PROPERTY_UPDATE_PRIORITY" + ); + }} maxHeight="md" customButton={