-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: cocoa crash handling due to sdkInfo removal in cocoa sdk #68
Changes from all commits
23de3e4
40108ac
4ba841a
8038076
0500a64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,9 +31,7 @@ import NSException.Sentry.SentryThreadInspector | |
import NSException.Sentry.currentHub | ||
import NSException.Sentry.isCrashEvent | ||
import NSException.Sentry.kSentryLevelFatal | ||
import NSException.Sentry.options | ||
import NSException.Sentry.prepareEvent | ||
import NSException.Sentry.sdkInfo | ||
import NSException.Sentry.storeEnvelope | ||
import NSException.Sentry.threadInspector | ||
import kotlinx.cinterop.UnsafeNumber | ||
|
@@ -66,19 +64,19 @@ internal fun setSentryUnhandledExceptionHook(): Unit = wrapUnhandledExceptionHoo | |
/** | ||
* Tag used to mark the Kotlin termination crash. | ||
*/ | ||
private const val kotlinCrashedTag = "nsexceptionkt.kotlin_crashed" | ||
internal const val kotlinCrashedTag = "nsexceptionkt.kotlin_crashed" | ||
|
||
/** | ||
* Converts `this` [Throwable] to a [SentryEnvelope]. | ||
*/ | ||
private fun Throwable.asSentryEnvelope(): SentryEnvelope { | ||
internal fun Throwable.asSentryEnvelope(): SentryEnvelope { | ||
val event = asSentryEvent() | ||
val preparedEvent = SentrySDK.currentHub().let { hub -> | ||
hub.getClient()?.prepareEvent(event, hub.scope, alwaysAttachStacktrace = false, isCrashEvent = true) | ||
} ?: event | ||
val item = SentryEnvelopeItem(preparedEvent) | ||
// TODO: pass traceState when enabling performance monitoring for KMP SDK | ||
val header = SentryEnvelopeHeader(preparedEvent.eventId, SentrySDK.options?.sdkInfo, null) | ||
val header = SentryEnvelopeHeader(preparedEvent.eventId, null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. M: why is the sdkInfo removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does that mean that events dont have the SDK info anymore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's removed because the cocoa sdk deprecated sdkInfo. So The sdkInfo is still being set in |
||
return SentryEnvelope(header, listOf(item)) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,8 @@ package io.sentry.kotlin.multiplatform.nsexception | |
internal val Throwable.causes: List<Throwable> get() = buildList { | ||
val causes = mutableSetOf<Throwable>() | ||
var cause = cause | ||
while (cause != null && cause !in causes) { | ||
while (cause != null && causes.add(cause)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this just an optimization? can There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup, just a minor optimization - |
||
add(cause) | ||
causes.add(cause) | ||
cause = cause.cause | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
language = Objective-C | ||
headers = SentryClient.h SentryDebugImageProvider.h SentryDebugMeta.h SentryDefines.h SentryEnvelope.h SentryEvent.h \ | ||
SentryException.h SentryHub.h SentryId.h SentryMechanism.h SentryMechanism+NSExceptionKt.h SentryOptions.h \ | ||
SentryScope.h SentrySDK.h SentrySdkInfo.h SentryStacktrace.h SentryThread.h SentryThread+NSExceptionKt.h \ | ||
Private/SentryClient.h Private/SentryCrashMonitor_NSException.h Private/SentryCrashMonitor_NSException+NSExceptionKt.h \ | ||
Private/SentryCrashStackCursor.h Private/SentryDependencyContainer.h Private/SentryEvent.h Private/SentryHook.h \ | ||
Private/SentryOptions.h Private/SentrySDK.h Private/SentryStacktraceBuilder.h Private/SentryThreadInspector.h \ | ||
Private/SentryTraceContext.h | ||
SentryException.h SentryHub.h SentryId.h SentryMechanism.h SentryMechanism+NSExceptionKt.h SentryOptions.h \ | ||
SentryScope.h SentrySDK.h SentryStacktrace.h SentryThread.h SentryThread+NSExceptionKt.h Private/SentryClient.h \ | ||
Private/SentryCrashMonitor_NSException.h Private/SentryCrashMonitor_NSException+NSExceptionKt.h \ | ||
Private/SentryCrashStackCursor.h Private/SentryDependencyContainer.h Private/SentryEvent.h Private/SentryHook.h \ | ||
Private/SentrySDK.h Private/SentryStacktraceBuilder.h Private/SentryThreadInspector.h Private/SentryTraceContext.h |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since
beforeSend
is based on the lambda result we have to putdropKotlinCrashEvent
at the end.