fix: Add back analytics for ai gen theme

This commit is contained in:
Sahaj Jain
2025-06-01 00:19:09 +05:30
parent f8b0110c2b
commit cbf3e42b50
+6
View File
@@ -1,10 +1,12 @@
import { toast } from "@/components/ui/use-toast";
import { useAIThemeGenerationStore } from "@/store/ai-theme-generation-store";
import { usePostHog } from "posthog-js/react";
export function useAIThemeGeneration() {
const generateTheme = useAIThemeGenerationStore((state) => state.generateTheme);
const loading = useAIThemeGenerationStore((state) => state.loading);
const cancelThemeGeneration = useAIThemeGenerationStore((state) => state.cancelThemeGeneration);
const posthog = usePostHog();
const handleGenerateTheme = async (prompt: string) => {
try {
@@ -15,6 +17,10 @@ export function useAIThemeGeneration() {
description: "Your AI-generated theme has been applied",
});
posthog.capture("AI_GENERATE_THEME", {
prompt,
});
return result; // Return the result from the store
} catch (error) {
if (error instanceof Error && error.name === "AbortError") {