Skip to content

Commit 42dad12

Browse files
authored
feat(sdk): add kmp platform (#6452)
* add initial kmp platform setup * add init strategies & improve docs * add comment to init and remove android description * review improvements * add viewhierarchy * doc review * short introduction * change file type to kts for build.gradle * add experimental note * review improvements
1 parent 52c20ae commit 42dad12

File tree

41 files changed

+440
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+440
-18
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
```kotlin
2+
import io.sentry.kotlin.multiplatform.Sentry
3+
4+
Sentry.captureException(exception)
5+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
```kotlin
2+
import io.sentry.kotlin.multiplatform.Sentry
3+
4+
Sentry.captureMessage("Something went wrong")
5+
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
```kotlin
2+
import io.sentry.kotlin.multiplatform.Sentry
3+
4+
// Application context is only needed for Android targets
5+
Sentry.init(context) { options ->
6+
options.dsn = "___PUBLIC_DSN___"
7+
options.release = "[email protected]+1"
8+
}
9+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The Kotlin Multiplatform SDK uses native SDKs to automatically store Sentry events on the device's disk before shutdown.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
To add an attachment, either add it to the scope or pass it to any of the `capture` methods.
2+
3+
### Passing Attachments to Capture
4+
5+
You can pass attachments to any of the `capture` methods. For example, when capturing an exception:
6+
7+
```kotlin
8+
import io.sentry.kotlin.multiplatform.Attachment
9+
import io.sentry.kotlin.multiplatform.Sentry
10+
11+
val fileAttachment = Attachment("your/path/file.log")
12+
13+
Sentry.captureException(IllegalStateException()) { scope ->
14+
scope.addAttachment(fileAttachment)
15+
}
16+
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
```kotlin
2+
import io.sentry.kotlin.multiplatform.Sentry
3+
4+
// Application context is only needed for Android targets
5+
Sentry.init(context) { options ->
6+
options.attachScreenshot = true
7+
}
8+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Note>
2+
3+
Currently only available on iOS and Android.
4+
5+
</Note>
6+
7+
```kotlin
8+
import io.sentry.kotlin.multiplatform.sentry
9+
10+
// Application context is only needed for Android targets
11+
Sentry.init(context) { options ->
12+
options.dsn = "___PUBLIC_DSN___"
13+
options.attachViewHierarchy = true
14+
}
15+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```kotlin
2+
import io.sentry.kotlin.multiplatform.Sentry
3+
import io.sentry.kotlin.multiplatform.Attachment
4+
5+
val attachment = Attachment(bytes, "file.log")
6+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```kotlin
2+
import io.sentry.kotlin.multiplatform.Sentry
3+
import io.sentry.kotlin.multiplatform.Attachment
4+
5+
val attachment = Attachment("your/path/file.log")
6+
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
```kotlin
2+
import io.sentry.kotlin.multiplatform.Sentry
3+
4+
// Application context is only needed for Android targets
5+
Sentry.init(context) { options ->
6+
options.maxAttachmentSize = 5 * 1024 * 1024 // 5 MiB
7+
}
8+
```

0 commit comments

Comments
 (0)