mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: updated project member invite events
This commit is contained in:
parent
d263335a29
commit
6108f98adb
@ -11,10 +11,12 @@ import { ConfirmProjectMemberRemove } from "components/project";
|
|||||||
import { CustomSelect, Tooltip } from "@plane/ui";
|
import { CustomSelect, Tooltip } from "@plane/ui";
|
||||||
// icons
|
// icons
|
||||||
import { ChevronDown, Dot, XCircle } from "lucide-react";
|
import { ChevronDown, Dot, XCircle } from "lucide-react";
|
||||||
|
// helpers
|
||||||
|
import { getUserRole } from "helpers/user.helper";
|
||||||
// constants
|
// constants
|
||||||
import { ROLE } from "constants/workspace";
|
import { ROLE } from "constants/workspace";
|
||||||
import { EUserProjectRoles } from "constants/project";
|
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 = {
|
type Props = {
|
||||||
userId: string;
|
userId: string;
|
||||||
@ -65,14 +67,23 @@ export const ProjectMemberListItem: React.FC<Props> = observer((props) => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else
|
} else
|
||||||
await removeMemberFromProject(workspaceSlug.toString(), projectId.toString(), userDetails.member.id).catch(
|
await removeMemberFromProject(workspaceSlug.toString(), projectId.toString(), userDetails.member.id)
|
||||||
(err) =>
|
.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({
|
setToastAlert({
|
||||||
type: "error",
|
type: "error",
|
||||||
title: "Error",
|
title: "Error",
|
||||||
message: err?.error || "Something went wrong. Please try again.",
|
message: err?.error || "Something went wrong. Please try again.",
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!userDetails) return null;
|
if (!userDetails) return null;
|
||||||
@ -147,16 +158,25 @@ export const ProjectMemberListItem: React.FC<Props> = observer((props) => {
|
|||||||
|
|
||||||
updateMember(workspaceSlug.toString(), projectId.toString(), userDetails.member.id, {
|
updateMember(workspaceSlug.toString(), projectId.toString(), userDetails.member.id, {
|
||||||
role: value,
|
role: value,
|
||||||
}).catch((err) => {
|
})
|
||||||
const error = err.error;
|
.then(() => {
|
||||||
const errorString = Array.isArray(error) ? error[0] : error;
|
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;
|
||||||
|
|
||||||
setToastAlert({
|
setToastAlert({
|
||||||
type: "error",
|
type: "error",
|
||||||
title: "Error!",
|
title: "Error!",
|
||||||
message: errorString ?? "An error occurred while updating member role. Please try again.",
|
message: errorString ?? "An error occurred while updating member role. Please try again.",
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}}
|
}}
|
||||||
disabled={
|
disabled={
|
||||||
userDetails.member.id === currentUser?.id || !currentProjectRole || currentProjectRole < userDetails.role
|
userDetails.member.id === currentUser?.id || !currentProjectRole || currentProjectRole < userDetails.role
|
||||||
|
@ -88,12 +88,8 @@ export const SendProjectInvitationModal: React.FC<Props> = observer((props) => {
|
|||||||
message: "Members added successfully.",
|
message: "Members added successfully.",
|
||||||
});
|
});
|
||||||
captureEvent(PROJECT_MEMBER_ADDED, {
|
captureEvent(PROJECT_MEMBER_ADDED, {
|
||||||
members: [
|
member_id: payload.members?.[0]?.member_id,
|
||||||
...payload.members.map((member) => ({
|
role: ROLE[payload.members?.[0]?.role],
|
||||||
member_id: member.member_id,
|
|
||||||
role: ROLE[member.role],
|
|
||||||
})),
|
|
||||||
],
|
|
||||||
state: "SUCCESS",
|
state: "SUCCESS",
|
||||||
element: "Project settings members page",
|
element: "Project settings members page",
|
||||||
});
|
});
|
||||||
|
@ -250,6 +250,8 @@ export const MEMBER_INVITED = "Member invited";
|
|||||||
export const MEMBER_ACCEPTED = "Member accepted";
|
export const MEMBER_ACCEPTED = "Member accepted";
|
||||||
export const PROJECT_MEMBER_ADDED = "Project member added";
|
export const PROJECT_MEMBER_ADDED = "Project member added";
|
||||||
export const PROJECT_MEMBER_LEAVE = "Project member leave";
|
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";
|
export const WORKSPACE_MEMBER_lEAVE = "Workspace member leave";
|
||||||
// Sign-in & Sign-up Events
|
// Sign-in & Sign-up Events
|
||||||
export const NAVIGATE_TO_SIGNUP = "Navigate to sign-up page";
|
export const NAVIGATE_TO_SIGNUP = "Navigate to sign-up page";
|
||||||
|
Loading…
Reference in New Issue
Block a user