[WEB-4645]chore: added event trackers for labels #7552
This commit is contained in:
parent
c5e5454265
commit
806619d73f
3 changed files with 62 additions and 4 deletions
|
|
@ -6,10 +6,11 @@ import { TwitterPicker } from "react-color";
|
||||||
import { Controller, SubmitHandler, useForm } from "react-hook-form";
|
import { Controller, SubmitHandler, useForm } from "react-hook-form";
|
||||||
import { Popover, Transition } from "@headlessui/react";
|
import { Popover, Transition } from "@headlessui/react";
|
||||||
// plane imports
|
// 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 { useTranslation } from "@plane/i18n";
|
||||||
import { IIssueLabel } from "@plane/types";
|
import { IIssueLabel } from "@plane/types";
|
||||||
import { Button, Input, TOAST_TYPE, setToast } from "@plane/ui";
|
import { Button, Input, TOAST_TYPE, setToast } from "@plane/ui";
|
||||||
|
import { captureError, captureSuccess } from "@/helpers/event-tracker.helper";
|
||||||
|
|
||||||
export type TLabelOperationsCallbacks = {
|
export type TLabelOperationsCallbacks = {
|
||||||
createLabel: (data: Partial<IIssueLabel>) => Promise<IIssueLabel>;
|
createLabel: (data: Partial<IIssueLabel>) => Promise<IIssueLabel>;
|
||||||
|
|
@ -59,11 +60,25 @@ export const CreateUpdateLabelInline = observer(
|
||||||
|
|
||||||
await labelOperationsCallbacks
|
await labelOperationsCallbacks
|
||||||
.createLabel(formData)
|
.createLabel(formData)
|
||||||
.then(() => {
|
.then((res) => {
|
||||||
|
captureSuccess({
|
||||||
|
eventName: PROJECT_SETTINGS_TRACKER_EVENTS.label_created,
|
||||||
|
payload: {
|
||||||
|
name: res.name,
|
||||||
|
id: res.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
handleClose();
|
handleClose();
|
||||||
reset(defaultValues);
|
reset(defaultValues);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
captureError({
|
||||||
|
eventName: PROJECT_SETTINGS_TRACKER_EVENTS.label_created,
|
||||||
|
payload: {
|
||||||
|
name: formData.name,
|
||||||
|
},
|
||||||
|
error,
|
||||||
|
});
|
||||||
setToast({
|
setToast({
|
||||||
title: "Error!",
|
title: "Error!",
|
||||||
type: TOAST_TYPE.ERROR,
|
type: TOAST_TYPE.ERROR,
|
||||||
|
|
@ -78,11 +93,26 @@ export const CreateUpdateLabelInline = observer(
|
||||||
|
|
||||||
await labelOperationsCallbacks
|
await labelOperationsCallbacks
|
||||||
.updateLabel(labelToUpdate.id, formData)
|
.updateLabel(labelToUpdate.id, formData)
|
||||||
.then(() => {
|
.then((res) => {
|
||||||
|
captureSuccess({
|
||||||
|
eventName: PROJECT_SETTINGS_TRACKER_EVENTS.label_updated,
|
||||||
|
payload: {
|
||||||
|
name: res.name,
|
||||||
|
id: res.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
reset(defaultValues);
|
reset(defaultValues);
|
||||||
handleClose();
|
handleClose();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
captureError({
|
||||||
|
eventName: PROJECT_SETTINGS_TRACKER_EVENTS.label_updated,
|
||||||
|
payload: {
|
||||||
|
name: formData.name,
|
||||||
|
id: labelToUpdate.id,
|
||||||
|
},
|
||||||
|
error,
|
||||||
|
});
|
||||||
setToast({
|
setToast({
|
||||||
title: "Oops!",
|
title: "Oops!",
|
||||||
type: TOAST_TYPE.ERROR,
|
type: TOAST_TYPE.ERROR,
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ import type { IIssueLabel } from "@plane/types";
|
||||||
import { AlertModalCore, TOAST_TYPE, setToast } from "@plane/ui";
|
import { AlertModalCore, TOAST_TYPE, setToast } from "@plane/ui";
|
||||||
// hooks
|
// hooks
|
||||||
import { useLabel } from "@/hooks/store";
|
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 = {
|
type Props = {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
|
|
@ -37,11 +39,27 @@ export const DeleteLabelModal: React.FC<Props> = observer((props) => {
|
||||||
|
|
||||||
await deleteLabel(workspaceSlug.toString(), projectId.toString(), data.id)
|
await deleteLabel(workspaceSlug.toString(), projectId.toString(), data.id)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
captureSuccess({
|
||||||
|
eventName: PROJECT_SETTINGS_TRACKER_EVENTS.label_deleted,
|
||||||
|
payload: {
|
||||||
|
name: data.name,
|
||||||
|
project_id: projectId,
|
||||||
|
},
|
||||||
|
});
|
||||||
handleClose();
|
handleClose();
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
setIsDeleteLoading(false);
|
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.";
|
const error = err?.error || "Label could not be deleted. Please try again.";
|
||||||
setToast({
|
setToast({
|
||||||
type: TOAST_TYPE.ERROR,
|
type: TOAST_TYPE.ERROR,
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ import { CreateUpdateLabelInline, TLabelOperationsCallbacks } from "./create-upd
|
||||||
import { ICustomMenuItem, LabelItemBlock } from "./label-block/label-item-block";
|
import { ICustomMenuItem, LabelItemBlock } from "./label-block/label-item-block";
|
||||||
import { LabelDndHOC } from "./label-drag-n-drop-HOC";
|
import { LabelDndHOC } from "./label-drag-n-drop-HOC";
|
||||||
import { ProjectSettingLabelItem } from "./project-setting-label-item";
|
import { ProjectSettingLabelItem } from "./project-setting-label-item";
|
||||||
|
import { captureClick } from "@/helpers/event-tracker.helper";
|
||||||
|
import { PROJECT_SETTINGS_TRACKER_ELEMENTS } from "@plane/constants";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
label: IIssueLabel;
|
label: IIssueLabel;
|
||||||
|
|
@ -49,6 +51,9 @@ export const ProjectSettingLabelGroup: React.FC<Props> = observer((props) => {
|
||||||
{
|
{
|
||||||
CustomIcon: Pencil,
|
CustomIcon: Pencil,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
|
captureClick({
|
||||||
|
elementName: PROJECT_SETTINGS_TRACKER_ELEMENTS.LABELS_CONTEXT_MENU,
|
||||||
|
});
|
||||||
setEditLabelForm(true);
|
setEditLabelForm(true);
|
||||||
setIsUpdating(true);
|
setIsUpdating(true);
|
||||||
},
|
},
|
||||||
|
|
@ -58,7 +63,12 @@ export const ProjectSettingLabelGroup: React.FC<Props> = observer((props) => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
CustomIcon: Trash2,
|
CustomIcon: Trash2,
|
||||||
onClick: handleLabelDelete,
|
onClick: () => {
|
||||||
|
captureClick({
|
||||||
|
elementName: PROJECT_SETTINGS_TRACKER_ELEMENTS.LABELS_CONTEXT_MENU,
|
||||||
|
});
|
||||||
|
handleLabelDelete(label);
|
||||||
|
},
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
text: "Delete label",
|
text: "Delete label",
|
||||||
key: "delete_label",
|
key: "delete_label",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue