getsentry / getsentry/sentry-react-native

Support File URIs for Attachments

Offen
#4,605 3 Kommentare 3 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Attachments Feature React-Native
Vorherrschende Sprache
TypeScript
Sterne
1.8k
Forks
366
Ø Merge
1 T. 5 Std.
Gemergte PRs (30 T.)
93

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, den vorhandenen Einstiegspunkt NATIVE.getDataFromUri in @sentry/react-native/dist/js/wrapper und die im Issue gezeigte Attachment-Form zu überprüfen. Kläre, ob der akzeptierte Umfang eine öffentliche Konvertierungs-API, direkte Anhänge von file://-URIs oder beides umfasst; abgeschlossen bedeutet, dass ein offiziell unterstützter Attachment-Workflow nicht mehr von der privaten Wrapper-Methode abhängt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
react-native, typescript
Bereich
mobile
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.