diff --git a/querybook/webapp/hooks/ui/useSurveyTrigger.tsx b/querybook/webapp/hooks/ui/useSurveyTrigger.tsx index 12142ee52..b7c6ece15 100644 --- a/querybook/webapp/hooks/ui/useSurveyTrigger.tsx +++ b/querybook/webapp/hooks/ui/useSurveyTrigger.tsx @@ -7,6 +7,7 @@ import { saveSurveyTriggerRecord, shouldTriggerSurvey, } from 'lib/survey/triggerLogic'; +import { useDebouncedFn } from 'hooks/useDebouncedFn'; export async function triggerSurvey( surface: SurveySurfaceType, @@ -37,7 +38,7 @@ export async function triggerSurvey( export function useSurveyTrigger(endSurveyOnUnmount: boolean = false) { const toastId = useRef(null); - const triggerSurveyHook = React.useCallback( + const triggerSurveyHook = useDebouncedFn( (surface: SurveySurfaceType, surfaceMeta: Record) => { if (toastId.current) { toast.dismiss(toastId.current); @@ -50,6 +51,7 @@ export function useSurveyTrigger(endSurveyOnUnmount: boolean = false) { } ); }, + 500, [] );