DEV Community

Alex Spinov
Alex Spinov

Posted on

Sentry Has a Free API: Catch Errors Before Your Users Report Them

What is Sentry?

Sentry is an application monitoring platform that captures errors, performance issues, and session replays in real-time. When your production code throws an error, Sentry catches it, groups it, and shows you the exact line of code, user context, and breadcrumb trail.

Why Sentry?

  • Free tier — 5K errors/month, 10K performance transactions, 50 session replays
  • Automatic error grouping — same error from 1000 users = 1 issue
  • Stack traces — with source maps, see the exact line in YOUR code
  • Session replays — watch what the user did before the error
  • Performance monitoring — track slow pages, API calls, database queries
  • Every platform — JavaScript, Python, Go, Java, Ruby, PHP, React Native, Flutter

Quick Start (JavaScript)

npm install @sentry/node
Enter fullscreen mode Exit fullscreen mode
import * as Sentry from '@sentry/node';

Sentry.init({
  dsn: 'https://your-key@sentry.io/your-project',
  tracesSampleRate: 0.1, // 10% of transactions for performance
  environment: 'production',
  release: 'my-app@1.0.0'
});

// Errors are captured automatically!
try {
  await processOrder(orderId);
} catch (error) {
  Sentry.captureException(error, {
    tags: { orderId, paymentMethod: 'stripe' },
    user: { id: userId, email: userEmail }
  });
  throw error;
}
Enter fullscreen mode Exit fullscreen mode

React Integration

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

Sentry.init({
  dsn: 'https://your-key@sentry.io/project',
  integrations: [
    Sentry.browserTracingIntegration(),
    Sentry.replayIntegration({ maskAllText: false })
  ],
  tracesSampleRate: 0.1,
  replaysSessionSampleRate: 0.1, // 10% of sessions get replay
  replaysOnErrorSampleRate: 1.0  // 100% of error sessions get replay
});

// Error boundary
const SentryErrorBoundary = Sentry.withErrorBoundary(App, {
  fallback: <ErrorFallback />,
  showDialog: true // Shows user feedback dialog
});
Enter fullscreen mode Exit fullscreen mode

Performance Monitoring

// Automatic for Express/Next.js/FastAPI
// Manual spans for custom operations
const transaction = Sentry.startTransaction({ name: 'process-order' });

const dbSpan = transaction.startChild({ op: 'db.query', description: 'SELECT order' });
const order = await db.select().from(orders).where(eq(orders.id, orderId));
dbSpan.finish();

const paymentSpan = transaction.startChild({ op: 'http.client', description: 'Stripe charge' });
await stripe.charges.create({ amount: order.total });
paymentSpan.finish();

transaction.finish();
Enter fullscreen mode Exit fullscreen mode

Sentry API

# List project issues
curl 'https://sentry.io/api/0/projects/my-org/my-project/issues/' \
  -H 'Authorization: Bearer YOUR_AUTH_TOKEN' | jq '.[0:3] | .[] | {title, count, lastSeen}'

# Resolve an issue
curl -X PUT 'https://sentry.io/api/0/issues/ISSUE_ID/' \
  -H 'Authorization: Bearer YOUR_AUTH_TOKEN' \
  -d '{"status": "resolved"}'
Enter fullscreen mode Exit fullscreen mode

Sentry vs Alternatives

Feature Sentry Datadog New Relic LogRocket
Free errors/mo 5,000 500 100GB logs 1,000 sessions
Session replays Yes Yes (paid) No Core feature
Source maps Yes Yes Yes Yes
Performance Yes Yes Yes Limited
Open source Partial No No No
Self-hosted Yes No No No

Real-World Impact

A startup discovered through Sentry that 12% of checkout attempts silently failed due to a timezone parsing bug — users saw a blank page and left. The bug existed for 3 weeks with zero support tickets (users just left). With Sentry's session replay, they saw exactly what happened, fixed it in 30 minutes, and recovered estimated $15K/week in lost revenue.


Building production applications? I help teams implement proper observability. Contact spinov001@gmail.com or explore my data tools on Apify.

Top comments (0)