Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -35,7 +35,7 @@ routes or controllers.
As you start using an SDK, a scope and hub are automatically created for you out
of the box. It's unlikely that you'll interact with the hub directly unless you're
writing an integration or you want to create or destroy scopes. Scopes, on the
other hand are more user facing. You can call <PlatformIdentifier name="configure-scope" /> at any point in
other hand are more user facing. You can call various setters at any point in
time to modify data stored on the scope. This is useful for doing things like
[modifying the context](../context/).

Expand All @@ -53,7 +53,8 @@ For details on how this affects tracing, check out the [Connect Errors With Span

## Configuring the Scope

The most useful operation when working with scopes is the <PlatformIdentifier name="configure-scope" /> function. It can be used to reconfigure the current scope.
The Native SDK maintains most data in a global scope, but allows creating transient
local scopes for capturing individual events.

You can, for instance, add custom tags or inform Sentry about the currently authenticated user.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
The Native SDK maintains all data in a single global scope.

```c
```c {tabTitle:Global Scope}
#include <sentry.h>

sentry_set_tag("my-tag", "my value");
Expand All @@ -9,3 +7,19 @@ sentry_set_tag("my-tag", "my value");
sentry_value_t user = sentry_value_new_user("42", "Jane Doe", "[email protected]", "{{auto}}");
sentry_set_user(user);
```

```c {tabTitle:Local Scope}
#include <sentry.h>

sentry_scope_t *scope = sentry_local_scope_new();

sentry_scope_set_tag(scope, "my-tag", "my scoped value");

// Set a user with id, username, email, and ip_address
sentry_value_t user = sentry_value_new_user("42", "Jane Doe", "[email protected]", "{{auto}}");
sentry_scope_set_user(scope, user);

sentry_value_t event = sentry_value_new_event();
/* ... */
sentry_capture_event_with_scope(event, scope);
```
Loading