Set up Sentry crash reporting for mobile app

- Initialize @sentry/react-native with dedicated mobile project DSN
- Wrap root layout with Sentry.wrap() for unhandled error capture
- Configure Sentry plugin with org (trails-qq) and project (mobile)
  for source map uploads during EAS builds
- Disabled in dev, full tracing in production

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-04-13 01:53:47 +02:00
parent dd06d2f231
commit 42a9c29c84
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9
4 changed files with 34 additions and 4 deletions

View file

@ -39,7 +39,10 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
"expo-secure-store",
"expo-web-browser",
"@maplibre/maplibre-react-native",
"@sentry/react-native",
["@sentry/react-native", {
organization: "trails-qq",
project: "mobile",
}],
"expo-sqlite",
],
extra: {

View file

@ -1,9 +1,12 @@
import { useEffect, useState } from "react";
import { Stack, router } from "expo-router";
import { Sentry, initSentry } from "../lib/sentry";
import { isAuthenticated } from "../lib/auth";
import { startVersionCheck } from "../lib/version-check";
export default function RootLayout() {
initSentry();
function RootLayout() {
const [checked, setChecked] = useState(false);
useEffect(() => {
@ -21,3 +24,5 @@ export default function RootLayout() {
return <Stack screenOptions={{ headerShown: false }} />;
}
export default Sentry.wrap(RootLayout);

View file

@ -9,10 +9,16 @@
"distribution": "internal",
"ios": {
"simulator": true
},
"env": {
"SENTRY_DISABLE_AUTO_UPLOAD": "true"
}
},
"preview": {
"distribution": "internal"
"distribution": "internal",
"env": {
"SENTRY_DISABLE_AUTO_UPLOAD": "true"
}
},
"production": {
"autoIncrement": true
@ -23,7 +29,10 @@
"ios": {
"simulator": true
},
"environment": "development"
"environment": "development",
"env": {
"SENTRY_DISABLE_AUTO_UPLOAD": "true"
}
}
},
"submit": {

13
apps/mobile/lib/sentry.ts Normal file
View file

@ -0,0 +1,13 @@
import * as Sentry from "@sentry/react-native";
const SENTRY_DSN = "https://af50ac7aea803216adbe21e9dd4b896b@o4509530546634752.ingest.de.sentry.io/4511209742532688";
export function initSentry() {
Sentry.init({
dsn: SENTRY_DSN,
tracesSampleRate: __DEV__ ? 0 : 1.0,
enabled: !__DEV__,
});
}
export { Sentry };