-
-
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.
- Loading branch information
Showing
4 changed files
with
22 additions
and
51 deletions.
There are no files selected for viewing
39 changes: 3 additions & 36 deletions
39
src/collections/_documentation/platforms/javascript/getting-started-dsn/react.md
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,42 +1,9 @@ | ||
<!-- WIZARD --> | ||
If you’re using React 16 or above, Error Boundaries are an important tool for defining the behavior of your application in the face of errors. Be sure to send errors they catch to Sentry using `Sentry.captureException`, and optionally this is also a great opportunity to surface User Feedback. | ||
You should `init` the Sentry browser SDK as soon as possible during your application load up, before initializing React: | ||
|
||
```jsx | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
// Sentry.init({ | ||
// dsn: "___PUBLIC_DSN___" | ||
// }); | ||
// should have been called before using it here | ||
// ideally before even rendering your react app | ||
Sentry.init({ dsn: '___PUBLIC_DSN___' }); | ||
|
||
class ExampleBoundary extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { error: null }; | ||
} | ||
|
||
componentDidCatch(error, errorInfo) { | ||
this.setState({ error }); | ||
Sentry.withScope(scope => { | ||
Object.keys(errorInfo).forEach(key => { | ||
scope.setExtra(key, errorInfo[key]); | ||
}); | ||
Sentry.captureException(error); | ||
}); | ||
} | ||
|
||
render() { | ||
if (this.state.error) { | ||
//render fallback UI | ||
return ( | ||
<a onClick={() => Sentry.showReportDialog()}>Report feedback</a> | ||
); | ||
} else { | ||
//when there's not an error, render children untouched | ||
return this.props.children; | ||
} | ||
} | ||
} | ||
ReactDOM.render(</App>, document.querySelector('#app')); | ||
``` | ||
<!-- ENDWIZARD --> |
10 changes: 2 additions & 8 deletions
10
...tions/_documentation/platforms/javascript/getting-started-install/browsernpm.md
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,13 +1,7 @@ | ||
If you are using `yarn` you can add our package as a dependency: | ||
Add the `@sentry/browser` to your project: | ||
|
||
```bash | ||
$ yarn add @sentry/browser@{% sdk_version sentry.javascript.browser %} | ||
``` | ||
|
||
Or alternatively, you can npm install it: | ||
|
||
```bash | ||
$ npm install @sentry/browser@{% sdk_version sentry.javascript.browser %} | ||
$ npm install --save @sentry/browser | ||
``` | ||
|
||
You can also [use our more convenient CDN version](?platform=browser). |
8 changes: 4 additions & 4 deletions
8
...ollections/_documentation/platforms/javascript/getting-started-install/react.md
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,9 @@ | ||
The quickest way to get started is to use the CDN hosted version of the JavaScript browser SDK: | ||
Add the `@sentry/browser` to your project: | ||
|
||
```html | ||
<script src="https://browser.sentry-cdn.com/{% sdk_version sentry.javascript.browser %}/bundle.min.js" crossorigin="anonymous"></script> | ||
```bash | ||
$ npm install --save @sentry/browser@{% sdk_version sentry.javascript.browser %} | ||
``` | ||
|
||
{% wizard hide %} | ||
You can also [NPM install our browser library](?platform=browsernpm). | ||
You can also [use our more convenient CDN version](?platform=browser). | ||
{% endwizard %} |
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