Back to 🧪 Testing & Monitoring

Setup Sentry Error Tracking

MonitoringSentryErrorsProduction
---
description: Track and debug production errors with Sentry
---

1. **Install Sentry SDK**:
- Install the Next.js SDK.
// turbo
- Run npm install @sentry/nextjs

2. **Initialize Sentry**:
- Run the wizard.
// turbo
- Run npx @sentry/wizard@latest -i nextjs
- This creates sentry.client.config.ts, sentry.server.config.ts, and updates next.config.js.

3. **Configure Environment Variables**:
- Add to .env.local.
NEXT_PUBLIC_SENTRY_DSN=https://[email protected]/xxx
SENTRY_AUTH_TOKEN=your-auth-token


4. **Test Error Tracking**:
- Trigger a test error.
// app/test-error/page.tsx
export default function TestError() {
return (
<button onClick={() => {
throw new Error('Sentry Test Error');
}}>
Trigger Error
</button>
);
}


5. **Capture User Context**:
- Add user info to errors.
import * as Sentry from '@sentry/nextjs';

Sentry.setUser({
id: user.id,
email: user.email,
username: user.name,
});


6. **Track Performance**:
- Sentry automatically tracks Core Web Vitals.
- Set sample rate in config.
Sentry.init({
tracesSampleRate: 0.1, // 10% of transactions
});


7. **Pro Tips**:
- Set up email/Slack alerts for critical errors.
- Use source maps to see original code in stack traces.
- Filter out known errors (e.g., browser extensions).
- Create releases to track errors by deployment.
By Antigravity Team

How to Use This Workflow

Option A: Project-Specific (Recommended)

  1. Click "Download" above
  2. In your project, create the directory: .agent/workflows/
  3. Save the file as setup-sentry-error-tracking-monitoring.md
  4. In Antigravity, type /setup_sentry_error_tracking_monitoring or just describe what you want to do

Learn more about workflows →

Related Workflows

Recommended Rules

View more rules →

Recommended MCP Servers

View more MCP servers →

Take It Further

Maximize your productivity with these powerful resources

📋

Define Your Standards

Set up coding standards to ensure this workflow produces consistent, high-quality results.

Browse Rules Library
📖

Master Workflows

Learn how to create custom workflows, use Turbo Mode, and build your automation library.

Complete Guide