mirror of
https://github.com/walkxcode/dashboard-icons.git
synced 2025-06-28 15:30:22 +08:00
feat: integrate PostHog for tracking when no icons are found in search
This commit is contained in:
parent
6f51ba60ab
commit
f995c84478
@ -24,6 +24,7 @@ import { useTheme } from "next-themes"
|
|||||||
import Image from "next/image"
|
import Image from "next/image"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { usePathname, useRouter, useSearchParams } from "next/navigation"
|
import { usePathname, useRouter, useSearchParams } from "next/navigation"
|
||||||
|
import posthog from "posthog-js"
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
||||||
|
|
||||||
type SortOption = "relevance" | "alphabetical-asc" | "alphabetical-desc" | "newest"
|
type SortOption = "relevance" | "alphabetical-asc" | "alphabetical-desc" | "newest"
|
||||||
@ -139,6 +140,8 @@ export function IconSearch({ icons }: IconSearchProps) {
|
|||||||
[pathname, router, initialSort],
|
[pathname, router, initialSort],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const handleSearch = useCallback(
|
const handleSearch = useCallback(
|
||||||
(query: string) => {
|
(query: string) => {
|
||||||
setSearchQuery(query)
|
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
|
if (!searchParams) return null
|
||||||
|
|
||||||
const getSortLabel = (sort: SortOption) => {
|
const getSortLabel = (sort: SortOption) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user