Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions next.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { withSentryConfig } from '@sentry/nextjs';
// import { withSentryConfig } from '@sentry/nextjs';
import type { NextConfig } from 'next';

const nextConfig: NextConfig = {
Expand Down Expand Up @@ -46,14 +46,19 @@ const nextConfig: NextConfig = {
},
};

// Sentry options
// Sentry options (currently unused, see note below)
/* eslint-disable @typescript-eslint/no-unused-vars */
const sentryOptions = {
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options

// Suppresses source map uploading logs during build
silent: true,

// Disable automatic error page injection (we use custom global-error.tsx)
autoInstrumentServerFunctions: false,
autoInstrumentMiddleware: false,

// Only include if all required values are present
...(process.env.SENTRY_ORG &&
process.env.SENTRY_PROJECT &&
Expand All @@ -74,8 +79,16 @@ const sentryOptions = {
telemetry: false,
}),
};
/* eslint-enable @typescript-eslint/no-unused-vars */

// Export with Sentry configuration if DSN is provided (auth token only needed for uploads)
export default process.env.NEXT_PUBLIC_SENTRY_DSN || process.env.SENTRY_DSN
? withSentryConfig(nextConfig, sentryOptions)
: nextConfig;
// Export configuration
// NOTE: Sentry withSentryConfig wrapper temporarily disabled due to Next.js 15 compatibility issue
// The Sentry SDK (v10.16.0) generates Pages Router error pages that use `<Html>` component
// which is not compatible with App Router in Next.js 15.
// Issue: https://github.com/getsentry/sentry-javascript/issues/14526
// Tracking: We've implemented custom instrumentation files and global-error.tsx
// Once Sentry releases a fix, re-enable with:
// export default process.env.NEXT_PUBLIC_SENTRY_DSN || process.env.SENTRY_DSN
// ? withSentryConfig(nextConfig, sentryOptions)
// : nextConfig;
export default nextConfig;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
]
},
"dependencies": {
"@sentry/nextjs": "^10.8.0",
"@sentry/react": "^10.8.0",
"@sentry/nextjs": "^10.16.0",
"@sentry/react": "^10.16.0",
"@tanstack/react-query": "^5.85.9",
"date-fns": "^4.1.0",
"framer-motion": "^12.23.12",
Expand Down
60 changes: 0 additions & 60 deletions sentry.edge.config.ts

This file was deleted.

75 changes: 0 additions & 75 deletions sentry.server.config.ts

This file was deleted.

112 changes: 112 additions & 0 deletions src/app/global-error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/**
* Global Error Handler for Next.js App Router
* Catches React rendering errors and reports them to Sentry
* @see https://nextjs.org/docs/app/building-your-application/routing/error-handling#handling-errors-in-root-layouts
*/

'use client';

import * as Sentry from '@sentry/nextjs';
import { useEffect } from 'react';
import Link from 'next/link';
import { AlertTriangle, RefreshCw, Home } from 'lucide-react';

interface GlobalErrorProps {
error: Error & { digest?: string };
reset: () => void;
}

export default function GlobalError({
error,
reset,
}: GlobalErrorProps): React.ReactElement {
useEffect(() => {
// Report error to Sentry
Sentry.captureException(error);
}, [error]);

return (
<html lang="en">
<body>
<div className="flex min-h-screen items-center justify-center bg-slate-950 p-4">
<div className="max-w-md rounded-lg border border-red-800 bg-red-950/20 p-8 text-center backdrop-blur">
<div className="mb-6 flex justify-center">
<AlertTriangle className="h-16 w-16 text-red-400" />
</div>

<h2 className="mb-4 text-2xl font-bold text-red-300">
Something went wrong
</h2>

<p className="mb-6 text-slate-300">
We encountered an unexpected error. This has been reported and
we&apos;ll look into it.
</p>

{process.env.NODE_ENV === 'development' && (
<details className="mb-6 text-left">
<summary className="cursor-pointer text-sm font-medium text-slate-400 hover:text-slate-300">
Technical Details
</summary>
<div className="mt-4 rounded bg-slate-900/50 p-4 font-mono text-xs text-red-300">
<div className="mb-2">
<strong>Error:</strong> {error.name}
</div>
<div className="mb-2">
<strong>Message:</strong> {error.message}
</div>
{error.digest && (
<div className="mb-2">
<strong>Digest:</strong> {error.digest}
</div>
)}
{error.stack && (
<div>
<strong>Stack:</strong>
<pre className="mt-1 whitespace-pre-wrap">
{error.stack}
</pre>
</div>
)}
</div>
</details>
)}

<div className="flex flex-wrap justify-center gap-4">
<button
onClick={() => reset()}
className="flex items-center gap-2 rounded-lg bg-red-600 px-6 py-3 text-white transition-colors hover:bg-red-700 focus:ring-2 focus:ring-red-500 focus:ring-offset-2 focus:ring-offset-slate-900 focus:outline-none"
type="button"
aria-label="Try again"
>
<RefreshCw className="h-4 w-4" />
Try Again
</button>

<Link
href="/"
className="flex items-center gap-2 rounded-lg border border-slate-600 bg-slate-800 px-6 py-3 text-slate-300 transition-colors hover:bg-slate-700 focus:ring-2 focus:ring-slate-500 focus:ring-offset-2 focus:ring-offset-slate-900 focus:outline-none"
aria-label="Go to home page"
>
<Home className="h-4 w-4" />
Go Home
</Link>
</div>

<p className="mt-6 text-sm text-slate-500">
If this problem persists, please{' '}
<a
href="https://github.com/jimmcq/mars-weather-dashboard/issues"
target="_blank"
rel="noopener noreferrer"
className="text-red-400 underline hover:text-red-300"
>
report the issue
</a>
</p>
</div>
</div>
</body>
</html>
);
}
3 changes: 0 additions & 3 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import { Geist, Geist_Mono } from 'next/font/google';
import './globals.css';
import { Providers } from './providers';

// Import Sentry configuration
import '../../sentry.client.config';

const geistSans = Geist({
variable: '--font-geist-sans',
subsets: ['latin'],
Expand Down
46 changes: 46 additions & 0 deletions src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Custom 404 Not Found page for App Router
* @see https://nextjs.org/docs/app/api-reference/file-conventions/not-found
*/

'use client';

import Link from 'next/link';
import { Home, ArrowLeft } from 'lucide-react';

export default function NotFound(): React.ReactElement {
return (
<div className="flex min-h-screen items-center justify-center bg-slate-950 p-4">
<div className="max-w-md rounded-lg border border-slate-700 bg-slate-800/50 p-8 text-center backdrop-blur">
<div className="mb-6">
<h1 className="text-6xl font-bold text-blue-400">404</h1>
</div>

<h2 className="mb-4 text-2xl font-bold text-white">Page Not Found</h2>

<p className="mb-6 text-slate-300">
The page you&apos;re looking for doesn&apos;t exist or has been moved.
</p>

<div className="flex flex-wrap justify-center gap-4">
<Link
href="/"
className="flex items-center gap-2 rounded-lg bg-blue-600 px-6 py-3 text-white transition-colors hover:bg-blue-700 focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-slate-900 focus:outline-none"
>
<Home className="h-4 w-4" />
Go Home
</Link>

<button
onClick={() => window.history.back()}
className="flex items-center gap-2 rounded-lg border border-slate-600 bg-slate-800 px-6 py-3 text-slate-300 transition-colors hover:bg-slate-700 focus:ring-2 focus:ring-slate-500 focus:ring-offset-2 focus:ring-offset-slate-900 focus:outline-none"
type="button"
>
<ArrowLeft className="h-4 w-4" />
Go Back
</button>
</div>
</div>
</div>
);
}
6 changes: 5 additions & 1 deletion sentry.client.config.ts → src/instrumentation-client.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
/**
* Sentry client-side configuration
* Client-side instrumentation file
* This file configures error monitoring and performance tracking for the browser
* @see https://nextjs.org/docs/app/api-reference/file-conventions/instrumentation-client
*/

import * as Sentry from '@sentry/nextjs';

const SENTRY_DSN = process.env.NEXT_PUBLIC_SENTRY_DSN || process.env.SENTRY_DSN;

// Export router transition hook for navigation instrumentation
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;

if (SENTRY_DSN) {
Sentry.init({
dsn: SENTRY_DSN,
Expand Down
Loading