Sentry Error Monitoring & Debugging
Status: Production-ready configuration with MCP integration Last Updated: 2025-11-18 Aligned with: CLAUDE.md Project ValuesTable of Contents
- Overview
- Current Status
- MCP Server Setup
- Production Configuration
- Multi-Tenant Context
- Best Practices
- Development Tools
- Release Tracking
- Troubleshooting
Overview
Purpose
Sentry provides real-time error monitoring, performance tracking, and debugging for the Sanctiv mobile app. This document outlines our production-ready configuration aligned with project values:- 100% Excellence - Proper error boundaries, source maps, release tracking
- Speed to Market - Fast debugging with AI-assisted root cause analysis
- Multi-Tenant Architecture - org_id tagging for church isolation
- Follow the Leader - Best-in-class Sentry configuration
Key Capabilities
- β Real-time error tracking (JS + Native crashes)
- β Performance monitoring (20% sampling in production)
- β Session tracking & crash-free rate
- β Breadcrumb trails for debugging context
- β AI-powered root cause analysis (via MCP)
- β Multi-tenant context tagging
- π§ Source maps upload (pending CI/CD)
- π§ Release tracking (pending versioning)
- π§ User feedback integration (pending)
Current Status
β Whatβs Working
Configuration: src/lib/sentry.ts Current Sentry configuration:- DSN: Hardcoded in
src/lib/sentry.ts(public, safe to commit) - Fallback: Can override via
EXPO_PUBLIC_SENTRY_DSNenv var if needed - Note: DSN is PUBLIC and safe to commit - itβs visible in client-side code anyway
- Debug mode: Enabled in
__DEV__, disabled in production - Traces sample rate: 100% in development, 20% in production
- Session tracking: 10-second intervals, auto-tracking enabled
- Native crash handling: Enabled for both iOS and Android
- Error boundaries: App wrapped with
Sentry.wrap()in App.tsx - Initialization: Called via
initializeSentry()in App.tsx with graceful fallback
- Send Test Error
- Send Test Message
- Send Error with Breadcrumbs
- Run Full Sentry Test (all 3 tests)
- β Errors captured and sent to Sentry dashboard
- β Test utilities functional with Alert confirmations
- β Console logging for debugging
- β Graceful fallback if DSN not configured
π§ Needs Implementation
The following features are documented but not yet implemented:- Source Maps Upload - Required for readable stack traces in production (see Production Configuration)
- Release Tracking - Version tracking and regression detection (see Production Configuration)
- Multi-Tenant Context - Organization tagging for B2B error isolation (see Multi-Tenant Context)
- Performance Optimization - Sample rate tuning based on volume (see Production Configuration)
- User Feedback Integration - Allow users to report issues (see Production Configuration)
- π΄ Critical: Source maps, Release tracking
- π‘ High: Multi-tenant context (org_id tagging)
- π’ Medium: Performance tuning, User feedback
MCP Server Setup
What is Sentry MCP?
The Sentry Model Context Protocol (MCP) server allows AI agents (like Claude Code) to:- Query Sentry issues and events in real-time
- Analyze errors with AI-powered root cause analysis
- Get fix recommendations from Sentryβs Seer AI
- Monitor release health and trends
Setup for Cursor IDE (Recommended)
Project Configuration: The Sentry MCP server is pre-configured in.cursor/mcp.json. To enable it:
-
Set Sentry Auth Token in Cursor Secrets:
- Cursor Settings β Cloud Agents β Secrets
- Add secret:
SENTRY_AUTH_TOKEN - Value: Your Sentry User Auth Token (from https://sentry.io/settings/account/api/auth-tokens/)
- Scopes needed:
org:read,project:read,event:read,project:releases
-
Restart Cursor:
- Restart Cursor IDE to load MCP server configuration
- MCP server will automatically use
SENTRY_AUTH_TOKENfrom secrets
-
Verify Connection:
- MCP server uses the same token as Sentry CLI
- Both CLI (
sentry-cli) and MCP server share the same authentication - Test with:
./scripts/verify-sentry-events.sh
.cursor/mcp.json
- β Persistent configuration (secrets stored in Cursor)
- β Works with Cloud Agents automatically
- β Same token for CLI and MCP server
- β No manual token management needed
.cursor/README.md for more details.
Setup for Claude Code (CLI)
Option 1: Remote Hosted (Recommended)
Option 2: Local STDIO
- Clone the Sentry MCP server:
-
Get Sentry Auth Token:
- Go to https://sentry.io/settings/account/api/auth-tokens/
- Create token with
org:read,project:read,event:readscopes
- Configure Claude Code:
Setup for Claude Desktop
- Open Claude Desktop Settings
- Navigate to: Settings β Developer β Edit Config
- Add to
claude_desktop_config.json:
- Restart Claude Desktop
- Authenticate via OAuth when prompted
Available MCP Tools
Once configured, you can:Production Configuration
Critical: Source Maps
Why: Without source maps, stack traces show minified code, making debugging impossible. Implementation:- Install Sentry CLI as dev dependency:
- Configure Sentry properties:
sentry.properties:
- Add to
package.json:
- Configure in EAS Build (eas.json):
- Set EAS secret:
Critical: Release Tracking
Why: Track which version has which bugs, monitor release health, identify regressions. Implementation: Update src/lib/sentry.ts:Critical: Performance Monitoring
Current: 20% traces sample rate in production β Optimization: Adjust based on volume:Optional: User Feedback
Allow users to report issues directly:Multi-Tenant Context
Critical for B2B SaaS
Since Sanctiv is a multi-tenant B2B platform, always tag errors with org_id to:- Filter issues by church/organization
- Identify organization-specific bugs
- Track error rates per customer
- Prioritize fixes based on customer impact
Proposed Implementation
π§ To Implement: Multi-tenant context tagging (not yet implemented) Step 1: Create src/lib/sentryContext.ts:Best Practices
1. Error Boundaries
Already implemented: App.tsx wrapped withSentry.wrap(App) β
Add screen-level boundaries:
2. Breadcrumbs
Already available:addBreadcrumb() helper in sentry.ts β
Usage examples:
3. Structured Error Capture
4. Filter Noise
Add to Sentry.init():5. Sampling Strategy
Current: 100% dev, 20% production β Adjust for pilot phase:Development Tools
Testing Sentry Integration
Location: Settings β Developer Tools (DEV mode only) Available Tests:- Send Test Error - Single error with context
- Send Test Message - Info-level message
- Send Error with Breadcrumbs - Error with navigation trail
- Run Full Sentry Test - All 3 tests sequentially
π§ [DEV TOOLS] prefixed logs to verify test execution.
Manual Testing
Sentry CLI Commands
Authentication: For Cursor Cloud Agents (Recommended):- Set
SENTRY_AUTH_TOKENin Cursor Settings β Cloud Agents β Secrets - Setup workflow (
/setup) will automatically configure~/.sentryclirc - MCP server will use the same token automatically
- No manual configuration needed
SENTRY_AUTH_TOKEN environment variable is set (from Cursor Secrets), the setup workflow will automatically configure ~/.sentryclirc from it.
Verify Token Access:
sntryu_...) have full read/write access via REST API, even if sentry-cli info shows only org:ci scope. Org tokens (sntrys_...) are write-only.
Release Tracking
Release Creation Workflow
Automated (via EAS Build): Add to.github/workflows/build.yml (when CI/CD implemented):
Monitoring Release Health
Sentry Dashboard:- Go to Releases tab
- View crash-free sessions/users
- Compare releases
- Identify regressions
Troubleshooting
Issue: Errors not appearing in Sentry
Check:- DSN configured:
echo $EXPO_PUBLIC_SENTRY_DSN - Sentry initialized: Look for
β Sentry initializedin logs - Network connectivity: Test with Developer Tools
- Sample rate: May not capture 100% in production
Issue: Stack traces are minified
Solution: Upload source maps (see Production Configuration)Issue: Wrong release version
Check:Issue: MCP server not connecting
Claude Code:- Check
claude_desktop_config.jsonsyntax - Restart Claude Desktop
- Check OAuth token validity
Issue: Too many errors (noise)
Solution: Add beforeSend filter (see Best Practices)Next Steps for Pilot
Pre-Launch Checklist
- Source maps upload configured in EAS Build
- Release tracking automated
- Multi-tenant context (org_id) implemented
- Error boundaries on all critical screens
- Breadcrumbs added to key user flows
- Sample rate tuned for pilot volume (50%)
- Alerts configured for critical errors
- Team trained on Sentry dashboard
- MCP server configured for AI debugging
- User feedback integration (optional)
Monitoring During Pilot
Key Metrics:- Crash-free session rate (target: >99%)
- Error rate per organization
- Most common errors
- Performance issues (slow screens)
- Check new issues
- Identify organization-specific problems
- Prioritize fixes based on customer impact
- Monitor release health trends
- Get daily error summaries
- Analyze top issues with Seer AI
- Track fix deployment success
- Compare church-to-church error rates
Resources
Official Documentation
- Sentry React Native: https://docs.sentry.io/platforms/react-native/
- Sentry MCP: https://docs.sentry.io/product/sentry-mcp/
- Sentry CLI: https://docs.sentry.io/product/cli/
- Using Sentry with Expo: https://docs.expo.dev/guides/using-sentry/
Internal Files
- src/lib/sentry.ts - Initialization & helpers
- src/lib/sentryTest.ts - Dev testing tools
- App.tsx - Error boundary wrapper
- .env - EXPO_PUBLIC_SENTRY_DSN (gitignored)
Related Documentation
- ARCHITECTURE.md - System architecture
- SECURITY.md - Security practices
- TESTING.md - E2E testing
- TROUBLESHOOTING.md - Common issues
Maintained by: Development Team Questions? Check CLAUDE.md for AI agent support or Slack #dev-support