Learn
Observability

How to Track Errors in My Cursor App

Add Sentry to your project the same way you would any standard project — Cursor is a code editor, not a deployment platform, so the integration depends on your framework (React, Next.js, Python, etc.), not on Cursor itself. Install the Sentry SDK, initialize it with your DSN, and deploy. Sentry will catch errors regardless of whether the code was written by you or by Cursor AI.

Why this matters

Cursor generates code using AI, which means the code is as likely to contain bugs as human-written code — sometimes more. Reports indicate that Cursor AI can introduce hallucinated imports, incorrect API usage, and subtle logic errors that pass type checks but fail at runtime. Error tracking catches these issues when real users encounter them.

What's at stake

AI-generated code that works in development can fail in production in unexpected ways. Unlike hand-written bugs where you understand the logic, AI-generated bugs can be in code you did not carefully review. Error tracking is your safety net for code you did not write yourself.

Step by step.

1

Install Sentry for your framework

In your Cursor terminal, install the Sentry SDK matching your project. For React: npm install @sentry/react. For Next.js: npm install @sentry/nextjs. For Python: pip install sentry-sdk. Cursor handles package installation the same way as VS Code.

npm install @sentry/react
# or
npm install @sentry/nextjs
# or
pip install sentry-sdk
2

Initialize Sentry in your app entry point

Add the Sentry initialization code to your app entry point. You can ask Cursor AI to do this: "Add Sentry error tracking with this DSN: [your DSN]. Include browser tracing and replay." Review the code Cursor generates to ensure the DSN is correct and initialization is in the right file.

import * as Sentry from "@sentry/react";

Sentry.init({
  dsn: "YOUR_SENTRY_DSN",
  integrations: [
    Sentry.browserTracingIntegration(),
    Sentry.replayIntegration(),
  ],
  tracesSampleRate: 1.0,
  replaysOnErrorSampleRate: 1.0,
});
3

Store the DSN in environment variables

Add your Sentry DSN to your .env file and reference it via process.env. Add .env to your .gitignore if it is not already there. Cursor respects standard environment variable patterns — the DSN will be available at build time.

4

Add Sentry checks to your .cursorrules

Add a rule to your .cursorrules file: "Always wrap new async functions in try-catch blocks with Sentry.captureException in the catch handler." This ensures Cursor AI includes error tracking in new code it generates, not just the existing code.

5

Review AI-generated code for error patterns

After Cursor generates code, review it for common AI mistakes: missing error handling in async functions, incorrect API endpoint URLs, and hallucinated library imports. Sentry will catch these at runtime, but catching them in code review is faster and cheaper.

Catch every bug Cursor AI introduces — even the ones you missed in review

  • Automated error detection for AI-generated code in production
  • Stack traces pointing to the exact line Cursor wrote that failed
  • Error patterns showing whether AI-generated code is improving or degrading over time
Get started with BWORLDS

Frequently asked questions.

No. Cursor is a code editor (a VS Code fork), not a deployment platform. Error tracking is determined by your framework and deployment target, not by your editor. Set up Sentry the same way you would for any project.

Sentry shows you the exact file and line number that caused the error. If you use Cursor Blame (available on Enterprise), you can trace whether that code was AI-generated or human-written. For most builders, the more practical approach is to check Sentry after each Cursor AI session for new errors.

Yes — especially for small projects. With AI-generated code, you are more likely to have errors you did not anticipate because you did not write the logic yourself. Sentry is free for up to 5,000 errors/month, which is more than enough for a small project.

Yes. Add rules like "Always include try-catch blocks for async operations" and "Use Sentry.captureException for error reporting." Cursor AI will follow these rules when generating new code, building error tracking into your codebase from the start.