From 2f67ca7a5f403a71326500bea0095a22644ab024 Mon Sep 17 00:00:00 2001 From: LAKHAN BAHETI Date: Thu, 2 May 2024 18:16:19 +0530 Subject: [PATCH] chore: views events updated --- web/components/views/quick-actions.tsx | 14 +++++++++++--- web/components/views/view-list-item-action.tsx | 12 +++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/web/components/views/quick-actions.tsx b/web/components/views/quick-actions.tsx index c9993169b..88c92728e 100644 --- a/web/components/views/quick-actions.tsx +++ b/web/components/views/quick-actions.tsx @@ -8,12 +8,13 @@ import { ContextMenu, CustomMenu, TContextMenuItem, TOAST_TYPE, setToast } from // components import { CreateUpdateProjectViewModal, DeleteProjectViewModal } from "@/components/views"; // constants +import { E_VIEWS } from "@/constants/event-tracker"; import { EUserProjectRoles } from "@/constants/project"; // helpers import { cn } from "@/helpers/common.helper"; import { copyUrlToClipboard } from "@/helpers/string.helper"; // hooks -import { useUser } from "@/hooks/store"; +import { useEventTracker, useUser } from "@/hooks/store"; type Props = { parentRef: React.RefObject; @@ -31,6 +32,7 @@ export const ViewQuickActions: React.FC = observer((props) => { const { membership: { currentProjectRole }, } = useUser(); + const { setTrackElement } = useEventTracker(); // auth const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER; @@ -48,7 +50,10 @@ export const ViewQuickActions: React.FC = observer((props) => { const MENU_ITEMS: TContextMenuItem[] = [ { key: "edit", - action: () => setCreateUpdateViewModal(true), + action: () => { + setTrackElement(E_VIEWS); + setCreateUpdateViewModal(true); + }, title: "Edit", icon: Pencil, shouldRender: isEditingAllowed, @@ -67,7 +72,10 @@ export const ViewQuickActions: React.FC = observer((props) => { }, { key: "delete", - action: () => setDeleteViewModal(true), + action: () => { + setTrackElement(E_VIEWS); + setDeleteViewModal(true); + }, title: "Delete", icon: Trash2, shouldRender: isEditingAllowed, diff --git a/web/components/views/view-list-item-action.tsx b/web/components/views/view-list-item-action.tsx index 0c72d0dca..f7b66b783 100644 --- a/web/components/views/view-list-item-action.tsx +++ b/web/components/views/view-list-item-action.tsx @@ -7,11 +7,12 @@ import { IProjectView } from "@plane/types"; import { FavoriteStar } from "@/components/core"; import { DeleteProjectViewModal, CreateUpdateProjectViewModal, ViewQuickActions } from "@/components/views"; // constants +import { E_VIEWS, VIEW_FAVORITED, VIEW_UNFAVORITED } from "@/constants/event-tracker"; import { EUserProjectRoles } from "@/constants/project"; // helpers import { calculateTotalFilters } from "@/helpers/filter.helper"; // hooks -import { useProjectView, useUser } from "@/hooks/store"; +import { useEventTracker, useProjectView, useUser } from "@/hooks/store"; type Props = { parentRef: React.RefObject; @@ -31,6 +32,7 @@ export const ViewListItemAction: FC = observer((props) => { membership: { currentProjectRole }, } = useUser(); const { addViewToFavorites, removeViewFromFavorites } = useProjectView(); + const { captureEvent } = useEventTracker(); // derived values const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER; @@ -42,12 +44,20 @@ export const ViewListItemAction: FC = observer((props) => { if (!workspaceSlug || !projectId) return; addViewToFavorites(workspaceSlug.toString(), projectId.toString(), view.id); + captureEvent(VIEW_FAVORITED, { + view_id: view.id, + element: E_VIEWS, + }); }; const handleRemoveFromFavorites = () => { if (!workspaceSlug || !projectId) return; removeViewFromFavorites(workspaceSlug.toString(), projectId.toString(), view.id); + captureEvent(VIEW_UNFAVORITED, { + view_id: view.id, + element: E_VIEWS, + }); }; return (