Skip to content

Commit 7558bbe

Browse files
authored
[Modified] React Wizard (#6355)
1 parent e265c3a commit 7558bbe

File tree

1 file changed

+37
-27
lines changed

1 file changed

+37
-27
lines changed

src/wizard/javascript/react.md

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ doc_link: https://docs.sentry.io/platforms/javascript/guides/react/
44
support_level: production
55
type: framework
66
---
7+
In this quick guide you’ll set up:
8+
- `@sentry/react` for [error monitoring](https://docs.sentry.io/platforms/javascript/guides/react/)
9+
- `@sentry/tracing` for [performance monitoring](https://docs.sentry.io/platforms/javascript/guides/react/performance/)
10+
---
711

8-
To instrument your React application with Sentry, first install the `@sentry/react` and `@sentry/tracing` packages:
12+
## Install
13+
Sentry captures data by using an SDK within your application’s runtime.
914

1015
```bash
1116
# Using yarn
@@ -15,39 +20,44 @@ yarn add @sentry/react @sentry/tracing
1520
npm install --save @sentry/react @sentry/tracing
1621
```
1722

23+
## Configure
24+
Initialise Sentry as early as possible in your application's lifecycle.
25+
1826
Next, import and initialize the Sentry module as early as possible, before initializing React:
1927

2028
```javascript
21-
import React from "react";
22-
import ReactDOM from "react-dom";
23-
import * as Sentry from "@sentry/react";
24-
import { BrowserTracing } from "@sentry/tracing";
25-
import App from "./App";
26-
27-
Sentry.init({
28-
dsn: "___PUBLIC_DSN___",
29-
integrations: [new BrowserTracing()],
30-
31-
// Set tracesSampleRate to 1.0 to capture 100%
32-
// of transactions for performance monitoring.
33-
// We recommend adjusting this value in production
34-
tracesSampleRate: 1.0,
35-
});
36-
37-
ReactDOM.render(<App />, document.getElementById("root"));
38-
39-
// Can also use with React Concurrent Mode
40-
// ReactDOM.createRoot(document.getElementById('root')).render(<App />);
29+
import { createRoot } React from "react-dom/client";
30+
import React from "react";
31+
import * as Sentry from "@sentry/react";
32+
import { BrowserTracing } from "@sentry/tracing";
33+
import App from "./App";
34+
35+
Sentry.init({
36+
dsn: "___PUBLIC_DSN___",
37+
integrations: [new BrowserTracing()],
38+
tracesSampleRate: 1.0,
39+
});
40+
41+
const container = document.getElementById(“app”);
42+
const root = createRoot(container);
43+
root.render(<App />)
4144
```
4245

43-
The above configuration captures both error and performance data. To reduce the volume of performance data captured, change `tracesSampleRate` to a value between 0 and 1.
44-
45-
After this step, Sentry will report any uncaught exceptions triggered by your application.
46+
<div class="alert alert-info" role="alert">
47+
<h5 class="no_toc"><code>tracesSampleRate: 1.0</code></h5>
48+
<div class="alert-body content-flush-bottom">
49+
The example above ensures every transaction will be to Sentry, but we recommend lowering this value in production.
50+
</div>
51+
</div>
4652

47-
You can trigger your first event from your development environment by raising an exception somewhere within your application. An example of this would be rendering a button whose `onClick` handler attempts to invoke a method that does not exist:
53+
## Verify
54+
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.
4855

4956
```javascript
5057
return <button onClick={() => methodDoesNotExist()}>Break the world</button>;
5158
```
52-
53-
Once you've verified the library is initialized properly and sent a test event, consider visiting our [complete React docs](https://docs.sentry.io/platforms/javascript/guides/react/). There you'll find additional instructions for surfacing valuable context from React error boundaries, React Router, Redux, and more.
59+
---
60+
## Next Steps
61+
- [Source Maps](https://docs.sentry.io/platforms/javascript/guides/react/sourcemaps/): Learn how to enable readable stack traces in your Sentry errors.
62+
- [React Features](https://docs.sentry.io/platforms/javascript/guides/react/features/): Learn about our first class integration with the React framework.
63+
- [Session Replay](https://docs.sentry.io/platforms/javascript/guides/react/session-replay/): Get to the root cause of an error or latency issue faster by seeing all the technical details related to that issue in one visual replay on your web application.

0 commit comments

Comments
 (0)