AI Resource Pro / website · airesourcepro.com / src / components / record-tutorial-view.tsx
| 1 | "use client"; |
| 2 | |
| 3 | import { useEffect } from "react"; |
| 4 | import { accountRequest } from "@/lib/account-client"; |
| 5 | import { useUser } from "@/lib/use-user"; |
| 6 | |
| 7 | // Counts a signed-in user's visit to a tutorial (tutorial_activity), part of their usage profile. Renders nothing. |
| 8 | export function RecordTutorialView({ tutorialKey }: { tutorialKey: string }) { |
| 9 | const { user } = useUser(); |
| 10 | const userId = user?.id; |
| 11 | |
| 12 | useEffect(() => { |
| 13 | if (!userId) return; |
| 14 | accountRequest<null>("view", { key: tutorialKey }).then(({ error }) => { |
| 15 | if (error) console.error("Failed to record tutorial view:", error); |
| 16 | }); |
| 17 | }, [userId, tutorialKey]); |
| 18 | |
| 19 | return null; |
| 20 | } |