chore: updated project member invite events

This commit is contained in:
LAKHAN BAHETI 2024-03-04 13:46:36 +05:30
parent d263335a29
commit 6108f98adb
3 changed files with 36 additions and 18 deletions

View File

@ -11,10 +11,12 @@ import { ConfirmProjectMemberRemove } from "components/project";
import { CustomSelect, Tooltip } from "@plane/ui";
// icons
import { ChevronDown, Dot, XCircle } from "lucide-react";
// helpers
import { getUserRole } from "helpers/user.helper";
// constants
import { ROLE } from "constants/workspace";
import { EUserProjectRoles } from "constants/project";
import { PROJECT_MEMBER_LEAVE } from "constants/event-tracker";
import { PM_ROLE_CHANGED, PROJECT_MEMBER_LEAVE, PROJECT_MEMBER_REMOVED } from "constants/event-tracker";
type Props = {
userId: string;
@ -65,8 +67,17 @@ export const ProjectMemberListItem: React.FC<Props> = observer((props) => {
})
);
} else
await removeMemberFromProject(workspaceSlug.toString(), projectId.toString(), userDetails.member.id).catch(
(err) =>
await removeMemberFromProject(workspaceSlug.toString(), projectId.toString(), userDetails.member.id)
.then(() => {
captureEvent(PROJECT_MEMBER_REMOVED, {
member_id: userDetails.member.id,
role: getUserRole(userDetails.role as number),
removed_by_role : getUserRole(currentProjectRole as number),
state: "SUCCESS",
element: "Project settings members page",
});
})
.catch((err) =>
setToastAlert({
type: "error",
title: "Error",
@ -147,7 +158,16 @@ export const ProjectMemberListItem: React.FC<Props> = observer((props) => {
updateMember(workspaceSlug.toString(), projectId.toString(), userDetails.member.id, {
role: value,
}).catch((err) => {
})
.then(() => {
captureEvent(PM_ROLE_CHANGED, {
member_id: userDetails.member.id,
changed_role: getUserRole(value as number),
state: "SUCCESS",
element: "Project settings members page",
});
})
.catch((err) => {
const error = err.error;
const errorString = Array.isArray(error) ? error[0] : error;

View File

@ -88,12 +88,8 @@ export const SendProjectInvitationModal: React.FC<Props> = observer((props) => {
message: "Members added successfully.",
});
captureEvent(PROJECT_MEMBER_ADDED, {
members: [
...payload.members.map((member) => ({
member_id: member.member_id,
role: ROLE[member.role],
})),
],
member_id: payload.members?.[0]?.member_id,
role: ROLE[payload.members?.[0]?.role],
state: "SUCCESS",
element: "Project settings members page",
});

View File

@ -250,6 +250,8 @@ export const MEMBER_INVITED = "Member invited";
export const MEMBER_ACCEPTED = "Member accepted";
export const PROJECT_MEMBER_ADDED = "Project member added";
export const PROJECT_MEMBER_LEAVE = "Project member leave";
export const PROJECT_MEMBER_REMOVED = "Project member removed";
export const PM_ROLE_CHANGED = "Project member role changed";
export const WORKSPACE_MEMBER_lEAVE = "Workspace member leave";
// Sign-in & Sign-up Events
export const NAVIGATE_TO_SIGNUP = "Navigate to sign-up page";