44import os
55import sys
66from datetime import datetime , timedelta
7- from uuid import UUID
7+ from uuid import UUID , uuid4
88
99from dateutil .tz import tzutc
1010from six import string_types
1111
1212from posthog .consumer import Consumer
13- from posthog .exception_capture import DEFAULT_DISTINCT_ID , ExceptionCapture
13+ from posthog .exception_capture import ExceptionCapture
1414from posthog .exception_utils import exc_info_from_error , exceptions_from_error_tuple , handle_in_app
1515from posthog .feature_flags import InconclusiveMatchError , match_feature_flag_properties
1616from posthog .poller import Poller
@@ -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 ,
@@ -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
@@ -385,7 +392,7 @@ def capture_exception(
385392 self .log .warning ("No exception information available" )
386393 return
387394
388- # Format stack trace like sentry
395+ # Format stack trace for cymbal
389396 all_exceptions_with_trace = exceptions_from_error_tuple (exc_info )
390397
391398 # Add in-app property to frames in the exceptions
0 commit comments