1+ import { useEffect } from "react" ;
12import { Toaster } from "@/components/ui/sonner" ;
23import { Button } from "@/components/ui/button" ;
3- import { Routes , Route , Navigate } from "react-router-dom" ;
4+ import { Route , Routes , useLocation } from "react-router-dom" ;
45import ChatSettingsPage from "@/pages/ChatSettingsPage" ;
56import UserSettingsPage from "@/pages/UserSettingsPage" ;
67import AccessSettingsPage from "@/pages/AccessSettingsPage" ;
@@ -14,8 +15,38 @@ import OnboardingPage from "@/pages/OnboardingPage";
1415import logoVector from "@/assets/logo-vector.svg" ;
1516import { DEFAULT_LANGUAGE } from "@/lib/languages" ;
1617import { t } from "@/lib/translations" ;
18+ import {
19+ trackFeatureAction ,
20+ trackPageError ,
21+ trackPageView ,
22+ } from "@/lib/analytics" ;
23+
24+ function RootRedirect ( ) {
25+ useEffect ( ( ) => {
26+ window . location . replace ( import . meta. env . VITE_LANDING_PAGE_URL ) ;
27+ } , [ ] ) ;
28+
29+ return null ;
30+ }
1731
1832function NotFoundPage ( ) {
33+ const location = useLocation ( ) ;
34+
35+ useEffect ( ( ) => {
36+ trackPageView ( {
37+ pageId : "not_found" ,
38+ pageState : "not_found" ,
39+ occurrenceId : location . key ,
40+ interfaceLanguage : DEFAULT_LANGUAGE . isoCode ,
41+ } ) ;
42+ trackPageError ( {
43+ pageId : "not_found" ,
44+ occurrenceId : location . key ,
45+ errorCategory : "not_found" ,
46+ errorCode : "route_not_found" ,
47+ } ) ;
48+ } , [ location . key ] ) ;
49+
1950 return (
2051 < main className = "settings-pane-atmosphere flex min-h-dvh items-center justify-center px-[1rem] py-[3rem]" >
2152 < section className = "relative w-full max-w-xl overflow-hidden rounded-3xl border border-border/80 bg-surface-raised/78 shadow-[0_24px_90px_oklch(0.04_0.01_292/0.32)]" >
@@ -28,14 +59,23 @@ function NotFoundPage() {
2859 < p className = "mt-[1.5rem] font-mono text-sm font-semibold tracking-[0.18em] text-blue-300" >
2960 404
3061 </ p >
31- < h1 className = "mt-[0.75rem] text-[clamp(2rem,8vw,3.5rem )] font-semibold leading-[1.05] tracking-[-0.045em] text-foreground" >
62+ < h1 className = "mt-[0.75rem] text-[clamp(1.875rem,7vw,3rem )] font-semibold leading-[1.05] tracking-[-0.045em] text-foreground" >
3263 { t ( "not_found_page.title" ) }
3364 </ h1 >
3465 < p className = "mt-[1rem] max-w-md text-base leading-7 text-muted-foreground" >
3566 { t ( "not_found_page.description" ) }
3667 </ p >
3768 < Button asChild size = "lg" className = "mt-[2rem] rounded-xl" >
38- < a href = { import . meta. env . VITE_LANDING_PAGE_URL } >
69+ < a
70+ href = { import . meta. env . VITE_LANDING_PAGE_URL }
71+ onClick = { ( ) =>
72+ trackFeatureAction ( {
73+ featureId : "not_found_recovery" ,
74+ action : "return" ,
75+ sourceArea : "not_found" ,
76+ } )
77+ }
78+ >
3979 { t ( "not_found_page.action" ) }
4080 </ a >
4181 </ Button >
@@ -88,16 +128,8 @@ function App() {
88128 element = { < OnboardingPage /> }
89129 />
90130 { /* Edge-cases */ }
91- < Route
92- path = "*"
93- element = { < NotFoundPage /> }
94- />
95- < Route
96- path = "/"
97- element = {
98- < Navigate to = { `/${ DEFAULT_LANGUAGE . isoCode } /help` } replace />
99- }
100- />
131+ < Route path = "/" element = { < RootRedirect /> } />
132+ < Route path = "*" element = { < NotFoundPage /> } />
101133 </ Routes >
102134 < Toaster />
103135 </ >
0 commit comments