11import { findSearchBasedSymbolDefinitions } from "@/app/api/(client)/client" ;
22import { SourceRange } from "@/features/search" ;
3+ import useCaptureEvent from "@/hooks/useCaptureEvent" ;
34import { useDomain } from "@/hooks/useDomain" ;
4- import { unwrapServiceError } from "@/lib/utils" ;
5+ import { measure , unwrapServiceError } from "@/lib/utils" ;
56import { useQuery } from "@tanstack/react-query" ;
67import { ReactCodeMirrorRef } from "@uiw/react-codemirror" ;
78import { useCallback , useEffect , useMemo , useRef , useState } from "react" ;
@@ -53,16 +54,26 @@ export const useHoveredOverSymbolInfo = ({
5354 return ( symbolElement && symbolElement . textContent ) ?? undefined ;
5455 } , [ symbolElement ] ) ;
5556
57+ const captureEvent = useCaptureEvent ( ) ;
58+
5659 const { data : symbolDefinitions , isLoading : isSymbolDefinitionsLoading } = useQuery ( {
5760 queryKey : [ "definitions" , symbolName , revisionName , language , domain , repoName ] ,
58- queryFn : ( ) => unwrapServiceError (
59- findSearchBasedSymbolDefinitions ( {
60- symbolName : symbolName ! ,
61- language,
62- revisionName,
63- repoName,
64- } )
65- ) ,
61+ queryFn : async ( ) => {
62+ const response = await measure ( ( ) => unwrapServiceError (
63+ findSearchBasedSymbolDefinitions ( {
64+ symbolName : symbolName ! ,
65+ language,
66+ revisionName,
67+ repoName,
68+ } )
69+ ) , 'findSearchBasedSymbolDefinitions' , false ) ;
70+
71+ captureEvent ( 'wa_find_hovered_over_symbol_definitions' , {
72+ durationMs : response . durationMs ,
73+ } ) ;
74+
75+ return response . data ;
76+ } ,
6677 select : ( ( data ) => {
6778 return data . files . flatMap ( ( file ) => {
6879 return file . matches . map ( ( match ) => {
@@ -113,7 +124,7 @@ export const useHoveredOverSymbolInfo = ({
113124
114125 const handleMouseOut = ( ) => {
115126 clearTimers ( ) ;
116-
127+
117128 mouseOutTimerRef . current = setTimeout ( ( ) => {
118129 setIsVisible ( false ) ;
119130 } , SYMBOL_HOVER_POPUP_MOUSE_OUT_TIMEOUT_MS ) ;
@@ -136,13 +147,13 @@ export const useHoveredOverSymbolInfo = ({
136147
137148 const view = editorRef . view ;
138149 const rect = symbolElement . getBoundingClientRect ( ) ;
139-
150+
140151 // Get the start position (left edge, middle vertically)
141152 const startPos = view . posAtCoords ( {
142153 x : rect . left ,
143154 y : rect . top + rect . height / 2 ,
144155 } ) ;
145-
156+
146157 // Get the end position (right edge, middle vertically)
147158 const endPos = view . posAtCoords ( {
148159 x : rect . right ,
@@ -156,7 +167,7 @@ export const useHoveredOverSymbolInfo = ({
156167 // Convert CodeMirror positions to SourceRange format
157168 const startLine = view . state . doc . lineAt ( startPos ) ;
158169 const endLine = view . state . doc . lineAt ( endPos ) ;
159-
170+
160171 const startColumn = startPos - startLine . from + 1 ; // 1-based column
161172 const endColumn = endPos - endLine . from + 1 ; // 1-based column
162173
0 commit comments