project favorite event

This commit is contained in:
LAKHAN BAHETI 2024-04-30 18:37:56 +05:30
parent aab34ff36d
commit bcd38357b4
2 changed files with 8 additions and 1 deletions

View File

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

View File

@ -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";