From 9545d36ee4ee8875c0c360838ec823de2fa5e730 Mon Sep 17 00:00:00 2001 From: Markus Hintersteiner Date: Tue, 27 Aug 2024 10:31:52 +0200 Subject: [PATCH] Update shared-environments.mdx --- .../platforms/android/configuration/shared-environments.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/platforms/android/configuration/shared-environments.mdx b/docs/platforms/android/configuration/shared-environments.mdx index b309aa2b4d997..b5a8fb37e9280 100644 --- a/docs/platforms/android/configuration/shared-environments.mdx +++ b/docs/platforms/android/configuration/shared-environments.mdx @@ -12,12 +12,12 @@ Using the Sentry SDK within another SDK is [discouraged](https://docs.sentry.io/ -When setting up Sentry in a shared environment where multiple Sentry instances may run, you should **not use `Sentry.init()`**, as this will pollute the global state. +When setting up Sentry inside a library, the consuming app could use the Sentry SDK as well, thus you should **not use `Sentry.init()`**, as this will pollute the global state. In order to not conflict with other Sentry instances, you should use the `Hub` API to create a new instance of Sentry. -The Hub API works the same way as the global Sentry instance, but it is not global and can be used within your component. If you want to capture uncaught exceptions, you can use the `UncaughtExceptionHandlerIntegration` to capture them. As this will capture all uncaught exceptions within your app, you should use the `BeforeSendCallback` to filter out events that are not relevant for your SDK. +The Hub API works the same way as the global Sentry instance, but it is not global and can be used within your component. If you want to capture uncaught exceptions, you can use the `UncaughtExceptionHandlerIntegration` to capture them. As this will capture all uncaught exceptions within an app, you should use the `BeforeSendCallback` to only accept events that are relevant for your SDK. ```kotlin import io.sentry.Hub @@ -30,7 +30,7 @@ val options = SentryOptions().apply { isEnableUncaughtExceptionHandler = true setBeforeSend { event, _ -> // as uncaught exceptions are captured globally, - // you need to filter out events which are not relevant for your SDK + // you need to only accept events which are relevant if (isRelevantForMySdk(event.throwable)) { return@setBeforeSend event }