chore: posthog event for workspace invite (#2989)

* chore: posthog event for workspace invite

* chore: updated event names, added all the existing events to workspace metrics group

* chore: seperated workspace invite

* fix: workspace invite accept event updated

---------

Co-authored-by: Ramesh Kumar Chandra <rameshkumar2299@gmail.com>
This commit is contained in:
Bavisetti Narayan 2023-12-06 17:15:14 +05:30 committed by sriram veeraghanta
parent 37c03ff239
commit b35874e294
25 changed files with 441 additions and 120 deletions

View file

@ -46,6 +46,7 @@ const UserInvitationsPage: NextPageWithLayout = observer(() => {
const {
workspace: { workspaceSlug },
user: { currentUserSettings },
trackEvent: { postHogEventTracker }
} = useMobxStore();
const router = useRouter();
@ -88,10 +89,18 @@ const UserInvitationsPage: NextPageWithLayout = observer(() => {
workspaceService
.joinWorkspaces({ invitations: invitationsRespond })
.then(() => {
.then((res) => {
mutate("USER_WORKSPACES");
const firstInviteId = invitationsRespond[0];
const redirectWorkspace = invitations?.find((i) => i.id === firstInviteId)?.workspace;
postHogEventTracker(
"MEMBER_ACCEPTED",
{
...res,
state: "SUCCESS",
accepted_from: "App"
}
);
userService
.updateUser({ last_workspace_id: redirectWorkspace?.id })
.then(() => {
@ -147,11 +156,10 @@ const UserInvitationsPage: NextPageWithLayout = observer(() => {
return (
<div
key={invitation.id}
className={`flex cursor-pointer items-center gap-2 border py-5 px-3.5 rounded ${
isSelected
className={`flex cursor-pointer items-center gap-2 border py-5 px-3.5 rounded ${isSelected
? "border-custom-primary-100"
: "border-custom-border-200 hover:bg-custom-background-80"
}`}
}`}
onClick={() => handleInvitation(invitation, isSelected ? "withdraw" : "accepted")}
>
<div className="flex-shrink-0">