Skip to content

Commit 57120d8

Browse files
committed
Add support for stub sourceSet
1 parent 457cca0 commit 57120d8

File tree

15 files changed

+151
-169
lines changed

15 files changed

+151
-169
lines changed

sentry-kotlin-multiplatform/build.gradle.kts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ kotlin {
5454
js(IR) {
5555
browser()
5656
binaries.library()
57-
58-
// Disable JS test execution; commonTest already covers logic
59-
testTask {
60-
enabled = false
61-
}
6257
}
6358
iosArm64()
6459
iosSimulatorArm64()
@@ -204,6 +199,15 @@ kotlin {
204199
"-DSentryMetricsAPIDelegate=SentryMetricsAPIDelegateUnavailable"
205200
)
206201
}
202+
203+
val commonStub by creating {
204+
dependsOn(commonMain.get())
205+
}
206+
val commonStubTest by creating {
207+
dependsOn(commonTest.get())
208+
}
209+
jsMain.get().dependsOn(commonStub)
210+
jsTest.get().dependsOn(commonStubTest)
207211
}
208212
}
209213

sentry-kotlin-multiplatform/sentry_kotlin_multiplatform.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ Pod::Spec.new do |spec|
5454
}
5555
]
5656

57-
end
57+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package io.sentry.kotlin.multiplatform
2+
3+
import io.sentry.kotlin.multiplatform.protocol.Breadcrumb
4+
import io.sentry.kotlin.multiplatform.protocol.SentryId
5+
import io.sentry.kotlin.multiplatform.protocol.User
6+
import io.sentry.kotlin.multiplatform.protocol.UserFeedback
7+
8+
internal actual class SentryBridge actual constructor(
9+
private val sentryInstance: SentryInstance
10+
) {
11+
actual fun init(context: Context, configuration: OptionsConfiguration) {
12+
}
13+
14+
actual fun init(configuration: OptionsConfiguration) {
15+
}
16+
17+
actual fun initWithPlatformOptions(configuration: PlatformOptionsConfiguration) {
18+
}
19+
20+
actual fun captureMessage(message: String): SentryId {
21+
return SentryId.EMPTY_ID
22+
}
23+
24+
actual fun captureMessage(message: String, scopeCallback: ScopeCallback): SentryId {
25+
return SentryId.EMPTY_ID
26+
}
27+
28+
actual fun captureException(throwable: Throwable): SentryId {
29+
return SentryId.EMPTY_ID
30+
}
31+
32+
actual fun captureException(throwable: Throwable, scopeCallback: ScopeCallback): SentryId {
33+
return SentryId.EMPTY_ID
34+
}
35+
36+
actual fun configureScope(scopeCallback: ScopeCallback) {
37+
}
38+
39+
actual fun captureUserFeedback(userFeedback: UserFeedback) {
40+
}
41+
42+
actual fun addBreadcrumb(breadcrumb: Breadcrumb) {
43+
}
44+
45+
actual fun setUser(user: User?) {
46+
}
47+
48+
actual fun isCrashedLastRun(): Boolean {
49+
return false
50+
}
51+
52+
actual fun isEnabled(): Boolean {
53+
return false
54+
}
55+
56+
actual fun close() {
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package io.sentry.kotlin.multiplatform
2+
3+
internal actual class SentryPlatformInstance : SentryInstance {
4+
actual override fun init(configuration: PlatformOptionsConfiguration) {
5+
}
6+
}

sentry-kotlin-multiplatform/src/jsMain/kotlin/io/sentry/kotlin/multiplatform/SentryPlatformOptions.js.kt renamed to sentry-kotlin-multiplatform/src/commonStub/kotlin/io/sentry/kotlin/multiplatform/SentryPlatformOptions.commonStub.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package io.sentry.kotlin.multiplatform
22

3-
public actual class SentryPlatformOptions {
4-
// Minimal stub – extend as needed
5-
var dsn: String? = null
6-
}
3+
public actual class SentryPlatformOptions
74

85
internal actual fun SentryPlatformOptions.prepareForInit() {
96
// no-op on JS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package io.sentry.kotlin.multiplatform
2+
3+
import io.sentry.kotlin.multiplatform.protocol.Breadcrumb
4+
import io.sentry.kotlin.multiplatform.protocol.User
5+
6+
actual abstract class BaseSentryScopeTest {
7+
actual fun initializeScope(): Scope = StubScope()
8+
}
9+
10+
private class StubScope(
11+
override var user: User? = null,
12+
override var level: SentryLevel? = null
13+
) : Scope {
14+
override fun getTags(): MutableMap<String, String> {
15+
return mutableMapOf()
16+
}
17+
18+
override fun getContexts(): MutableMap<String, Any> {
19+
return mutableMapOf()
20+
}
21+
22+
override fun addAttachment(attachment: Attachment) {
23+
}
24+
25+
override fun clearAttachments() {
26+
}
27+
28+
override fun addBreadcrumb(breadcrumb: Breadcrumb) {
29+
}
30+
31+
override fun clearBreadcrumbs() {
32+
}
33+
34+
override fun setContext(key: String, value: Any) {
35+
}
36+
37+
override fun setContext(key: String, value: Boolean) {
38+
}
39+
40+
override fun setContext(key: String, value: String) {
41+
}
42+
43+
override fun setContext(key: String, value: Number) {
44+
}
45+
46+
override fun setContext(key: String, value: Collection<*>) {
47+
}
48+
49+
override fun setContext(key: String, value: Array<*>) {
50+
}
51+
52+
override fun setContext(key: String, value: Char) {
53+
}
54+
55+
override fun removeContext(key: String) {
56+
}
57+
58+
override fun setTag(key: String, value: String) {
59+
}
60+
61+
override fun removeTag(key: String) {
62+
}
63+
64+
override fun setExtra(key: String, value: String) {
65+
}
66+
67+
override fun removeExtra(key: String) {
68+
}
69+
70+
override fun clear() {
71+
}
72+
73+
}

0 commit comments

Comments
 (0)