
    jKj                        d Z ddlmZ ddlmZmZ ddl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 dd
lmZ 	 	 	 	 	 	 ddZddZy)zMaterialize an ``McpEvent`` against per-server tracking data + resolved
identity, then hand it to the ``McpEventSink`` for the
sanitize/truncate/before_send/capture pipeline.    )annotations)datetimetimezone)Any	CoroutineDictOptional   )MCPAnalyticsEventType)MCPAnalyticsDatalog)McpCaptureOptions)__version__c                ~   | j                   }|y|j                  d      xs | j                  }| j                  j                  |      }|j                  d      xs# t	        j
                  t        j                        }|j                  d      }|H|j                  d      r7t	        j
                  t        j                        |z
  j                         dz  }i d|j                  d      xs dd|d|j                  d      xs t        j                  d	|j                  d	      d|d|d
ddt        d| j                  d| j                  d|j                  d      d|j                  d      d|r|j                  ndd|r|j                  xs i ni d|r|j                   ndd|j                  d      d|j                  d      |j                  d      |j                  d      |j                  d      |j                  d      |j                  d      |j                  d      |j                  d      |j                  d      |j                  d      |j                  d      d 
}t#        | j$                  j&                  | j$                  j(                  !      }|j+                  ||      S )"zEnrich an event with session/identity/server/sdk metadata and return the
    sink's capture coroutine (so the custom-event handle can await it). Auto-capture
    callers schedule it and ignore the result. Returns ``None`` if no sink is attached.N
session_id	timestampdurationi  id 
event_type
event_namesdk_languagePythonsdk_versionserver_nameserver_versionclient_nameclient_versionidentify_actor_given_ididentify_actor_datagroupsresource_nametool_categorytool_descriptionlisted_tool_names
parametersresponseuser_intentuser_intent_sourceis_errorerrorconversation_id
properties)
r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   )enable_exception_autocapturebefore_send)sinkgetr   identified_sessionsr   nowr   utctotal_secondsr   CUSTOMr   r   r   distinct_idr.   r"   r   optionsr/   r0   capture)	dataevent_inputr1   r   actorr   r   
full_eventr9   s	            e/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/posthog/mcp/_capture.pycapture_eventr@      s    99D|.A$//J$$((4E,JX\\0JIz*HKOOK8LL.:IIKdR"kood#)r"j" 	kool3S7L7S7S" 	kool3	"
 	Y" 	H" 	" 	{" 	t''" 	$--" 	{}5" 	+//*:;" 	"5#4#44" 	5 0 0 6Bb" 	%%,,T"  	9!"" 	9#"$ (OO,>?(__-@A!ool3OOJ/"}5)oo.BCOOJ/)&??+<=!ool37"J<  %)\\%N%NLL,,G <<
G,,    c                     t        d       y )NzEWarning: Server tracking data not found. Event will not be published.r    rA   r?   log_capture_skippedrD   L   s    OPrA   N)r;   r   r<   zDict[str, Any]returnz#Optional[Coroutine[Any, Any, None]])rE   None)__doc__
__future__r   r   r   typingr   r   r   r	   _event_typesr   	_internalr   loggerr   _sinkr   versionr   r@   rD   rC   rA   r?   <module>rO      sK   
3 # ' 1 1 / '  $  4-
4-)74-(4-nQrA   