1- import * as Sentry from '@sentry/react' ;
2- import packageJson from '../package.json' ;
3- import * as React from 'react' ;
4- import {
5- createRoutesFromChildren ,
6- matchRoutes ,
7- useLocation ,
8- useNavigationType ,
9- } from 'react-router-dom' ;
1+ // This file configures the initialization of Sentry on the client.
2+ // The config you add here will be used whenever a user loads a page in their browser.
3+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/
4+
5+ import * as Sentry from '@sentry/nextjs' ;
6+ import packageJson from './package.json' ;
107
118// Helper to safely parse Sentry sample rates from environment variables
129const parseSampleRate = (
@@ -40,35 +37,28 @@ const replaysOnErrorSampleRate = parseSampleRate(
4037) ;
4138
4239if ( dsn . length > 0 ) {
43- const routerTracingIntegration =
44- Sentry . reactRouterV6BrowserTracingIntegration ( {
45- useEffect : React . useEffect ,
46- useLocation,
47- useNavigationType,
48- createRoutesFromChildren,
49- matchRoutes,
50- } ) ;
51-
52- const integrations = [ ] ;
53- if ( routerTracingIntegration != null ) {
54- integrations . push ( routerTracingIntegration ) ;
55- }
56- const replayIntegration = Sentry . replayIntegration ?.( ) ;
57- if ( replayIntegration != null ) {
58- integrations . push ( replayIntegration ) ;
59- }
60-
6140 Sentry . init ( {
6241 dsn,
6342 environment,
6443 release,
65- integrations,
44+
45+ // Adjust this value in production, or use tracesSampler for greater control
6646 tracesSampleRate,
67- replaysSessionSampleRate,
47+
48+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
49+ debug : false ,
50+
6851 replaysOnErrorSampleRate,
52+ replaysSessionSampleRate,
53+
54+ // You can add integrations below. The Replay integration is enabled by
55+ // default when replaysSessionSampleRate or replaysOnErrorSampleRate > 0.
56+ integrations : [ Sentry . replayIntegration ( ) ] ,
57+
6958 ignoreErrors : [ / R e s i z e O b s e r v e r l o o p l i m i t e x c e e d e d / i] ,
59+
7060 beforeSend ( event ) {
71- // remove user IP and geo context
61+ // Remove user IP and geo context for privacy
7262 if ( event . user != null ) {
7363 delete event . user . ip_address ;
7464 }
@@ -80,5 +70,4 @@ if (dsn.length > 0) {
8070 } ) ;
8171}
8272
83- export const SentryErrorBoundary = Sentry . ErrorBoundary ;
84- export const captureException = Sentry . captureException ;
73+ export const onRouterTransitionStart = Sentry . captureRouterTransitionStart ;
0 commit comments