Skip to content

Add Sentry error/crash tracking - #7

Merged
myaschmitz merged 2 commits into
mainfrom
myaschmitz-refactored-barnacle
Jul 11, 2026
Merged

Add Sentry error/crash tracking#7
myaschmitz merged 2 commits into
mainfrom
myaschmitz-refactored-barnacle

Conversation

@myaschmitz

Copy link
Copy Markdown
Owner

Summary

Adds error and crash tracking via @sentry/react-native, wired behind a MonitoringService static-class singleton so components and services never touch the SDK directly (consistent with the services/ convention).

Verified end-to-end: a preview (release) build was produced and test errors were confirmed arriving in the Sentry dashboard with source-mapped stack traces.

What changed

  • services/MonitoringService.ts (new) — wrapper exposing init, captureException, captureMessage, setUser, addBreadcrumb, and wrap. All calls no-op unless Sentry is initialized.
  • app/_layout.tsx — calls MonitoringService.init() and wraps the root export.
  • components/ErrorBoundary.tsx — forwards caught errors to Sentry (existing fallback UI and console.error retained).
  • app.config.js — adds the @sentry/react-native/expo config plugin (org/project).
  • metro.config.js (new) — getSentryExpoConfig for source-map Debug IDs.
  • eas.jsonEXPO_PUBLIC_SENTRY_DSN added to the preview and production profiles (the DSN is not secret; the source-map auth token is stored as an EAS secret).
  • utils/environment.ts — surfaces sentryDsn from EXPO_PUBLIC_SENTRY_DSN.
  • jest.setup.js — defines global.__DEV__ for the node test environment.
  • __tests__/services/MonitoringService.test.ts (new) — 11 tests.

Behavior / gating

Sentry only initializes when a DSN is present and the environment is not development, so local dev doesn't consume the free-tier quota. It's active in preview/production release builds.

Testing

  • npx tsc --noEmit — clean
  • npm test — 83 passed (11 new)

The new tests cover the wrapper only (init gating, idempotency, event forwarding, user set/clear) — not the Sentry SDK itself, and nothing asserts events reach Sentry's servers.

Follow-ups (not in this PR)

  • Optionally wire MonitoringService.setUser(household_id) into the auth flow so issues group by household.

Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com

myaschmitz and others added 2 commits July 10, 2026 23:29
Wire @sentry/react-native behind a MonitoringService static-class singleton so components/services never touch the SDK directly. Gated off in local dev to protect the free-tier quota; only initializes in preview/production builds. Root layout inits + wraps the app, ErrorBoundary forwards caught errors, Expo/metro config handle source-map upload, DSN lives in eas.json and the auth token is an EAS secret. Includes unit tests for the wrapper and a TEMP test-error button in settings for verification.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Verified Sentry receives events; removing the settings-screen test trigger.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rooted Ready Ready Preview, Comment Jul 11, 2026 6:56am

@myaschmitz
myaschmitz merged commit f6d12d7 into main Jul 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant