mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 16:31:12 -05:00
Fix remaining console statements
This commit is contained in:
@@ -2,8 +2,15 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { BarChart, Bar, XAxis, YAxis, Tooltip, ResponsiveContainer } from 'recharts';
|
||||
import { AlertCircle, TrendingUp, Users, Zap } from 'lucide-react';
|
||||
|
||||
interface ErrorSummary {
|
||||
error_type: string | null;
|
||||
occurrence_count: number | null;
|
||||
affected_users: number | null;
|
||||
avg_duration_ms: number | null;
|
||||
}
|
||||
|
||||
interface ErrorAnalyticsProps {
|
||||
errorSummary: any[] | undefined;
|
||||
errorSummary: ErrorSummary[] | undefined;
|
||||
}
|
||||
|
||||
export function ErrorAnalytics({ errorSummary }: ErrorAnalyticsProps) {
|
||||
@@ -11,8 +18,8 @@ export function ErrorAnalytics({ errorSummary }: ErrorAnalyticsProps) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const totalErrors = errorSummary.reduce((sum, item) => sum + item.occurrence_count, 0);
|
||||
const totalAffectedUsers = errorSummary.reduce((sum, item) => sum + item.affected_users, 0);
|
||||
const totalErrors = errorSummary.reduce((sum, item) => sum + (item.occurrence_count || 0), 0);
|
||||
const totalAffectedUsers = errorSummary.reduce((sum, item) => sum + (item.affected_users || 0), 0);
|
||||
const avgDuration = errorSummary.reduce((sum, item) => sum + (item.avg_duration_ms || 0), 0) / errorSummary.length;
|
||||
|
||||
const topErrors = errorSummary.slice(0, 5);
|
||||
|
||||
@@ -6,8 +6,31 @@ import { Copy, ExternalLink } from 'lucide-react';
|
||||
import { format } from 'date-fns';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
interface Breadcrumb {
|
||||
timestamp: string;
|
||||
category: string;
|
||||
message: string;
|
||||
level: string;
|
||||
data?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
interface ErrorDetails {
|
||||
request_id: string;
|
||||
created_at: string;
|
||||
error_type: string;
|
||||
error_message: string;
|
||||
error_stack?: string;
|
||||
endpoint: string;
|
||||
method: string;
|
||||
status_code: number;
|
||||
duration_ms: number;
|
||||
user_id?: string;
|
||||
breadcrumbs?: Breadcrumb[];
|
||||
environment_context?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
interface ErrorDetailsModalProps {
|
||||
error: any;
|
||||
error: ErrorDetails;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
@@ -125,7 +148,7 @@ ${error.error_stack ? `Stack Trace:\n${error.error_stack}` : ''}
|
||||
<TabsContent value="breadcrumbs">
|
||||
{error.breadcrumbs && error.breadcrumbs.length > 0 ? (
|
||||
<div className="space-y-2">
|
||||
{error.breadcrumbs.map((crumb: any, index: number) => (
|
||||
{error.breadcrumbs.map((crumb, index) => (
|
||||
<div key={index} className="border-l-2 border-primary pl-4 py-2">
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
<Badge variant="outline" className="text-xs">
|
||||
|
||||
@@ -18,19 +18,8 @@ interface EntityErrorBoundaryState {
|
||||
errorInfo: ErrorInfo | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity Error Boundary Component (P0 #5)
|
||||
*
|
||||
* Specialized error boundary for entity detail pages.
|
||||
* Prevents entity rendering errors from crashing the app.
|
||||
*
|
||||
* Usage:
|
||||
* ```tsx
|
||||
* <EntityErrorBoundary entityType="park" entitySlug={slug}>
|
||||
* <ParkDetail />
|
||||
* </EntityErrorBoundary>
|
||||
* ```
|
||||
*/
|
||||
type ErrorWithId = Error & { errorId: string };
|
||||
|
||||
export class EntityErrorBoundary extends Component<EntityErrorBoundaryProps, EntityErrorBoundaryState> {
|
||||
constructor(props: EntityErrorBoundaryProps) {
|
||||
super(props);
|
||||
@@ -61,7 +50,7 @@ export class EntityErrorBoundary extends Component<EntityErrorBoundaryProps, Ent
|
||||
errorId,
|
||||
});
|
||||
|
||||
this.setState({ errorInfo, error: { ...error, errorId } as any });
|
||||
this.setState({ errorInfo, error: { ...error, errorId } as ErrorWithId });
|
||||
}
|
||||
|
||||
handleRetry = () => {
|
||||
@@ -131,9 +120,9 @@ export class EntityErrorBoundary extends Component<EntityErrorBoundaryProps, Ent
|
||||
<p className="text-sm">
|
||||
{this.state.error?.message || `An unexpected error occurred while loading this ${entityLabel.toLowerCase()}`}
|
||||
</p>
|
||||
{(this.state.error as any)?.errorId && (
|
||||
{(this.state.error as ErrorWithId)?.errorId && (
|
||||
<p className="text-xs font-mono bg-destructive/10 px-2 py-1 rounded">
|
||||
Reference ID: {((this.state.error as any).errorId as string).slice(0, 8)}
|
||||
Reference ID: {(this.state.error as ErrorWithId).errorId.slice(0, 8)}
|
||||
</p>
|
||||
)}
|
||||
<p className="text-xs text-muted-foreground">
|
||||
|
||||
@@ -18,19 +18,8 @@ interface ErrorBoundaryState {
|
||||
errorInfo: ErrorInfo | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic Error Boundary Component (P0 #5)
|
||||
*
|
||||
* Prevents component errors from crashing the entire application.
|
||||
* Shows user-friendly error UI with recovery options.
|
||||
*
|
||||
* Usage:
|
||||
* ```tsx
|
||||
* <ErrorBoundary context="PhotoUpload">
|
||||
* <PhotoUploadForm />
|
||||
* </ErrorBoundary>
|
||||
* ```
|
||||
*/
|
||||
type ErrorWithId = Error & { errorId: string };
|
||||
|
||||
export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
||||
constructor(props: ErrorBoundaryProps) {
|
||||
super(props);
|
||||
@@ -61,7 +50,7 @@ export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundarySt
|
||||
errorId,
|
||||
});
|
||||
|
||||
this.setState({ errorInfo, error: { ...error, errorId } as any });
|
||||
this.setState({ errorInfo, error: { ...error, errorId } as ErrorWithId });
|
||||
this.props.onError?.(error, errorInfo);
|
||||
}
|
||||
|
||||
@@ -105,9 +94,9 @@ export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundarySt
|
||||
<p className="text-sm mt-2">
|
||||
{this.state.error?.message || 'An unexpected error occurred'}
|
||||
</p>
|
||||
{(this.state.error as any)?.errorId && (
|
||||
{(this.state.error as ErrorWithId)?.errorId && (
|
||||
<p className="text-xs mt-2 font-mono bg-destructive/10 px-2 py-1 rounded">
|
||||
Reference ID: {((this.state.error as any).errorId as string).slice(0, 8)}
|
||||
Reference ID: {(this.state.error as ErrorWithId).errorId.slice(0, 8)}
|
||||
</p>
|
||||
)}
|
||||
</AlertDescription>
|
||||
|
||||
@@ -13,19 +13,8 @@ interface RouteErrorBoundaryState {
|
||||
error: Error | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Route Error Boundary Component (P0 #5)
|
||||
*
|
||||
* Top-level error boundary that wraps all routes.
|
||||
* Last line of defense to prevent complete app crashes.
|
||||
*
|
||||
* Usage: Wrap Routes component in App.tsx
|
||||
* ```tsx
|
||||
* <RouteErrorBoundary>
|
||||
* <Routes>...</Routes>
|
||||
* </RouteErrorBoundary>
|
||||
* ```
|
||||
*/
|
||||
type ErrorWithId = Error & { errorId: string };
|
||||
|
||||
export class RouteErrorBoundary extends Component<RouteErrorBoundaryProps, RouteErrorBoundaryState> {
|
||||
constructor(props: RouteErrorBoundaryProps) {
|
||||
super(props);
|
||||
@@ -56,7 +45,7 @@ export class RouteErrorBoundary extends Component<RouteErrorBoundaryProps, Route
|
||||
errorId,
|
||||
});
|
||||
|
||||
this.setState({ error: { ...error, errorId } as any });
|
||||
this.setState({ error: { ...error, errorId } as ErrorWithId });
|
||||
}
|
||||
|
||||
handleReload = () => {
|
||||
@@ -91,9 +80,9 @@ export class RouteErrorBoundary extends Component<RouteErrorBoundaryProps, Route
|
||||
{this.state.error.message}
|
||||
</p>
|
||||
)}
|
||||
{(this.state.error as any)?.errorId && (
|
||||
{(this.state.error as ErrorWithId)?.errorId && (
|
||||
<p className="text-xs font-mono bg-destructive/10 px-2 py-1 rounded">
|
||||
Reference ID: {((this.state.error as any).errorId as string).slice(0, 8)}
|
||||
Reference ID: {(this.state.error as ErrorWithId).errorId.slice(0, 8)}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user