feat: add analytics init, identify, search tracking, consent header, settings toggle

This commit is contained in:
ashim-hq
2026-04-22 19:14:16 +08:00
parent f115275796
commit 6e319efadd
4 changed files with 122 additions and 2 deletions
+13 -1
View File
@@ -1,9 +1,10 @@
import type { CategoryInfo, Tool } from "@ashim/shared";
import { CATEGORIES, TOOLS } from "@ashim/shared";
import { ANALYTICS_EVENTS, CATEGORIES, TOOLS } from "@ashim/shared";
import { Eye, EyeOff, FileImage, LayoutGrid, List, Search } from "lucide-react";
import { useEffect, useMemo, useState } from "react";
import { Link, useNavigate } from "react-router-dom";
import { GemLogo } from "@/components/common/gem-logo";
import { track } from "@/lib/analytics";
import { apiGet } from "@/lib/api";
import { ICON_MAP } from "@/lib/icon-map";
import { cn } from "@/lib/utils";
@@ -51,6 +52,17 @@ export function FullscreenGridPage() {
);
}, [search, visibleTools]);
useEffect(() => {
if (!search) return;
const timer = setTimeout(() => {
track(ANALYTICS_EVENTS.SEARCH, {
query: search,
results_count: filteredTools.length,
});
}, 1000);
return () => clearTimeout(timer);
}, [search, filteredTools.length]);
const groupedTools = useMemo(() => {
const groups = new Map<string, Tool[]>();
for (const tool of filteredTools) {