You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- Use this checklist to make sure your PR is ready for merge. You may
delete any sections you don't need. -->
## DESCRIBE YOUR PR
Converted the Remix Manual Setup guide into a Quick Start guide.
I removed the "Profiling" onboarding option because it is not in the
wizard.
If we want to keep it in the quick start guide(s), we should create a
separate GH issue to add Profiling to both guides as a manual step
(updating the wizard installer itself would be best, though)
There's also an update in the wizard QS guide:
"Step 2: Server-Side Performance Monitoring" -> This is an important
step that is included in the manual setup but not in the wizard.
@chargome is inquiring about updating the wizard installer.
## IS YOUR CHANGE URGENT?
Help us prioritize incoming PRs by letting us know when the change needs
to go live.
- [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE -->
- [ ] Other deadline: <!-- ENTER DATE HERE -->
- [x] None: Not urgent, can wait up to 1 week+
## SLA
- Teamwork makes the dream work, so please add a reviewer to your PRs.
- Please give the docs team up to 1 week to review your PR unless you've
added an urgent due date to it.
Thanks in advance for your help!
## PRE-MERGE CHECKLIST
*Make sure you've checked the following before merging your changes:*
- [ ] Checked Vercel preview for correctness, including links
- [ ] PR was reviewed and approved by any necessary SMEs (subject matter
experts)
- [ ] PR was reviewed and approved by a member of the [Sentry docs
team](https://github.com/orgs/getsentry/teams/docs)
## EXTRA RESOURCES
- [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
---------
Co-authored-by: Charly Gomez <charly.gomez@sentry.io>
If you haven't tested your Sentry configuration yet, let's do it now. You can confirm that Sentry is working properly and sending data to your Sentry project by using the example page created by the installation wizard:
description: "Learn how to set up the SDK manually."
4
+
description: "Learn how to manually set up Sentry in your Remix app and capture your first errors."
5
5
---
6
6
7
-
If you can't (or prefer not to) run the [automatic setup](/platforms/javascript/guides/remix/#install), you can follow the instructions below to configure your application.
8
-
9
-
## Features
7
+
<Alerttype="info">
8
+
For the fastest setup, we recommend using the [wizard
9
+
installer](/platforms/javascript/guides/remix).
10
+
</Alert>
10
11
11
-
In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also analyze performance profiles from real users with [profiling](/product/explore/profiling/). Lastly, adding [session replay](/product/explore/session-replay/web/getting-started/) lets you get to the root of an error or performance issue faster by watching a video-like reproduction of a user session with.
Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.
14
+
## Step 1: Install
14
15
15
-
## Install
16
+
Choose the features you want to configure, and this guide will show you how:
Run the command for your preferred package manager to add the Sentry SDK to your application:
22
27
23
28
```bash {tabTitle:npm}
24
29
npm install @sentry/remix --save
@@ -32,11 +37,11 @@ yarn add @sentry/remix
32
37
pnpm add @sentry/remix
33
38
```
34
39
35
-
## Configure
40
+
## Step 2: Configure
36
41
37
-
To use this SDK, initialize Sentry in your Remix project for both the client and server.
42
+
### Configure Client-Side Sentry
38
43
39
-
### Client-side Configuration
44
+
Create a client file `entry.client.tsx` in the `app` folder of your project if you don't have one already. In this file, import and initialize the Sentry SDK:
To capture errors from [ErrorBoundary](https://remix.run/docs/en/main/route/error-boundary), you should define your own `ErrorBoundary` in `root.tsx` and use `Sentry.captureRemixErrorBoundaryError` inside of it. You can also create route-specific error capturing behavior by defining `ErrorBoundary` in your route components. The `ErrorBoundary` you define in `root.tsx` will be used as a fallback for all routes.
108
+
To capture errors from your [ErrorBoundary](https://remix.run/docs/en/main/route/error-boundary), define it in `root.tsx` to act as a fallback for all routes or create route-specific error boundaries in your route components.
109
+
110
+
In your `ErrorBoundary` component, use `Sentry.captureRemixErrorBoundaryError` to send the captured error to Sentry:
To capture performance data, wrap your Remix root with `withSentry`.
124
+
#### Performance Monitoring
125
+
126
+
Wrap your Remix root component with `withSentry` to capture performance data:
118
127
119
128
```tsx {filename: root.tsx}
120
129
import {
@@ -148,21 +157,21 @@ function App() {
148
157
exportdefaultwithSentry(App);
149
158
```
150
159
151
-
### Server-side Configuration
160
+
### Configure Server-Side Sentry
152
161
153
-
Create an instrumentation file (named here as `instrument.server.mjs`) in your project. Add your initialization code in this file for the server-side SDK.
162
+
Create an instrumentation file `instrument.server.mjs` in your project's root folder and initialize the Sentry SDK within it:
// We recommend adjusting this value in production
@@ -185,22 +194,34 @@ Sentry.init({
185
194
});
186
195
```
187
196
188
-
Then run your Remix server with:
197
+
Then run your Remix server using the `--import` command line option and point it to this file to make sure the Sentry module loads before any other application code runs:
If you use the Express server instead of the Remix built-in server, you can alternatively import your instrumentation file directly at the top of your server implementation. See the example [here](#custom-express-server).
205
+
<Expandabletitle="Are you using Express?">
206
+
If you use the Express server instead of the built-in Remix server, you can import your instrumentation file directly at the top of your server implementation.
197
207
198
-
Sentry's Remix SDK will automatically record your [`action`](https://remix.run/docs/en/main/route/action) and [`loader`](https://remix.run/docs/en/main/route/loader) transactions, as well as server-side errors. You can also initialize Sentry's database integrations, such as <Linkto="/platforms/javascript/guides/node/configuration/integrations/prisma/">Prisma</Link>, to get spans for your database calls.
208
+
```typescript {filename: server.(mjs|cjs)}
209
+
// import the Sentry instrumentation file before anything else.
To capture server-side errors automatically, instrument the [`handleError`](https://remix.run/docs/en/main/file-conventions/entry.server#handleerror) function in your server entry point.
203
-
Wrap your error handler with `wrapHandleErrorWithSentry` or use `sentryHandleError` to export as your `handleError` function:
215
+
const app =express();
216
+
217
+
// ...
218
+
```
219
+
220
+
</Expandable>
221
+
222
+
#### Capture Server-Side Errors
223
+
224
+
To automatically capture server-side errors, instrument the [`handleError`](https://remix.run/docs/en/main/file-conventions/entry.server#handleerror) function in your server entry point (`entry.server.tsx`). You can wrap your custom error handler with `wrapHandleErrorWithSentry` or directly use `sentryHandleError`:
To enable readable stack traces, <PlatformLinkto="/sourcemaps">configure source maps upload</PlatformLink> for your production builds.
241
+
Sentry's Remix SDK automatically records your [`action`](https://remix.run/docs/en/main/route/action) and [`loader`](https://remix.run/docs/en/main/route/loader) transactions for performance monitoring. You can also initialize Sentry's database integrations, such as [Prisma](/platforms/javascript/guides/node/configuration/integrations/prisma/), to get spans for your database calls.
221
242
222
-
After you've completed this setup, the SDK will automatically capture unhandled errors and promise rejections, and monitor performance. You can also [manually capture errors](/platforms/javascript/guides/remix/usage).
// If you use .sentryclirc or environment variables,
268
+
// you don't need to specify these options
269
+
org:"___ORG_SLUG___",
270
+
project:"___PROJECT_SLUG___",
271
+
// store your auth token in an environment variable
272
+
authToken:process.env.SENTRY_AUTH_TOKEN,
273
+
}),
274
+
],
275
+
276
+
build: {
277
+
sourcemap:true,
278
+
// ... rest of your Vite build options
279
+
},
280
+
});
240
281
```
241
282
242
-
<Alert>
283
+
To keep your auth token secure, always store it in an environment variable instead of directly in your files:
243
284
244
-
Learn more about manually capturing an error or message in our <PlatformLinkto="/usage/">Usage documentation</PlatformLink>.
285
+
<OrgAuthTokenNote />
245
286
246
-
</Alert>
287
+
```bash {filename:.env}
288
+
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
289
+
```
247
290
248
-
To view and resolve the recorded error, log into [sentry.io](https://sentry.io) and select your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
291
+
## Step 4: Avoid Ad Blockers With Tunneling (Optional)
You can refer to [Remix Docs](https://remix.run/docs/en/main/guides/envvars#browser-environment-variables) to learn how to use your Sentry DSN with environment variables.
295
+
## Step 5: Verify Your Setup
253
296
254
-
</Alert>
297
+
Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project.
255
298
256
-
##Custom Express Server
299
+
### Issues
257
300
258
-
You can import your server instrumentation file at the top of your Express server implementation.
301
+
To verify that Sentry captures errors and creates issues in your Sentry project, add a test button to one of your pages:
259
302
260
-
```typescript {filename: server.ts}
261
-
// import the Sentry instrumentation file before anything else.
Open the page in a browser (for most Remix applications, this will be at localhost:3000) and click the button to trigger a frontend error.
319
+
320
+
</OnboardingOption>
321
+
322
+
<OnboardingOptionoptionId="performance">
323
+
324
+
### Tracing
325
+
326
+
To test your tracing configuration, update the previous code snippet by calling a non-existing route and starting a trace to measure the time it takes for the execution of your code:
327
+
328
+
```javascript
329
+
<button
330
+
type="button"
331
+
onClick={async () => {
332
+
awaitSentry.startSpan(
333
+
{
334
+
name:"Example Frontend Span",
335
+
op:"test",
336
+
},
337
+
async () => {
338
+
constres=awaitfetch("/api/sentry-example-api");
339
+
if (!res.ok) {
340
+
thrownewError("Sentry Example Frontend Error");
341
+
}
342
+
}
343
+
);
344
+
}}
345
+
>
346
+
<span>Throw Sample Error</span>
347
+
</button>
348
+
```
266
349
267
-
const app =express();
350
+
Open the page in a browser (for most Remix applications, this will be at localhost:3000) and click the button to trigger the frontend error and a trace.
At this point, you should have integrated Sentry into your Remix application and should already be sending error and performance data to your Sentry project.
365
+
366
+
Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are:
367
+
368
+
- Learn how to [manually capture errors](/platforms/javascript/guides/remix/usage/)
369
+
- Continue to [customize your configuration](/platforms/javascript/guides/remix/configuration/)
370
+
- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts
371
+
372
+
<Expandablepermalink={false}title="Are you having problems setting up the SDK?">
373
+
374
+
- If you encountered issues with the manual setup, try <PlatformLinkto="/">our installation wizard</PlatformLink>
375
+
- Find various topics in <PlatformLinkto="/troubleshooting">Troubleshooting</PlatformLink>
0 commit comments