getsentry / getsentry/sentry-react-native

Support File URIs for Attachments

Aperta
#4,605 3 commenti 3 reazioni 0 assegnatari Vedi su GitHub
Attachments Feature React-Native
Lingua principale
TypeScript
Stelle
1.8k
Fork
366
Merge medio
1g 5h
PR unite (30g)
93

Descrizione

I’d like to request that the Sentry React Native SDK expose the getDataFromUri function as a public API. Right now, I’m importing it privately like this:

``` typescript
import { NATIVE } from '@sentry/react-native/dist/js/wrapper';

const jsByteArray = await NATIVE.getDataFromUri(image.url);

if (bd) {
const attachment: Attachment = {
filename: file.name || `file_${0}.${mime.getType(file.mediaContentType)}`,
data: jsByteArray,
contentType: file.mediaContentType,
};
attachments.push(attachment);
}
```
Depending on an internal method isn’t ideal—it feels brittle and may stop working if the SDK changes. Exposing getDataFromUri (or providing a similar official method) would make it safer and more straightforward to attach user-supplied files in a feedback workflow.

Additionally, it would be great if the SDK directly supported attaching files via a platform-based file URI (e.g., file://...). The code could look like this:
``` typescript
const attachment: Attachment = {
filename: file.name || `file_${index}.${mime.getType(file.mediaContentType)}`,
uri: image.url, // "file://etc"
contentType: file.mediaContentType,
};
```

Internally, Sentry could then convert that URI into the data it needs. This would simplify the process for developers who want to attach files without manually handling the conversion. If there’s another recommended approach, I’d love to hear it—otherwise, making getDataFromUri public (and potentially enhancing it to handle URIs directly) would be a big help.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia esaminando l’entry point NATIVE.getDataFromUri esistente in @sentry/react-native/dist/js/wrapper e la forma di Attachment mostrata nell’issue. Chiarisci se l’ambito accettato consiste in un’API pubblica di conversione, allegati diretti con URI file:// o entrambi; il lavoro è completato quando un workflow di allegati ufficialmente supportato non dipende più dal metodo privato del wrapper.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
react-native, typescript
Ambito
mobile
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.