File tree Expand file tree Collapse file tree 4 files changed +30
-1
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 4 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ internal actual fun SentryPlatformOptions.prepareForInit() {
2323 val existingBeforeSend = 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 (existingBeforeSend != null && existingBeforeSend .invoke(event) == null ) {
2727 return @beforeSend null
2828 }
2929
@@ -37,6 +37,7 @@ internal actual fun SentryPlatformOptions.prepareForInit() {
3737 sdk[" packages" ] = packages
3838 event?.sdk = sdk
3939
40+ existingBeforeSend?.invoke(event)
4041 dropKotlinCrashEvent(event)
4142 }
4243
Original file line number Diff line number Diff line change @@ -84,11 +84,25 @@ actual class SentryBridgeTest {
8484 fixture.sentryInstance.lastConfiguration?.invoke(this )
8585 }.let { it as CocoaSentryOptions }
8686
87+
8788 // THEN
8889 assert (option.beforeSend != null )
8990 assert (option.beforeSend!! .invoke(CocoaSentryEvent ()) != null )
9091 }
9192
93+ @Test
94+ actual fun `default beforeSend in init does not drop the event after prepareForInit` () {
95+ fixture.sut.init { }
96+
97+ val option = SentryPlatformOptions ().apply {
98+ fixture.sentryInstance.lastConfiguration?.invoke(this )
99+ prepareForInit()
100+ }.let { it as CocoaSentryOptions }
101+
102+ assert (option.beforeSend != null )
103+ assert (option.beforeSend!! .invoke(CocoaSentryEvent ()) != null )
104+ }
105+
92106 @Test
93107 actual fun `init sets the SDK packages` () {
94108 // 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