TinyInsights 1.14.0 includes a useful improvement for crash handling. The main addition is that you can now hook into the crash pipeline with callbacks, and TinyInsights also preserves a snapshot of the global properties from the moment the crash happened.
That matters because crashes are often sent on the next app launch, not at the exact moment the app goes down. Before this change, it was harder to attach the exact context from the failing session. With this update, TinyInsights stores that context together with the crash and uses it when the crash is sent to Application Insights later.
New crash callbacks
The ApplicationInsightsProvider now exposes two new callbacks:
- AfterCrash runs immediately after a crash has been captured and stored.
- BeforeSendCrash runs on the next app launch, right before the stored crash is sent to Application Insights.
This gives you two clear extension points.
Use AfterCrash when you want to do something synchronous right after the crash has been recorded, for example writing to the debug output, saving a small piece of local state, or triggering some simple cleanup.
Use BeforeSendCrash when you need async work before the crash telemetry is transmitted, for example preparing additional metadata, refreshing some local state, or deciding what properties should be attached before the crash is uploaded.
Here is what it looks like in MauiProgram.cs:
.UseTinyInsights("{CONNECTION-STRING}", (provider) =>
{
if (provider is ApplicationInsightsProvider appProvider)
{
appProvider.AfterCrash = (globalProperties) =>
{
// Runs right after the crash was captured.
};
appProvider.BeforeSendCrash = async (telemetryProperties) =>
{
// Runs before the stored crash is sent on next app launch.
await Task.CompletedTask;
};
}
});
Crash-time properties are now preserved
The bigger improvement behind the scenes is that TinyInsights now captures the global properties when the crash happens and stores them together with the crash payload.
That means the crash can be sent later with the same context that existed when the app actually failed. If you add properties such as app version, user ID, session information, device information, or your own custom global properties, those values can now follow the crash more reliably.
This should make crash reports easier to understand because the telemetry better reflects the original failing session instead of the state from the next app launch.
Better parity with Application Insights context
The implementation in this commit also recreates telemetry context from the stored crash properties when the crash is finally sent. Standard Application Insights context values such as device info, cloud role data, user ID, session ID, and component version are restored into the telemetry client instead of only being sent as generic custom properties.
That is a meaningful quality improvement if you use Application Insights queries and dashboards, because the crash data is more likely to show up in the right fields and be easier to correlate with the rest of your telemetry.
A few additional updates
This commit also includes a couple of supporting changes:
- The README now documents the new crash callbacks.
- The test app has been updated to demonstrate AfterCrash and BeforeSendCrash.
- The GitHub workflows have been moved to .NET 9.
- The project file continues the move toward .NET 10 target frameworks.
Those are not the headline features for app developers, but they are good signs that the package and repo are being kept current.
Summary
If you are already using TinyInsights for crash reporting in your .NET MAUI app, this is a solid update. The new callbacks give you more control over the crash lifecycle, and the preserved crash-time properties should lead to better and more accurate telemetry in Application Insights.
If you want to check the implementation details, have a look at the commit on GitHub: https://github.com/dhindrik/TinyInsights.Maui/commit/5fe542774155e331a1cdb099631f74183c461697