mirror of
				https://github.com/walkxcode/dashboard-icons.git
				synced 2025-10-31 16:57:58 +01:00 
			
		
		
		
	feat: integrate PostHog for tracking when no icons are found in search
This commit is contained in:
		| @@ -24,6 +24,7 @@ import { useTheme } from "next-themes" | ||||
| import Image from "next/image" | ||||
| import Link from "next/link" | ||||
| import { usePathname, useRouter, useSearchParams } from "next/navigation" | ||||
| import posthog from "posthog-js" | ||||
| import { useCallback, useEffect, useMemo, useRef, useState } from "react" | ||||
|  | ||||
| type SortOption = "relevance" | "alphabetical-asc" | "alphabetical-desc" | "newest" | ||||
| @@ -139,6 +140,8 @@ export function IconSearch({ icons }: IconSearchProps) { | ||||
| 		[pathname, router, initialSort], | ||||
| 	) | ||||
|  | ||||
| 	 | ||||
|  | ||||
| 	const handleSearch = useCallback( | ||||
| 		(query: string) => { | ||||
| 			setSearchQuery(query) | ||||
| @@ -193,6 +196,14 @@ export function IconSearch({ icons }: IconSearchProps) { | ||||
| 		} | ||||
| 	}, []) | ||||
|  | ||||
| 	useEffect(() => { | ||||
| 		if (filteredIcons.length === 0) { | ||||
| 			posthog.capture("no icons found", { | ||||
| 				query: searchQuery, | ||||
| 			}) | ||||
| 		} | ||||
| 	}, [filteredIcons, searchQuery]) | ||||
|  | ||||
| 	if (!searchParams) return null | ||||
|  | ||||
| 	const getSortLabel = (sort: SortOption) => { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user