mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-04-17 18:32:35 +00:00
Merge branch 'fix-posthog-user-cannot-be-none' into 'develop'
Fix distinct_id cannot be None in posthog Closes #2954 See merge request baserow/baserow!2649
This commit is contained in:
commit
a4eed09b2d
2 changed files with 18 additions and 2 deletions
backend/src/baserow/core
changelog/entries/unreleased/bug
|
@ -1,5 +1,6 @@
|
|||
from copy import deepcopy
|
||||
from typing import Optional
|
||||
from uuid import uuid4
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
|
@ -60,7 +61,15 @@ def capture_user_event(
|
|||
:param workspace: Optionally the workspace related to the event.
|
||||
"""
|
||||
|
||||
properties["user_email"] = getattr(user, "email", None)
|
||||
if user.is_anonymous:
|
||||
# The user_id cannot be None. It's needed by Posthog to identify the user
|
||||
user_id = str(uuid4())
|
||||
user_email = None
|
||||
else:
|
||||
user_id = user.id
|
||||
user_email = user.email
|
||||
|
||||
properties["user_email"] = user_email
|
||||
|
||||
if session is not None:
|
||||
properties["user_session"] = session
|
||||
|
@ -68,7 +77,7 @@ def capture_user_event(
|
|||
if workspace is not None:
|
||||
properties["workspace_id"] = workspace.id
|
||||
|
||||
capture_event(user.id, event, properties)
|
||||
capture_event(user_id, event, properties)
|
||||
|
||||
|
||||
@receiver(action_done)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"type": "bug",
|
||||
"message": "Fix posthog error when user is an AnonymousUser and distinc_id is None.",
|
||||
"issue_number": 2954,
|
||||
"bullet_points": [],
|
||||
"created_at": "2024-09-02"
|
||||
}
|
Loading…
Add table
Reference in a new issue