Skip to content

Commit 6dbbfc3

Browse files
committed
move distinct_id protection lower
1 parent 9fe0812 commit 6dbbfc3

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

posthog/client.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55
import sys
66
from datetime import datetime, timedelta
7-
from uuid import UUID
7+
from uuid import UUID, uuid4
88

99
from dateutil.tz import tzutc
1010
from six import string_types
@@ -373,6 +373,13 @@ def capture_exception(
373373
# this is important to ensure we don't unexpectedly re-raise exceptions in the user's code.
374374
try:
375375
properties = properties or {}
376+
377+
# if there's no distinct_id, we'll generate one and set personless mode
378+
# via $process_person_profile = false
379+
if distinct_id is None:
380+
properties["$process_person_profile"] = False
381+
distinct_id = uuid4()
382+
376383
require("distinct_id", distinct_id, ID_TYPES)
377384
require("properties", properties, dict)
378385

posthog/exception_capture.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
import sys
33
import threading
4-
import uuid
54
from enum import Enum
65
from typing import TYPE_CHECKING, List, Optional
76

@@ -60,14 +59,6 @@ def exception_receiver(self, exc_info, extra_properties):
6059
def capture_exception(self, exception, metadata=None):
6160
try:
6261
distinct_id = metadata.get("distinct_id") if metadata else None
63-
64-
# if there's no distinct_id, we'll generate one and set personless mode
65-
# via $process_person_profile = false
66-
properties = {}
67-
if distinct_id is None:
68-
properties["$process_person_profile"] = False
69-
distinct_id = uuid.uuid4()
70-
71-
self.client.capture_exception(exception, distinct_id, properties)
62+
self.client.capture_exception(exception, distinct_id)
7263
except Exception as e:
7364
self.log.exception(f"Failed to capture exception: {e}")

0 commit comments

Comments
 (0)