@@ -10,20 +10,28 @@ npx react-router reveal
1010
1111Initialize the Sentry React SDK in your ` entry.client.tsx ` file:
1212
13- ``` tsx {filename: entry.client.tsx}
13+ ``` tsx {filename: entry.client.tsx} {"onboardingOptions": {"performance": "9, 12-16", "session-replay": "10, 17-21"}}
1414import * as Sentry from " @sentry/react" ;
1515import { startTransition , StrictMode } from " react" ;
1616import { hydrateRoot } from " react-dom/client" ;
1717import { HydratedRouter } from " react-router/dom" ;
1818
1919Sentry .init ({
2020 dsn: " ___PUBLIC_DSN___" ,
21- integrations: [Sentry .browserTracingIntegration ()],
21+ integrations: [
22+ Sentry .browserTracingIntegration (),
23+ Sentry .replayIntegration (),
24+ ],
2225
2326 tracesSampleRate: 1.0 , // Capture 100% of the transactions
2427
2528 // Set `tracePropagationTargets` to declare which URL(s) should have trace propagation enabled
2629 tracePropagationTargets: [/ ^ \/ / , / ^ https:\/\/ yourserver\. io\/ api/ ],
30+
31+ // Capture Replay for 10% of all sessions,
32+ // plus 100% of sessions with an error
33+ sessionReplaySampleRate: 1.0 ,
34+ sessionReplayRecordingRate: 1.0 ,
2735});
2836
2937startTransition (() => {
@@ -38,7 +46,7 @@ startTransition(() => {
3846
3947Now, update your ` app/root.tsx ` file to report any unhandled errors from your error boundary:
4048
41- ``` tsx {filename: app/root.tsx} {14,15 }
49+ ``` tsx {diff} { filename: app/root.tsx}
4250import * as Sentry from " @sentry/react" ;
4351
4452export function ErrorBoundary({ error }: Route .ErrorBoundaryProps ) {
@@ -53,20 +61,20 @@ export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
5361 ? " The requested page could not be found."
5462 : error .statusText || details ;
5563 } else if (error && error instanceof Error ) {
56- // you only want to capture non 404-errors that reach the error boundary
57- Sentry .captureException (error );
64+ // you only want to capture non 404-errors that reach the boundary
65+ + Sentry .captureException (error );
5866 if (import .meta .env .DEV ) {
5967 details = error .message ;
6068 stack = error .stack ;
6169 }
6270 }
6371
6472 return (
65- <main className = " pt-16 p-4 container mx-auto " >
73+ <main >
6674 <h1 >{ message } </h1 >
6775 <p >{ details } </p >
6876 { stack && (
69- <pre className = " w-full p-4 overflow-x-auto " >
77+ <pre >
7078 <code >{ stack } </code >
7179 </pre >
7280 )}
@@ -80,25 +88,28 @@ export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
8088
8189Create an ` instrument.server.mjs ` file in the root of your app:
8290
83- ``` js {filename: instrument.server.mjs}
91+ ``` js {filename: instrument.server.mjs} {"onboardingOptions": {"performance": "7", "profiling": "2, 6, 8"}}
8492import * as Sentry from " @sentry/node" ;
93+ import { nodeProfilingIntegration } from ' @sentry/profiling-node' ;
8594
8695Sentry .init ({
8796 dsn: " ___PUBLIC_DSN___" ,
97+ integrations: [nodeProfilingIntegration ()],
8898 tracesSampleRate: 1.0 , // Capture 100% of the transactions
99+ profilesSampleRate: 1.0 , // profile every transaction
89100});
90101```
91102
92103In your ` entry.server.tsx ` file, export the ` handleError ` function:
93104
94- ``` tsx {filename: entry.server.tsx} {7 }
105+ ``` tsx {diff} { filename: entry.server.tsx}
95106import * as Sentry from " @sentry/node" ;
96107import { type HandleErrorFunction } from " react-router" ;
97108
98109export const handleError: HandleErrorFunction = (error , { request }) => {
99110 // React Router may abort some interrupted requests, report those
100111 if (! request .signal .aborted ) {
101- Sentry .captureException (error );
112+ + Sentry .captureException (error );
102113
103114 // make sure to still log the error so you can see it
104115 console .error (error );
0 commit comments