Description
The frontend has no monitoring, analytics, or error tracking. In production, there is no visibility into application health, user behavior, or error frequency. For a decentralized application handling financial data, monitoring is essential for user trust and operational excellence.
Monitoring gaps:
- No error tracking (Sentry, LogRocket)
- No user analytics (PostHog, Plausible, Umami)
- No performance monitoring (RUM, Web Vitals)
- No feature usage tracking
- No custom event tracking for blockchain operations
- No session recording for debugging
- No uptime monitoring
- No alert system for error spikes
- No privacy-compliant analytics (GDPR, cookie-free option)
Technical Context & Impact
- Affected Components/Files:
src/lib/monitoring/ (missing), src/lib/analytics/ (missing)
- Impact: Blind to production issues; cannot measure user engagement or diagnose errors
Step-by-Step Implementation Guide
- Set up Sentry:
npm install @sentry/nextjs:
- Create
sentry.client.config.ts, sentry.server.config.ts, sentry.edge.config.ts
- Configure DSN from env var
NEXT_PUBLIC_SENTRY_DSN
- Add
Sentry.withSentryConfig in next.config.ts
- Set up error boundary that reports to Sentry
- Configure performance tracing (30% sample rate)
- Add release tracking for source maps
- Set up analytics: Install PostHog or Plausible:
- Create
src/lib/analytics/AnalyticsProvider.tsx
- Track page views (automatic via Next.js router)
- Track custom events:
connectWallet, registerMeter, createStream, submitReading
- Track transaction outcomes (success/failure + time)
- Respect Do Not Track header for privacy
- Implement RUM (Real User Monitoring):
src/lib/monitoring/web-vitals.ts:
- Report LCP, FID, CLS, INP, TTFB
- Tag reports with page path, device type, connection type
- Create Monitoring Dashboard module: (for development):
- Show error count, active users, page views
- Filter by time range, error type, user
- Add session replay: Sentry session replay or LogRocket for debugging user sessions
- Set up alerts: Configure Sentry alert rules for:
- Error frequency spike (>100% increase in 1 hour)
- New error type that hasn't appeared before
- Core Web Vitals degradation
- Implement privacy controls: Cookie consent banner, data anonymization, opt-out mechanism
Verification & Testing Steps
- Trigger a test error -> verify it appears in Sentry dashboard within 2 minutes
- Navigate through app -> verify page views appear in analytics
- Complete a transaction -> verify custom event appears in analytics
- Verify privacy controls: enable Do Not Track -> verify no analytics sent
- Check Web Vitals are reported in Sentry Performance tab
- Verify source maps are uploaded for production error debugging
Description
The frontend has no monitoring, analytics, or error tracking. In production, there is no visibility into application health, user behavior, or error frequency. For a decentralized application handling financial data, monitoring is essential for user trust and operational excellence.
Monitoring gaps:
Technical Context & Impact
src/lib/monitoring/(missing),src/lib/analytics/(missing)Step-by-Step Implementation Guide
npm install @sentry/nextjs:sentry.client.config.ts,sentry.server.config.ts,sentry.edge.config.tsNEXT_PUBLIC_SENTRY_DSNSentry.withSentryConfiginnext.config.tssrc/lib/analytics/AnalyticsProvider.tsxconnectWallet,registerMeter,createStream,submitReadingsrc/lib/monitoring/web-vitals.ts:Verification & Testing Steps