From 3ba9cddc2ac2808df315365a3d21b2088a655430 Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Wed, 29 Mar 2023 16:15:11 +0530 Subject: [PATCH 1/2] chore: add user id when logging for analytics --- apiserver/plane/api/views/authentication.py | 8 ++++---- apiserver/plane/api/views/oauth.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apiserver/plane/api/views/authentication.py b/apiserver/plane/api/views/authentication.py index f5ec8aa08..13fc2abd8 100644 --- a/apiserver/plane/api/views/authentication.py +++ b/apiserver/plane/api/views/authentication.py @@ -99,7 +99,7 @@ class SignInEndpoint(BaseAPIView): "event_data": { "medium": "email", }, - "user": {"email": email}, + "user": {"email": email, "id": user.id}, "device_ctx": { "ip": request.META.get("REMOTE_ADDR"), "user_agent": request.META.get("HTTP_USER_AGENT"), @@ -150,7 +150,7 @@ class SignInEndpoint(BaseAPIView): "event_data": { "medium": "email", }, - "user": {"email": email}, + "user": {"email": email, "id": user.id}, "device_ctx": { "ip": request.META.get("REMOTE_ADDR"), "user_agent": request.META.get("HTTP_USER_AGENT"), @@ -324,7 +324,7 @@ class MagicSignInEndpoint(BaseAPIView): "event_data": { "medium": "code", }, - "user": {"email": email}, + "user": {"email": email, "id": user.id}, "device_ctx": { "ip": request.META.get("REMOTE_ADDR"), "user_agent": request.META.get( @@ -354,7 +354,7 @@ class MagicSignInEndpoint(BaseAPIView): "event_data": { "medium": "code", }, - "user": {"email": email}, + "user": {"email": email, "id": user.id}, "device_ctx": { "ip": request.META.get("REMOTE_ADDR"), "user_agent": request.META.get( diff --git a/apiserver/plane/api/views/oauth.py b/apiserver/plane/api/views/oauth.py index 13bf15e4d..ff19431c5 100644 --- a/apiserver/plane/api/views/oauth.py +++ b/apiserver/plane/api/views/oauth.py @@ -217,7 +217,7 @@ class OauthEndpoint(BaseAPIView): "event_data": { "medium": f"oauth-{medium}", }, - "user": {"email": email}, + "user": {"email": email, "id": user.id}, "device_ctx": { "ip": request.META.get("REMOTE_ADDR"), "user_agent": request.META.get("HTTP_USER_AGENT"), @@ -285,7 +285,7 @@ class OauthEndpoint(BaseAPIView): "event_data": { "medium": f"oauth-{medium}", }, - "user": {"email": email}, + "user": {"email": email, "id": user.id}, "device_ctx": { "ip": request.META.get("REMOTE_ADDR"), "user_agent": request.META.get("HTTP_USER_AGENT"), From 1255f4756db396c2ba0cc16d00152a1a23a3b60c Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Wed, 29 Mar 2023 16:25:06 +0530 Subject: [PATCH 2/2] fix: uuid serilaizable error --- apiserver/plane/api/views/authentication.py | 12 ++++++------ apiserver/plane/api/views/oauth.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apiserver/plane/api/views/authentication.py b/apiserver/plane/api/views/authentication.py index 13fc2abd8..a63f199ad 100644 --- a/apiserver/plane/api/views/authentication.py +++ b/apiserver/plane/api/views/authentication.py @@ -86,7 +86,7 @@ class SignInEndpoint(BaseAPIView): "user": serialized_user, } - # Send event to Jitsu for tracking + # Send Analytics if settings.ANALYTICS_BASE_API: _ = requests.post( settings.ANALYTICS_BASE_API, @@ -99,7 +99,7 @@ class SignInEndpoint(BaseAPIView): "event_data": { "medium": "email", }, - "user": {"email": email, "id": user.id}, + "user": {"email": email, "id": str(user.id)}, "device_ctx": { "ip": request.META.get("REMOTE_ADDR"), "user_agent": request.META.get("HTTP_USER_AGENT"), @@ -137,7 +137,7 @@ class SignInEndpoint(BaseAPIView): user.save() access_token, refresh_token = get_tokens_for_user(user) - # Send event to Jitsu for tracking + # Send Analytics if settings.ANALYTICS_BASE_API: _ = requests.post( settings.ANALYTICS_BASE_API, @@ -150,7 +150,7 @@ class SignInEndpoint(BaseAPIView): "event_data": { "medium": "email", }, - "user": {"email": email, "id": user.id}, + "user": {"email": email, "id": str(user.id)}, "device_ctx": { "ip": request.META.get("REMOTE_ADDR"), "user_agent": request.META.get("HTTP_USER_AGENT"), @@ -324,7 +324,7 @@ class MagicSignInEndpoint(BaseAPIView): "event_data": { "medium": "code", }, - "user": {"email": email, "id": user.id}, + "user": {"email": email, "id": str(user.id)}, "device_ctx": { "ip": request.META.get("REMOTE_ADDR"), "user_agent": request.META.get( @@ -354,7 +354,7 @@ class MagicSignInEndpoint(BaseAPIView): "event_data": { "medium": "code", }, - "user": {"email": email, "id": user.id}, + "user": {"email": email, "id": str(user.id)}, "device_ctx": { "ip": request.META.get("REMOTE_ADDR"), "user_agent": request.META.get( diff --git a/apiserver/plane/api/views/oauth.py b/apiserver/plane/api/views/oauth.py index ff19431c5..650a8cc96 100644 --- a/apiserver/plane/api/views/oauth.py +++ b/apiserver/plane/api/views/oauth.py @@ -217,7 +217,7 @@ class OauthEndpoint(BaseAPIView): "event_data": { "medium": f"oauth-{medium}", }, - "user": {"email": email, "id": user.id}, + "user": {"email": email, "id": str(user.id)}, "device_ctx": { "ip": request.META.get("REMOTE_ADDR"), "user_agent": request.META.get("HTTP_USER_AGENT"), @@ -285,7 +285,7 @@ class OauthEndpoint(BaseAPIView): "event_data": { "medium": f"oauth-{medium}", }, - "user": {"email": email, "id": user.id}, + "user": {"email": email, "id": str(user.id)}, "device_ctx": { "ip": request.META.get("REMOTE_ADDR"), "user_agent": request.META.get("HTTP_USER_AGENT"),