Skip to content

Commit cba9861

Browse files
authored
fix(ember): Update README docs to match sentry-docs (#5315)
There were quite a few updates especially around how config is preferred to be set, this cleans up the README to clarify and match with sentry-docs to avoid confusion.
1 parent 3abfb2d commit cba9861

File tree

1 file changed

+36
-29
lines changed

1 file changed

+36
-29
lines changed

packages/ember/README.md

+36-29
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,41 @@ This package is an Ember addon that wraps `@sentry/browser`, with added function
2121
As with other Ember addons, run:
2222
`ember install @sentry/ember`
2323

24-
Then add the following config to `config/environment.js`
24+
Then add the following to your `<your-app>/app.js`
2525

2626
```javascript
27-
ENV['@sentry/ember'] = {
28-
sentry: {
29-
dsn: '__DSN__' // replace __DSN__ with your DSN,
30-
tracesSampleRate: 1.0, // Be sure to lower this for your production environment
31-
}
32-
};
27+
import * as Sentry from "@sentry/ember";
28+
29+
Sentry.init({
30+
dsn: '__DSN__' // replace __DSN__ with your DSN,
31+
32+
// Set tracesSampleRate to 1.0 to capture 100%
33+
// of transactions for performance monitoring.
34+
// We recommend adjusting this value in production,
35+
tracesSampleRate: 1.0,
36+
});
3337
```
38+
3439
### Usage
3540

36-
To use this SDK, call `InitSentryForEmber` before the application is initialized, in `app.js`. This will load Sentry config from `environment.js` for you.
41+
To use this SDK, call `Sentry.init` before the application is initialized, in `app.js`. This will allow Sentry to capture information while your app is starting.
42+
Any additional SDK settings can be modified via the usual config in `environment.js` for you, see the Additional Configuration section for more details.
3743

3844
```javascript
3945
import Application from '@ember/application';
4046
import Resolver from 'ember-resolver';
4147
import loadInitializers from 'ember-load-initializers';
4248
import config from './config/environment';
43-
import { InitSentryForEmber } from '@sentry/ember';
49+
import * as Sentry from "@sentry/ember";
4450

45-
InitSentryForEmber();
51+
Sentry.init({
52+
dsn: '__DSN__' // replace __DSN__ with your DSN,
53+
54+
// Set tracesSampleRate to 1.0 to capture 100%
55+
// of transactions for performance monitoring.
56+
// We recommend adjusting this value in production,
57+
tracesSampleRate: 1.0,
58+
});
4659

4760
export default class App extends Application {
4861
modulePrefix = config.modulePrefix;
@@ -75,27 +88,12 @@ ENV['@sentry/ember'] = {
7588

7689
// All component definitions will be added as spans.
7790
enableComponentDefinition: true,
78-
79-
// See sentry-javascript configuration https://docs.sentry.io/error-reporting/configuration/?platform=javascript
80-
sentry: {}
8191
};
8292
```
8393

84-
You can also pass additional configuration for sentry-javascript directly to the `InitSentryForEmber` method.
85-
This configuration will be merged with `ENV['@sentry/ember'].sentry`:
86-
87-
```javascript
88-
InitSentryForEmber({
89-
ignoreErrors: [
90-
/You appear to be offline/,
91-
],
92-
})
93-
```
94-
95-
It is recommended to pass all static sentry-javascript configuration directly to `InitSentryForEmber`, and only keeping configuration that depends on the build environment/secrets in `config/environment.js`. Please note that due to how the environment config is serialized, any non-JSON-serializable config (like a regex) will not work properly when being kept in `config/environment.js`.
96-
9794
#### Disabling Performance
9895

96+
9997
`@sentry/ember` captures performance by default, if you would like to disable the automatic performance instrumentation, you can add the following to your `config/environment.js`:
10098

10199
```javascript
@@ -106,7 +104,9 @@ ENV['@sentry/ember'] = {
106104

107105

108106
### Performance
107+
109108
#### Routes
109+
110110
If you would like to capture `beforeModel`, `model`, `afterModel` and `setupController` times for one of your routes,
111111
you can import `instrumentRoutePerformance` and wrap your route with it.
112112

@@ -124,21 +124,25 @@ export default instrumentRoutePerformance(MyRoute);
124124
```
125125

126126
#### Runloop
127+
127128
The runloop queue durations are instrumented by default, as long as they are longer than a threshold (by default 5ms).
128129
This helps (via the render queue) capturing the entire render in case component render times aren't fully instrumented,
129130
such as when using glimmer components.
130131

131132
If you would like to change the runloop queue threshold, add the following to your config:
133+
132134
```javascript
133135
ENV['@sentry/ember'] = {
134136
minimumRunloopQueueDuration: 0, // All runloop queue durations will be added as spans.
135137
};
136138
```
137139

138140
#### Components
141+
139142
Non-glimmer component render times will automatically get captured.
140143

141144
If you would like to disable component render being instrumented, add the following to your config:
145+
142146
```javascript
143147
ENV['@sentry/ember'] = {
144148
disableInstrumentComponents: true, // Will disable automatic instrumentation for components.
@@ -147,16 +151,19 @@ ENV['@sentry/ember'] = {
147151

148152
Additionally, components whose render time is below a threshold (by default 2ms) will not be included as spans.
149153
If you would like to change this threshold, add the following to your config:
154+
150155
```javascript
151156
ENV['@sentry/ember'] = {
152157
minimumComponentRenderDuration: 0, // All (non-glimmer) component render durations will be added as spans.
153158
};
154159
```
155160

156161
#### Glimmer components
162+
157163
Currently glimmer component render durations can only be captured indirectly via the runloop instrumentation. You can
158164
optionally enable a setting to show component definitions (which will indicate which components are being rendered) be
159165
adding the following to your config:
166+
160167
```javascript
161168
ENV['@sentry/ember'] = {
162169
enableComponentDefinition: true, // All component definitions will be added as spans.
@@ -165,7 +172,7 @@ ENV['@sentry/ember'] = {
165172

166173
### Supported Versions
167174

168-
`@sentry/ember` currently supports Ember **3.8+** for error monitoring.
175+
`@sentry/ember` currently supports Ember **4.0+** for error monitoring.
169176

170177
### Previous Integration
171178

@@ -174,8 +181,8 @@ this Ember addon to offer more Ember-specific error and performancing monitoring
174181

175182
## Testing
176183

177-
You can find example instrumentation in the `dummy` application, which is also used for testing. To test with the dummy
178-
application, you must pass the dsn as an environment variable.
184+
For this package itself, you can find example instrumentation in the `dummy` application, which is also used for testing.
185+
To test with the dummy application, you must pass the dsn as an environment variable.
179186

180187
```javascript
181188
SENTRY_DSN=__DSN__ ember serve

0 commit comments

Comments
 (0)