PostHog event for measuring duration of resolving symbol definitions for hover preview

This commit is contained in:
bkellam 2025-11-30 18:17:07 -08:00
parent c868109ea8
commit a80e92eb3d
2 changed files with 28 additions and 13 deletions

View file

@ -1,7 +1,8 @@
import { findSearchBasedSymbolDefinitions } from "@/app/api/(client)/client";
import { SourceRange } from "@/features/search";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { useDomain } from "@/hooks/useDomain";
import { unwrapServiceError } from "@/lib/utils";
import { measure, unwrapServiceError } from "@/lib/utils";
import { useQuery } from "@tanstack/react-query";
import { ReactCodeMirrorRef } from "@uiw/react-codemirror";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
@ -53,16 +54,26 @@ export const useHoveredOverSymbolInfo = ({
return (symbolElement && symbolElement.textContent) ?? undefined;
}, [symbolElement]);
const captureEvent = useCaptureEvent();
const { data: symbolDefinitions, isLoading: isSymbolDefinitionsLoading } = useQuery({
queryKey: ["definitions", symbolName, revisionName, language, domain, repoName],
queryFn: () => unwrapServiceError(
queryFn: async () => {
const response = await measure(() => unwrapServiceError(
findSearchBasedSymbolDefinitions({
symbolName: symbolName!,
language,
revisionName,
repoName,
})
),
), 'findSearchBasedSymbolDefinitions', false);
captureEvent('wa_find_hovered_over_symbol_definitions', {
durationMs: response.durationMs,
});
return response.data;
},
select: ((data) => {
return data.files.flatMap((file) => {
return file.matches.map((match) => {

View file

@ -302,5 +302,9 @@ export type PosthogEventMap = {
//////////////////////////////////////////////////////////////////
wa_github_star_toast_displayed: {},
wa_github_star_toast_clicked: {},
//////////////////////////////////////////////////////////////////
wa_find_hovered_over_symbol_definitions: {
durationMs: number,
}
}
export type PosthogEvent = keyof PosthogEventMap;