Files
MyIP/ecosystem.config.cjs
T
jason5ng32andClaude Fable 5 9bfbf21a60 Feat(monitoring): integrate Sentry across frontend and backend, env-gated end to end
Frontend (@sentry/vue, loaded via build-time-gated dynamic import — no
VITE_SENTRY_DSN_FRONTEND, no Sentry in the bundle; init joins the mount
gate so instrumentation precedes the first render):
- uncaught errors, route-change tracing / Web Vitals, error-only masked
  Session Replay, console.error capture fingerprinted per message prefix
  so each fallback source stays a distinct issue
- explicit ip-source:exhausted signal via the app-events bus
- hidden source maps uploaded (then deleted) by @sentry/vite-plugin,
  gated on SENTRY_AUTH_TOKEN

Backend (@sentry/node, bootstrapped by sentry-instrument.js via
node --import so ESM loader hooks land before express; never loaded
without SENTRY_DSN_BACKEND):
- Express error capture + per-route tracing
- logger hook mirrors warn+ lines to Sentry Logs and elevates error+
  to grouped, alertable Issues
- Sentry Crons check-ins for the MaxMind / CAIDA / service-status jobs
  via the no-op-without-DSN wrapper common/sentry-cron.js

Delivery & ops:
- first-party tunnel /api/monitoring relays envelopes past ad blockers;
  DSN-allowlisted (never an open relay), exempt from the shared rate
  limiter with its own generous ceiling
- rate-limit ledger file becomes opt-in now that the warn line reaches
  Sentry Logs; ecosystem.config.cjs carries the --import flag for pm2

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 11:16:17 +08:00

23 lines
832 B
JavaScript

// ecosystem.config.cjs — pm2 process definitions for production.
// `pm2 start ecosystem.config.cjs` so nobody has to remember the node flags:
// the backend must load sentry-instrument.js via --import BEFORE express for
// Sentry's ESM auto-instrumentation (a no-op without SENTRY_DSN_BACKEND, so
// Sentry-less deployments can use this file unchanged).
// CommonJS on purpose: pm2 reads its config synchronously and the package is
// "type": "module", hence the .cjs extension.
module.exports = {
apps: [
{
name: 'myip-backend',
script: 'backend-server.js',
cwd: __dirname,
node_args: '--import ./sentry-instrument.js',
},
{
name: 'myip-frontend',
script: 'frontend-server.js',
cwd: __dirname,
},
],
};