-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...in-multiplatform/src/commonAppleMain/kotlin/io/sentry/kotlin/multiplatform/SentryEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.sentry.kotlin.multiplatform | ||
|
||
import io.sentry.kotlin.multiplatform.extensions.toKmpSentryLevel | ||
import io.sentry.kotlin.multiplatform.protocol.Message | ||
|
||
public actual class SentryEvent(cocoaSentryEvent: CocoaSentryEvent) : SentryBaseEvent() { | ||
public actual var level: SentryLevel? = cocoaSentryEvent.level?.toKmpSentryLevel() | ||
public actual var message: Message? | ||
get() = TODO("Not yet implemented") | ||
set(value) {} | ||
public actual var logger: String? | ||
get() = TODO("Not yet implemented") | ||
set(value) {} | ||
public actual var fingerprint: List<String>? | ||
get() = TODO("Not yet implemented") | ||
set(value) {} | ||
|
||
public actual fun isCrashed(): Boolean { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
public actual fun isError(): Boolean { | ||
TODO("Not yet implemented") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...tlin-multiplatform/src/commonJvmMain/kotlin/io/sentry/kotlin/multiplatform/SentryEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.sentry.kotlin.multiplatform | ||
|
||
import io.sentry.kotlin.multiplatform.extensions.toKmpMessage | ||
import io.sentry.kotlin.multiplatform.extensions.toKmpSentryLevel | ||
import io.sentry.kotlin.multiplatform.protocol.Message | ||
|
||
public actual class SentryEvent(jvmSentryEvent: JvmSentryEvent) : SentryBaseEvent() { | ||
public actual var level: SentryLevel? = jvmSentryEvent.level?.toKmpSentryLevel() | ||
public actual var message: Message? = jvmSentryEvent.message?.toKmpMessage() | ||
public actual var logger: String? = jvmSentryEvent.logger | ||
public actual var fingerprint: List<String>? = jvmSentryEvent.fingerprints?.toList() | ||
|
||
public actual fun isCrashed(): Boolean { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
public actual fun isError(): Boolean { | ||
TODO("Not yet implemented") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...m/src/commonJvmMain/kotlin/io/sentry/kotlin/multiplatform/extensions/MessageExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.sentry.kotlin.multiplatform.extensions | ||
|
||
import io.sentry.kotlin.multiplatform.JvmMessage | ||
import io.sentry.kotlin.multiplatform.protocol.Message | ||
|
||
internal fun JvmMessage.toKmpMessage() = Message( | ||
message = message, | ||
params = params, | ||
formatted = formatted | ||
) | ||
|
||
internal fun Message.toJvmMessage() = JvmMessage().apply { | ||
val scope = this@toJvmMessage | ||
message = scope.message | ||
params = scope.params | ||
formatted = scope.formatted | ||
} |
12 changes: 12 additions & 0 deletions
12
...c/commonJvmMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryEventExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.sentry.kotlin.multiplatform.extensions | ||
|
||
import io.sentry.kotlin.multiplatform.JvmSentryEvent | ||
import io.sentry.kotlin.multiplatform.SentryEvent | ||
|
||
internal fun JvmSentryEvent.applyKmpEvent(kmpEvent: SentryEvent): JvmSentryEvent { | ||
level = kmpEvent.level?.toJvmSentryLevel() | ||
message = kmpEvent.message?.toJvmMessage() | ||
logger = kmpEvent.logger | ||
fingerprints = kmpEvent.fingerprint | ||
return this | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...lin-multiplatform/src/commonMain/kotlin/io/sentry/kotlin/multiplatform/SentryBaseEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package io.sentry.kotlin.multiplatform | ||
|
||
import io.sentry.kotlin.multiplatform.protocol.Breadcrumb | ||
import io.sentry.kotlin.multiplatform.protocol.SentryId | ||
import io.sentry.kotlin.multiplatform.protocol.User | ||
|
||
public abstract class SentryBaseEvent(public var eventId: SentryId = SentryId.EMPTY_ID) { | ||
|
||
// public val contexts = Contexts() | ||
public var tags: MutableMap<String, String>? = null | ||
set(value) { | ||
field = value?.let { HashMap(it) } | ||
} | ||
public var release: String? = null | ||
public var environment: String? = null | ||
public var platform: String? = null | ||
public var user: User? = null | ||
protected var throwable: Throwable? = null | ||
public var serverName: String? = null | ||
public var dist: String? = null | ||
private var breadcrumbs: MutableList<Breadcrumb>? = null | ||
set(value) { | ||
field = value?.let { ArrayList(it) } | ||
} | ||
private var extra: MutableMap<String, Any>? = null | ||
set(value) { | ||
field = value?.let { HashMap(it) } | ||
} | ||
|
||
public fun removeTag(key: String) { | ||
tags?.remove(key) | ||
} | ||
|
||
public fun getTag(key: String): String? = tags?.get(key) | ||
|
||
public fun setTag(key: String, value: String) { | ||
if (tags == null) { | ||
tags = HashMap() | ||
} | ||
tags!![key] = value | ||
} | ||
|
||
public fun addBreadcrumb(breadcrumb: Breadcrumb) { | ||
if (breadcrumbs == null) { | ||
breadcrumbs = mutableListOf() | ||
} | ||
breadcrumbs?.add(breadcrumb) | ||
} | ||
|
||
public fun setExtra(key: String, value: Any) { | ||
if (extra == null) { | ||
extra = HashMap() | ||
} | ||
extra!![key] = value | ||
} | ||
|
||
public fun removeExtra(key: String) { | ||
extra?.remove(key) | ||
} | ||
|
||
public fun getExtra(key: String): Any? = extra?.get(key) | ||
|
||
public fun addBreadcrumb(message: String?) { | ||
addBreadcrumb(Breadcrumb(message = message)) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...-kotlin-multiplatform/src/commonMain/kotlin/io/sentry/kotlin/multiplatform/SentryEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.sentry.kotlin.multiplatform | ||
|
||
import io.sentry.kotlin.multiplatform.protocol.Message | ||
|
||
public expect class SentryEvent : SentryBaseEvent { | ||
public var message: Message? | ||
public var logger: String? | ||
public var level: SentryLevel? | ||
public var fingerprint: List<String>? | ||
public fun isCrashed(): Boolean | ||
public fun isError(): Boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...in-multiplatform/src/commonMain/kotlin/io/sentry/kotlin/multiplatform/protocol/Message.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.sentry.kotlin.multiplatform.protocol | ||
|
||
public data class Message( | ||
public var message: String? = null, | ||
public var params: List<String>? = null, | ||
public var formatted: String? = null | ||
) |