[WEB-4645]chore: added event trackers for labels #7552

This commit is contained in:
Vamsi Krishna 2025-08-06 22:29:55 +05:30 committed by GitHub
parent c5e5454265
commit 806619d73f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 62 additions and 4 deletions

View file

@ -6,10 +6,11 @@ import { TwitterPicker } from "react-color";
import { Controller, SubmitHandler, useForm } from "react-hook-form";
import { Popover, Transition } from "@headlessui/react";
// plane imports
import { getRandomLabelColor, LABEL_COLOR_OPTIONS } from "@plane/constants";
import { getRandomLabelColor, LABEL_COLOR_OPTIONS, PROJECT_SETTINGS_TRACKER_EVENTS } from "@plane/constants";
import { useTranslation } from "@plane/i18n";
import { IIssueLabel } from "@plane/types";
import { Button, Input, TOAST_TYPE, setToast } from "@plane/ui";
import { captureError, captureSuccess } from "@/helpers/event-tracker.helper";
export type TLabelOperationsCallbacks = {
createLabel: (data: Partial<IIssueLabel>) => Promise<IIssueLabel>;
@ -59,11 +60,25 @@ export const CreateUpdateLabelInline = observer(
await labelOperationsCallbacks
.createLabel(formData)
.then(() => {
.then((res) => {
captureSuccess({
eventName: PROJECT_SETTINGS_TRACKER_EVENTS.label_created,
payload: {
name: res.name,
id: res.id,
},
});
handleClose();
reset(defaultValues);
})
.catch((error) => {
captureError({
eventName: PROJECT_SETTINGS_TRACKER_EVENTS.label_created,
payload: {
name: formData.name,
},
error,
});
setToast({
title: "Error!",
type: TOAST_TYPE.ERROR,
@ -78,11 +93,26 @@ export const CreateUpdateLabelInline = observer(
await labelOperationsCallbacks
.updateLabel(labelToUpdate.id, formData)
.then(() => {
.then((res) => {
captureSuccess({
eventName: PROJECT_SETTINGS_TRACKER_EVENTS.label_updated,
payload: {
name: res.name,
id: res.id,
},
});
reset(defaultValues);
handleClose();
})
.catch((error) => {
captureError({
eventName: PROJECT_SETTINGS_TRACKER_EVENTS.label_updated,
payload: {
name: formData.name,
id: labelToUpdate.id,
},
error,
});
setToast({
title: "Oops!",
type: TOAST_TYPE.ERROR,

View file

@ -9,6 +9,8 @@ import type { IIssueLabel } from "@plane/types";
import { AlertModalCore, TOAST_TYPE, setToast } from "@plane/ui";
// hooks
import { useLabel } from "@/hooks/store";
import { PROJECT_SETTINGS_TRACKER_ELEMENTS, PROJECT_SETTINGS_TRACKER_EVENTS } from "@plane/constants";
import { captureError, captureSuccess } from "@/helpers/event-tracker.helper";
type Props = {
isOpen: boolean;
@ -37,11 +39,27 @@ export const DeleteLabelModal: React.FC<Props> = observer((props) => {
await deleteLabel(workspaceSlug.toString(), projectId.toString(), data.id)
.then(() => {
captureSuccess({
eventName: PROJECT_SETTINGS_TRACKER_EVENTS.label_deleted,
payload: {
name: data.name,
project_id: projectId,
},
});
handleClose();
})
.catch((err) => {
setIsDeleteLoading(false);
captureError({
eventName: PROJECT_SETTINGS_TRACKER_EVENTS.label_deleted,
payload: {
name: data.name,
project_id: projectId,
},
error: err,
});
const error = err?.error || "Label could not be deleted. Please try again.";
setToast({
type: TOAST_TYPE.ERROR,

View file

@ -11,6 +11,8 @@ import { CreateUpdateLabelInline, TLabelOperationsCallbacks } from "./create-upd
import { ICustomMenuItem, LabelItemBlock } from "./label-block/label-item-block";
import { LabelDndHOC } from "./label-drag-n-drop-HOC";
import { ProjectSettingLabelItem } from "./project-setting-label-item";
import { captureClick } from "@/helpers/event-tracker.helper";
import { PROJECT_SETTINGS_TRACKER_ELEMENTS } from "@plane/constants";
type Props = {
label: IIssueLabel;
@ -49,6 +51,9 @@ export const ProjectSettingLabelGroup: React.FC<Props> = observer((props) => {
{
CustomIcon: Pencil,
onClick: () => {
captureClick({
elementName: PROJECT_SETTINGS_TRACKER_ELEMENTS.LABELS_CONTEXT_MENU,
});
setEditLabelForm(true);
setIsUpdating(true);
},
@ -58,7 +63,12 @@ export const ProjectSettingLabelGroup: React.FC<Props> = observer((props) => {
},
{
CustomIcon: Trash2,
onClick: handleLabelDelete,
onClick: () => {
captureClick({
elementName: PROJECT_SETTINGS_TRACKER_ELEMENTS.LABELS_CONTEXT_MENU,
});
handleLabelDelete(label);
},
isVisible: true,
text: "Delete label",
key: "delete_label",