mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
added project estimates events
This commit is contained in:
parent
be60b25dad
commit
b854e79c51
@ -8,10 +8,12 @@ import { IEstimate, IEstimateFormData } from "@plane/types";
|
|||||||
import { Button, Input, TextArea, TOAST_TYPE, setToast } from "@plane/ui";
|
import { Button, Input, TextArea, TOAST_TYPE, setToast } from "@plane/ui";
|
||||||
// components
|
// components
|
||||||
import { EModalPosition, EModalWidth, ModalCore } from "@/components/core";
|
import { EModalPosition, EModalWidth, ModalCore } from "@/components/core";
|
||||||
|
// constants
|
||||||
|
import { ESTIMATE_CREATED, ESTIMATE_UPDATED } from "constants/event-tracker";
|
||||||
// helpers
|
// helpers
|
||||||
import { checkDuplicates } from "@/helpers/array.helper";
|
import { checkDuplicates } from "@/helpers/array.helper";
|
||||||
// hooks
|
// hooks
|
||||||
import { useEstimate } from "@/hooks/store";
|
import { useEstimate, useEventTracker } from "@/hooks/store";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
@ -39,6 +41,7 @@ export const CreateUpdateEstimateModal: React.FC<Props> = observer((props) => {
|
|||||||
const { workspaceSlug, projectId } = router.query;
|
const { workspaceSlug, projectId } = router.query;
|
||||||
// store hooks
|
// store hooks
|
||||||
const { createEstimate, updateEstimate } = useEstimate();
|
const { createEstimate, updateEstimate } = useEstimate();
|
||||||
|
const { captureEvent } = useEventTracker();
|
||||||
// form info
|
// form info
|
||||||
const {
|
const {
|
||||||
formState: { errors, isSubmitting },
|
formState: { errors, isSubmitting },
|
||||||
@ -58,8 +61,16 @@ export const CreateUpdateEstimateModal: React.FC<Props> = observer((props) => {
|
|||||||
if (!workspaceSlug || !projectId) return;
|
if (!workspaceSlug || !projectId) return;
|
||||||
|
|
||||||
await createEstimate(workspaceSlug.toString(), projectId.toString(), payload)
|
await createEstimate(workspaceSlug.toString(), projectId.toString(), payload)
|
||||||
.then(() => {
|
.then((res) => {
|
||||||
onClose();
|
onClose();
|
||||||
|
captureEvent(ESTIMATE_CREATED, {
|
||||||
|
estimate_id: res.id,
|
||||||
|
estimate_points: res.points.map((point) => ({
|
||||||
|
id: point.id,
|
||||||
|
value: point.value,
|
||||||
|
key: point.key,
|
||||||
|
})),
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
const error = err?.error;
|
const error = err?.error;
|
||||||
@ -82,6 +93,10 @@ export const CreateUpdateEstimateModal: React.FC<Props> = observer((props) => {
|
|||||||
await updateEstimate(workspaceSlug.toString(), projectId.toString(), data.id, payload)
|
await updateEstimate(workspaceSlug.toString(), projectId.toString(), data.id, payload)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
onClose();
|
onClose();
|
||||||
|
captureEvent(ESTIMATE_UPDATED, {
|
||||||
|
estimate_id: data.id,
|
||||||
|
estimate_points: payload.estimate_points
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
const error = err?.error;
|
const error = err?.error;
|
||||||
|
@ -7,8 +7,10 @@ import { IEstimate } from "@plane/types";
|
|||||||
import { TOAST_TYPE, setToast } from "@plane/ui";
|
import { TOAST_TYPE, setToast } from "@plane/ui";
|
||||||
// components
|
// components
|
||||||
import { AlertModalCore } from "@/components/core";
|
import { AlertModalCore } from "@/components/core";
|
||||||
|
// constants
|
||||||
|
import { ESTIMATE_DELETED } from "constants/event-tracker";
|
||||||
// hooks
|
// hooks
|
||||||
import { useEstimate } from "@/hooks/store";
|
import { useEstimate, useEventTracker } from "@/hooks/store";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
@ -25,6 +27,7 @@ export const DeleteEstimateModal: React.FC<Props> = observer((props) => {
|
|||||||
const { workspaceSlug, projectId } = router.query;
|
const { workspaceSlug, projectId } = router.query;
|
||||||
// store hooks
|
// store hooks
|
||||||
const { deleteEstimate } = useEstimate();
|
const { deleteEstimate } = useEstimate();
|
||||||
|
const { captureEvent } = useEventTracker();
|
||||||
|
|
||||||
const handleEstimateDelete = async () => {
|
const handleEstimateDelete = async () => {
|
||||||
if (!workspaceSlug || !projectId) return;
|
if (!workspaceSlug || !projectId) return;
|
||||||
@ -37,6 +40,9 @@ export const DeleteEstimateModal: React.FC<Props> = observer((props) => {
|
|||||||
await deleteEstimate(workspaceSlug.toString(), projectId.toString(), estimateId)
|
await deleteEstimate(workspaceSlug.toString(), projectId.toString(), estimateId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
handleClose();
|
handleClose();
|
||||||
|
captureEvent(ESTIMATE_DELETED, {
|
||||||
|
estimate_id: estimateId,
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
const error = err?.error;
|
const error = err?.error;
|
||||||
|
@ -5,8 +5,12 @@ import { useRouter } from "next/router";
|
|||||||
import { Pencil, Trash2 } from "lucide-react";
|
import { Pencil, Trash2 } from "lucide-react";
|
||||||
import { IEstimate } from "@plane/types";
|
import { IEstimate } from "@plane/types";
|
||||||
import { Button, CustomMenu, TOAST_TYPE, setToast } from "@plane/ui";
|
import { Button, CustomMenu, TOAST_TYPE, setToast } from "@plane/ui";
|
||||||
|
// constants
|
||||||
|
import { ESTIMATE_DISABLED } from "constants/event-tracker";
|
||||||
|
// helpers
|
||||||
import { orderArrayBy } from "@/helpers/array.helper";
|
import { orderArrayBy } from "@/helpers/array.helper";
|
||||||
import { useProject } from "@/hooks/store";
|
// hooks
|
||||||
|
import { useProject, useEventTracker } from "@/hooks/store";
|
||||||
// ui
|
// ui
|
||||||
//icons
|
//icons
|
||||||
// helpers
|
// helpers
|
||||||
@ -25,22 +29,29 @@ export const EstimateListItem: React.FC<Props> = observer((props) => {
|
|||||||
const { workspaceSlug, projectId } = router.query;
|
const { workspaceSlug, projectId } = router.query;
|
||||||
// store hooks
|
// store hooks
|
||||||
const { currentProjectDetails, updateProject } = useProject();
|
const { currentProjectDetails, updateProject } = useProject();
|
||||||
|
const { captureEvent } = useEventTracker();
|
||||||
|
|
||||||
const handleUseEstimate = async () => {
|
const handleUseEstimate = async () => {
|
||||||
if (!workspaceSlug || !projectId) return;
|
if (!workspaceSlug || !projectId) return;
|
||||||
|
|
||||||
await updateProject(workspaceSlug.toString(), projectId.toString(), {
|
await updateProject(workspaceSlug.toString(), projectId.toString(), {
|
||||||
estimate: estimate.id,
|
estimate: estimate.id,
|
||||||
}).catch((err) => {
|
})
|
||||||
const error = err?.error;
|
.then(() =>
|
||||||
const errorString = Array.isArray(error) ? error[0] : error;
|
captureEvent(ESTIMATE_DISABLED, {
|
||||||
|
current_estimate_id: currentProjectDetails?.estimate,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.catch((err) => {
|
||||||
|
const error = err?.error;
|
||||||
|
const errorString = Array.isArray(error) ? error[0] : error;
|
||||||
|
|
||||||
setToast({
|
setToast({
|
||||||
type: TOAST_TYPE.ERROR,
|
type: TOAST_TYPE.ERROR,
|
||||||
title: "Error!",
|
title: "Error!",
|
||||||
message: errorString ?? "Estimate points could not be used. Please try again.",
|
message: errorString ?? "Estimate points could not be used. Please try again.",
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -197,6 +197,12 @@ export const MEMBER_ACCEPTED = "Member accepted";
|
|||||||
export const PROJECT_MEMBER_ADDED = "Project member added";
|
export const PROJECT_MEMBER_ADDED = "Project member added";
|
||||||
export const PROJECT_MEMBER_LEAVE = "Project member leave";
|
export const PROJECT_MEMBER_LEAVE = "Project member leave";
|
||||||
export const WORKSPACE_MEMBER_lEAVE = "Workspace member leave";
|
export const WORKSPACE_MEMBER_lEAVE = "Workspace member leave";
|
||||||
|
// Estimate Events
|
||||||
|
export const ESTIMATE_CREATED = "Estimate created";
|
||||||
|
export const ESTIMATE_UPDATED = "Estimate updated";
|
||||||
|
export const ESTIMATE_DELETED = "Estimate deleted";
|
||||||
|
export const ESTIMATE_USED = "Estimate used";
|
||||||
|
export const ESTIMATE_DISABLED = "Estimate disabled";
|
||||||
// Sign-in & Sign-up Events
|
// Sign-in & Sign-up Events
|
||||||
export const NAVIGATE_TO_SIGNUP = "Navigate to sign-up page";
|
export const NAVIGATE_TO_SIGNUP = "Navigate to sign-up page";
|
||||||
export const NAVIGATE_TO_SIGNIN = "Navigate to sign-in page";
|
export const NAVIGATE_TO_SIGNIN = "Navigate to sign-in page";
|
||||||
|
Loading…
Reference in New Issue
Block a user