Sentry in a Next.js AI Product Stack
Next.js requires Sentry configuration in three places: client-side (browser), server-side (Node.js App Router server components and API routes), and edge runtime (middleware and edge API routes). Sentry's official @sentry/nextjs SDK handles all three when configured correctly. Source maps uploaded to Sentry during deployment mean that production error stack traces show your original TypeScript source code, not the minified bundle, which makes debugging significantly faster. SpeedMVPs configures the Sentry Next.js SDK as part of the project setup, including source map upload in the CI/CD pipeline, environment tagging (so errors in production are distinguished from staging), and release tracking (linking errors to the specific git commit that introduced them). Alert rules are configured to notify the team immediately on new unhandled exceptions in production.
Error Tracking for LLM and AI Pipeline Failures
AI products have failure modes that standard web apps do not: LLM API rate limits, context length exceeded errors, malformed JSON from structured output parsing, vector database timeouts, and unexpected model response formats. SpeedMVPs instruments these failure points with Sentry's manual error capture and custom breadcrumbs. When an LLM call fails, Sentry captures the error with context: which model was called, the approximate prompt length, the error code from the LLM provider, and the surrounding user action. This context makes it far faster to diagnose whether a production incident is a transient API issue, a prompt construction bug, or an edge case in the response parsing logic. Custom Sentry tags (model name, feature area, subscription plan) allow filtering the error dashboard to see whether errors cluster in specific AI features or user segments.
Performance Monitoring and Transaction Tracing
Sentry Performance monitoring captures transaction traces showing the time spent in each part of your request lifecycle. For an AI product, this means seeing that a particular API route spends 50ms in the database query, 200ms in the embedding lookup, and 3.2 seconds in the LLM call, in a single trace view. This makes it immediately clear where optimisation effort should be focused. Sentry also tracks Core Web Vitals for the frontend (LCP, FID, CLS), which matters for SEO and user experience. SpeedMVPs configures performance monitoring with appropriate sampling rates: 100% in staging for full visibility during development, and 10-20% in production to balance visibility with data volume and cost.
Release Tracking and Deployment Visibility
Sentry integrates with GitHub Actions to create a new Sentry release on every deployment, tagged with the git commit SHA and the deployment timestamp. When a new error appears after a deployment, Sentry links it to the release and shows which commits were included, making root cause identification faster. Sentry can also email the author of the specific commit that introduced the error, which improves accountability and reduces the time to diagnosis. SpeedMVPs configures the Sentry GitHub integration and the release creation step in the CI/CD pipeline as part of the standard project setup.
Alerting and Incident Response
Sentry's alert rules are highly configurable. SpeedMVPs sets up a sensible default alert configuration: immediate Slack notification for any new unhandled exception in production (errors you have never seen before are highest priority), a digest of recurring errors once per day (so known issues do not create alert fatigue), and a high-frequency alert for errors exceeding a per-hour threshold (indicating a systematic failure rather than a one-off incident). For AI products with critical uptime requirements (such as patient-facing NHS tools or financial services platforms), SpeedMVPs configures PagerDuty integration and defines escalation paths as part of the operational runbook delivered with the product.
GDPR Considerations and PII Scrubbing
Sentry captures error context including user identity, URL parameters, request headers, and sometimes request bodies or local variable values. This can include personal data. Sentry provides several mechanisms to prevent PII from being stored in error reports: a data scrubbing feature that automatically redacts fields matching common patterns (email, credit card numbers, passwords), server-side filtering hooks where you can remove sensitive fields before they are sent to Sentry, and Sentry's EU data residency option (data stored in Frankfurt) for GDPR-compliant operation. SpeedMVPs configures appropriate PII scrubbing for every project and uses Sentry's EU region by default for UK and EU AI products, with a Sentry DPA in place as required by ICO guidance.