Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(scope): Add small clarifications on current scope #10350

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Sentry.captureException(new Error("my error"));

## Configuring the Scope

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.
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 current active isolation scope).
s1gr1d marked this conversation as resolved.
Show resolved Hide resolved

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

Expand All @@ -111,14 +111,15 @@ You'll first need to import the SDK, as usual:
You can, for instance, add custom tags or inform Sentry about the currently authenticated user.

```javascript
/// Usually, you don't want to write on the current scope, so use with care!
const scope = Sentry.getCurrentScope();
scope.setTag("my-tag", "my value");
scope.setUser({
id: 42,
email: "[email protected]",
});

// Or use the global methods
// Or use the global methods (which will set data on the currently active isolation scope):
s1gr1d marked this conversation as resolved.
Show resolved Hide resolved
Sentry.setTag("my-tag", "my value");
Sentry.setUser({
id: 42,
Expand Down
Loading