mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
estimates events added
This commit is contained in:
parent
6c78b98c9c
commit
6cea3f5e94
@ -4,7 +4,7 @@ import { Controller, useForm } from "react-hook-form";
|
|||||||
import { Dialog, Transition } from "@headlessui/react";
|
import { Dialog, Transition } from "@headlessui/react";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
// store hooks
|
// store hooks
|
||||||
import { useEstimate } from "hooks/store";
|
import { useEstimate, useEventTracker } from "hooks/store";
|
||||||
import useToast from "hooks/use-toast";
|
import useToast from "hooks/use-toast";
|
||||||
// ui
|
// ui
|
||||||
import { Button, Input, TextArea } from "@plane/ui";
|
import { Button, Input, TextArea } from "@plane/ui";
|
||||||
@ -12,6 +12,8 @@ import { Button, Input, TextArea } from "@plane/ui";
|
|||||||
import { checkDuplicates } from "helpers/array.helper";
|
import { checkDuplicates } from "helpers/array.helper";
|
||||||
// types
|
// types
|
||||||
import { IEstimate, IEstimateFormData } from "@plane/types";
|
import { IEstimate, IEstimateFormData } from "@plane/types";
|
||||||
|
// constants
|
||||||
|
import { ESTIMATE_CREATED, ESTIMATE_UPDATED } from "constants/event-tracker";
|
||||||
|
|
||||||
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
|
||||||
// toast alert
|
// toast alert
|
||||||
const { setToastAlert } = useToast();
|
const { setToastAlert } = useToast();
|
||||||
@ -60,7 +63,15 @@ 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) => {
|
||||||
|
captureEvent(ESTIMATE_CREATED, {
|
||||||
|
estimate_id: res.id,
|
||||||
|
estimate_points: res.points.map((point) => ({
|
||||||
|
id: point.id,
|
||||||
|
value: point.value,
|
||||||
|
key: point.key,
|
||||||
|
})),
|
||||||
|
});
|
||||||
onClose();
|
onClose();
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@ -83,6 +94,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(() => {
|
||||||
|
captureEvent(ESTIMATE_UPDATED, {
|
||||||
|
estimate_id: data.id,
|
||||||
|
estimate_points: payload.estimate_points
|
||||||
|
});
|
||||||
onClose();
|
onClose();
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
@ -4,12 +4,14 @@ import { Dialog, Transition } from "@headlessui/react";
|
|||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { AlertTriangle } from "lucide-react";
|
import { AlertTriangle } from "lucide-react";
|
||||||
// store hooks
|
// store hooks
|
||||||
import { useEstimate } from "hooks/store";
|
import { useEstimate, useEventTracker } from "hooks/store";
|
||||||
import useToast from "hooks/use-toast";
|
import useToast from "hooks/use-toast";
|
||||||
// types
|
// types
|
||||||
import { IEstimate } from "@plane/types";
|
import { IEstimate } from "@plane/types";
|
||||||
// ui
|
// ui
|
||||||
import { Button } from "@plane/ui";
|
import { Button } from "@plane/ui";
|
||||||
|
// constants
|
||||||
|
import { ESTIMATE_DELETED } from "constants/event-tracker";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
@ -26,6 +28,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();
|
||||||
// toast alert
|
// toast alert
|
||||||
const { setToastAlert } = useToast();
|
const { setToastAlert } = useToast();
|
||||||
|
|
||||||
@ -36,6 +39,9 @@ export const DeleteEstimateModal: React.FC<Props> = observer((props) => {
|
|||||||
|
|
||||||
deleteEstimate(workspaceSlug.toString(), projectId.toString(), estimateId)
|
deleteEstimate(workspaceSlug.toString(), projectId.toString(), estimateId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
captureEvent(ESTIMATE_DELETED, {
|
||||||
|
estimate_id: estimateId,
|
||||||
|
});
|
||||||
setIsDeleteLoading(false);
|
setIsDeleteLoading(false);
|
||||||
handleClose();
|
handleClose();
|
||||||
})
|
})
|
||||||
|
@ -2,7 +2,7 @@ import React from "react";
|
|||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
// hooks
|
// hooks
|
||||||
import { useProject } from "hooks/store";
|
import { useEventTracker, useProject } from "hooks/store";
|
||||||
import useToast from "hooks/use-toast";
|
import useToast from "hooks/use-toast";
|
||||||
// ui
|
// ui
|
||||||
import { Button, CustomMenu } from "@plane/ui";
|
import { Button, CustomMenu } from "@plane/ui";
|
||||||
@ -12,6 +12,8 @@ import { Pencil, Trash2 } from "lucide-react";
|
|||||||
import { orderArrayBy } from "helpers/array.helper";
|
import { orderArrayBy } from "helpers/array.helper";
|
||||||
// types
|
// types
|
||||||
import { IEstimate } from "@plane/types";
|
import { IEstimate } from "@plane/types";
|
||||||
|
// constants
|
||||||
|
import { ESTIMATE_USED } from "constants/event-tracker";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
estimate: IEstimate;
|
estimate: IEstimate;
|
||||||
@ -26,6 +28,7 @@ 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();
|
||||||
// hooks
|
// hooks
|
||||||
const { setToastAlert } = useToast();
|
const { setToastAlert } = useToast();
|
||||||
|
|
||||||
@ -34,16 +37,22 @@ export const EstimateListItem: React.FC<Props> = observer((props) => {
|
|||||||
|
|
||||||
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_USED, {
|
||||||
|
estimate_id: estimate.id,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
const error = err?.error;
|
||||||
|
const errorString = Array.isArray(error) ? error[0] : error;
|
||||||
|
|
||||||
setToastAlert({
|
setToastAlert({
|
||||||
type: "error",
|
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 (
|
||||||
|
@ -3,7 +3,7 @@ import { useRouter } from "next/router";
|
|||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { useTheme } from "next-themes";
|
import { useTheme } from "next-themes";
|
||||||
// store hooks
|
// store hooks
|
||||||
import { useEstimate, useProject, useUser } from "hooks/store";
|
import { useEstimate, useEventTracker, useProject, useUser } from "hooks/store";
|
||||||
import useToast from "hooks/use-toast";
|
import useToast from "hooks/use-toast";
|
||||||
// components
|
// components
|
||||||
import { CreateUpdateEstimateModal, DeleteEstimateModal, EstimateListItem } from "components/estimates";
|
import { CreateUpdateEstimateModal, DeleteEstimateModal, EstimateListItem } from "components/estimates";
|
||||||
@ -16,6 +16,7 @@ import { IEstimate } from "@plane/types";
|
|||||||
import { orderArrayBy } from "helpers/array.helper";
|
import { orderArrayBy } from "helpers/array.helper";
|
||||||
// constants
|
// constants
|
||||||
import { PROJECT_SETTINGS_EMPTY_STATE_DETAILS } from "constants/empty-state";
|
import { PROJECT_SETTINGS_EMPTY_STATE_DETAILS } from "constants/empty-state";
|
||||||
|
import { ESTIMATE_DISABLED } from "constants/event-tracker";
|
||||||
|
|
||||||
export const EstimatesList: React.FC = observer(() => {
|
export const EstimatesList: React.FC = observer(() => {
|
||||||
// states
|
// states
|
||||||
@ -31,6 +32,7 @@ export const EstimatesList: React.FC = observer(() => {
|
|||||||
const { updateProject, currentProjectDetails } = useProject();
|
const { updateProject, currentProjectDetails } = useProject();
|
||||||
const { projectEstimates, getProjectEstimateById } = useEstimate();
|
const { projectEstimates, getProjectEstimateById } = useEstimate();
|
||||||
const { currentUser } = useUser();
|
const { currentUser } = useUser();
|
||||||
|
const { captureEvent } = useEventTracker();
|
||||||
// toast alert
|
// toast alert
|
||||||
const { setToastAlert } = useToast();
|
const { setToastAlert } = useToast();
|
||||||
|
|
||||||
@ -46,16 +48,22 @@ export const EstimatesList: React.FC = observer(() => {
|
|||||||
const disableEstimates = () => {
|
const disableEstimates = () => {
|
||||||
if (!workspaceSlug || !projectId) return;
|
if (!workspaceSlug || !projectId) return;
|
||||||
|
|
||||||
updateProject(workspaceSlug.toString(), projectId.toString(), { estimate: null }).catch((err) => {
|
updateProject(workspaceSlug.toString(), projectId.toString(), { estimate: null })
|
||||||
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;
|
||||||
|
|
||||||
setToastAlert({
|
setToastAlert({
|
||||||
type: "error",
|
type: "error",
|
||||||
title: "Error!",
|
title: "Error!",
|
||||||
message: errorString ?? "Estimate could not be disabled. Please try again",
|
message: errorString ?? "Estimate could not be disabled. Please try again",
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const emptyStateDetail = PROJECT_SETTINGS_EMPTY_STATE_DETAILS["estimate"];
|
const emptyStateDetail = PROJECT_SETTINGS_EMPTY_STATE_DETAILS["estimate"];
|
||||||
|
@ -246,6 +246,12 @@ export const AUTO_ARCHIVE_TOGGLED = "Auto archive toggled";
|
|||||||
export const AUTO_ARCHIVE_UPDATED = "Auto archive updated";
|
export const AUTO_ARCHIVE_UPDATED = "Auto archive updated";
|
||||||
export const AUTO_CLOSE_Toggled = "Auto close toggled";
|
export const AUTO_CLOSE_Toggled = "Auto close toggled";
|
||||||
export const AUTO_CLOSE_UPDATED = "Auto close updated";
|
export const AUTO_CLOSE_UPDATED = "Auto close updated";
|
||||||
|
// 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";
|
||||||
// Project Page Events
|
// Project Page Events
|
||||||
export const PAGE_CREATED = "Page created";
|
export const PAGE_CREATED = "Page created";
|
||||||
export const PAGE_UPDATED = "Page updated";
|
export const PAGE_UPDATED = "Page updated";
|
||||||
|
@ -184,7 +184,7 @@ export class EstimateStore implements IEstimateStore {
|
|||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
set(this.estimateMap, [responseEstimate.id], responseEstimate);
|
set(this.estimateMap, [responseEstimate.id], responseEstimate);
|
||||||
});
|
});
|
||||||
return response.estimate;
|
return responseEstimate;
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user