getsentry / team-mobile

Meta issues for the Mobile team
4 stars 1 forks source link

Sentry.crashedLastRunEventId #76

Open krystofwoldrich opened 1 year ago

krystofwoldrich commented 1 year ago

We already have in the mobile SDKs Sentry.crashedLastRun, but if users would like to create userFeedback or attachment for the event causing the crash, they can't at the moment because Sentry.lastEventId returns undefined on the app relaunch. Therefore, we add a new property, Sentry.crashedLastRunEventId, which returns the event id of the last crash if the app crashed on a previous run or null if there was no crash on a previous run.

### Tasks
- [ ] https://github.com/getsentry/sentry-java/issues/2560
- [ ] Capacitor
- [ ] https://github.com/getsentry/sentry-cocoa/issues/2694
- [ ] https://github.com/getsentry/sentry-dart/issues/1308
- [ ] .NET
- [ ] https://github.com/getsentry/sentry-react-native/issues/2789
philipphofmann commented 1 year ago

Shouldn't it be named Sentry.crashedLastRunEventId? Sentry.lastEvendId is too generic. I could assume that it returns the last send event ID or the last captured event ID.

krystofwoldrich commented 1 year ago

Sentry.lastEvendId is too generic. I could assume that it returns the last send event ID or the last captured event ID.

It returns the last captured event id.

The last captured event will likely be the one that caused the crash.

philipphofmann commented 1 year ago

You can already get the event id of the last captured event, as capture... returns the event id. You can use that for attachments and user feedback.

The last captured event will likely be the one that caused the crash.

How can Sentry.lastEvendId guarantee to return the event id of the last crash? What if you immediately capture an event after launching your application? On Android, the SDK may send the event before the OS terminates the crashing app, so we would need to store the event id to disk.

For adding an attachment to the crash event, the event id wouldn't help, as you can't send attachments only with the event id. You can only add them to an event, as far as I know. For that use case, we can use hints.

romtsn commented 1 year ago

I agree with Philipp, we should probably introduce a new crashedLastRunEventId, because lastEventId might be overwritten by some other event, but the users of the SDK have not asked their users about feedback yet, then the lastEventId would point to the incorrect event. @krystofwoldrich thoughts?

krystofwoldrich commented 1 year ago

@philipphofmann @romtsn I agree the Sentry.crashedLastRunEventId is a better option, as there can not be any confusion about what is it id for.

ludwig-pro commented 1 year ago

Hi, Do you have an update on this feature for react-native ? I don't find crashedLastRunEventId anywhere? cheers !

krystofwoldrich commented 1 year ago

@ludwig-pro Thank you for your interest, as mentioned in sentry-react-native, we haven't implemented this yet.