Skip to content

Commit 54cefc5

Browse files
Apply suggestions from code review - new scopes
Co-authored-by: Liza Mock <[email protected]>
1 parent 34bc100 commit 54cefc5

File tree

1 file changed

+8
-10
lines changed
  • docs/platforms/react-native/enriching-events/scopes

1 file changed

+8
-10
lines changed

docs/platforms/react-native/enriching-events/scopes/index.mdx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ The global scope is applied to _all_ events, no matter where they originate. You
3939

4040
You can access the global scope via `Sentry.getGlobalScope()`.
4141

42-
Note that the global scope can only be used to write data, not to capture events. Events can only be captured on the current scope (e.g. `getCurrentScope().captureException()` and similar APIs).
42+
Note, that the global scope can only be used to write data, not to capture events. Events can only be captured on the current scope (for example, `getCurrentScope().captureException()` and similar APIs).
4343

4444
### Isolation Scope
4545

46-
The isolation scope is used to isolate events from each other. For example, each request in a web server might get its own isolation scope, so that events from one request don't interfere with events from another request. In most cases, you'll want to put data that should be applied to your events on the isolation scope - which is also why all `Sentry.setXXX` methods, like `Sentry.setTag()`, will write data onto the currently active isolation scope. A classic example for data that belongs on the isolation scope is a user - each request may have a different user, so you want to make sure that the user is set on the isolation scope.
46+
The isolation scope is used to isolate events from each other. For example, each request in a web server might get its own isolation scope, so that events from one request don't interfere with events from another. In most cases, you'll want to put data that should be applied to your events on the isolation scope. This is why all `Sentry.setXXX` methods, like `Sentry.setTag()` will write data onto the currently active isolation scope. A classic example of data that belongs on the isolation scope is user data, where each request may have a different user, so you'd want to make sure that the user is set on the isolation scope.
4747

4848
You can access the isolation scope via `Sentry.getIsolationScope()`, but usually you'll just use the `Sentry.setXXX` methods to set data on the currently active isolation scope:
4949

@@ -54,16 +54,14 @@ Sentry.getIsolationScope().setTag("my-tag", "my value");
5454
```
5555

5656
<PlatformCategorySection supported={["browser"]}>
57-
In the browser, the isolation scope is never forked, because it is impossible
58-
to keep track of where an isolation scope would belong to. Because of this, in
59-
the browser the isolation scope is effectively global.
57+
In the browser, the isolation scope is never forked because it's impossible to keep track of where an isolation scope would belong. This is why the isolation scope is effectively global in the browser.
6058
</PlatformCategorySection>
6159

62-
Note that the isolation scope can only be used to write data, not to capture events. Events can only be captured on the current scope (e.g. `getCurrentScope().captureException()` and similar APIs).
60+
Note, that the isolation scope can only be used to write data, not to capture events. Events can only be captured on the current scope (for example, `getCurrentScope().captureException()` and similar APIs).
6361

6462
### Current Scope
6563

66-
The current scope is the local scope that is currently active. Unlike the rarely-forked isolation scope, the current scope may be forked more frequently and under the hood. It can be used to store data that should only be applied to specific events. In most cases, you should not access this scope directly, but use `Sentry.withScope` to create a new scope that is only active for a specific part of your code:
64+
Current scope is the local scope that's currently active. Unlike the rarely-forked isolation scope, the current scope may be forked more frequently and under the hood. It can be used to store data that should only be applied to specific events. In most cases, you shouldn't access this scope directly, but use `Sentry.withScope` to create a new scope that's only active for a specific part of your code:
6765

6866
```javascript
6967
Sentry.withScope((scope) => {
@@ -77,7 +75,7 @@ Sentry.withScope((scope) => {
7775
Sentry.captureException(new Error("my other error"));
7876
```
7977

80-
You can access the current scope via `Sentry.getCurrentScope()`, but usually you should use `Sentry.withScope()` to interact with local scopes instead.
78+
You can access the current scope via `Sentry.getCurrentScope()`, but you should use `Sentry.withScope()` to interact with local scopes in most cases instead.
8179

8280
## How Scope Data is Applied to Events
8381

@@ -106,7 +104,7 @@ Sentry.captureException(new Error("my error"));
106104

107105
## Configuring the Scope
108106

109-
There are two main ways to interact with the scope. You can access the current scope via `Sentry.getCurrentScope()` and use setters on the resulting scope, or you can use global methods like `Sentry.setTag()` directly, which will set on the respective scope under the hood (which will be the isolation scope).
107+
There are two main ways to interact with the scope. You can access the current scope via `Sentry.getCurrentScope()` and use setters on the resulting scope, or you can use global methods like `Sentry.setTag()` directly, which will set on the respective scope under the hood (this will be the isolation scope).
110108

111109
You'll first need to import the SDK, as usual:
112110

@@ -140,6 +138,6 @@ In the following example we use <PlatformIdentifier name="with-scope" /> to atta
140138

141139
<PlatformContent includePath="enriching-events/scopes/with-scope" />
142140

143-
The scope inside the `withScope()` callback is only valid inside of the callback. Once the callback ends, the scope will be removed and no longer applied. The inner scope is only applied to events that are captured inside of the callback. `withScope()` will clone (or fork) the current scope, so that the current scope is not modified. This allows you to
141+
The scope inside the `withScope()` callback is only valid inside of the callback. Once the callback ends, the scope will be removed and will no longer apply. The inner scope is only applied to events that are captured inside of the callback. `withScope()` will clone (or fork) the current scope, so the current scope won't be modified. This allows you to
144142
more easily isolate pieces of context information to specific locations in your code or
145143
even call <PlatformIdentifier name="clear" /> to briefly remove all context information.

0 commit comments

Comments
 (0)