getsentry / getsentry/sentry-react-native

feat: Expose crashed last run API

Ouverte
#5,852 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Errors Feature React-Native
Langage dominant
TypeScript
Étoiles
1.8k
Forks
366
Merge moyen
1 j 6 h
PR mergées (30 j)
94

Description

## Problem Statement

Both native SDKs now provide APIs to check if the previous app session ended in a crash:

- **iOS (Cocoa SDK 9.8.0+):** [`SentrySDK.lastRunStatus`](https://github.com/getsentry/sentry-cocoa/issues/7469) — returns unknown, no-crash, or crash
- **Android:** `Sentry.isCrashedLastRun()` — returns a boolean

There is currently no way to access this information from the React Native (JavaScript) layer.

## Use Cases

- Show a recovery UI (e.g., "Sorry, the app crashed") after restarting from a crash
- Disable experimental features that may have caused a crash
- Send custom analytics or breadcrumbs about crash recovery
- Implement progressive rollout logic that backs off after crashes

## Proposed Solution

Expose a unified JS API, e.g.:

```typescript
import * as Sentry from '@sentry/react-native';

const status = Sentry.lastRunStatus();
// Returns: 'unknown' | 'no-crash' | 'crash'
```

### Implementation Notes

- Bridge `SentrySDK.lastRunStatus` on iOS and `Sentry.isCrashedLastRun()` on Android through the native modules
- Normalize the return value across platforms (iOS has 3 states, Android has a boolean — need to decide on a unified shape)
- Should be callable after `Sentry.init()`

## References

- Cocoa SDK PR: https://github.com/getsentry/sentry-cocoa/issues/7469
- Cocoa SDK bump to 9.8.0: https://github.com/getsentry/sentry-react-native/pull/5847

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par localiser les modules natifs React Native et le chemin d’initialisation utilisé après Sentry.init(), puis comparez les intégrations iOS lastRunStatus et Android isCrashedLastRun décrites dans l’issue. Le travail est considéré comme terminé lorsqu’une API JavaScript appelable expose un résultat documenté et cohérent sur les deux plateformes.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
android, ios, react-native, typescript
Domaine
api, mobile
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
48/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.