Skip to content

Commit 1dfcaca

Browse files
committed
fix: debounce analytics search tracking to capture final query only
The 300ms debounce meant every keystroke was tracked (g, gt, githu, github). Use a separate 1500ms debounce for analytics so only the final query is sent to PostHog. Signed-off-by: Mohammod Al Amin Ashik <maa.ashik00@gmail.com>
1 parent f645d36 commit 1dfcaca

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

apps/desktop/src/features/registry/RegistryPage.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,20 @@ export function RegistryPage() {
8686
const timer = setTimeout(() => {
8787
if (localSearch !== searchQuery) {
8888
search(localSearch);
89-
if (localSearch.trim()) {
90-
capture('registry_search', { query: localSearch.trim() });
91-
}
9289
}
9390
}, 300);
9491
return () => clearTimeout(timer);
9592
}, [localSearch, searchQuery, search]);
9693

94+
// Track search analytics with longer debounce to capture final query only
95+
useEffect(() => {
96+
if (!localSearch.trim()) return;
97+
const timer = setTimeout(() => {
98+
capture('registry_search', { query: localSearch.trim() });
99+
}, 1500);
100+
return () => clearTimeout(timer);
101+
}, [localSearch]);
102+
97103
const handleInstall = async (id: string) => {
98104
const server = servers.find(s => s.id === id);
99105
const serverName = server?.name || 'Server';

0 commit comments

Comments
 (0)