diff --git a/src/includes/enriching-events/attachment-upload/android.mdx b/src/includes/enriching-events/attachment-upload/android.mdx new file mode 100644 index 0000000000000..bc9642ac3f7de --- /dev/null +++ b/src/includes/enriching-events/attachment-upload/android.mdx @@ -0,0 +1,33 @@ +```java +import io.sentry.Sentry; +import io.sentry.Attachment; + +Attachment fileAttachment = new Attachment("your/path/file.log"); + +// Add an attachment +Sentry.configureScope(scope -> { + scope.addAttachment(fileAttachment); +}); + +// Clear all attachments +Sentry.configureScope(scope -> { + scope.clearAttachments(); +}); +``` + +```kotlin +import io.sentry.Sentry +import io.sentry.Attachment + +val fileAttachment = Attachment("your/path/file.log") + +// Add an attachment +Sentry.configureScope { scope -> + scope.addAttachment(fileAttachment) +} + +// Clear all attachments +Sentry.configureScope { scope -> + scope.clearAttachments() +} +``` diff --git a/src/includes/enriching-events/scopes/configure-scope/android.mdx b/src/includes/enriching-events/scopes/configure-scope/android.mdx index 498e4c5858d6a..9e36bdf29724a 100644 --- a/src/includes/enriching-events/scopes/configure-scope/android.mdx +++ b/src/includes/enriching-events/scopes/configure-scope/android.mdx @@ -1,11 +1 @@ - -### Scope Synchronization - -If you want to set context data in the Java layer, then receive that context data when a native (C/C++) crash happens, you need to synchronize the Java `Scope` with the native `Scope`. This feature was introduced in version `3.0.0` of the Android SDK and requires an opt-in: - -```xml {filename:AndroidManifest.xml} - - - -``` diff --git a/src/includes/enriching-events/scopes/scope-synchronization/android.mdx b/src/includes/enriching-events/scopes/scope-synchronization/android.mdx new file mode 100644 index 0000000000000..80a330417e444 --- /dev/null +++ b/src/includes/enriching-events/scopes/scope-synchronization/android.mdx @@ -0,0 +1,9 @@ +### Scope Synchronization + +If you want to set context data in the Java layer, then receive that context data when a native (C/C++) crash happens, you need to synchronize the Java `Scope` with the native `Scope`. This feature was introduced in version `3.0.0` of the Android SDK and requires an opt-in: + +```xml {filename:AndroidManifest.xml} + + + +``` diff --git a/src/includes/enriching-events/scopes/with-scope/android.mdx b/src/includes/enriching-events/scopes/with-scope/android.mdx deleted file mode 100644 index ac1b0879639fc..0000000000000 --- a/src/includes/enriching-events/scopes/with-scope/android.mdx +++ /dev/null @@ -1 +0,0 @@ -The Sentry Android SDK doesn't support the concept of `Local Scopes`. It's a single and shared `Scope` across the App's lifecycle. diff --git a/src/platforms/common/enriching-events/attachments/index.mdx b/src/platforms/common/enriching-events/attachments/index.mdx index 7a487db38e667..4d84913fb401d 100644 --- a/src/platforms/common/enriching-events/attachments/index.mdx +++ b/src/platforms/common/enriching-events/attachments/index.mdx @@ -86,7 +86,7 @@ You'll first need to import the SDK, as usual: - + Attachments live on the Scope. You can either add an attachment on the global scope to be sent with every event or add it on the local Scope to just send the attachment with one specific event. @@ -94,6 +94,14 @@ Attachments live on the Scope + + +Attachments live on the Scope, and will be sent with all events. + + + + + Unity features a global scope to which you add an attachment that will be sent with every event. diff --git a/src/platforms/common/enriching-events/scopes.mdx b/src/platforms/common/enriching-events/scopes.mdx index e81a9fb18bef1..8d77ed466dc72 100644 --- a/src/platforms/common/enriching-events/scopes.mdx +++ b/src/platforms/common/enriching-events/scopes.mdx @@ -40,11 +40,11 @@ routes or controllers. ## How the Scope and Hub Work As you start using an SDK, a scope and hub are automatically created for you out -of the box. You are unlikely to be interacting with the hub directly unless you -are writing an integration or you want to create or destroy scopes. Scopes, on the -other hand are more user facing. You can at any point in time call -`configure-scope` to modify data stored on the scope. This is for instance -used to [modify the context](../context/). +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 `configure-scope` at any point in +time to to modify data stored on the scope. This is useful for doing things like +[modifying the context](../context/). If you are very curious about how thread locality works: On platforms such as .NET @@ -80,26 +80,44 @@ You can also apply this configuration when unsetting a user at logout: + + + + + + To learn what useful information can be associated with scopes see [the context documentation](../context/). + + ## Local Scopes -We also have support for pushing and configuring a scope in one go. This is typically called `with-scope` or `push-scope` which is also very helpful if you only want to send data with one specific event. In the following example we are using that function to attach a `level` and a `tag` to only one specific error: +We also support pushing and configuring a scope within a single call. This is typically +called `with-scope` or `push-scope` depending on the SDK, and is very helpful if +you only want to send data for one specific event. In the following example we use +`with-scope` to attach a `level` and a `tag` to only one specific error: -While this example looks similar to `configure-scope`, it's very different, in the sense that `configure-scope` actually changes the current active scope, all successive calls to `configure-scope` -will keep the changes. +While this example looks similar to `configure-scope`, it is actually very different. +Calls to `configure-scope` change the current active scope; all successive calls +to `configure-scope` will maintain previously set changes unless they are explicitly +unset. + +On the other hand, `with-scope` creates a clone of the current scope, and the changes +made will stay isolated within the `with-scope` callback function. This allows you to +more easily isolate pieces of context information to specific locations in your code or +even call `clear` to briefly remove all context information. -While on the other hand using `with-scope` creates a clone of the current scope -and will stay isolated until the function call is completed. So you can either -set context information in there that you don't want to be somewhere else or not -attach any context information at all by calling `clear` on the scope, while the -"global" scope remains unchanged. + -Keep in mind that `with-scope` will not capture any exceptions that happen inside its callback function, -and every error that happens there will be silently ignored and *not* reported. +Any exceptions that occur within the callback function for `with-scope` will not be +caught, and all errors that occur will be silently ignored and **not** reported. + + + + @@ -140,4 +158,5 @@ launch(SentryContext()) { } } ``` +