mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 03:11:12 -05:00
Refactor code structure and remove redundant changes
This commit is contained in:
37
src-old/components/analytics/AnalyticsWrapper.tsx
Normal file
37
src-old/components/analytics/AnalyticsWrapper.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import { Analytics } from "@vercel/analytics/react";
|
||||
import { Component, ReactNode } from "react";
|
||||
import { logger } from "@/lib/logger";
|
||||
|
||||
class AnalyticsErrorBoundary extends Component<
|
||||
{ children: ReactNode },
|
||||
{ hasError: boolean }
|
||||
> {
|
||||
constructor(props: { children: ReactNode }) {
|
||||
super(props);
|
||||
this.state = { hasError: false };
|
||||
}
|
||||
|
||||
static getDerivedStateFromError() {
|
||||
return { hasError: true };
|
||||
}
|
||||
|
||||
componentDidCatch(error: Error) {
|
||||
// Silently fail - analytics should never break the app
|
||||
logger.info('Analytics failed to load, continuing without analytics', { error: error.message });
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.hasError) {
|
||||
return null;
|
||||
}
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
export function AnalyticsWrapper() {
|
||||
return (
|
||||
<AnalyticsErrorBoundary>
|
||||
<Analytics />
|
||||
</AnalyticsErrorBoundary>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user