From bcd38357b49dbcbb9346cb6f862de46a1bc363f7 Mon Sep 17 00:00:00 2001 From: LAKHAN BAHETI Date: Tue, 30 Apr 2024 18:37:56 +0530 Subject: [PATCH] project favorite event --- web/components/project/sidebar-list-item.tsx | 7 ++++++- web/constants/event-tracker.ts | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/web/components/project/sidebar-list-item.tsx b/web/components/project/sidebar-list-item.tsx index 0a2d9ffb8..95d94d018 100644 --- a/web/components/project/sidebar-list-item.tsx +++ b/web/components/project/sidebar-list-item.tsx @@ -31,7 +31,7 @@ import { } from "@plane/ui"; import { LeaveProjectModal, ProjectLogo, PublishProjectModal } from "@/components/project"; // constants -import { E_SIDEBAR } from "@/constants/event-tracker"; +import { E_SIDEBAR, PROJECT_FAVORITED, PROJECT_UNFAVORITED } from "@/constants/event-tracker"; import { EUserProjectRoles } from "@/constants/project"; import { cn } from "@/helpers/common.helper"; // hooks @@ -97,6 +97,7 @@ export const ProjectSidebarListItem: React.FC = observer((props) => { const { setTrackElement } = useEventTracker(); const { addProjectToFavorites, removeProjectFromFavorites, getProjectById } = useProject(); const { isMobile } = usePlatformOS(); + const { captureEvent } = useEventTracker(); // states const [leaveProjectModalOpen, setLeaveProjectModal] = useState(false); const [publishModalOpen, setPublishModal] = useState(false); @@ -128,6 +129,7 @@ export const ProjectSidebarListItem: React.FC = observer((props) => { message: () => "Couldn't add the project to favorites. Please try again.", }, }); + addToFavoritePromise.then(() => captureEvent(PROJECT_FAVORITED, { project_id: project.id, element: E_SIDEBAR })); }; const handleRemoveFromFavorites = () => { @@ -145,6 +147,9 @@ export const ProjectSidebarListItem: React.FC = observer((props) => { message: () => "Couldn't remove the project from favorites. Please try again.", }, }); + removeFromFavoritePromise.then(() => + captureEvent(PROJECT_UNFAVORITED, { project_id: project.id, element: E_SIDEBAR }) + ); }; const handleLeaveProject = () => { diff --git a/web/constants/event-tracker.ts b/web/constants/event-tracker.ts index 0c7a6ad33..0d4b0add9 100644 --- a/web/constants/event-tracker.ts +++ b/web/constants/event-tracker.ts @@ -188,6 +188,8 @@ export const WORKSPACE_DELETED = "Workspace deleted"; export const PROJECT_CREATED = "Project created"; export const PROJECT_UPDATED = "Project updated"; export const PROJECT_DELETED = "Project deleted"; +export const PROJECT_FAVORITED = "Project favorited"; +export const PROJECT_UNFAVORITED = "Project unfavorited"; // Cycle Events export const CYCLE_CREATED = "Cycle created"; export const CYCLE_UPDATED = "Cycle updated";