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 1010### Fixes
1111
1212- 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 ) )
1314
1415### Miscellaneous
1516
Original file line number Diff line number Diff line change @@ -20,13 +20,12 @@ public actual abstract class Context
2020// like on JVM and Android, we may do that later on if needed.
2121internal actual fun SentryPlatformOptions.prepareForInit () {
2222 val cocoa = this as ? CocoaSentryOptions
23- val existingBeforeSend = cocoa?.beforeSend
23+ val userDefinedBeforeSend = cocoa?.beforeSend
2424 val modifiedBeforeSend: (CocoaSentryEvent ? ) -> CocoaSentryEvent ? = beforeSend@{ event ->
2525 // Return early if the user's beforeSend returns null
26- if (existingBeforeSend? .invoke(event) == null ) {
26+ if (userDefinedBeforeSend != null && userDefinedBeforeSend .invoke(event) == null ) {
2727 return @beforeSend null
2828 }
29-
3029 val cocoaName = BuildKonfig .SENTRY_COCOA_PACKAGE_NAME
3130 val cocoaVersion = BuildKonfig .SENTRY_COCOA_VERSION
3231
Original file line number Diff line number Diff line change @@ -89,6 +89,19 @@ actual class SentryBridgeTest {
8989 assert (option.beforeSend!! .invoke(CocoaSentryEvent ()) != null )
9090 }
9191
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+
92105 @Test
93106 actual fun `init sets the SDK packages` () {
94107 // GIVEN
Original file line number Diff line number Diff line change @@ -73,6 +73,19 @@ actual class SentryBridgeTest {
7373 assert (option.beforeSend!! .execute(JvmSentryEvent (), Hint ()) != null )
7474 }
7575
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+
7689 @Test
7790 actual fun `init sets the SDK packages` () {
7891 // WHEN
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ expect class SentryBridgeTest {
44 fun `init sets correct configuration` ()
55 fun `setting null in beforeSend during init drops the event` ()
66 fun `default beforeSend in init does not drop the event` ()
7+ fun `default beforeSend in init does not drop the event after prepareForInit` ()
78 fun `init sets the SDK packages` ()
89 fun `init sets SDK version and name` ()
910}
You can’t perform that action at this time.
0 commit comments