Skip to main content

Source: ocean/docs/sentry-production-diagnostic.md | ✏️ Edit on GitHub

Sentry Production Diagnostic Report

Issue Summary

Sentry is not receiving data from the production environment at https://goldfish.software.

Root Cause Analysis

1. Missing Environment Variable (Most Likely Issue)

The VITE_SENTRY_DSN environment variable is not configured in production:

  • Not found in .env.production
  • Not included in the environment validation schema (src/lib/env.ts)
  • Not configured in GitHub workflows

2. Sentry Initialization Logic

In src/lib/sentry.tsx:

dsn: isDevelopment
? undefined // Disable in development to save costs
: import.meta.env.VITE_SENTRY_DSN,
  • Sentry is disabled in development (DSN is undefined)
  • In production, it relies on VITE_SENTRY_DSN being set
  • If VITE_SENTRY_DSN is undefined in production, Sentry won't initialize

3. Aggressive Filtering

The beforeSend filter may be blocking events:

  • Non-error events are sampled at 10% in production
  • Many common errors are ignored (browser extensions, network errors, etc.)
  • Browser quirks like ResizeObserver errors are filtered out

4. Low Sample Rates

Production sample rates are very conservative:

  • Traces: 10% (tracesSampleRate: 0.1)
  • Session replays: 1% (replaysSessionSampleRate: 0.01)
  • Profile sampling: 1% (profilesSampleRate: 0.01)

Immediate Actions Required

1. Add Sentry DSN to Production Environment

Add the VITE_SENTRY_DSN to your Vercel environment variables:

  1. Go to Vercel Dashboard → Project Settings → Environment Variables
  2. Add: VITE_SENTRY_DSN = your-sentry-dsn-here
  3. Ensure it's enabled for Production environment
  4. Redeploy the application

2. Update Environment Validation

Add Sentry DSN to src/lib/env.ts:

{ key: 'VITE_SENTRY_DSN', required: false },

3. Add Logging for Debugging

Temporarily add logging to verify Sentry initialization:

export function initSentry() {
const environment = import.meta.env.MODE
const isDevelopment = environment === 'development'
const dsn = isDevelopment ? undefined : import.meta.env.VITE_SENTRY_DSN

console.log('[Sentry] Initializing with:', {
environment,
hasDsn: !!dsn,
dsn: dsn ? 'configured' : 'missing',
})

// ... rest of initialization
}

Browser Testing Steps

  1. Visit https://goldfish.software
  2. Open DevTools Console
  3. Run these diagnostic commands:
// Check if Sentry is loaded
console.log('Sentry object:', window.Sentry)

// Check configuration
if (window.Sentry) {
const client = window.Sentry.getClient()
console.log('Client configured:', !!client)
console.log('DSN present:', !!client?.getOptions()?.dsn)
console.log('Options:', client?.getOptions())
}

// Check environment variable
console.log('DSN from env:', import.meta.env.VITE_SENTRY_DSN)

// Force send a test error
if (window.Sentry?.captureException) {
window.Sentry.captureException(new Error('Production test error'))
console.log('Test error sent - check Network tab')
}
  1. Check Network tab for requests to:
    • *.ingest.sentry.io
    • Look for "envelope" requests

Expected Network Requests

When working correctly, you should see:

  • POST requests to https://[project-id].ingest.sentry.io/api/[project-id]/envelope/
  • Response status: 200 OK
  • Request payload containing error/transaction data

Verification After Fix

After adding the DSN and redeploying:

  1. Trigger an error in production
  2. Check Sentry dashboard for new events
  3. Verify performance monitoring is working
  4. Test session replay capture (1% sample rate)

Long-term Recommendations

  1. Add monitoring for Sentry itself:

    • Log when Sentry fails to initialize
    • Add health check endpoint that verifies Sentry is configured
  2. Consider adjusting sample rates for better visibility:

    • Increase tracesSampleRate to 0.2 (20%) temporarily
    • Monitor costs and adjust accordingly
  3. Add environment variable documentation:

    • Document all required environment variables
    • Add setup instructions for new developers
  4. Implement Sentry debug mode for staging:

    debug: environment === 'staging',

This will help diagnose issues faster in non-production environments.