Skip to content

Commit 4568455

Browse files
committed
Update
1 parent 552926f commit 4568455

File tree

2 files changed

+51
-18
lines changed

2 files changed

+51
-18
lines changed

docs/platforms/kotlin/guides/compose-multiplatform/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ While Sentry's Kotlin Multiplatform SDK works in Compose Multiplatform projects,
2020

2121
It is required to use the [Sentry Kotlin Multiplatform SDK](/platforms/kotlin/guides/kotlin-multiplatform/) which provides error tracking across multiple Kotlin targets. While the SDK functions in Compose Multiplatform projects using the same APIs as pure KMP setups, it's important to note:
2222

23-
- **Experimental support**: The KMP SDK works in CMP projects and currently supports capturing crashes and errors as well as other basic features that are available through the Sentry KMP SDK.
24-
- ⚠️ **Not CMP-native**: No specific CMP optimizations or testing.
25-
- 🔍 **Untested edge cases**: Some platform-specific behaviors may be incomplete.
23+
- **Experimental support**: The KMP SDK works in CMP projects and currently supports capturing crashes and errors as well as other basic features that are available through the Sentry KMP SDK.
24+
- **Not CMP-native**: No specific CMP optimizations or testing.
25+
- **Untested edge cases**: Some platform-specific behaviors may be incomplete.
2626

2727
## Installation
2828

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,52 @@
1-
Initialize Sentry in your main application entry point, typically in your `main()` function or `App` composable:
1+
1. Add a function to initialize Sentry to your shared module (`commonMain`).
2+
2. Call the function in your iOS and Android app modules.
23

3-
```kotlin {filename:App.kt}
4+
```kotlin {filename:SentrySetup.kt}{tabTitle: commonMain}
45
import io.sentry.kotlin.multiplatform.Sentry
5-
import androidx.compose.runtime.Composable
6-
7-
@Composable
8-
fun App() {
9-
// Initialize Sentry when your app starts
10-
Sentry.init { options ->
11-
options.dsn = "___PUBLIC_DSN___"
12-
// Adds request headers and IP for users, for more info visit:
13-
// https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/data-management/data-collected/
14-
options.sendDefaultPii = true
6+
7+
fun initializeSentry() {
8+
Sentry.init { options ->
9+
options.dsn = "___PUBLIC_DSN___"
10+
// Adds request headers and IP for users, for more info visit:
11+
// https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/data-management/data-collected/
12+
options.sendDefaultPii = true
13+
}
14+
}
15+
```
16+
```swift {tabTitle: iosApp}
17+
import ComposeApp // Replace this with the name of the shared framework
18+
19+
@main
20+
struct iOSApp: App {
21+
init() {
22+
SentrySetupKt.initializeSentry()
1523
}
16-
17-
// ... your compose UI content
24+
var body: some Scene {
25+
WindowGroup {
26+
ContentView()
27+
}
28+
}
29+
}
30+
31+
// OR alternatively in AppDelegate:
32+
33+
34+
func application(
35+
_ application: UIApplication,
36+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
37+
) -> Bool {
38+
SentrySetupKt.initializeSentry()
39+
return true
40+
}
41+
42+
```
43+
```kotlin {filename:MainActivity.kt}{tabTitle: androidApp}
44+
import your.kmp.app.initializeSentry
45+
46+
class YourApplication : Application() {
47+
override fun onCreate() {
48+
super.onCreate()
49+
initializeSentry()
50+
}
1851
}
19-
```
52+
```

0 commit comments

Comments
 (0)