File tree Expand file tree Collapse file tree
app/workspace/[workspaceId]/home/hooks Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1360,7 +1360,10 @@ export function useChat(
13601360 const onRequestStartedRef = useRef ( options ?. onRequestStarted )
13611361 onRequestStartedRef . current = options ?. onRequestStarted
13621362
1363- const getCurrentRequestId = useCallback ( ( ) => streamRequestIdRef . current , [ ] )
1363+ const getCurrentRequestId = useCallback ( ( ) => {
1364+ const traceId = streamTraceparentRef . current ?. split ( '-' ) [ 1 ] ?? ''
1365+ return / ^ [ 0 - 9 a - f ] { 32 } $ / . test ( traceId ) ? traceId : undefined
1366+ } , [ ] )
13641367
13651368 const clearQueueDispatchState = useCallback ( ( ) => {
13661369 queueDispatchEpochRef . current ++
Original file line number Diff line number Diff line change @@ -71,13 +71,14 @@ export function captureServerEvent<E extends PostHogEventName>(
7171 const client = getClient ( )
7272 if ( ! client ) return
7373
74- const requestId = getRequestContext ( ) ?. requestId
74+ const contextRequestId = getRequestContext ( ) ?. requestId
75+ const props = properties as Record < string , unknown >
7576 client . capture ( {
7677 distinctId,
7778 event,
7879 properties : {
79- ...( requestId ? { request_id : requestId } : { } ) ,
8080 ...properties ,
81+ ...( contextRequestId && ! ( 'request_id' in props ) ? { request_id : contextRequestId } : { } ) ,
8182 ...( options ?. groups ? { $groups : options . groups } : { } ) ,
8283 ...( options ?. set ? { $set : options . set } : { } ) ,
8384 ...( options ?. setOnce ? { $set_once : options . setOnce } : { } ) ,
You can’t perform that action at this time.
0 commit comments