Add Sentry error/crash tracking - #7
Merged
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds error and crash tracking via
@sentry/react-native, wired behind aMonitoringServicestatic-class singleton so components and services never touch the SDK directly (consistent with theservices/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 exposinginit,captureException,captureMessage,setUser,addBreadcrumb, andwrap. All calls no-op unless Sentry is initialized.app/_layout.tsx— callsMonitoringService.init()and wraps the root export.components/ErrorBoundary.tsx— forwards caught errors to Sentry (existing fallback UI andconsole.errorretained).app.config.js— adds the@sentry/react-native/expoconfig plugin (org/project).metro.config.js(new) —getSentryExpoConfigfor source-map Debug IDs.eas.json—EXPO_PUBLIC_SENTRY_DSNadded to thepreviewandproductionprofiles (the DSN is not secret; the source-map auth token is stored as an EAS secret).utils/environment.ts— surfacessentryDsnfromEXPO_PUBLIC_SENTRY_DSN.jest.setup.js— definesglobal.__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— cleannpm 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)
MonitoringService.setUser(household_id)into the auth flow so issues group by household.Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com