getsentry / sentry-cocoa

The official Sentry SDK for iOS, tvOS, macOS, watchOS.
https://sentry.io/for/cocoa/
MIT License
818 stars 330 forks source link

Improve support for Kotlin Native #1999

Open rickclephas opened 2 years ago

rickclephas commented 2 years ago

Problem Statement

I have been playing with Sentry in a Kotlin Multiplatform iOS app.

So far I have been able to successfully log a fatal Kotlin exception. However it currently requires using a lot of private APIs.

Solution Brainstorm

To convert a Kotlin Exception to a SentryException we'll need something like:

@interface SentryStacktrace ()

+ (SentryStacktrace *)stacktraceFromCallStackReturnAddresses:(NSArray<NSNumber *> *)callStackReturnAddresses;

@end

All the logic already exists, but it currently requires using SentryStacktraceBuilder and SentryCrashStackCursor.

The other API that's missing is a way to store a crash event. Currently there is storeEnvelope (which is also private) which requires a lot of private APIs to create a SentryEnvelope. Something like the following (that internally prepares the event and creates the envelope) would be great.

@interface SentrySDK ()

+ (void)storeCrashEvent:(SentryEvent *)event;

@end
brustolin commented 2 years ago

Hey @rickclephas thanks for this. It looks like a nice use case. We gonna look into it.

github-actions[bot] commented 2 years ago

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

philipphofmann commented 2 years ago

@buenaflor, you worked on the Kotlin Multiplatform in the past weeks. Isn't that issue already fixed? Or how did you work around the issue again?

github-actions[bot] commented 2 years ago

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

philipphofmann commented 2 years ago

Should be fixed with https://github.com/getsentry/sentry-kotlin-multiplatform/pull/20. Feel free to open if not.

rickclephas commented 2 years ago

@philipphofmann I don't think that really solves the "problem". That PR uses similar logic to what I have used, which relies on a number of private APIs.

I feel like it would be better to officially support this in the Cocoa SDK.

A KMP SDK is great, but one of the biggest strengths of KMP is its ability to integrate with native projects. Providing the required APIs as part of the public API would improve the KMP experience. It would also decouple the KMP SDK from the Cocoa SDK, allowing it to focus on improving the Kotlin experience without having to worry too much about the underlying native SDKs.

github-actions[bot] commented 2 years ago

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀