
    Qi                     L    d dl Z d dlZd dlZd dlmZ erd dlmZ  G d d      Zy)    N)TYPE_CHECKING)Clientc                   X    e Zd Z ej                  d      Zd	dZd Zd Zd Z	d Z
d
dZy)ExceptionCaptureposthogc                     || _         t        j                  | _        | j                  t        _        | j
                  t        _        y N)clientsys
excepthookoriginal_excepthookexception_handlerthread_exception_handler	threading)selfr
   s     U/mnt/e/genesis-system/.venv/lib/python3.12/site-packages/posthog/exception_capture.py__init__zExceptionCapture.__init__   s0    #&>> //#<<	    c                 .    | j                   t        _        y r	   )r   r   r   )r   s    r   closezExceptionCapture.close   s    11r   c                 R    | j                  |||f       | j                  |||       y r	   )capture_exceptionr   )r   exc_type	exc_valueexc_tracebacks       r   r   z"ExceptionCapture.exception_handler   s)    )]CD  9mDr   c                 h    | j                  |j                  |j                  |j                  f       y r	   )r   r   r   r   )r   argss     r   r   z)ExceptionCapture.thread_exception_handler"   s%    t~~t?Q?QRSr   c                 \    d|v rd|d   i}nd }| j                  |d   |d   |d   f|       y )Ndistinct_idr         )r   )r   exc_infoextra_propertiesmetadatas       r   exception_receiverz#ExceptionCapture.exception_receiver%   sC    ,,%'7'FGHHXa[(1+FQr   Nc                     	 |r|j                  d      nd }| j                  j                  ||       y # t        $ r(}| j                  j                  d|        Y d }~y d }~ww xY w)Nr   )r   zFailed to capture exception: )getr
   r   	Exceptionlog	exception)r   r*   r$   r   es        r   r   z"ExceptionCapture.capture_exception,   s`    	D9A(,,}5tKKK))))M 	DHH!>qcBCC	Ds   25 	A&A!!A&)r
   r   r	   )__name__
__module____qualname__logging	getLoggerr)   r   r   r   r   r%   r    r   r   r   r      s8     '

I
&C=2E
TRDr   r   )r/   r   r   typingr   posthog.clientr   r   r1   r   r   <module>r4      s%     
   %"D "Dr   