[WEB-4409] refactor: event constants (#7276)
* refactor: event constants * fix: cycle event keys * chore: store extension * chore: update events naming convention --------- Co-authored-by: sriramveeraghanta <veeraghanta.sriram@gmail.com>
This commit is contained in:
parent
e09aeab5b8
commit
4a065e14d0
67 changed files with 553 additions and 513 deletions
|
|
@ -6,7 +6,13 @@ import { useParams } from "next/navigation";
|
|||
import { Controller, useForm } from "react-hook-form";
|
||||
import { CalendarClock, ChevronDown, ChevronRight, Info, Plus, SquareUser, Users } from "lucide-react";
|
||||
import { Disclosure, Transition } from "@headlessui/react";
|
||||
import { MODULE_STATUS, MODULE_LINK_CREATED, MODULE_LINK_DELETED, MODULE_LINK_UPDATED, MODULE_UPDATED, EUserPermissions, EUserPermissionsLevel, EEstimateSystem } from "@plane/constants";
|
||||
import {
|
||||
MODULE_STATUS,
|
||||
EUserPermissions,
|
||||
EUserPermissionsLevel,
|
||||
EEstimateSystem,
|
||||
MODULE_TRACKER_EVENTS,
|
||||
} from "@plane/constants";
|
||||
// plane types
|
||||
import { useTranslation } from "@plane/i18n";
|
||||
import { ILinkDetails, IModule, ModuleLink } from "@plane/types";
|
||||
|
|
@ -74,13 +80,13 @@ export const ModuleAnalyticsSidebar: React.FC<Props> = observer((props) => {
|
|||
updateModuleDetails(workspaceSlug.toString(), projectId.toString(), moduleId.toString(), data)
|
||||
.then((res) => {
|
||||
captureModuleEvent({
|
||||
eventName: MODULE_UPDATED,
|
||||
eventName: MODULE_TRACKER_EVENTS.update,
|
||||
payload: { ...res, changed_properties: Object.keys(data)[0], element: "Right side-peek", state: "SUCCESS" },
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
captureModuleEvent({
|
||||
eventName: MODULE_UPDATED,
|
||||
eventName: MODULE_TRACKER_EVENTS.update,
|
||||
payload: { ...data, state: "FAILED" },
|
||||
});
|
||||
});
|
||||
|
|
@ -92,7 +98,7 @@ export const ModuleAnalyticsSidebar: React.FC<Props> = observer((props) => {
|
|||
const payload = { metadata: {}, ...formData };
|
||||
|
||||
await createModuleLink(workspaceSlug.toString(), projectId.toString(), moduleId.toString(), payload).then(() =>
|
||||
captureEvent(MODULE_LINK_CREATED, {
|
||||
captureEvent(MODULE_TRACKER_EVENTS.link.create, {
|
||||
module_id: moduleId,
|
||||
state: "SUCCESS",
|
||||
})
|
||||
|
|
@ -106,7 +112,7 @@ export const ModuleAnalyticsSidebar: React.FC<Props> = observer((props) => {
|
|||
|
||||
await updateModuleLink(workspaceSlug.toString(), projectId.toString(), moduleId.toString(), linkId, payload).then(
|
||||
() =>
|
||||
captureEvent(MODULE_LINK_UPDATED, {
|
||||
captureEvent(MODULE_TRACKER_EVENTS.link.update, {
|
||||
module_id: moduleId,
|
||||
state: "SUCCESS",
|
||||
})
|
||||
|
|
@ -118,7 +124,7 @@ export const ModuleAnalyticsSidebar: React.FC<Props> = observer((props) => {
|
|||
|
||||
deleteModuleLink(workspaceSlug.toString(), projectId.toString(), moduleId.toString(), linkId)
|
||||
.then(() => {
|
||||
captureEvent(MODULE_LINK_DELETED, {
|
||||
captureEvent(MODULE_TRACKER_EVENTS.link.delete, {
|
||||
module_id: moduleId,
|
||||
state: "SUCCESS",
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import React, { useState } from "react";
|
|||
import { observer } from "mobx-react";
|
||||
import { useParams } from "next/navigation";
|
||||
// types
|
||||
import { PROJECT_ERROR_MESSAGES, MODULE_DELETED } from "@plane/constants";
|
||||
import { MODULE_TRACKER_EVENTS, PROJECT_ERROR_MESSAGES } from "@plane/constants";
|
||||
import { useTranslation } from "@plane/i18n";
|
||||
import type { IModule } from "@plane/types";
|
||||
// ui
|
||||
|
|
@ -52,7 +52,7 @@ export const DeleteModuleModal: React.FC<Props> = observer((props) => {
|
|||
message: "Module deleted successfully.",
|
||||
});
|
||||
captureModuleEvent({
|
||||
eventName: MODULE_DELETED,
|
||||
eventName: MODULE_TRACKER_EVENTS.delete,
|
||||
payload: { ...data, state: "SUCCESS" },
|
||||
});
|
||||
})
|
||||
|
|
@ -67,7 +67,7 @@ export const DeleteModuleModal: React.FC<Props> = observer((props) => {
|
|||
message: currentError.i18n_message && t(currentError.i18n_message),
|
||||
});
|
||||
captureModuleEvent({
|
||||
eventName: MODULE_DELETED,
|
||||
eventName: MODULE_TRACKER_EVENTS.delete,
|
||||
payload: { ...data, state: "FAILED" },
|
||||
});
|
||||
})
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import React, { useEffect, useState } from "react";
|
|||
import { observer } from "mobx-react";
|
||||
import { useForm } from "react-hook-form";
|
||||
// types
|
||||
import { MODULE_CREATED, MODULE_UPDATED } from "@plane/constants";
|
||||
import { MODULE_TRACKER_EVENTS } from "@plane/constants";
|
||||
import type { IModule } from "@plane/types";
|
||||
// ui
|
||||
import { EModalPosition, EModalWidth, ModalCore, TOAST_TYPE, setToast } from "@plane/ui";
|
||||
|
|
@ -64,7 +64,7 @@ export const CreateUpdateModuleModal: React.FC<Props> = observer((props) => {
|
|||
message: "Module created successfully.",
|
||||
});
|
||||
captureModuleEvent({
|
||||
eventName: MODULE_CREATED,
|
||||
eventName: MODULE_TRACKER_EVENTS.create,
|
||||
payload: { ...res, state: "SUCCESS" },
|
||||
});
|
||||
})
|
||||
|
|
@ -75,7 +75,7 @@ export const CreateUpdateModuleModal: React.FC<Props> = observer((props) => {
|
|||
message: err?.detail ?? err?.error ?? "Module could not be created. Please try again.",
|
||||
});
|
||||
captureModuleEvent({
|
||||
eventName: MODULE_CREATED,
|
||||
eventName: MODULE_TRACKER_EVENTS.create,
|
||||
payload: { ...data, state: "FAILED" },
|
||||
});
|
||||
});
|
||||
|
|
@ -95,7 +95,7 @@ export const CreateUpdateModuleModal: React.FC<Props> = observer((props) => {
|
|||
message: "Module updated successfully.",
|
||||
});
|
||||
captureModuleEvent({
|
||||
eventName: MODULE_UPDATED,
|
||||
eventName: MODULE_TRACKER_EVENTS.update,
|
||||
payload: { ...res, changed_properties: Object.keys(dirtyFields || {}), state: "SUCCESS" },
|
||||
});
|
||||
})
|
||||
|
|
@ -106,7 +106,7 @@ export const CreateUpdateModuleModal: React.FC<Props> = observer((props) => {
|
|||
message: err?.detail ?? err?.error ?? "Module could not be updated. Please try again.",
|
||||
});
|
||||
captureModuleEvent({
|
||||
eventName: MODULE_UPDATED,
|
||||
eventName: MODULE_TRACKER_EVENTS.update,
|
||||
payload: { ...data, state: "FAILED" },
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,11 +9,10 @@ import { Info, SquareUser } from "lucide-react";
|
|||
import {
|
||||
MODULE_STATUS,
|
||||
PROGRESS_STATE_GROUPS_DETAILS,
|
||||
MODULE_FAVORITED,
|
||||
MODULE_UNFAVORITED,
|
||||
EUserPermissions,
|
||||
EUserPermissionsLevel,
|
||||
IS_FAVORITE_MENU_OPEN,
|
||||
MODULE_TRACKER_EVENTS,
|
||||
} from "@plane/constants";
|
||||
import { useLocalStorage } from "@plane/hooks";
|
||||
import { IModule } from "@plane/types";
|
||||
|
|
@ -80,7 +79,7 @@ export const ModuleCardItem: React.FC<Props> = observer((props) => {
|
|||
const addToFavoritePromise = addModuleToFavorites(workspaceSlug.toString(), projectId.toString(), moduleId).then(
|
||||
() => {
|
||||
if (!storedValue) toggleFavoriteMenu(true);
|
||||
captureEvent(MODULE_FAVORITED, {
|
||||
captureEvent(MODULE_TRACKER_EVENTS.favorite, {
|
||||
module_id: moduleId,
|
||||
element: "Grid layout",
|
||||
state: "SUCCESS",
|
||||
|
|
@ -111,7 +110,7 @@ export const ModuleCardItem: React.FC<Props> = observer((props) => {
|
|||
projectId.toString(),
|
||||
moduleId
|
||||
).then(() => {
|
||||
captureEvent(MODULE_UNFAVORITED, {
|
||||
captureEvent(MODULE_TRACKER_EVENTS.unfavorite, {
|
||||
module_id: moduleId,
|
||||
element: "Grid layout",
|
||||
state: "SUCCESS",
|
||||
|
|
|
|||
|
|
@ -8,11 +8,10 @@ import { SquareUser } from "lucide-react";
|
|||
// types
|
||||
import {
|
||||
MODULE_STATUS,
|
||||
MODULE_FAVORITED,
|
||||
MODULE_UNFAVORITED,
|
||||
EUserPermissions,
|
||||
EUserPermissionsLevel,
|
||||
IS_FAVORITE_MENU_OPEN,
|
||||
MODULE_TRACKER_EVENTS,
|
||||
} from "@plane/constants";
|
||||
import { useLocalStorage } from "@plane/hooks";
|
||||
import { useTranslation } from "@plane/i18n";
|
||||
|
|
@ -69,7 +68,7 @@ export const ModuleListItemAction: FC<Props> = observer((props) => {
|
|||
() => {
|
||||
// open favorites menu if closed
|
||||
if (!storedValue) toggleFavoriteMenu(true);
|
||||
captureEvent(MODULE_FAVORITED, {
|
||||
captureEvent(MODULE_TRACKER_EVENTS.favorite, {
|
||||
module_id: moduleId,
|
||||
element: "Grid layout",
|
||||
state: "SUCCESS",
|
||||
|
|
@ -100,7 +99,7 @@ export const ModuleListItemAction: FC<Props> = observer((props) => {
|
|||
projectId.toString(),
|
||||
moduleId
|
||||
).then(() => {
|
||||
captureEvent(MODULE_UNFAVORITED, {
|
||||
captureEvent(MODULE_TRACKER_EVENTS.unfavorite, {
|
||||
module_id: moduleId,
|
||||
element: "Grid layout",
|
||||
state: "SUCCESS",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue