getsentry / sentry-cocoa

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

Add isCrashed() property in SentryEvent Model #4552

Open KimTaeHyeong17 opened 1 week ago

KimTaeHyeong17 commented 1 week ago

Problem Statement

As implementing Sentry sdk in both android and ios device, we wanted to make sure to implement same way in both os.

There were some difference in android/iOS sentry interface but one thing I hoped to be added is "isCrashed" property.

As an ios developer who wanted to distinguish crash event and normal event at beforeSend closure, I tried to find flag to whether event is crash event and I was able to find only at android sdk.

After that I was started to think what's the difference between event.logLevel fatal and isCrashed value I planned to use loglevel fatal in ios, and isCrahsed in android but it seems bit wrong for determine crash event. After getting answer from sentry team about this question and I understood clearly.

However if there is "isCrahsed" in sentry-cocoa too, it would be much clear for this usecase.

Solution Brainstorm

- (BOOL)isCrash
{
    for (SentryException *exception in self.exceptions) {
        if (exception.mechanism != nil) {
            return YES;
        }
    }
    return NO;
}

Are you willing to submit a PR?

No response

philipphofmann commented 1 week ago

We already have that; we need to make it public. We could consider making isAppHangEvent and isMetricKitEvent public too.

https://github.com/getsentry/sentry-cocoa/blob/1928267073dc3a0d3ce4e9f7912d52404ca5ee77/Sources/Sentry/include/SentryEvent%2BPrivate.h#L11-L35

We will discuss this internally and get back to you.