Spaces:
Running
Running
chore: conflict
Browse files- package.json +1 -0
- pnpm-lock.yaml +41 -0
- src/app/layout.tsx +9 -6
- src/app/providers.tsx +21 -0
- src/components/preview.tsx +5 -0
- src/components/prompt-input.tsx +6 -0
package.json
CHANGED
|
@@ -50,6 +50,7 @@
|
|
| 50 |
"nanoid": "^5.1.5",
|
| 51 |
"next": "15.2.4",
|
| 52 |
"next-themes": "^0.4.4",
|
|
|
|
| 53 |
"react": "^19",
|
| 54 |
"react-day-picker": "8.10.1",
|
| 55 |
"react-dom": "^19",
|
|
|
|
| 50 |
"nanoid": "^5.1.5",
|
| 51 |
"next": "15.2.4",
|
| 52 |
"next-themes": "^0.4.4",
|
| 53 |
+
"posthog-js": "^1.249.2",
|
| 54 |
"react": "^19",
|
| 55 |
"react-day-picker": "8.10.1",
|
| 56 |
"react-dom": "^19",
|
pnpm-lock.yaml
CHANGED
|
@@ -131,6 +131,9 @@ importers:
|
|
| 131 |
next-themes:
|
| 132 |
specifier: ^0.4.4
|
| 133 |
version: 0.4.6([email protected]([email protected]))([email protected])
|
|
|
|
|
|
|
|
|
|
| 134 |
react:
|
| 135 |
specifier: ^19
|
| 136 |
version: 19.1.0
|
|
@@ -1403,6 +1406,9 @@ packages:
|
|
| 1403 |
resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==}
|
| 1404 |
engines: {node: '>= 6'}
|
| 1405 |
|
|
|
|
|
|
|
|
|
|
| 1406 | |
| 1407 |
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
|
| 1408 |
engines: {node: '>= 8'}
|
|
@@ -1524,6 +1530,9 @@ packages:
|
|
| 1524 | |
| 1525 |
resolution: {integrity: sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==}
|
| 1526 |
|
|
|
|
|
|
|
|
|
|
| 1527 | |
| 1528 |
resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==}
|
| 1529 |
engines: {node: '>=8'}
|
|
@@ -1784,6 +1793,20 @@ packages:
|
|
| 1784 |
resolution: {integrity: sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==}
|
| 1785 |
engines: {node: ^10 || ^12 || >=14}
|
| 1786 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1787 | |
| 1788 |
resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}
|
| 1789 |
|
|
@@ -2057,6 +2080,9 @@ packages:
|
|
| 2057 | |
| 2058 |
resolution: {integrity: sha512-PnpQQMuxlwYdocC8fIJqVXvkeViHYzotI+NJrCuav0ZYFoq912ZHBk3mCeuj+5/VpodOjPe1z0Fk2ihgzlXqjQ==}
|
| 2059 |
|
|
|
|
|
|
|
|
|
|
| 2060 | |
| 2061 |
resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==}
|
| 2062 |
engines: {node: '>= 8'}
|
|
@@ -3251,6 +3277,8 @@ snapshots:
|
|
| 3251 |
|
| 3252 | |
| 3253 |
|
|
|
|
|
|
|
| 3254 | |
| 3255 |
dependencies:
|
| 3256 |
path-key: 3.1.1
|
|
@@ -3355,6 +3383,8 @@ snapshots:
|
|
| 3355 |
dependencies:
|
| 3356 |
reusify: 1.1.0
|
| 3357 |
|
|
|
|
|
|
|
| 3358 | |
| 3359 |
dependencies:
|
| 3360 |
to-regex-range: 5.0.1
|
|
@@ -3575,6 +3605,15 @@ snapshots:
|
|
| 3575 |
picocolors: 1.1.1
|
| 3576 |
source-map-js: 1.2.1
|
| 3577 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3578 | |
| 3579 |
dependencies:
|
| 3580 |
loose-envify: 1.4.0
|
|
@@ -3888,6 +3927,8 @@ snapshots:
|
|
| 3888 |
d3-time: 3.1.0
|
| 3889 |
d3-timer: 3.0.1
|
| 3890 |
|
|
|
|
|
|
|
| 3891 | |
| 3892 |
dependencies:
|
| 3893 |
isexe: 2.0.0
|
|
|
|
| 131 |
next-themes:
|
| 132 |
specifier: ^0.4.4
|
| 133 |
version: 0.4.6([email protected]([email protected]))([email protected])
|
| 134 |
+
posthog-js:
|
| 135 |
+
specifier: ^1.249.2
|
| 136 |
+
version: 1.249.2
|
| 137 |
react:
|
| 138 |
specifier: ^19
|
| 139 |
version: 19.1.0
|
|
|
|
| 1406 |
resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==}
|
| 1407 |
engines: {node: '>= 6'}
|
| 1408 |
|
| 1409 | |
| 1410 |
+
resolution: {integrity: sha512-Sz4PP4ZA+Rq4II21qkNqOEDTDrCvcANId3xpIgB34NDkWc3UduWj2dqEtN9yZIq8Dk3HyPI33x9sqqU5C8sr0g==}
|
| 1411 |
+
|
| 1412 | |
| 1413 |
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
|
| 1414 |
engines: {node: '>= 8'}
|
|
|
|
| 1530 | |
| 1531 |
resolution: {integrity: sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==}
|
| 1532 |
|
| 1533 | |
| 1534 |
+
resolution: {integrity: sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA==}
|
| 1535 |
+
|
| 1536 | |
| 1537 |
resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==}
|
| 1538 |
engines: {node: '>=8'}
|
|
|
|
| 1793 |
resolution: {integrity: sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==}
|
| 1794 |
engines: {node: ^10 || ^12 || >=14}
|
| 1795 |
|
| 1796 | |
| 1797 |
+
resolution: {integrity: sha512-OMXCO/IfcJBjYTuebVynMbp8Kq329yKEQSCAnkqLmi8W2Bt5bi7S5xxMwDM3Pm7818Uh0C40XMG3rAtYozId6Q==}
|
| 1798 |
+
peerDependencies:
|
| 1799 |
+
'@rrweb/types': 2.0.0-alpha.17
|
| 1800 |
+
rrweb-snapshot: 2.0.0-alpha.17
|
| 1801 |
+
peerDependenciesMeta:
|
| 1802 |
+
'@rrweb/types':
|
| 1803 |
+
optional: true
|
| 1804 |
+
rrweb-snapshot:
|
| 1805 |
+
optional: true
|
| 1806 |
+
|
| 1807 | |
| 1808 |
+
resolution: {integrity: sha512-1nMfdFjucm5hKvq0IClqZwK4FJkGXhRrQstOQ3P4vp8HxKrJEMFcY6RdBRVTdfQS/UlnX6gfbPuTvaqx/bDoeQ==}
|
| 1809 |
+
|
| 1810 | |
| 1811 |
resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}
|
| 1812 |
|
|
|
|
| 2080 | |
| 2081 |
resolution: {integrity: sha512-PnpQQMuxlwYdocC8fIJqVXvkeViHYzotI+NJrCuav0ZYFoq912ZHBk3mCeuj+5/VpodOjPe1z0Fk2ihgzlXqjQ==}
|
| 2082 |
|
| 2083 | |
| 2084 |
+
resolution: {integrity: sha512-r4DIlprAGwJ7YM11VZp4R884m0Vmgr6EAKe3P+kO0PPj3Unqyvv59rczf6UiGcb9Z8QxZVcqKNwv/g0WNdWwsw==}
|
| 2085 |
+
|
| 2086 | |
| 2087 |
resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==}
|
| 2088 |
engines: {node: '>= 8'}
|
|
|
|
| 3277 |
|
| 3278 | |
| 3279 |
|
| 3280 |
+
[email protected]: {}
|
| 3281 |
+
|
| 3282 | |
| 3283 |
dependencies:
|
| 3284 |
path-key: 3.1.1
|
|
|
|
| 3383 |
dependencies:
|
| 3384 |
reusify: 1.1.0
|
| 3385 |
|
| 3386 |
+
[email protected]: {}
|
| 3387 |
+
|
| 3388 | |
| 3389 |
dependencies:
|
| 3390 |
to-regex-range: 5.0.1
|
|
|
|
| 3605 |
picocolors: 1.1.1
|
| 3606 |
source-map-js: 1.2.1
|
| 3607 |
|
| 3608 | |
| 3609 |
+
dependencies:
|
| 3610 |
+
core-js: 3.42.0
|
| 3611 |
+
fflate: 0.4.8
|
| 3612 |
+
preact: 10.26.8
|
| 3613 |
+
web-vitals: 4.2.4
|
| 3614 |
+
|
| 3615 |
+
[email protected]: {}
|
| 3616 |
+
|
| 3617 | |
| 3618 |
dependencies:
|
| 3619 |
loose-envify: 1.4.0
|
|
|
|
| 3927 |
d3-time: 3.1.0
|
| 3928 |
d3-timer: 3.0.1
|
| 3929 |
|
| 3930 |
+
[email protected]: {}
|
| 3931 |
+
|
| 3932 | |
| 3933 |
dependencies:
|
| 3934 |
isexe: 2.0.0
|
src/app/layout.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import { ThemeProvider } from "@/components/theme-provider"
|
|
| 6 |
import { TooltipProvider } from "@/components/ui/tooltip"
|
| 7 |
import { Toaster } from "sonner"
|
| 8 |
import { ModelProvider } from "@/lib/contexts/model-context"
|
|
|
|
| 9 |
|
| 10 |
const inter = Inter({ subsets: ["latin"] })
|
| 11 |
|
|
@@ -22,12 +23,14 @@ export default function RootLayout({
|
|
| 22 |
return (
|
| 23 |
<html lang="en" suppressHydrationWarning>
|
| 24 |
<body className={inter.className} suppressHydrationWarning>
|
| 25 |
-
<
|
| 26 |
-
<
|
| 27 |
-
<
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
</body>
|
| 32 |
</html>
|
| 33 |
)
|
|
|
|
| 6 |
import { TooltipProvider } from "@/components/ui/tooltip"
|
| 7 |
import { Toaster } from "sonner"
|
| 8 |
import { ModelProvider } from "@/lib/contexts/model-context"
|
| 9 |
+
import { PostHogProvider } from './providers'
|
| 10 |
|
| 11 |
const inter = Inter({ subsets: ["latin"] })
|
| 12 |
|
|
|
|
| 23 |
return (
|
| 24 |
<html lang="en" suppressHydrationWarning>
|
| 25 |
<body className={inter.className} suppressHydrationWarning>
|
| 26 |
+
<PostHogProvider>
|
| 27 |
+
<ThemeProvider attribute="class" defaultTheme="dark" enableSystem disableTransitionOnChange>
|
| 28 |
+
<ModelProvider>
|
| 29 |
+
<TooltipProvider>{children}</TooltipProvider>
|
| 30 |
+
<Toaster richColors />
|
| 31 |
+
</ModelProvider>
|
| 32 |
+
</ThemeProvider>
|
| 33 |
+
</PostHogProvider>
|
| 34 |
</body>
|
| 35 |
</html>
|
| 36 |
)
|
src/app/providers.tsx
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// app/providers.tsx
|
| 2 |
+
'use client'
|
| 3 |
+
|
| 4 |
+
import posthog from 'posthog-js'
|
| 5 |
+
import { PostHogProvider as PHProvider } from 'posthog-js/react'
|
| 6 |
+
import { useEffect } from 'react'
|
| 7 |
+
|
| 8 |
+
export function PostHogProvider({ children }: { children: React.ReactNode }) {
|
| 9 |
+
useEffect(() => {
|
| 10 |
+
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY || '', {
|
| 11 |
+
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
|
| 12 |
+
defaults: '2025-05-24',
|
| 13 |
+
})
|
| 14 |
+
}, [])
|
| 15 |
+
|
| 16 |
+
return (
|
| 17 |
+
<PHProvider client={posthog}>
|
| 18 |
+
{children}
|
| 19 |
+
</PHProvider>
|
| 20 |
+
)
|
| 21 |
+
}
|
src/components/preview.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import { Loader2, Share2 } from "lucide-react"
|
|
| 9 |
import { cn } from "@/lib/utils"
|
| 10 |
import { generateShareLink } from "@/lib/sharelink"
|
| 11 |
import { ShareDialog } from "./share-dialog"
|
|
|
|
| 12 |
|
| 13 |
interface PreviewProps {
|
| 14 |
initialHtml?: string;
|
|
@@ -137,6 +138,8 @@ export const Preview = forwardRef<PreviewRef, PreviewProps>(function Preview(
|
|
| 137 |
// Only include html in the request if it's not DEFAULT_HTML
|
| 138 |
const isDefaultHtml = initialHtml === DEFAULT_HTML;
|
| 139 |
|
|
|
|
|
|
|
| 140 |
const response = await fetch('/api/generate-code', {
|
| 141 |
method: 'POST',
|
| 142 |
headers: {
|
|
@@ -152,6 +155,7 @@ export const Preview = forwardRef<PreviewRef, PreviewProps>(function Preview(
|
|
| 152 |
});
|
| 153 |
|
| 154 |
if (!response.ok) {
|
|
|
|
| 155 |
// Check specifically for 401 error (authentication required)
|
| 156 |
if (response.status === 401 || response.status === 403) {
|
| 157 |
try {
|
|
@@ -249,6 +253,7 @@ export const Preview = forwardRef<PreviewRef, PreviewProps>(function Preview(
|
|
| 249 |
}
|
| 250 |
} catch (err) {
|
| 251 |
const errorMessage = (err as Error).message || 'An error occurred while generating code';
|
|
|
|
| 252 |
setError(errorMessage);
|
| 253 |
if (onErrorChange) {
|
| 254 |
onErrorChange(errorMessage);
|
|
|
|
| 9 |
import { cn } from "@/lib/utils"
|
| 10 |
import { generateShareLink } from "@/lib/sharelink"
|
| 11 |
import { ShareDialog } from "./share-dialog"
|
| 12 |
+
import posthog from 'posthog-js'
|
| 13 |
|
| 14 |
interface PreviewProps {
|
| 15 |
initialHtml?: string;
|
|
|
|
| 138 |
// Only include html in the request if it's not DEFAULT_HTML
|
| 139 |
const isDefaultHtml = initialHtml === DEFAULT_HTML;
|
| 140 |
|
| 141 |
+
posthog.capture("Generate code", {"model": selectedModelId});
|
| 142 |
+
|
| 143 |
const response = await fetch('/api/generate-code', {
|
| 144 |
method: 'POST',
|
| 145 |
headers: {
|
|
|
|
| 155 |
});
|
| 156 |
|
| 157 |
if (!response.ok) {
|
| 158 |
+
posthog.capture("Generate code", {"type": "failed", "model": selectedModelId, "status": response.status});
|
| 159 |
// Check specifically for 401 error (authentication required)
|
| 160 |
if (response.status === 401 || response.status === 403) {
|
| 161 |
try {
|
|
|
|
| 253 |
}
|
| 254 |
} catch (err) {
|
| 255 |
const errorMessage = (err as Error).message || 'An error occurred while generating code';
|
| 256 |
+
posthog.capture("Generate code", {"type": "failed", "model": selectedModelId, "error": errorMessage});
|
| 257 |
setError(errorMessage);
|
| 258 |
if (onErrorChange) {
|
| 259 |
onErrorChange(errorMessage);
|
src/components/prompt-input.tsx
CHANGED
|
@@ -11,6 +11,7 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/comp
|
|
| 11 |
import { FullscreenToggle } from "./ui/fullscreen-toggle"
|
| 12 |
import { AuthErrorPopup } from "./auth-error-popup"
|
| 13 |
import { getInferenceToken } from "@/lib/auth"
|
|
|
|
| 14 |
|
| 15 |
interface PromptInputProps {
|
| 16 |
onSubmit: (prompt: string, colors: string[]) => Promise<void>;
|
|
@@ -74,6 +75,8 @@ export function PromptInput({
|
|
| 74 |
const isAuthenticated = await checkAuth();
|
| 75 |
if (!isAuthenticated) return;
|
| 76 |
|
|
|
|
|
|
|
| 77 |
// Clear previous errors
|
| 78 |
setImproveError(null);
|
| 79 |
setShowAuthError(false);
|
|
@@ -89,6 +92,8 @@ export function PromptInput({
|
|
| 89 |
})
|
| 90 |
|
| 91 |
if (!response.ok) {
|
|
|
|
|
|
|
| 92 |
// Handle auth error with openLogin flag
|
| 93 |
if (response.status === 401) {
|
| 94 |
const errorData = await response.json();
|
|
@@ -135,6 +140,7 @@ export function PromptInput({
|
|
| 135 |
}
|
| 136 |
}
|
| 137 |
} catch (error) {
|
|
|
|
| 138 |
console.error("Error improving prompt:", error)
|
| 139 |
setImproveError(error instanceof Error ? error.message : "Failed to improve prompt")
|
| 140 |
} finally {
|
|
|
|
| 11 |
import { FullscreenToggle } from "./ui/fullscreen-toggle"
|
| 12 |
import { AuthErrorPopup } from "./auth-error-popup"
|
| 13 |
import { getInferenceToken } from "@/lib/auth"
|
| 14 |
+
import posthog from 'posthog-js'
|
| 15 |
|
| 16 |
interface PromptInputProps {
|
| 17 |
onSubmit: (prompt: string, colors: string[]) => Promise<void>;
|
|
|
|
| 75 |
const isAuthenticated = await checkAuth();
|
| 76 |
if (!isAuthenticated) return;
|
| 77 |
|
| 78 |
+
posthog.capture("Improve prompt", {});
|
| 79 |
+
|
| 80 |
// Clear previous errors
|
| 81 |
setImproveError(null);
|
| 82 |
setShowAuthError(false);
|
|
|
|
| 92 |
})
|
| 93 |
|
| 94 |
if (!response.ok) {
|
| 95 |
+
posthog.capture("Improve prompt", {"type": "failed", "status": response.status});
|
| 96 |
+
|
| 97 |
// Handle auth error with openLogin flag
|
| 98 |
if (response.status === 401) {
|
| 99 |
const errorData = await response.json();
|
|
|
|
| 140 |
}
|
| 141 |
}
|
| 142 |
} catch (error) {
|
| 143 |
+
posthog.capture("Improve prompt", {"type": "failed", "error": error});
|
| 144 |
console.error("Error improving prompt:", error)
|
| 145 |
setImproveError(error instanceof Error ? error.message : "Failed to improve prompt")
|
| 146 |
} finally {
|