-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(react-router): Update guide for
@sentry/react-router
(#12867)
--------- Co-authored-by: Andrei <[email protected]> Co-authored-by: Sigrid Huemer <[email protected]>
- Loading branch information
Showing
5 changed files
with
63 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 15 additions & 7 deletions
22
platform-includes/getting-started-install/javascript.react-router.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,42 @@ | ||
<OnboardingOptionButtons | ||
options={["error-monitoring", "performance", "profiling", "session-replay"]} | ||
options={[ | ||
"error-monitoring", | ||
"performance", | ||
"session-replay", | ||
{ | ||
id: 'profiling', | ||
checked: false | ||
} | ||
]} | ||
/> | ||
|
||
<OnboardingOption optionId="profiling"> | ||
|
||
```bash {tabTitle:npm} | ||
npm install @sentry/react @sentry/node @sentry/profiling-node | ||
npm install @sentry/react-router @sentry/profiling-node | ||
``` | ||
|
||
```bash {tabTitle:yarn} | ||
yarn add @sentry/react @sentry/node @sentry/profiling-node | ||
yarn add @sentry/react-router @sentry/profiling-node | ||
``` | ||
|
||
```bash {tabTitle:pnpm} | ||
pnpm add @sentry/react @sentry/node @sentry/profiling-node | ||
pnpm add @sentry/react-router @sentry/profiling-node | ||
``` | ||
|
||
</OnboardingOption> | ||
|
||
<OnboardingOption optionId="profiling" hideForThisOption> | ||
```bash {tabTitle:npm} | ||
npm install @sentry/react @sentry/node | ||
npm install @sentry/react-router | ||
``` | ||
|
||
```bash {tabTitle:yarn} | ||
yarn add @sentry/react @sentry/node | ||
yarn add @sentry/react-router | ||
``` | ||
|
||
```bash {tabTitle:pnpm} | ||
pnpm add @sentry/react @sentry/node | ||
pnpm add @sentry/react-router | ||
``` | ||
</OnboardingOption> | ||
|
10 changes: 5 additions & 5 deletions
10
platform-includes/getting-started-primer/javascript.react-router.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
<Alert title='Looking for library mode?' level='warning'> | ||
<Alert title='SDK Limitations' level='warning'> | ||
|
||
If you are using React Router in library mode, you can follow the instructions in the [React guide here](/platforms/javascript/guides/react/features/react-router/v7). | ||
This SDK is considered **experimental and in an alpha state**. It may experience breaking changes. Please reach out on [GitHub](https://github.com/getsentry/sentry-javascript/issues/) if you have any feedback or concerns. | ||
|
||
</Alert> | ||
|
||
<Alert title='SDK Limitations' level='warning'> | ||
<Alert title='Looking for library mode?' level='info'> | ||
|
||
We do not yet have a dedicated SDK for React Router in framework mode. | ||
This guide demonstrates how to setup error monitoring and basic performance tracing using the `@sentry/react` and `@sentry/node` packages instead. | ||
If you are using React Router in library mode, you can follow the instructions in the [React guide here](/platforms/javascript/guides/react/features/react-router/v7). | ||
|
||
</Alert> | ||
|
44 changes: 39 additions & 5 deletions
44
platform-includes/getting-started-sourcemaps/javascript.react-router.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,43 @@ | ||
## Add Readable Stack Traces to Errors | ||
## Source Maps Upload | ||
|
||
By default, React Router will minify your JavaScript and CSS files in production. This makes it difficult to debug errors. To make debugging easier, you can generate source maps and upload them to Sentry. | ||
Update `vite.config.ts` to include the `sentryReactRouter` plugin. Also add your `SentryReactRouterBuildOptions` config options to the Vite config (this is required for uploading source maps at the end of the build): | ||
|
||
We recommend using [Sentry's Vite plugin](/platforms/javascript/sourcemaps/uploading/vite/) to upload sourcemaps. | ||
<OrgAuthTokenNote /> | ||
|
||
Please refer to the <PlatformLink to="/sourcemaps">Source Maps Documentation</PlatformLink>, for more information. | ||
```typescript {filename: vite.config.ts} | ||
import { reactRouter } from '@react-router/dev/vite'; | ||
import { sentryReactRouter, type SentryReactRouterBuildOptions } from '@sentry/react-router'; | ||
import { defineConfig } from 'vite'; | ||
|
||
For more advanced configuration, you can use [`sentry-cli`](https://github.com/getsentry/sentry-cli) directly to upload source maps. | ||
const sentryConfig: SentryReactRouterBuildOptions = { | ||
org: "___ORG_SLUG___", | ||
project: "___PROJECT_SLUG___", | ||
|
||
// An auth token is required for uploading source maps. | ||
authToken: "___ORG_AUTH_TOKEN___" | ||
// ... | ||
}; | ||
|
||
export default defineConfig(config => { | ||
return { | ||
plugins: [reactRouter(), sentryReactRouter(sentryConfig, config)], | ||
sentryConfig, | ||
}; | ||
}); | ||
``` | ||
|
||
Include the `sentryOnBuildEnd` hook in `react-router.config.ts`: | ||
|
||
```typescript {filename: react-router.config.ts} {9} | ||
import type { Config } from '@react-router/dev/config'; | ||
import { sentryOnBuildEnd } from '@sentry/react-router'; | ||
|
||
export default { | ||
ssr: true, | ||
buildEnd: ({ viteConfig, reactRouterConfig, buildManifest }) => { | ||
// ... | ||
// Call this at the end of the hook | ||
sentryOnBuildEnd({ viteConfig, reactRouterConfig, buildManifest }); | ||
}, | ||
} satisfies Config; | ||
``` |