Skip to content

Commit b3b5d42

Browse files
authored
chore(readme): update init code (#59)
* Update README.md * Update README.md * update dsn in readme
1 parent 83a4a77 commit b3b5d42

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,21 @@ Create a Kotlin file in your commonMain e.g. `AppSetup.kt` or however you want t
9797
```Kotlin
9898
import io.sentry.kotlin.multiplatform.Context
9999
import io.sentry.kotlin.multiplatform.Sentry
100+
import io.sentry.kotlin.multiplatform.OptionsConfiguration
100101

101102
// The context is needed for Android initializations
102-
fun initializeSentry(context: Context?) {
103-
Sentry.init(context) {
104-
it.dsn = "__DSN__"
105-
}
103+
fun initializeSentry(context: Context) {
104+
Sentry.init(context, optionsConfiguration())
105+
}
106+
107+
fun initializeSentry() {
108+
Sentry.init(optionsConfiguration())
106109
}
110+
111+
private fun optionsConfiguration(): OptionsConfiguration = {
112+
it.dsn = "__DSN__"
113+
}
114+
107115
```
108116

109117
Now call this function in an early lifecycle stage in your platforms.
@@ -131,7 +139,7 @@ class AppDelegate: NSObject, UIApplicationDelegate {
131139
_ application: UIApplication,
132140
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
133141
) -> Bool {
134-
AppSetupKt.initializeSentry(context = nil)
142+
AppSetupKt.initializeSentry()
135143
return true
136144
}
137145
}

0 commit comments

Comments
 (0)