Skip to content

Commit 7b3f4b1

Browse files
committed
add onboarding options + diffs
1 parent d3598df commit 7b3f4b1

File tree

3 files changed

+50
-17
lines changed

3 files changed

+50
-17
lines changed

platform-includes/getting-started-config/javascript.react-router.mdx

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,28 @@ npx react-router reveal
1010

1111
Initialize 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"}}
1414
import * as Sentry from "@sentry/react";
1515
import { startTransition, StrictMode } from "react";
1616
import { hydrateRoot } from "react-dom/client";
1717
import { HydratedRouter } from "react-router/dom";
1818

1919
Sentry.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

2937
startTransition(() => {
@@ -38,7 +46,7 @@ startTransition(() => {
3846

3947
Now, 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}
4250
import * as Sentry from "@sentry/react";
4351

4452
export 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

8189
Create 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"}}
8492
import * as Sentry from "@sentry/node";
93+
import { nodeProfilingIntegration } from '@sentry/profiling-node';
8594

8695
Sentry.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

92103
In your `entry.server.tsx` file, export the `handleError` function:
93104

94-
```tsx {filename: entry.server.tsx} {7}
105+
```tsx {diff} {filename: entry.server.tsx}
95106
import * as Sentry from "@sentry/node";
96107
import { type HandleErrorFunction } from "react-router";
97108

98109
export 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);
Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
1+
<OnboardingOptionButtons
2+
options={["error-monitoring", "performance", "profiling", "session-replay"]}
3+
/>
4+
5+
<OnboardingOption optionId="profiling">
6+
17
```bash {tabTitle:npm}
2-
npm install @sentry/react @sentry/node
8+
npm install @sentry/react @sentry/node @sentry/profiling-node
39
```
410

511
```bash {tabTitle:yarn}
6-
yarn add @sentry/react @sentry/node
12+
yarn add @sentry/react @sentry/node @sentry/profiling-node
713
```
814

915
```bash {tabTitle:pnpm}
10-
pnpm add @sentry/react @sentry/node
16+
pnpm add @sentry/react @sentry/node @sentry/profiling-node
1117
```
18+
19+
</OnboardingOption>
20+
21+
<OnboardingOption optionId="profiling" hideForThisOption>
22+
```bash {tabTitle:npm}
23+
npm install @sentry/react @sentry/node
24+
```
25+
26+
```bash {tabTitle:yarn}
27+
yarn add @sentry/react @sentry/node
28+
```
29+
30+
```bash {tabTitle:pnpm}
31+
pnpm add @sentry/react @sentry/node
32+
```
33+
</OnboardingOption>
34+

platform-includes/getting-started-verify/javascript.react-router.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@ Throw an error in a loader to verify that Sentry is working.
22
After opening this route in your browser, you should see two errors in the Sentry issue stream, one captured from the server and one captured from the client.
33

44
```tsx {filename: error.tsx}
5-
import type { Route } from "./+types/error-loader";
5+
import type { Route } from "./+types/example-page";
66

77
export async function loader() {
8-
console.log("server loader");
98
throw new Error("some error thrown in a loader");
109
}
1110

12-
export default function Loaders({ loaderData }: Route.ComponentProps) {
11+
export default function ExamplePage() {
1312
return (
1413
<div>
15-
Loaders, loaderData: <pre>{JSON.stringify(loaderData, null, 2)}</pre>
14+
Loading this page will throw an error
1615
</div>
1716
);
1817
}

0 commit comments

Comments
 (0)