Skip to content

Commit d5ecbdf

Browse files
authored
fix: cocoa crash handling due to sdkInfo removal in cocoa sdk (#68)
* remove sdkInfo from SentryEnvelopHeader init * Update CHANGELOG.md
1 parent 2b14023 commit d5ecbdf

File tree

8 files changed

+12
-68
lines changed

8 files changed

+12
-68
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Fixes
1010

1111
- ref: use explicit api & add code consistency ([#63](https://github.com/getsentry/sentry-kotlin-multiplatform/pull/63))
12+
- fix: cocoa crash handling due to sdkInfo removal in cocoa sdk ([#68](https://github.com/getsentry/sentry-kotlin-multiplatform/pull/68))
1213

1314
## 0.0.3
1415

sentry-kotlin-multiplatform/src/commonAppleMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryOptionsExtensions.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ internal fun CocoaSentryOptions.applyCocoaBaseOptions(options: SentryOptions) {
3131
this.maxAttachmentSize = options.maxAttachmentSize.convert()
3232
this.maxBreadcrumbs = options.maxBreadcrumbs.convert()
3333
this.beforeSend = { event ->
34-
dropKotlinCrashEvent(event as NSExceptionSentryEvent?) as SentryEvent?
35-
3634
val cocoaName = BuildKonfig.SENTRY_COCOA_PACKAGE_NAME
3735
val cocoaVersion = BuildKonfig.SENTRY_COCOA_VERSION
3836

@@ -50,7 +48,7 @@ internal fun CocoaSentryOptions.applyCocoaBaseOptions(options: SentryOptions) {
5048
sdk?.set("packages", packages)
5149

5250
event?.sdk = sdk
53-
event
51+
dropKotlinCrashEvent(event as NSExceptionSentryEvent?) as SentryEvent?
5452
}
5553

5654
val sdkName = options.sdk?.name ?: BuildKonfig.SENTRY_KMP_COCOA_SDK_NAME

sentry-kotlin-multiplatform/src/commonAppleMain/kotlin/io/sentry/kotlin/multiplatform/nsexception/SentryUnhandledExceptions.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ import NSException.Sentry.SentryThreadInspector
3131
import NSException.Sentry.currentHub
3232
import NSException.Sentry.isCrashEvent
3333
import NSException.Sentry.kSentryLevelFatal
34-
import NSException.Sentry.options
3534
import NSException.Sentry.prepareEvent
36-
import NSException.Sentry.sdkInfo
3735
import NSException.Sentry.storeEnvelope
3836
import NSException.Sentry.threadInspector
3937
import kotlinx.cinterop.UnsafeNumber
@@ -66,19 +64,19 @@ internal fun setSentryUnhandledExceptionHook(): Unit = wrapUnhandledExceptionHoo
6664
/**
6765
* Tag used to mark the Kotlin termination crash.
6866
*/
69-
private const val kotlinCrashedTag = "nsexceptionkt.kotlin_crashed"
67+
internal const val kotlinCrashedTag = "nsexceptionkt.kotlin_crashed"
7068

7169
/**
7270
* Converts `this` [Throwable] to a [SentryEnvelope].
7371
*/
74-
private fun Throwable.asSentryEnvelope(): SentryEnvelope {
72+
internal fun Throwable.asSentryEnvelope(): SentryEnvelope {
7573
val event = asSentryEvent()
7674
val preparedEvent = SentrySDK.currentHub().let { hub ->
7775
hub.getClient()?.prepareEvent(event, hub.scope, alwaysAttachStacktrace = false, isCrashEvent = true)
7876
} ?: event
7977
val item = SentryEnvelopeItem(preparedEvent)
8078
// TODO: pass traceState when enabling performance monitoring for KMP SDK
81-
val header = SentryEnvelopeHeader(preparedEvent.eventId, SentrySDK.options?.sdkInfo, null)
79+
val header = SentryEnvelopeHeader(preparedEvent.eventId, null)
8280
return SentryEnvelope(header, listOf(item))
8381
}
8482

sentry-kotlin-multiplatform/src/commonAppleMain/kotlin/io/sentry/kotlin/multiplatform/nsexception/Throwable.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ package io.sentry.kotlin.multiplatform.nsexception
2222
internal val Throwable.causes: List<Throwable> get() = buildList {
2323
val causes = mutableSetOf<Throwable>()
2424
var cause = cause
25-
while (cause != null && cause !in causes) {
25+
while (cause != null && causes.add(cause)) {
2626
add(cause)
27-
causes.add(cause)
2827
cause = cause.cause
2928
}
3029
}
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
language = Objective-C
22
headers = SentryClient.h SentryDebugImageProvider.h SentryDebugMeta.h SentryDefines.h SentryEnvelope.h SentryEvent.h \
3-
SentryException.h SentryHub.h SentryId.h SentryMechanism.h SentryMechanism+NSExceptionKt.h SentryOptions.h \
4-
SentryScope.h SentrySDK.h SentrySdkInfo.h SentryStacktrace.h SentryThread.h SentryThread+NSExceptionKt.h \
5-
Private/SentryClient.h Private/SentryCrashMonitor_NSException.h Private/SentryCrashMonitor_NSException+NSExceptionKt.h \
6-
Private/SentryCrashStackCursor.h Private/SentryDependencyContainer.h Private/SentryEvent.h Private/SentryHook.h \
7-
Private/SentryOptions.h Private/SentrySDK.h Private/SentryStacktraceBuilder.h Private/SentryThreadInspector.h \
8-
Private/SentryTraceContext.h
3+
SentryException.h SentryHub.h SentryId.h SentryMechanism.h SentryMechanism+NSExceptionKt.h SentryOptions.h \
4+
SentryScope.h SentrySDK.h SentryStacktrace.h SentryThread.h SentryThread+NSExceptionKt.h Private/SentryClient.h \
5+
Private/SentryCrashMonitor_NSException.h Private/SentryCrashMonitor_NSException+NSExceptionKt.h \
6+
Private/SentryCrashStackCursor.h Private/SentryDependencyContainer.h Private/SentryEvent.h Private/SentryHook.h \
7+
Private/SentrySDK.h Private/SentryStacktraceBuilder.h Private/SentryThreadInspector.h Private/SentryTraceContext.h

sentry-kotlin-multiplatform/src/nativeInterop/cinterop/SentryNSException/Private/SentryOptions.h

Lines changed: 0 additions & 26 deletions
This file was deleted.

sentry-kotlin-multiplatform/src/nativeInterop/cinterop/SentryNSException/SentryEnvelope.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@
2020
#import <Private/SentryTraceContext.h>
2121
#import <SentryEvent.h>
2222
#import <SentryId.h>
23-
#import <SentrySdkInfo.h>
2423

2524
@interface SentryEnvelopeHeader : NSObject
2625

2726
- (instancetype)initWithId:(nullable SentryId *)eventId
28-
sdkInfo:(nullable SentrySdkInfo *)sdkInfo
29-
traceContext:(nullable SentryTraceContext *)traceContext NS_DESIGNATED_INITIALIZER;
27+
traceContext:(nullable SentryTraceContext *)traceContext;
3028

3129
@end
3230

sentry-kotlin-multiplatform/src/nativeInterop/cinterop/SentryNSException/SentrySdkInfo.h

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)