Prompt
How do I capture mobile crashes with enough context to fix them?
Latest observation
To capture mobile crashes with enough context to actually fix them, you want three things together:
- A crash report with a stack trace
- Context about what the app was doing
- A way to reproduce or correlate it to logs, session, and device state
Here’s a practical approach that works well on iOS and Android.
1) Use a crash reporting SDK
Don’t rely only on OS logs. Integrate a crash reporting tool that automatically records:
- stack trace / exception
- device model and OS version
- app version/build
- thread info
- breadcrumbs/events leading up to crash
- non-fatal errors
Common options:
- Firebase Crashlytics
- Sentry
- Bugsnag
- Datadog RUM/Error Tracking
These tools give you the core crash data and often let you add custom context.
2) Add breadcrumbs or event trail
The most useful context is the sequence of actions before the crash.
Record events like:
- screen/view changes
- button taps
- API requests and responses
- navigation transitions
- important state changes
- authentication state changes
Example breadcrumb ideas:
Opened CheckoutSelected Shipping Method: ExpressAPI /cart/price updatedTapped Pay Now
Keep them:
- short
- timestamped
- ordered
- privacy-safe
Most crash tools support breadcrumbs directly.
3) Attach app state to crashes
Capture the app state at key moments and include it as crash context, such as:
- current screen
- user role / auth state
- feature flags
- selected item IDs
- network connectivity state
- locale / timezone
- offline/online mode
- release channel
Example custom keys:
current_screen = Checkoutuser_tier = Premiumfeature_new_checkout = truecart_item_count = 3
This is often the difference between “crashed somewhere in checkout” and “crashed only when applying a discount code on iOS 17.2 with feature flag X enabled.”
4) Log errors and warnings before the crash
Not every issue is the crash itself. Often the real cause appears earlier:
- failed API call
- invalid response payload
- null/empty state
- timeout
- permission denial
- database migration failure
Log non-fatal exceptions and warnings too.
These often show the lead-up to the crash.
5) Correlate crash reports with server logs
Give every app session or request a correlation ID.
Useful IDs:
- session ID
- request ID
- user ID
- device/session token
Then include that ID in:
- app logs
- backend logs
- crash reports
That way you can answer:
- What API calls happened before the crash?
- Did the server return bad data?
- Was this isolated to one user/session?
6) Capture stack traces properly in release builds
Make sure symbolication/deobfuscation is set up:
- iOS: upload dSYM files
- Android: upload ProGuard/R8 mapping files
Without this, your stack traces may be useless in production.
7) Record uncaught exceptions and signals
Make sure the SDK is configured to catch:
- uncaught exceptions
- fatal signals / native crashes
- ANRs on Android
- main-thread freezes if supported
Native crashes are especially important if you use:
- C/C++
- Flutter plugins
- React Native native modules
- media or graphics libraries
8) Don’t store sensitive data
You want enough context, but not passwords, tokens, or private content.
Avoid:
- access tokens
- full request bodies with PII
- payment data
- personal messages
- raw credentials
Instead, store:
- IDs
- truncated values
- boolean flags
- sanitized error messages
9) Set up replay/debugging for hard cases
For crashes that are hard to reproduce, add:
- session replay
- screen recordings
- UI event history
- recent network requests
- local state snapshots
This is especially useful for:
- intermittent crashes
- race conditions
- UI state bugs
- crashes after background/foreground transitions
10) Make reports actionable
A good crash report should answer these questions quickly:
- What crashed?
- On what device/OS/app version?
- What was the user doing?
- What data/state was present?
- What changed recently?
- Can I reproduce it?
If your crash report doesn’t help answer at least 3–4 of those, add more context.
Recommended minimal setup
If you want a strong baseline:
- Install Crashlytics or Sentry
- Add breadcrumbs
- Set custom keys for screen/state/feature flags
- Upload symbols/mapping files
- Correlate with session/request IDs
- Log non-fatal errors
- Sanitize anything sensitive
Example of useful crash context
A report like this is much more actionable:
- App:
4.8.1 (build 214) - OS:
Android 14 - Device:
Pixel 7 - Screen:
Checkout > Payment - User state:
logged_in,premium=true - Breadcrumbs:
Opened CheckoutApplied coupon SUMMER20Shipping changed to ExpressAPI /payment/intent returned 200
- Custom data:
cart_items=3feature_new_checkout=truelocale=en-US
- Crash:
NullPointerException in PaymentSummaryView.bind()
That’s usually enough to start fixing immediately.
If you want, I can also give you:
- a Crashlytics setup checklist
- a Sentry setup checklist
- or a best-practice crash context schema for mobile apps.