
    j                        U d dl Z d dlZd dlZd dlZd dlmZ d dlmZmZ d dlm	Z	 d dl
mZmZmZmZmZ d dlZd dlmZ d dlmZ d dlmZ d d	lmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& d d
l'm(Z( d dl)m*Z* d dl+m,Z, d dl-m.Z.m/Z/ d dl0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6 d dl7m8Z8m9Z9 d dl:m;Z; d dl<m=Z= d dl>m?Z? d dl@mAZA d dlBmCZCmDZDmEZE d dlFmGZG d dlHmIZI er|d dl
mJZJ d dl
mKZK d dl
mLZL d dl
mMZM d dl
mNZN d dl
mOZO d dl
mPZP d dlQmRZRmSZSmTZTmUZUmVZVmWZW d dl7mXZX d d lYmZZZ d d!l[m\Z\ d d"l]m^Z^ d d#l_m`Z` d d$l-maZambZb d d%lcmdZd d dlmZ d d&lmeZe  ePd'eX(      Zf ed)      Zgd*e5d+e5d,gd-Zhd.eid/<   d>d0Zj	 ekZl G d1 d2      Zo G d3 d4eo      Zp G d5 d6eo      Zqd d7l
mZ er G d8 d9e6eereJf         Zs G d: d;e6eq      Zty d<        Zs d=        Zty# em$ r enZlY `w xY w)?    N)Mapping)datetimetimezone)import_module)TYPE_CHECKINGListDictcastoverload)check_uwsgi_thread_support)MetricsBatcher)SpanBatcher)AnnotatedValue
ContextVarcapture_internal_exceptionscurrent_stacktraceenv_to_boolformat_timestampget_sdk_nameget_type_nameget_default_releasehandle_in_apploggerget_before_send_logget_before_send_metrichas_logs_enabledhas_metrics_enabled)	serialize)trace)has_span_streaming_enabled)BaseHttpTransportmake_transport)SPANDATADEFAULT_MAX_VALUE_LENGTHDEFAULT_OPTIONSINSTRUMENTERVERSIONClientConstructor)_DEFAULT_INTEGRATIONSsetup_integrations)DedupeIntegration)SessionFlusher)Envelope)setup_continuous_profiler)has_profiling_enabledProfilesetup_profiler)EventScrubber)Monitor)Any)Callable)Optional)Sequence)Type)Union)TypeVar)EventHintSDKInfoLogMetricEventDataCategory)Integration)Scope)Session)SpotlightClient)StreamedSpan)	TransportItem
LogBatcher)DsnI)boundclient_init_debugzsentry.pythonzpypi:sentry-sdk)nameversion)rN   rO   packagesr=   SDK_INFOc                     | r)t        | d   t        t        f      s| d   | d   }| dd  } nd }t        |       dkD  rt	        d      t        t              }t        | i |}||j                  d      ||d<   |j                         D ]  \  }}||vrt	        d|      |||<    |d   "t        j                  j                  d      |d<   |d   t               |d<   |d   &t        j                  j                  d	      xs d
|d<   |d   1t        t        j                  j                  d      d      xs d|d<   |d   't        t        d      rt        j                         |d<   |d   t         j"                  |d<   |d   	 t        j$                         }||d<   |d   du r
|d   d|d<   |d   t)        |d   dn|d         |d<   |d   r-t        |d   t*              st-        j.                  d       d |d<   |d   1t        t        j                  j                  d      d      xs d|d<   |d   t1        j2                  dt4        d        |S # t&        $ r d }Y w xY w)!Nr      z+Only single positional argument is expecteddsnzUnknown option 
SENTRY_DSNreleaseenvironmentSENTRY_ENVIRONMENT
productiondebugSENTRY_DEBUGT)strictFserver_namegethostnameinstrumenterproject_rootenable_tracingtraces_sample_rate      ?event_scrubbersend_default_pii)re   socket_optionszxIgnoring socket_options because of unexpected format. See urllib3.HTTPConnection.socket_options for the expected format.
keep_aliveSENTRY_KEEP_ALIVEzVThe `enable_tracing` parameter is deprecated. Please use `traces_sample_rate` instead.   )
stacklevel)
isinstancebytesstrlen	TypeErrordictr%   getitemsosenvironr   r   hasattrsocketr^   r&   SENTRYgetcwd	Exceptionr2   listr   warningwarningswarnDeprecationWarning)argskwargsrT   rvoptionskeyvaluer`   s           j/Users/manta/Documents/Projects/TheRoad-I1/backend/.venv/lib/python3.12/site-packages/sentry_sdk/client.py_get_optionsr   X   s   DGeS\2d1go#AwABx
4y1}EFF	o	BD#F#G
7;;u-5mmo
Ub=38993	 & 
%yJJNN<05		)}+-9	- JJNN+?@PL=	'{!"**.."@NWRW7	- WV]%C"..0=	.!)00>	.!	 99;L *>	
t#+?(@(H#& 	
#,./7R@R=S 
 

Jr2B/CT$J G	
  $	,

':;DIRU 	< 

'd	
 IC  	 L	 s   I I-,I-c                       e Zd ZU dZdZded<   dddZddZddZe	dd	       Z
e	d d
       ZdefdZdefdZd!dZd"dZd#dZd$dZddZerededdfd       Zed%d       Z	 	 	 	 d&dZddZddZd'dZd(dZy))
BaseClientzp
    .. versionadded:: 2.0.0

    The basic definition of a client that is used for sending data to Sentry.
    NzOptional[SpotlightClient]	spotlightreturnc                 v    ||nt         | _        d | _        d | _        d | _        d | _        d | _        i | _        y N)r%   r   	transportmonitorlog_batchermetrics_batcherspan_batcherintegrations)selfr   s     r   __init__zBaseClient.__init__   sC    *G 	 15,037;?5968    c                 
    di iS Nr    r   r   r   s      r   __getstate__zBaseClient.__getstate__   s    2r   c                      y r   r   r   s      r   __setstate__zBaseClient.__setstate__       r   c                      y r   r   r   s    r   rT   zBaseClient.dsn       r   c                      y r   r   r   s    r   
parsed_dsnzBaseClient.parsed_dsn   r   r   c                      y)NFr   r   s    r   should_send_default_piiz"BaseClient.should_send_default_pii   s    r   c                      y)u
        .. versionadded:: 2.0.0

        Returns whether the client is active (able to send data to Sentry)
        Fr   r   s    r   	is_activezBaseClient.is_active   s     r   c                      y r   r   r   s      r   capture_eventzBaseClient.capture_event       r   c                      y r   r   r   logscopes      r   _capture_logzBaseClient._capture_log   r   r   c                      y r   r   r   metricr   s      r   _capture_metriczBaseClient._capture_metric   r   r   c                      y r   r   r   spanr   s      r   _capture_spanzBaseClient._capture_span   r   r   c                      y r   r   r   s      r   capture_sessionzBaseClient.capture_session   r   r   name_or_classOptional[Integration]c                      y r   r   r   r   s     r   get_integrationzBaseClient.get_integration       RUr   c                      y r   r   r   s     r   r   zBaseClient.get_integration       NQr   c                      y r   r   r   s     r   r   zBaseClient.get_integration   s     r   c                      y r   r   r   s      r   closezBaseClient.close   r   r   c                      y r   r   r   s      r   flushzBaseClient.flush   r   r   c                     | S r   r   r   s    r   	__enter__zBaseClient.__enter__       r   c                      y r   r   r   exc_type	exc_valuetbs       r   __exit__zBaseClient.__exit__  r   r   r   )r   zOptional[Dict[str, Any]]r   N)r   r4   r   r4   r   r4   r   r4   r   r4   r   Nr   Optional[str]r   zOptional[Dsn])r   r4   r   r4   r   r   )r   r>   r   rB   r   N)r   r?   r   rB   r   N)r   rE   r   rB   r   Nr   ztype[I]r   zOptional[I])r   zUnion[str, type[Integration]]r   r   )r   r   r   r4   r   r4   r   r4   r   N)__name__
__module____qualname____doc__r   __annotations__r   r   r   propertyrT   r   boolr   r   r   r   r   r   r   r   r   rm   r   r   r   r   r   r   r   r   r   r      s     .2I*1
9     4  	UU9PU 
U	Q 
Q<	 
r   r   c                       e Zd ZdZy)NonRecordingClientz
    .. versionadded:: 2.0.0

    A client that does not send any events to Sentry. This is used as a fallback when the Sentry SDK is not yet initialized.
    N)r   r   r   r   r   r   r   r   r     s     	r   r   c            	           e Zd ZdZd+ fdZd,dZd-dZ	 	 	 	 d.dZd/dZde	fd	Z
de	fd
Zed0d       Zed1d       Z	 	 	 	 	 	 	 	 d2dZddddde	fdZ	 d3ddddddde	fdZddddde	fdZ	 	 	 	 	 	 d4dZ	 	 d5	 	 	 	 	 	 	 d6dZdddeddddfdZd7dZd8dZd9d Z	 	 	 	 d:d!Zered"edd#fd$       Zed;d%       Z	 	 	 	 d<d&Z	 	 d5	 	 	 	 	 d=d'Z	 	 d5	 	 	 	 	 d=d(Zd>d)Z d?d*Z! xZ"S )@_ClientaI  
    The client is internally responsible for capturing the events and
    forwarding them to sentry through the configured transport.  It takes
    the client options as keyword arguments and optionally the DSN as first
    argument.

    Alias of :py:class:`sentry_sdk.Client`. (Was created for better intelisense support)
    r   Nc                 `    t         t        |   t        |i |       | j	                          y )Nr   )superr   r   get_options
_init_impl)r   r   r   	__class__s      r   r   z_Client.__init__  s)    gt%k4.J6.J%Kr   c                     d| j                   iS r   r   r   s    r   r   z_Client.__getstate__  s    4<<((r   c                 8    |d   | _         | j                          y r   )r   r   )r   states     r   r   z_Client.__setstate__   s    Y'r   c                    |D ]b  }d}|d   }|j                  dd      \  }}	 t        |      }t        ||      }t        ||t	        |             t        j                  d|       d y# t        $ r 	 |j                  dd      \  }}t        |      }t        ||      }	t        |	|      }t        |	j                  |         }
t	        |      }|
t        t        fv rt        |      }t        |	||       t        |||	       t        j                  d|       n-# t        $ r!}t        j                  d||       Y d}~nd}~ww xY wY Et        $ r"}t        j                  d||       Y d}~jd}~ww xY w)z
        Instruments the functions given in the list `functions_to_trace` with the `@sentry_sdk.tracing.trace` decorator.
        Nqualified_name.rS   zEnabled tracing for %szWCan not enable tracing for '%s'. (%s) Please check your `functions_to_trace` parameter.)rsplitr   getattrsetattrr   r   rZ   module_not_found_errortype__dict__staticmethodclassmethodry   r{   )r   functions_to_tracefunction
class_namefunction_qualnamemodule_namefunction_name
module_objfunction_obj	class_objfunction_typetraced_functiones                r   _setup_instrumentationz_Client._setup_instrumentation$  sr    +HJ ()9 :):)A)A#q)I&K' +;7
&z=A
M53FG57HI + *  /:.@.@a.H+K!.{!;J '
J ?I#*9m#DL$(););M)J$KM&+L&9O${(CC*6*GI}oFJ
I>LL!9;LM  NNq)   m% sI   AA))	E23B$DE2	E!D=8E2=EE2E2E--E2c                     t         j                  d      }d, fd}	 	 d-dt        ddddd	t        dd f
 fd
}	 t         j	                   j
                  d          t         j
                         _        d  _         j                  r) j
                  d   rt         j                         _        ddl
m}  | j
                         _         j                  N j
                  d   s?d }d j
                  d<   | j
                  d<   | j
                  d<   | j
                  d<   t        |       _        d  _        t!         j
                        rddlm}  |||       _        d  _        t)         j
                        rt+        ||       _        d  _        t/         j
                        rt1        ||       _        d} j
                  d   |vrt3        dj5                  |             j
                  d   j                  dd      rOt7        j8                  d       t:        j<                   j
                  d<   d t>        vrt?        j@                  d        tC         j
                  d!    j
                  d"    j
                  d#    j
                  d$    j
                  %       _"        tG        tI         jD                  jK                                     }|tL        d&<   t7        j8                  d'|       tO         j
                        r	 tQ         j
                         n	 tU         j
                  tL        |)       t         j	                  |        jW                   j
                  j                  d+g               j                  sS j                  sG j&                  s; j,                  s/tO         j
                        stY         j                  tZ              rt]                y y # tR        $ r }	t7        j8                  d(|	       Y d }	~	d }	~	ww xY w# tR        $ r }	t7        j8                  d*|	       Y d }	~	d }	~	ww xY w# t         j	                  |       w xY w).NFr   c                     j                   j                   j                  |        j                  j                  j                  |        y y r   )r   capture_enveloper   )enveloper   s    r   _capture_envelopez-_Client._init_impl.<locals>._capture_envelope[  s@    ~~)//9~~)//9 *r   reasondata_categoryr@   itemzOptional[Item]quantityc                 ^    j                    j                   j                  | |||       y y )N)r  r  r	  r
  )r   record_lost_event)r  r  r	  r
  r   s       r   _record_lost_eventz._Client._init_impl.<locals>._record_lost_eventa  s7     ~~)00!"/%	 1  *r   rZ   enable_backpressure_handlingr   )setup_spotlightrT   c                       y)Nrc   r   )_args_kwargss     r   <lambda>z$_Client._init_impl.<locals>.<lambda>~  s    sr   Tre   error_samplertraces_samplerprofiles_sampler)capture_funcrH   )r  record_lost_func)alwaysneversmallmediummax_request_body_sizez:Invalid value for max_request_body_size. Must be one of {}_experimentsotel_powered_performancezA[OTel] Enabling experimental OTel-powered performance monitoring.r_   zJsentry_sdk.integrations.opentelemetry.integration.OpenTelemetryIntegrationr   default_integrationsauto_enabling_integrationsdisabled_integrations)with_defaultswith_auto_enabling_integrationsr"  r   rN   zSetting SDK name to '%s'zCan not set up profiler. (%s))sdk_infor  z(Can not set up continuous profiler. (%s)r   )r  r-   r   N)NrS   )/_client_init_debugrq   rm   intsetr   r"   r   r   r3   sentry_sdk.spotlightr  r   r,   session_flusherr   r   sentry_sdk._log_batcherrI   r   r   r   r   r    r   
ValueErrorformatr   rZ   r&   OTELr)   appendr*   r   r   rz   keysrQ   r/   r1   ry   r.   r  rk   r!   r   )
r   	old_debugr  r  r  
sample_allrI   r  sdk_namer   s
   `         r   r   z_Client._init_implX  s   &**51		: &*			.	 #	 		
 	b	.""4<<#89+DLL9DNDL~~<< >?#*4>>#:DL =,T\\:DN~~)$,,u2E:
37/00:_-1;-.3=/0#1?P#QD #D->#-!2%7$ 
 $(D "4<<0'5!2%7($
 !%D)$,,7$/!2%7%!
 %K!||34<QQ PWW-  ||N+//0JERW 0</@/@^,`01 *00d !3^,"ll+AB0401 '+ll3J&K!D $D):):)?)?)A$BCH'HVLL3X>$T\\2E"4<<0P-!)%6 ""9-##DLL$4$45I2$NO LL##  $T\\2$..*;< '(	 =/ ! ELL!@!DDE ! PLL!KQOOP ""9-sZ   KQ O3 *Q ,P 3	P<PQ PQ 	Q(Q>Q QQ Q"c                      y)r   Tr   r   s    r   r   z_Client.is_active  s     r   c                 @    | j                   j                  d      xs dS )z
        .. versionadded:: 2.0.0

        Returns whether the client should send default PII (Personally Identifiable Information) data to Sentry.
        re   F)r   rq   r   s    r   r   z_Client.should_send_default_pii  s     || 23<u<r   c                      | j                   d   S )z%Returns the configured DSN as string.rT   r   r   s    r   rT   z_Client.dsn  s     ||E""r   c                 J    | j                   r| j                   j                  S dS )z)Returns the configured parsed DSN object.N)r   r   r   s    r   r   z_Client.parsed_dsn  s     -1NNt~~((DDr   eventr;   hintr<   r   Optional[Scope]c                 L   d }d }|j                  d      &t        j                  t        j                        |d<   |j                  d      dk(  }|t        t        t        t        t        t        f      |j                  dg                   }|j                  ||| j                        }|Q| j                  rD| j                  j                  d|rdnd       |r!| j                  j                  dd|d	z   
       y |}|t        t        t        t        t        t        f      |j                  dg                   z
  }	|j                  dd      }
|rR| j                  F|	dkD  r| j                  j                  dd|	
       |
dkD  r| j                  j                  dd|

       |
|	z   }|dkD  r||z   }|j                   dkD  rN|j                  di       }t#        |t$              s|j                  dg       ng }t        |      |j                   z   }|s}| j                  d   rnd|vrjd|vrfd|vrbt'               5  dt)        | j                  j                  dd      | j                  j                  dt*                    dddgi|d<   d d d        dD ]M  }|j                  |      | j                  |   %t        | j                  |         j-                         ||<   O |j                  d      :t/        t0              }t3        | j4                  j7                               |d<   ||d<   |j                  d      d|d<   t9        || j                  d   | j                  d    | j                  d!         }|"| j                  d"   }|r|j;                  |       ||j<                  r|j                  dg       }t#        |t>              r|D ]  }|j                  d#d       }|j                  d$i       }|s*||j<                  v s9t@        jB                  |v sLt%        |t@        jB                     d%|j<                  |   i      |t@        jB                  <    |!t%        |j                  dg       d%|i      |d<   |#t%        |j                  ddg i      d%|i      |d<   |nt        d&tE        t        d'|      | j                  j                  d(      | j                  j                  d      | j                  j                  d)      *            }| j                  d+   }|||j                  d      dk7  rd }t'               5   |||xs i       }d d d        |ctG        jH                  d,       | j                  r| j                  j                  d+d       |j                  d      rtK        jL                          |}| j                  d-   }|(|%|j                  d      dk(  rd }t        t        t        t        t        t        f      |j                  dg                   }t'               5   |||xs i       }d d d        |`tG        jH                  d.       | j                  r| j                  j                  d+d/       | j                  j                  d+d|d	z   0       nM|t        |j                  dg             z
  }	|	dkD  r*| j                  | j                  j                  d+d|	0       |}|S # 1 sw Y   wxY w# 1 sw Y   xY w# 1 sw Y   xY w)1N	timestampr   transactionspansevent_processorerrorr  r   rS   )r  r
  _dropped_spansr   buffer_overflowbreadcrumbsvaluesattach_stacktrace	exception
stacktracethreadsinclude_local_variablesTmax_value_length)rJ  rK  F)rH  crashedcurrent)rV   rW   r]   distsdkr   platformpythonin_app_excludein_app_includer`   rd   span_iddatarn   r;   Dict[str, Any]r  custom_repr)r  rK  rW  before_sendzbefore send dropped eventbefore_send_transactionz%before send transaction dropped event)r  r  )r  r  r
  )'rq   r   nowr   utcrn   r
   r   r	   rm   objectapply_to_eventr   r   r  pop_n_breadcrumbs_truncatedrk   r   r   r   r$   striprp   rQ   sortedr   r0  r   scrub_event_gen_ai_original_message_countrz   r#   GEN_AI_REQUEST_MESSAGESr   r   infor+   reset_last_seen)r   r8  r9  r   previous_total_spansprevious_total_breadcrumbsis_transactionspans_beforeevent_spans_deltaspan_recorder_dropped_spansdropped_spansrD  rE  r   r%  rd   r>  r   rT  	span_datarX  	new_eventrY  s                           r   _prepare_eventz_Client._prepare_event  s    156:"99[!)!)hll!;E+6*m;tDc6k):$;UYYwPR=STUL))%t||DF ~>>NN44)8F}G 5  &88-*0%1A%5 9 
 E&T$sF{+,eii.DE* K 05yy9I1/M'$.."<?NN44)+ 5  /2NN44)&,!< 5  "={!JMq '3m'C$--1#iir: &k>B  OOHb1  K%"@"@@ +
 015(E)&,.*<8<8H8H$=t9" 261A1A$68P2"	+ (-'+$i  /$ CCyy~%$,,s*;*G c!2399;c
 C 99U#H~H'-d.?.?.D.D.F'GH^$#E%L99Z ( (E*LL)*LL)*LL(	
 !\\*:;N**51!E!E=BYYwPR=SE%&!D"hhy$7G $ 4I#u'K'KK$<<	IFT%h&F&FG"E$H$H$QRG	("B"BC "  ++		'2&0D(EE'N &1#1		-(B823$E-  )51*.,,*:*:;R*S%)\\%5%56H%I $ 0 0 ?	E ll=1#!		&!]2I,.'tzr:	 / 78>>NN44%W 5  99[)%557E"&,,/H"I#/!		&!]2ItDc6k):$;UYYwPR=STUL,.3E4:2F	 / CD>>NN44,M 5  NN44,&,!-!1 5  +Sw1K-LL?t~~'ANN44,F[ 5  EM /.l /.4 /.s%   ;A\ \7\ \
\\#c                     |j                  d      }|y|d   }t        |d         }|d   j                  d|}| j                  d   D ]-  }t	        |t
              r||k(  s||k(  s yt        ||      s- y y)Nexc_infoFr   r   ignore_errorsT)rq   r   r   r   rk   rm   
issubclass)r   r8  r9  rs  r@  error_type_nameerror_full_nameignored_errors           r   _is_ignored_errorz_Client._is_ignored_error  s    88J''4%-a[%;%;_M!\\/:M -- O3}7We]3 ; r   c                     |j                  d      dk(  }|ry|d uxr |j                   }|ry| j                  ||      }|ryy)Nr   r=  TF)rq   _should_capturery  )r   r8  r9  r   ri  ignoring_prevents_recursionignored_by_config_options          r   r{  z_Client._should_capture  sX     6*m;&+4&7&U@U@U<U#&#'#9#9%#F #r   c                 0   | j                   j                  dd       }t        |      rt               5   |||      }d d d        n| j                   d   }	 dk  xr t	        j                         |k\  }|r*| j                  r| j                  j                  dd       yy# 1 sw Y   UxY w# t
        $ r t        j                  d       d}Y [t        $ r? t        |      rdnd\  }}t        j                  d|d	|d
t              d       d}Y w xY w)Nr  sample_raterc   zMThe provided error_sampler raised an error. Defaulting to sampling the event.F)r  returned)r  containszThe provided  z an invalid value of zJ. The value should be a float or a bool. Defaulting to sampling the event.r@  rA  T)r   rq   callabler   random	NameErrorr   r{   ro   reprr   r  )r   r8  r9  r  r  not_in_sample_rate	parameterverbs           r   _should_sample_errorz_Client._should_sample_error  s   
 (($?M",.+E48 /. ,,}5K	'!,s!2!Uv}}+7U0 ~~00g0VK /.  	'NN_ "' 	' M* .0 It
 NNdD$57 "'	's$   
B B,  B), DADDc                 |   d}d}d }|j                  d      xs i j                  d      }|rbd}|D ][  }t        |t              r|j                  xs i }|j                  d      }t        |t              sE|j                  d      du sYd} n |j                  d      }	|j
                  g|j                  d      xs i j                  d	      }
t        |
t              r|
ni }|j                         D ]  \  }}|j                         d
k(  s|} n |j                  |rdnd |	||j                  |xs |z          y )NFrG  rE  T	mechanismhandleduserrequestheadersz
user-agentrL  )statusr  
user_agenterrors)rq   rk   r   r   r   r  rp   rr   lowerupdater  )r   sessionr8  rL  erroredr  
exceptionsr@  r  r  r  headers_dictkvs                 r   _update_session_from_eventz"_Client._update_session_from_event$  s4   
 
ii,277A
G#e^4!KK-2E!IIk2	i1immI6NRW6W"G $ yy %yy+1r66yAG&0$&?7RL$**,1779,!"J -
 	 '9T!>>W%78	 	 	
r   c                    t        |xs d      }| j                  |||      sy|j                  dd      }|j                  d      }|#t	        j
                         j                  x|d<   }| j                  |||      }|y|r|j                  nd}|r| j                  ||       |j                  d      dk(  }|j                  d      dk(  }	|s|	s| j                  ||      sy|j                  d      }
|j                  d	i       j                  d
      xs i }|j                  di       }|d   t        t        j                  t        j                              d}|r||d
<   t!        |      }|rMt#        |t$              r+|j'                  |j)                  || j*                               |j-                  |       n%|	r|j/                  |       n|j1                  |       |
xs dD ]!  }|j3                  |j5                                # d}| j6                  r| j6                  j9                  |       |}| j:                  | j:                  j9                  |       |}|S )a  Captures an event.

        :param event: A ready-made event that can be directly sent to Sentry.

        :param hint: Contains metadata about the event that can be read from `before_send`, such as the original exception object or a HTTP request object.

        :param scope: An optional :py:class:`sentry_sdk.Scope` to apply to events.

        :returns: An event ID. May be `None` if there is no DSN set or of if the SDK decided to discard the event for other reasons. In such situations setting `debug=True` on `init()` may help.
        r   Nprofileevent_idr   r=  check_inattachmentscontextsr   dynamic_sampling_context)r  sent_at)r  )rp   r{  r^  rq   uuiduuid4hexrq  _sessionr  r  r   r   rZ  r   r[  r-   rk   r0   add_profileto_jsonr   add_transactionadd_checkin	add_eventadd_itemto_envelope_itemr   r  r   )r   r8  r9  r   r  r  	event_optr  ri  
is_checkinr  trace_contextr  r  r  
attachmentreturn_values                    r   r   z_Client.capture_eventI  s4     DJB'##E47))It,99Z(+/::<+;+;;E*''tU;	 %*%..t++GU;"v.-?]]6*j8
 --eT:hh}-!j"599'BHb#0#4#45OQS#T  "*-'X\\(BC(

 $7GGG,'7+$$W__Y%MN$$Y/  +y)%++Jj99;< , >>NN++H5#L>>%NN++H5#Lr   	telemetryz*Optional[Union[Log, Metric, StreamedSpan]]tyrB   c                 L   |y |j                  |       d }|dk(  rt        | j                        }n|dk(  rt        | j                        }|	 ||i       }|y d }|dk(  r| j                  }n#|dk(  r| j
                  }n|dk(  r| j                  }||j                  |       y y )Nr   r   r   )apply_to_telemetryr   r   r   r   r   r   add)r   r  r  r   rX  batchers         r   _capture_telemetryz_Client._capture_telemetry  s       +;-dll;K8^0>K"#Ir2I;&&G8^**G6\''GKK	" r   c                 *    | j                  |d|       y )Nr   r  r   s      r   r   z_Client._capture_log  s    UE2r   c                 *    | j                  |d|       y )Nr   r  r   s      r   r   z_Client._capture_metric  s    %8r   c                 *    | j                  |d|       y )Nr   r  r   s      r   r   z_Client._capture_span  s    fe4r   c                 ~    |j                   st        j                  d       y | j                  j	                  |       y )Nz3Discarded session update because of missing release)rV   r   re  r*  add_session)r   r  s     r   r   z_Client.capture_session  s,     KKMN  ,,W5r   r   r   c                      y r   r   r   s     r   r   z_Client.get_integration  r   r   c                      y r   r   r   s     r   r   z_Client.get_integration  r   r   c                     t        |t              r|}n$|j                  |j                  }nt        d      | j                  j                  |      S )zReturns the integration for this client by name or class.
        If the client does not have that integration then `None` is returned.
        zIntegration has no name)rk   rm   
identifierr,  r   rq   )r   r   integration_names      r   r   z_Client.get_integration  sP     mS),%%1,77677  $$%566r   c                    | j                   | j                  ||       | j                  j                          | j                  | j                  j                          | j
                  | j
                  j                          | j                  | j                  j                          | j                  r| j                  j                          | j                   j                          d| _         yy)z
        Close the client and shut down the transport. Arguments have the same
        semantics as :py:meth:`Client.flush`.
        Ntimeoutcallback)r   r   r*  killr   r   r   r   r   r  r  s      r   r   z_Client.close  s     >>%JJwJ:  %%'+  %%'##/$$))+  ,!!&&(||!!#NN!!DN &r   c                    | j                   || j                  d   }| j                  j                          | j                  | j                  j                          | j
                  | j
                  j                          | j                  | j                  j                          | j                   j                  ||       yy)a#  
        Wait for the current events to be sent.

        :param timeout: Wait for at most `timeout` seconds. If no `timeout` is provided, the `shutdown_timeout` option value is used.

        :param callback: Is invoked with the number of pending events and the configured timeout.
        Nshutdown_timeoutr  )r   r   r*  r   r   r   r   r  s      r   r   z_Client.flush  s     >>%,,'9:  &&(+  &&(##/$$**,  ,!!'')NN  8 D &r   c                     | S r   r   r   s    r   r   z_Client.__enter__  r   r   c                 $    | j                          y r   )r   r   s       r   r   z_Client.__exit__  s    

r   r   )r   r4   )r   r4   r   N)r   zSequence[Dict[str, str]]r   N)r   Nr   r   )r8  r;   r9  r<   r   r:  r   zOptional[Event]r   )r  rC   r8  r;   r   N)NN)r8  r;   r9  zOptional[Hint]r   r:  r   r   )r   zOptional[Log]r   rB   r   N)r   zOptional[Metric]r   rB   r   N)r   zOptional[StreamedSpan]r   rB   r   N)r  rC   r   Nr   )r   zUnion[str, Type[Integration]]r   r   )r  zOptional[float]r  z&Optional[Callable[[int, float], None]]r   N)r   r   r   )#r   r   r   r   r   r   r   r  r   r   r   r   r   rT   r   rq  ry  r{  r  r  r   rm   r  r   r   r   r   r   r   r   r   r   r   r   __classcell__)r   s   @r   r   r     sc   )2"<2	2hG)R4 = = # # E ENN N !	N
 
N`w f  2 $(	  !	
 
*-- - 
	-^#
#
 #
 
	#
P "&#'	RR R !	R
 
Rh!#?!# !# 	!#
 
!#F39566 
6 	UU9PU 
U	Q 
Q767 
!7$ &*=A""" ;" 
	"2 &*=AE"E ;E 
	E0r   r   )r   c                       e Zd Zy)r   Nr   r   r   r   r   r   r   r   )      r   r   c                       e Zd Zy)ClientNr  r   r   r   r  r  ,  r  r   r  c                      t         S r   )r   r   r   r   r  r  5  s    <r   c                      t         S r   )r   r   r   r   r  r  6  s    gr   )r   r   r   r4   r   rV  )urs   r  r  rv   collections.abcr   r   r   	importlibr   typingr   r   r	   r
   r   r|   sentry_sdk._compatr   sentry_sdk._metrics_batcherr   sentry_sdk._span_batcherr   sentry_sdk.utilsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   sentry_sdk.serializerr   sentry_sdk.tracingr   sentry_sdk.tracing_utilsr    sentry_sdk.transportr!   r"   sentry_sdk.constsr#   r$   r%   r&   r'   r(   sentry_sdk.integrationsr)   r*   sentry_sdk.integrations.deduper+   sentry_sdk.sessionsr,   sentry_sdk.enveloper-   'sentry_sdk.profiler.continuous_profilerr.   (sentry_sdk.profiler.transaction_profilerr/   r0   r1   sentry_sdk.scrubberr2   sentry_sdk.monitorr3   r4   r5   r6   r7   r8   r9   r:   sentry_sdk._typesr;   r<   r=   r>   r?   r@   rA   sentry_sdk.scoperB   sentry_sdk.sessionrC   r)  rD   sentry_sdk.tracesrE   rF   rG   r+  rI   rJ   rK   r&  rQ   r   r   ModuleNotFoundErrorr   ry   ImportErrorr   r   r   rm   r   r  r   r   r   <module>r     s   	    # ' # < <  9 6 0    " , $ ? B  N < . ( M 
 . &VV3&*4.42:$;'A 34  +@A) K\)0T Tn	 	Nj Nb !'c3h "G  (*K F[  )()s   &F? ?G	G	