From ffc987bcc86710b9496e38ad42040f6bacf19d08 Mon Sep 17 00:00:00 2001 From: Lakhan Date: Tue, 4 Jun 2024 14:37:57 +0530 Subject: [PATCH] added project states events --- .../states/create-update-state-inline.tsx | 17 ++++++++--------- .../states/project-setting-state-list-item.tsx | 4 +++- web/constants/event-tracker.ts | 4 ++++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/web/components/states/create-update-state-inline.tsx b/web/components/states/create-update-state-inline.tsx index dc584d5cd..3c8ea152f 100644 --- a/web/components/states/create-update-state-inline.tsx +++ b/web/components/states/create-update-state-inline.tsx @@ -8,7 +8,7 @@ import type { IState } from "@plane/types"; // ui import { Button, CustomSelect, Input, Tooltip, TOAST_TYPE, setToast } from "@plane/ui"; // constants -import { STATE_CREATED, STATE_UPDATED } from "@/constants/event-tracker"; +import { E_STATES, STATE_CREATED, STATE_UPDATED } from "@/constants/event-tracker"; import { GROUP_CHOICES } from "@/constants/project"; // hooks import { useEventTracker, useProjectState } from "@/hooks/store"; @@ -43,7 +43,7 @@ export const CreateUpdateStateInline: React.FC = observer((props) => { // form info const { handleSubmit, - formState: { errors, isSubmitting }, + formState: { errors, isSubmitting, dirtyFields }, watch, reset, control, @@ -91,7 +91,7 @@ export const CreateUpdateStateInline: React.FC = observer((props) => { payload: { ...res, state: "SUCCESS", - element: "Project settings states page", + element: E_STATES, }, }); }) @@ -114,7 +114,7 @@ export const CreateUpdateStateInline: React.FC = observer((props) => { payload: { ...formData, state: "FAILED", - element: "Project settings states page", + element: E_STATES, }, }); }); @@ -130,8 +130,9 @@ export const CreateUpdateStateInline: React.FC = observer((props) => { eventName: STATE_UPDATED, payload: { ...res, + change_details: Object.keys(dirtyFields), state: "SUCCESS", - element: "Project settings states page", + element: E_STATES, }, }); setToast({ @@ -158,7 +159,7 @@ export const CreateUpdateStateInline: React.FC = observer((props) => { payload: { ...formData, state: "FAILED", - element: "Project settings states page", + element: E_STATES, }, }); }); @@ -292,9 +293,7 @@ export const CreateUpdateStateInline: React.FC = observer((props) => { variant="primary" type="submit" loading={isSubmitting} - onClick={() => { - setTrackElement("PROJECT_SETTINGS_STATE_PAGE"); - }} + onClick={() => setTrackElement(E_STATES)} size="sm" > {data ? (isSubmitting ? "Updating" : "Update") : isSubmitting ? "Creating" : "Create"} diff --git a/web/components/states/project-setting-state-list-item.tsx b/web/components/states/project-setting-state-list-item.tsx index 01ac01c0e..d37c85a39 100644 --- a/web/components/states/project-setting-state-list-item.tsx +++ b/web/components/states/project-setting-state-list-item.tsx @@ -7,6 +7,8 @@ import { Pencil, X, ArrowDown, ArrowUp } from "lucide-react"; import { IState } from "@plane/types"; // ui import { Tooltip, StateGroupIcon } from "@plane/ui"; +// constants +import { E_STATES } from "@/constants/event-tracker"; // hooks import { useEventTracker, useProjectState } from "@/hooks/store"; import { usePlatformOS } from "@/hooks/use-platform-os"; @@ -103,7 +105,7 @@ export const StatesListItem: React.FC = observer((props) => { state.default || groupLength === 1 ? "cursor-not-allowed" : "" } grid place-items-center`} onClick={() => { - setTrackElement("PROJECT_SETTINGS_STATE_PAGE"); + setTrackElement(E_STATES); handleDeleteState(); }} disabled={state.default || groupLength === 1} diff --git a/web/constants/event-tracker.ts b/web/constants/event-tracker.ts index 7edfccba5..7b5a5c6ca 100644 --- a/web/constants/event-tracker.ts +++ b/web/constants/event-tracker.ts @@ -138,6 +138,7 @@ export const getProjectStateEventPayload = (payload: any) => ({ default: payload.default, state: payload.state, element: payload.element, + change_details: payload.change_details, }); // Workspace crud Events @@ -222,3 +223,6 @@ export const SNOOZED_NOTIFICATIONS = "Snoozed notifications viewed"; export const ARCHIVED_NOTIFICATIONS = "Archived notifications viewed"; // Groups export const GROUP_WORKSPACE = "Workspace_metrics"; + +// Elements +export const E_STATES = "Project states page"; \ No newline at end of file