From f7a4198865350776afc94b97e380c94e2304e860 Mon Sep 17 00:00:00 2001 From: Lakhan Date: Wed, 5 Jun 2024 13:45:54 +0530 Subject: [PATCH] added project-automation events --- .../automation/auto-archive-automation.tsx | 18 ++++++++++++---- .../automation/auto-close-automation.tsx | 21 +++++++++++++++---- web/constants/event-tracker.ts | 5 +++++ 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/web/components/automation/auto-archive-automation.tsx b/web/components/automation/auto-archive-automation.tsx index 68e3d2938..d9bdde9eb 100644 --- a/web/components/automation/auto-archive-automation.tsx +++ b/web/components/automation/auto-archive-automation.tsx @@ -8,8 +8,10 @@ import { CustomSelect, Loader, ToggleSwitch } from "@plane/ui"; import { SelectMonthModal } from "@/components/automation"; // icon // constants +import { AUTO_ARCHIVE_TOGGLED, AUTO_ARCHIVE_UPDATED } from "constants/event-tracker"; import { EUserProjectRoles, PROJECT_AUTOMATION_MONTHS } from "@/constants/project"; -import { useProject, useUser } from "@/hooks/store"; +// hooks +import { useProject, useUser, useEventTracker } from "@/hooks/store"; // types type Props = { @@ -27,6 +29,7 @@ export const AutoArchiveAutomation: React.FC = observer((props) => { membership: { currentProjectRole }, } = useUser(); const { currentProjectDetails } = useProject(); + const { captureEvent } = useEventTracker(); const isAdmin = currentProjectRole === EUserProjectRoles.ADMIN; @@ -54,11 +57,15 @@ export const AutoArchiveAutomation: React.FC = observer((props) => { + onChange={() => { currentProjectDetails?.archive_in === 0 ? handleChange({ archive_in: 1 }) - : handleChange({ archive_in: 0 }) - } + : handleChange({ archive_in: 0 }); + captureEvent(AUTO_ARCHIVE_TOGGLED, { + toggle: currentProjectDetails?.archive_in === 0 ? "true" : "false", + range: `${currentProjectDetails?.archive_in == 0 ? 1 : 0} month`, + }); + }} size="sm" disabled={!isAdmin} /> @@ -77,6 +84,9 @@ export const AutoArchiveAutomation: React.FC = observer((props) => { }`} onChange={(val: number) => { handleChange({ archive_in: val }); + captureEvent(AUTO_ARCHIVE_UPDATED, { + range: val === 1 ? "1 month" : `${val} months`, + }); }} input disabled={!isAdmin} diff --git a/web/components/automation/auto-close-automation.tsx b/web/components/automation/auto-close-automation.tsx index 875f37f12..b15d43bf6 100644 --- a/web/components/automation/auto-close-automation.tsx +++ b/web/components/automation/auto-close-automation.tsx @@ -5,8 +5,11 @@ import { ArchiveX } from "lucide-react"; import { IProject } from "@plane/types"; import { CustomSelect, CustomSearchSelect, ToggleSwitch, StateGroupIcon, DoubleCircleIcon, Loader } from "@plane/ui"; import { SelectMonthModal } from "@/components/automation"; +// constants +import { AUTO_CLOSE_Toggled, AUTO_CLOSE_UPDATED } from "constants/event-tracker"; import { EUserProjectRoles, PROJECT_AUTOMATION_MONTHS } from "@/constants/project"; -import { useProject, useProjectState, useUser } from "@/hooks/store"; +// hooks +import { useProject, useProjectState, useUser, useEventTracker } from "@/hooks/store"; // component // icons // types @@ -26,6 +29,7 @@ export const AutoCloseAutomation: React.FC = observer((props) => { } = useUser(); const { currentProjectDetails } = useProject(); const { projectStates } = useProjectState(); + const { captureEvent } = useEventTracker(); // const stateGroups = projectStateStore.groupedProjectStates ?? undefined; @@ -80,11 +84,16 @@ export const AutoCloseAutomation: React.FC = observer((props) => { + onChange={() => { currentProjectDetails?.close_in === 0 ? handleChange({ close_in: 1, default_state: defaultState }) - : handleChange({ close_in: 0, default_state: null }) - } + : handleChange({ close_in: 0, default_state: null }); + captureEvent(AUTO_CLOSE_Toggled, { + toggle: currentProjectDetails?.close_in === 0 ? "true" : "false", + range: `${currentProjectDetails?.close_in == 0 ? 1 : 0} month`, + state: currentProjectDetails?.close_in === 0 ? undefined : defaultState, + }); + }} size="sm" disabled={!isAdmin} /> @@ -104,6 +113,10 @@ export const AutoCloseAutomation: React.FC = observer((props) => { }`} onChange={(val: number) => { handleChange({ close_in: val }); + captureEvent(AUTO_CLOSE_UPDATED, { + range: val === 1 ? "1 month" : `${val} months`, + state: currentProjectDetails?.default_state, + }); }} input disabled={!isAdmin} diff --git a/web/constants/event-tracker.ts b/web/constants/event-tracker.ts index bb34ccbd3..a135303ec 100644 --- a/web/constants/event-tracker.ts +++ b/web/constants/event-tracker.ts @@ -186,6 +186,11 @@ export const LABEL_REMOVED_G = "Label removed from group"; export const PAGE_CREATED = "Page created"; export const PAGE_UPDATED = "Page updated"; export const PAGE_DELETED = "Page deleted"; +// Project Automation events +export const AUTO_ARCHIVE_TOGGLED = "Auto archive toggled"; +export const AUTO_ARCHIVE_UPDATED = "Auto archive updated"; +export const AUTO_CLOSE_Toggled = "Auto close toggled"; +export const AUTO_CLOSE_UPDATED = "Auto close updated"; // Member Events export const MEMBER_INVITED = "Member invited"; export const MEMBER_ACCEPTED = "Member accepted";