feat: Add GlitchTip error monitoring with Sentry SDK
- Install @sentry/nextjs - Add sentry.client.config.ts, sentry.server.config.ts, sentry.edge.config.ts - Conditional initialization based on GLITCHTIP_DSN env variable - Add /api/glitchtip-tunnel route to bypass ad blockers - Update next.config.mjs with withSentryConfig wrapper - Integrate Sentry.captureException in error.tsx and global-error.tsx - Support env vars: GLITCHTIP_DSN, NEXT_PUBLIC_GLITCHTIP_DSN, GLITCHTIP_URL, etc.
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import { withSentryConfig } from "@sentry/nextjs";
|
||||
|
||||
/** @type {import('next').Config} */
|
||||
const nextConfig = {
|
||||
output: 'standalone',
|
||||
productionBrowserSourceMaps: false,
|
||||
// Enable source maps for Sentry stack traces in production
|
||||
productionBrowserSourceMaps: !!process.env.GLITCHTIP_DSN,
|
||||
experimental: {
|
||||
serverActions: {
|
||||
bodySizeLimit: '10mb',
|
||||
@@ -9,4 +12,33 @@ const nextConfig = {
|
||||
},
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
// Wrap with Sentry only if DSN is configured
|
||||
const sentryEnabled = !!process.env.GLITCHTIP_DSN || !!process.env.NEXT_PUBLIC_GLITCHTIP_DSN;
|
||||
|
||||
const sentryWebpackPluginOptions = {
|
||||
// Suppresses source map uploading logs during build
|
||||
silent: true,
|
||||
|
||||
// Organization and project slugs (optional - for source map upload)
|
||||
org: process.env.GLITCHTIP_ORG,
|
||||
project: process.env.GLITCHTIP_PROJECT,
|
||||
|
||||
// GlitchTip server URL
|
||||
sentryUrl: process.env.GLITCHTIP_URL,
|
||||
|
||||
// Auth token for source map upload
|
||||
authToken: process.env.GLITCHTIP_AUTH_TOKEN,
|
||||
|
||||
// Hides source maps from generated client bundles
|
||||
hideSourceMaps: true,
|
||||
|
||||
// Automatically tree-shake Sentry logger statements
|
||||
disableLogger: true,
|
||||
|
||||
// Prevent bundling of native binaries
|
||||
widenClientFileUpload: true,
|
||||
};
|
||||
|
||||
export default sentryEnabled
|
||||
? withSentryConfig(nextConfig, sentryWebpackPluginOptions)
|
||||
: nextConfig;
|
||||
|
||||
Reference in New Issue
Block a user