diff --git a/docs/platforms/native/common/enriching-events/scopes/index.mdx b/docs/platforms/native/common/enriching-events/scopes/index.mdx index c71008ad3d6dc4..e5748e05294b46 100644 --- a/docs/platforms/native/common/enriching-events/scopes/index.mdx +++ b/docs/platforms/native/common/enriching-events/scopes/index.mdx @@ -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 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/). @@ -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 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. diff --git a/platform-includes/enriching-events/scopes/configure-scope/native.mdx b/platform-includes/enriching-events/scopes/configure-scope/native.mdx index 365f0f10dd4f0a..e374637ebcfae0 100644 --- a/platform-includes/enriching-events/scopes/configure-scope/native.mdx +++ b/platform-includes/enriching-events/scopes/configure-scope/native.mdx @@ -1,6 +1,4 @@ -The Native SDK maintains all data in a single global scope. - -```c +```c {tabTitle:Global Scope} #include sentry_set_tag("my-tag", "my value"); @@ -9,3 +7,19 @@ sentry_set_tag("my-tag", "my value"); sentry_value_t user = sentry_value_new_user("42", "Jane Doe", "jane.doe@example.com", "{{auto}}"); sentry_set_user(user); ``` + +```c {tabTitle:Local Scope} +#include + +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", "jane.doe@example.com", "{{auto}}"); +sentry_scope_set_user(scope, user); + +sentry_value_t event = sentry_value_new_event(); +/* ... */ +sentry_capture_event_with_scope(event, scope); +```