You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/react-native/enriching-events/scopes/index.mdx
+8-10Lines changed: 8 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,11 +39,11 @@ The global scope is applied to _all_ events, no matter where they originate. You
39
39
40
40
You can access the global scope via `Sentry.getGlobalScope()`.
41
41
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).
43
43
44
44
### Isolation Scope
45
45
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.
47
47
48
48
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:
49
49
@@ -54,16 +54,14 @@ Sentry.getIsolationScope().setTag("my-tag", "my value");
54
54
```
55
55
56
56
<PlatformCategorySectionsupported={["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.
60
58
</PlatformCategorySection>
61
59
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).
63
61
64
62
### Current Scope
65
63
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:
67
65
68
66
```javascript
69
67
Sentry.withScope((scope) => {
@@ -77,7 +75,7 @@ Sentry.withScope((scope) => {
77
75
Sentry.captureException(newError("my other error"));
78
76
```
79
77
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.
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).
110
108
111
109
You'll first need to import the SDK, as usual:
112
110
@@ -140,6 +138,6 @@ In the following example we use <PlatformIdentifier name="with-scope" /> to atta
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
144
142
more easily isolate pieces of context information to specific locations in your code or
145
143
even call <PlatformIdentifiername="clear" /> to briefly remove all context information.
0 commit comments