82 lines
2.6 KiB
TypeScript
82 lines
2.6 KiB
TypeScript
/**
|
|
* This file configures the initialization of Sentry on the client.
|
|
* The config you add here will be used whenever a users loads a page in their browser.
|
|
* https://docs.sentry.io/platforms/javascript/guides/nextjs/
|
|
*/
|
|
|
|
import * as Sentry from "@sentry/nextjs";
|
|
|
|
// Only initialize Sentry if DSN is provided
|
|
if (process.env.NEXT_PUBLIC_SENTRY_DSN) {
|
|
const isDevelopment = process.env.NODE_ENV === 'development';
|
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
|
|
Sentry.init({
|
|
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
|
|
|
// Environment
|
|
environment: process.env.NODE_ENV || 'development',
|
|
|
|
// Release tracking (use git commit or version)
|
|
release: process.env.NEXT_PUBLIC_APP_VERSION || process.env.VERCEL_GIT_COMMIT_SHA || undefined,
|
|
|
|
// Sample rates - lower in production to reduce costs
|
|
tracesSampleRate: isProduction ? 0.1 : 1.0, // 10% in production, 100% in dev
|
|
|
|
// Debug mode - only in development
|
|
debug: isDevelopment,
|
|
|
|
// Enable logs to be sent to Sentry
|
|
enableLogs: true,
|
|
|
|
// Session Replay - capture all errors, sample sessions
|
|
replaysOnErrorSampleRate: 1.0, // Always capture replays on errors
|
|
replaysSessionSampleRate: isProduction ? 0.05 : 0.1, // 5% in prod, 10% in dev
|
|
|
|
// Enable sending user PII (Personally Identifiable Information)
|
|
// https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#sendDefaultPii
|
|
sendDefaultPii: true,
|
|
|
|
// Integrations
|
|
integrations: [
|
|
Sentry.replayIntegration({
|
|
// Mask all text and block media for privacy
|
|
maskAllText: true,
|
|
blockAllMedia: true,
|
|
}),
|
|
Sentry.browserTracingIntegration(),
|
|
],
|
|
|
|
// Ignore specific errors
|
|
ignoreErrors: [
|
|
// Browser extensions
|
|
'top.GLOBALS',
|
|
'originalCreateNotification',
|
|
'canvas.contentDocument',
|
|
'MyApp_RemoveAllHighlights',
|
|
'atomicFindClose',
|
|
// Network errors that are expected
|
|
'NetworkError',
|
|
'Failed to fetch',
|
|
// Next.js specific
|
|
'ResizeObserver loop limit exceeded',
|
|
'Non-Error promise rejection captured',
|
|
// Known framework issues (Next.js 16.1.1 + Turbopack bug)
|
|
'OuterLayoutRouter',
|
|
'Each child in a list should have a unique "key" prop',
|
|
'Check the render method of `OuterLayoutRouter`',
|
|
],
|
|
|
|
// Filter out specific URLs
|
|
denyUrls: [
|
|
// Browser extensions
|
|
/extensions\//i,
|
|
/^chrome:\/\//i,
|
|
/^chrome-extension:\/\//i,
|
|
],
|
|
|
|
// Note: tunnelRoute is configured in next.config.ts via withSentryConfig
|
|
// The tunnel route (/monitoring) will automatically be used to bypass ad-blockers
|
|
});
|
|
}
|