-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
docs(js): React Quick Start guide for Error Monitoring feature only #13061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a443103
React Quick Start guide for Error Monitoring feature only
inventarSarah cef877a
Merge branch 'master' of github.com:getsentry/sentry-docs into smi/qu…
inventarSarah 310a83c
update section on error boundary
inventarSarah a0ec11d
make Step 4 optional
inventarSarah bb02c35
Merge branch 'master' of github.com:getsentry/sentry-docs into smi/qu…
inventarSarah b2939c2
Update JS snippet
inventarSarah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,31 +1,40 @@ | ||||||
| --- | ||||||
| title: React | ||||||
| description: "Learn about Sentry's React SDK and how it automatically reports errors and exceptions in your application." | ||||||
| description: "Learn how to manually set up Sentry in your React app and capture your first errors." | ||||||
| sdk: sentry.javascript.react | ||||||
| categories: | ||||||
| - javascript | ||||||
| - browser | ||||||
| --- | ||||||
|
|
||||||
| <Alert> | ||||||
|
|
||||||
| Sentry's React SDK enables automatic reporting of errors and exceptions. The SDK is a wrapper around @sentry/browser, with added functionality related to React. All methods available in @sentry/browser can be imported from @sentry/react. | ||||||
| <PlatformContent includePath="getting-started-prerequisites" /> | ||||||
|
|
||||||
| </Alert> | ||||||
| ## Step 1: Install | ||||||
|
|
||||||
| <PlatformContent includePath="getting-started-prerequisites" /> | ||||||
| Choose the features you want to configure, and this guide will show you how: | ||||||
|
|
||||||
| ## Features | ||||||
| <OnboardingOptionButtons | ||||||
| options={["error-monitoring", "performance", "session-replay"]} | ||||||
| /> | ||||||
|
|
||||||
| In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also get to the root of an error or performance issue faster, by watching a video-like reproduction of a user session with [session replay](/product/explore/session-replay/web/getting-started/). | ||||||
| <Expandable title="Want to learn more about these features?"> | ||||||
|
|
||||||
| Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. | ||||||
| - [**Issues**](/product/issues) (always enabled): Sentry's core error monitoring product that automatically reports errors, | ||||||
| uncaught exceptions, and unhandled rejections. If you have something that | ||||||
| looks like an exception, Sentry can capture it. | ||||||
| - [**Tracing**](/product/tracing): Track software performance while seeing the | ||||||
| impact of errors across multiple systems. For example, distributed tracing | ||||||
| allows you to follow a request from the frontend to the backend and back. | ||||||
| - [**Session Replay**](/product/explore/session-replay/web): | ||||||
| Get to the root cause of an issue faster by viewing a video-like reproduction | ||||||
| of what was happening in the user's browser before, during, and after the | ||||||
| problem. | ||||||
|
|
||||||
| ## Install | ||||||
| </Expandable> | ||||||
|
|
||||||
| <OnboardingOptionButtons options={["error-monitoring", "performance", "session-replay"]} /> | ||||||
| ### Install the Sentry SDK | ||||||
|
|
||||||
| Sentry captures data by using an SDK within your application’s runtime. | ||||||
| Run the command for your preferred package manager to add the Sentry SDK to your application: | ||||||
|
|
||||||
| ```bash {tabTitle:npm} | ||||||
| npm install @sentry/react --save | ||||||
|
|
@@ -39,12 +48,13 @@ yarn add @sentry/react | |||||
| pnpm add @sentry/react | ||||||
| ``` | ||||||
|
|
||||||
| ## Configure | ||||||
| ## Step 2: Configure | ||||||
|
|
||||||
| Sentry supports multiple versions of React Router. To learn how to configure them, read the <PlatformLink to="/configuration/integrations/react-router/">React Router Integration</PlatformLink> docs. | ||||||
|
|
||||||
| Sentry should be initialized as early as possible in your application. We recommend putting the Sentry initialization code into its own file and including that file as the first import in your application entry point as shown in the example below: | ||||||
| ### Initialize the Sentry SDK | ||||||
|
|
||||||
| To import and initialize Sentry, create a file, for example, `instrument.js`, in your project and add the following code: | ||||||
|
||||||
| To import and initialize Sentry, create a file, for example, `instrument.js`, in your project and add the following code: | |
| To import and initialize Sentry, create a file in your project's root directory, for example, `instrument.js`, in your project and add the following code: |
inventarSarah marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
inventarSarah marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
inventarSarah marked this conversation as resolved.
Show resolved
Hide resolved
inventarSarah marked this conversation as resolved.
Show resolved
Hide resolved
Outdated
Member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one is optional
This file contains hidden or 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
5 changes: 5 additions & 0 deletions
5
platform-includes/getting-started-browser-sandbox-warning/javascript.mdx
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <Alert level="warning" title="Important"> | ||
|
|
||
| Errors triggered from within your browser's developer tools (like the browser console) are sandboxed, so they will not trigger Sentry's error monitoring. | ||
|
|
||
| </Alert> |
5 changes: 5 additions & 0 deletions
5
platform-includes/getting-started-sourcemaps-short-version/javascript.mdx
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| The stack traces in your Sentry errors probably won't look like your actual code. To fix this, upload your source maps to Sentry. The easiest way to do this is by using the Sentry Wizard: | ||
|
|
||
| ```bash | ||
| npx @sentry/wizard@latest -i sourcemaps | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.