Repository navigation
Description
Cache current session information on disk. Close open sessions on restart as Abnormal.
The use case is when a crash happens that doesn't go through the UnhandledException integration (i.e: Native crash). Or the device ran out of battery for example.
The next step after this will be to differentiate abnormal from crash (with the help of native SDKs).
If the session is paused, we should mark it as such and the timestamp. If it dies while paused, on restart we can use that timestamp to end the sessions (as Exited). It's possible that there was a native crash on a background thread while the app was on the background but that we would only be able to answer with support of a native SDK.
To support differentiating Abnormal and Crashed (or even Exited when the session was paused) we need native SDK integration.
From the .NET SDK point of view this is just a callback:
SentryOptions
Func<booL>? CrashedLastRun
Similar to what we have on sentry-cocoa.
Use cases:
Without native SDK integration (callback is null):
-
Session starts, a file is written for the session state. App is put on the background. App dies (out of battery).
On restart Sentry will find the file and end that session as Exited. -
Sentry SDK starts, an open session is found. Close that session as Abnormal.
With native SDK integration (callback is set to something):
- SDK Init with an open session on disk. Ask native SDK (Through a callback): Did we crash on the last run? of so we close as Crashed otherwise as Abnormal.
Example Unity Android:
SentrySdk.Init(o => {
#if ANDROID
o.CrashedLastRun = () => SentryAndroid.didCrashLastRun();
#elif IOS
o.CrashedLastRun = () => SentryCocoa.didCrashLastRun();
#endif
});
In other words:
- When the .NET SDK starts, it checks for open sessions.
- If
CrashedLastRunis null it fallback to the best of its knowlege: Abnormal if session was not paused, otherwise Exited. - If callback exists, rely on its value to differentiate between a native crash and Abnormal (Out battery? User killed the app?) and Exited (if was put on the background).
Activity