Skip to content

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
markushi committed Aug 19, 2024
1 parent 52c6a9c commit c34cefd
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
---
title: Shared Environments
description: "Learn how to use the Sentry SDK within another SDK."
sidebar_order: 1
title: Using Sentry within an SDK
description: "Learn how to use the Sentry SDK within a shared environment, e.g. another SDK."
sidebar_order: 2000
---

<Note>

Using the sentry SDK within another SDK is discouraged. This can lead to unexpected behavior and potential data leakage. If you need to use Sentry within another SDK, please follow the best practices outlined below.
Using the Sentry SDK within another SDK is [discouraged](https://docs.sentry.io/platforms/). This can lead to unexpected behaviour and potential data leakage. If you need to use Sentry within another SDK, please follow the best practices outlined below.

</Note>

<Note>

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.

</ Note>
</Note>

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.
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.

```kotlin
import io.sentry.Hub
Expand All @@ -34,7 +34,7 @@ val options = SentryOptions().apply {
if (isRelevantForMySdk(event.throwable)) {
return@setBeforeSend event
}

// drop the event
return@setBeforeSend null
}

Expand Down

0 comments on commit c34cefd

Please sign in to comment.