getsentry / getsentry/sentry-react-native
Support File URIs for Attachments
- Lenguaje dominante
- TypeScript
- Estrellas
- 1.8k
- Forks
- 366
- Merge medio
- 1 d 6 h
- PR fusionados (30 d)
- 94
Descripción
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.
Guía de contribución
Línea de trabajo
Empieza revisando el punto de entrada NATIVE.getDataFromUri existente en @sentry/react-native/dist/js/wrapper y la forma de Attachment mostrada en el issue. Aclara si el alcance aceptado es una API pública de conversión, adjuntos de URI file:// directos o ambos; se considera terminado cuando un flujo de trabajo de adjuntos oficialmente compatible ya no depende del método privado del wrapper.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- react-native, typescript
- Área
- mobile
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 38/100