Skip to content

Commit 12889e7

Browse files
committed
set personless and use a random value
1 parent 8ae3f2b commit 12889e7

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

posthog/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def page(
362362
def capture_exception(
363363
self,
364364
exception=None,
365-
distinct_id=DEFAULT_DISTINCT_ID,
365+
distinct_id=None,
366366
properties=None,
367367
context=None,
368368
timestamp=None,
@@ -385,7 +385,7 @@ def capture_exception(
385385
self.log.warning("No exception information available")
386386
return
387387

388-
# Format stack trace like sentry
388+
# Format stack trace for cymbal
389389
all_exceptions_with_trace = exceptions_from_error_tuple(exc_info)
390390

391391
# Add in-app property to frames in the exceptions

posthog/exception_capture.py

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

@@ -61,14 +62,16 @@ def exception_receiver(self, exc_info, extra_properties):
6162

6263
def capture_exception(self, exception, metadata=None):
6364
try:
64-
# if hasattr(sys, "ps1"):
65-
# # Disable the excepthook for interactive Python shells
66-
# return
65+
distinct_id = metadata.get("distinct_id") if metadata else None
6766

68-
distinct_id = metadata.get("distinct_id") if metadata else DEFAULT_DISTINCT_ID
69-
# Make sure we have a distinct_id if its empty in metadata
70-
distinct_id = distinct_id or DEFAULT_DISTINCT_ID
67+
# if there's no distinct_id, we'll generate one and set personless mode
68+
# via $process_person_profile = false
69+
properties = {}
70+
if distinct_id is None:
71+
properties["$process_person_profile"] = False
72+
distinct_id = uuid.uuid4()
7173

72-
self.client.capture_exception(exception, distinct_id)
74+
75+
self.client.capture_exception(exception, distinct_id, properties)
7376
except Exception as e:
7477
self.log.exception(f"Failed to capture exception: {e}")

0 commit comments

Comments
 (0)