Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
```kotlin
import io.sentry.kotlin.multiplatform.Sentry

// Application context is only needed for Android targets
Sentry.init(context) { options ->
Sentry.init { options ->
options.dsn = "___PUBLIC_DSN___"
options.release = "[email protected]+1"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
```kotlin
import io.sentry.kotlin.multiplatform.Sentry

// Application context is only needed for Android targets
Sentry.init(context) { options ->
Sentry.init { options ->
options.attachScreenshot = true
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ Currently only available on iOS and Android.
```kotlin
import io.sentry.kotlin.multiplatform.sentry

// Application context is only needed for Android targets
Sentry.init(context) { options ->
Sentry.init { options ->
options.dsn = "___PUBLIC_DSN___"
options.attachViewHierarchy = true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
```kotlin
import io.sentry.kotlin.multiplatform.Sentry

// Application context is only needed for Android targets
Sentry.init(context) { options ->
Sentry.init { options ->
options.maxAttachmentSize = 5 * 1024 * 1024 // 5 MiB
}
```
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
```kotlin
import io.sentry.kotlin.multiplatform.Sentry

// Application context is only needed for Android targets
Sentry.init(context) { options ->
Sentry.init { options ->
options.beforeBreadcrumb = { breadcrumb ->
if ("a.spammy.Logger" == breadcrumb.category) {
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
```kotlin
import io.sentry.kotlin.multiplatform.Sentry

// Application context is only needed for Android targets
Sentry.init(context) { ->
Sentry.init { ->
options.dsn = "___PUBLIC_DSN___"
}
```
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
```kotlin
import io.sentry.kotlin.multiplatform.Sentry

// Application context is only needed for Android targets
Sentry.init(context) {
Sentry.init {
it.environment = "production"
}
```
3 changes: 1 addition & 2 deletions src/platform-includes/set-release/kotlin-multiplatform.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
```kotlin
import io.sentry.kotlin.multiplatform.Sentry

// Application context is only needed for Android targets
Sentry.init(context) { options ->
Sentry.init { options ->
options.release = "[email protected]"
}
```
Expand Down
33 changes: 12 additions & 21 deletions src/platforms/kotlin-multiplatform/initialization-strategies.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,15 @@ To initialize the SDK, create a Kotlin file in your `commonMain` e.g. `AppSetup.
<SignInNote />

```kotlin {filename:AppSetup.kt}
import io.sentry.kotlin.multiplatform.Context
import io.sentry.kotlin.multiplatform.Sentry

// Application context is only needed for Android targets
fun initializeSentry(context: Context?) {
fun initializeSentry() {
val configuration: (SentryOptions) -> Unit = {
it.dsn = "___PUBLIC_DSN___"
// Add common configuration here
}
if (context != null) {
Sentry.init(context, configuration)
} else {
Sentry.init(configuration)
}
Sentry.init(configuration)
}
```

Expand All @@ -48,8 +43,7 @@ import your.kmp.app.initializeSentry
class YourApplication : Application() {
override fun onCreate() {
super.onCreate()
// Make sure to add the context!
initializeSentry(this)
initializeSentry()
}
}
```
Expand All @@ -63,7 +57,7 @@ func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
) -> Bool {
AppSetupKt.initializeSentry(context = nil)
AppSetupKt.initializeSentry()
return true
}
```
Expand All @@ -79,7 +73,7 @@ This approach gives you the flexibility to fine-tune the SDK's behavior to meet
```kotlin {filename:commonMain/AppSetup.kt}
import io.sentry.kotlin.multiplatform.Context

expect fun initializeSentry(context: Context? = null)
expect fun initializeSentry()
```

### androidMain
Expand All @@ -90,12 +84,10 @@ expect fun initializeSentry(context: Context? = null)
import io.sentry.kotlin.multiplatform.Sentry
import io.sentry.kotlin.multiplatform.Context

actual fun initializeSentry(context: Context?) {
if (context != null) {
Sentry.init(context) {
it.dsn = "___PUBLIC_DSN___"
// Add Android-specific configuration here
}
actual fun initializeSentry() {
Sentry.init {
it.dsn = "___PUBLIC_DSN___"
// Add Android-specific configuration here
}
}
```
Expand All @@ -108,7 +100,7 @@ actual fun initializeSentry(context: Context?) {
import io.sentry.kotlin.multiplatform.Sentry
import io.sentry.kotlin.multiplatform.Context

actual fun initializeSentry(context: Context?) {
actual fun initializeSentry() {
Sentry.init {
it.dsn = "___PUBLIC_DSN___"
// Add iOS-specific configuration here
Expand All @@ -126,8 +118,7 @@ import your.kmp.app.initializeSentry
class YourApplication : Application() {
override fun onCreate() {
super.onCreate()
// Make sure to add the context!
initializeSentry(this)
initializeSentry()
}
}
```
Expand All @@ -141,7 +132,7 @@ func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
) -> Bool {
AppSetupKt.initializeSentry(context = nil)
AppSetupKt.initializeSentry()
return true
}
```
Expand Down