feat: integrate Sentry error tracking
- @sentry/nextjs installed and configured for client, server, and edge - Instrumentation hook registers Sentry on Node.js and edge runtimes - Global error boundary captures unhandled errors to Sentry - next.config.ts wrapped with withSentryConfig (source maps disabled) - No-op when NEXT_PUBLIC_SENTRY_DSN is not set To enable: set NEXT_PUBLIC_SENTRY_DSN in .env.local or .env.production Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import path from "path";
|
||||
import type { NextConfig } from "next";
|
||||
import { withSentryConfig } from "@sentry/nextjs";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
output: "standalone",
|
||||
@@ -44,4 +45,10 @@ const nextConfig: NextConfig = {
|
||||
},
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
export default withSentryConfig(nextConfig, {
|
||||
silent: true,
|
||||
sourcemaps: {
|
||||
disable: true,
|
||||
},
|
||||
telemetry: false,
|
||||
});
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
"@planarchy/shared": "workspace:*",
|
||||
"@planarchy/ui": "workspace:*",
|
||||
"@react-pdf/renderer": "^4.3.2",
|
||||
"@sentry/nextjs": "^10.45.0",
|
||||
"@tanstack/react-query": "^5.62.16",
|
||||
"@tanstack/react-virtual": "^3.13.21",
|
||||
"@trpc/client": "^11.0.0",
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
Sentry.init({
|
||||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
tracesSampleRate: 0.1,
|
||||
replaysSessionSampleRate: 0,
|
||||
replaysOnErrorSampleRate: 1.0,
|
||||
enabled: !!process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
Sentry.init({
|
||||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
tracesSampleRate: 0.1,
|
||||
enabled: !!process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
Sentry.init({
|
||||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
tracesSampleRate: 0.1,
|
||||
enabled: !!process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
"use client";
|
||||
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export default function GlobalError({
|
||||
error,
|
||||
reset,
|
||||
}: {
|
||||
error: Error;
|
||||
reset: () => void;
|
||||
}) {
|
||||
useEffect(() => {
|
||||
Sentry.captureException(error);
|
||||
}, [error]);
|
||||
|
||||
return (
|
||||
<html>
|
||||
<body>
|
||||
<div style={{ padding: "2rem", textAlign: "center" }}>
|
||||
<h2>Something went wrong</h2>
|
||||
<button onClick={reset}>Try again</button>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
export async function register() {
|
||||
if (process.env.NEXT_RUNTIME === "nodejs") {
|
||||
await import("../sentry.server.config");
|
||||
}
|
||||
if (process.env.NEXT_RUNTIME === "edge") {
|
||||
await import("../sentry.edge.config");
|
||||
}
|
||||
}
|
||||
|
||||
export const onRequestError = Sentry.captureRequestError;
|
||||
Reference in New Issue
Block a user