From 655b5e73ab957b6f9ab4a95fcefb272d34315331 Mon Sep 17 00:00:00 2001 From: NarayanBavisetti Date: Tue, 5 Dec 2023 14:49:24 +0530 Subject: [PATCH] chore: posthog event for workspace invite --- apiserver/plane/app/views/workspace.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/apiserver/plane/app/views/workspace.py b/apiserver/plane/app/views/workspace.py index 108b89f21..f43c941e2 100644 --- a/apiserver/plane/app/views/workspace.py +++ b/apiserver/plane/app/views/workspace.py @@ -73,8 +73,7 @@ from plane.app.permissions import ( ) from plane.bgtasks.workspace_invitation_task import workspace_invitation from plane.utils.issue_filters import issue_filters -from plane.utils.grouper import group_results - +from plane.bgtasks.event_tracking_task import auth_events class WorkSpaceViewSet(BaseViewSet): model = Workspace @@ -408,6 +407,18 @@ class WorkspaceJoinEndpoint(BaseAPIView): # Delete the invitation workspace_invite.delete() + # Send event + if settings.POSTHOG_API_KEY and settings.POSTHOG_HOST: + auth_events.delay( + user=user.id if user is not None else None, + email=email, + user_agent=request.META.get("HTTP_USER_AGENT"), + ip=request.META.get("REMOTE_ADDR"), + event_name="WORKSPACE_INVITE", + medium="EMAIL", + first_time=True if user is not None else False, + ) + return Response( {"message": "Workspace Invitation Accepted"}, status=status.HTTP_200_OK,