File tree Expand file tree Collapse file tree 5 files changed +30
-3
lines changed
sentry-kotlin-multiplatform/src
appleMain/kotlin/io/sentry/kotlin/multiplatform
appleTest/kotlin/io/sentry/kotlin/multiplatform
commonJvmTest/kotlin/io/sentry/kotlin/multiplatform
commonTest/kotlin/io/sentry/kotlin/multiplatform Expand file tree Collapse file tree 5 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 10
10
### Fixes
11
11
12
12
- Do not throw if exec operation fails ([ #360 ] ( https://github.com/getsentry/sentry-kotlin-multiplatform/pull/360 ) )
13
+ - ` initWithPlatforms ` not sending events if ` beforeSend ` is not set on iOS ([ #366 ] ( https://github.com/getsentry/sentry-kotlin-multiplatform/pull/366 ) )
13
14
14
15
### Miscellaneous
15
16
Original file line number Diff line number Diff line change @@ -20,13 +20,12 @@ public actual abstract class Context
20
20
// like on JVM and Android, we may do that later on if needed.
21
21
internal actual fun SentryPlatformOptions.prepareForInit () {
22
22
val cocoa = this as ? CocoaSentryOptions
23
- val existingBeforeSend = cocoa?.beforeSend
23
+ val userDefinedBeforeSend = cocoa?.beforeSend
24
24
val modifiedBeforeSend: (CocoaSentryEvent ? ) -> CocoaSentryEvent ? = beforeSend@{ event ->
25
25
// Return early if the user's beforeSend returns null
26
- if (existingBeforeSend? .invoke(event) == null ) {
26
+ if (userDefinedBeforeSend != null && userDefinedBeforeSend .invoke(event) == null ) {
27
27
return @beforeSend null
28
28
}
29
-
30
29
val cocoaName = BuildKonfig .SENTRY_COCOA_PACKAGE_NAME
31
30
val cocoaVersion = BuildKonfig .SENTRY_COCOA_VERSION
32
31
Original file line number Diff line number Diff line change @@ -89,6 +89,19 @@ actual class SentryBridgeTest {
89
89
assert (option.beforeSend!! .invoke(CocoaSentryEvent ()) != null )
90
90
}
91
91
92
+ @Test
93
+ actual fun `default beforeSend in init does not drop the event after prepareForInit` () {
94
+ fixture.sut.init { }
95
+
96
+ val option = SentryPlatformOptions ().apply {
97
+ fixture.sentryInstance.lastConfiguration?.invoke(this )
98
+ prepareForInit()
99
+ }.let { it as CocoaSentryOptions }
100
+
101
+ assert (option.beforeSend != null )
102
+ assert (option.beforeSend!! .invoke(CocoaSentryEvent ()) != null )
103
+ }
104
+
92
105
@Test
93
106
actual fun `init sets the SDK packages` () {
94
107
// GIVEN
Original file line number Diff line number Diff line change @@ -73,6 +73,19 @@ actual class SentryBridgeTest {
73
73
assert (option.beforeSend!! .execute(JvmSentryEvent (), Hint ()) != null )
74
74
}
75
75
76
+ @Test
77
+ actual fun `default beforeSend in init does not drop the event after prepareForInit` () {
78
+ fixture.sut.init { }
79
+
80
+ val option = SentryPlatformOptions ().apply {
81
+ fixture.sentryInstance.lastConfiguration?.invoke(this )
82
+ prepareForInit()
83
+ }.let { it as JvmSentryOptions }
84
+
85
+ assert (option.beforeSend != null )
86
+ assert (option.beforeSend!! .execute(JvmSentryEvent (), Hint ()) != null )
87
+ }
88
+
76
89
@Test
77
90
actual fun `init sets the SDK packages` () {
78
91
// WHEN
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ expect class SentryBridgeTest {
4
4
fun `init sets correct configuration` ()
5
5
fun `setting null in beforeSend during init drops the event` ()
6
6
fun `default beforeSend in init does not drop the event` ()
7
+ fun `default beforeSend in init does not drop the event after prepareForInit` ()
7
8
fun `init sets the SDK packages` ()
8
9
fun `init sets SDK version and name` ()
9
10
}
You can’t perform that action at this time.
0 commit comments