Skip to content

Commit 85a1bb3

Browse files
antonisclaude
andcommitted
docs(react-native): Add scope attributes API documentation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 39c95fc commit 85a1bb3

File tree

1 file changed

+30
-0
lines changed
  • docs/platforms/react-native/enriching-events/scopes

1 file changed

+30
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,36 @@ Sentry.setUser({
132132
To learn what useful information can be associated with scopes see
133133
[context](../context/), [tags](../tags), [users](../identify-user) and [breadcrumbs](../breadcrumbs/).
134134

135+
## Scope Attributes
136+
137+
Scope attributes are key-value pairs that are automatically included in structured logs and metrics. You can set, update, and remove attributes on the scope:
138+
139+
```javascript
140+
// Set a single attribute
141+
Sentry.getIsolationScope().setAttribute("org_id", "abc123");
142+
143+
// Set multiple attributes at once
144+
Sentry.getIsolationScope().setAttributes({
145+
user_tier: "premium",
146+
request_count: 42,
147+
is_admin: true,
148+
});
149+
150+
// Remove an attribute
151+
Sentry.getIsolationScope().removeAttribute("org_id");
152+
```
153+
154+
Attributes support primitive values: strings, numbers, and booleans. Non-primitive values (objects, arrays) are not synced to the native layer.
155+
156+
You can also set attributes within a specific scope using `withScope`:
157+
158+
```javascript
159+
Sentry.withScope((scope) => {
160+
scope.setAttribute("request_id", "req-123");
161+
Sentry.logger.info("Processing request");
162+
});
163+
```
164+
135165
## Using `withScope`
136166

137167
In the following example we use <PlatformIdentifier name="with-scope" /> to attach a `level` and a `tag` to only one specific error:

0 commit comments

Comments
 (0)