DEV Community

Alex Spinov
Alex Spinov

Posted on

Sentry Has a Free API — Error Tracking and Performance Monitoring for Every Stack

Sentry catches errors in production before your users report them. Stack traces, session replays, performance traces — across frontend, backend, and mobile.

Why Sentry?

  • Real error context — stack traces, breadcrumbs, user info, device data
  • Session Replay — watch what the user did before the error
  • Performance — trace slow API calls, database queries, renders
  • Free tier — 5K errors, 10K transactions, 50 replays/month
  • Every language — JS, Python, Go, Rust, Java, Ruby, PHP, .NET

Quick Start (JavaScript)

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

Sentry.init({
  dsn: 'https://YOUR_DSN@o0.ingest.sentry.io/0',
  tracesSampleRate: 1.0,
  environment: 'production',
});
Enter fullscreen mode Exit fullscreen mode

React

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

Sentry.init({
  dsn: 'YOUR_DSN',
  integrations: [
    Sentry.browserTracingIntegration(),
    Sentry.replayIntegration(),
  ],
  tracesSampleRate: 1.0,
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1.0,
});

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

Next.js

npx @sentry/wizard@latest -i nextjs
Enter fullscreen mode Exit fullscreen mode

Wizard auto-configures everything — sentry.client.config.ts, sentry.server.config.ts, and Next.js plugin.

Custom Error Context

try {
  await processOrder(orderId);
} catch (error) {
  Sentry.captureException(error, {
    tags: { module: 'payments', orderId },
    extra: { orderData: JSON.stringify(order) },
    user: { id: userId, email: userEmail },
  });
}

// Breadcrumbs (automatic trail of events)
Sentry.addBreadcrumb({
  category: 'payment',
  message: `Processing order ${orderId}`,
  level: 'info',
});
Enter fullscreen mode Exit fullscreen mode

Performance Monitoring

// Custom transaction
const transaction = Sentry.startTransaction({
  name: 'data-import',
  op: 'task',
});

const span = transaction.startChild({
  op: 'db.query',
  description: 'SELECT * FROM large_table',
});

await db.query('SELECT * FROM large_table');
span.finish();

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

Python

import sentry_sdk

sentry_sdk.init(
    dsn="YOUR_DSN",
    traces_sample_rate=1.0,
)

# Django — auto-instruments views, middleware, DB queries
# FastAPI — auto-instruments endpoints
# Flask — auto-instruments routes
Enter fullscreen mode Exit fullscreen mode

Alerts

Configure in Sentry dashboard:

  • Email/Slack when new error appears
  • Alert when error rate exceeds threshold
  • Alert when p95 latency > 500ms
  • Weekly report summaries

Building reliable scraping pipelines? Check out my Apify actors with built-in error handling, or email spinov001@gmail.com for monitored data solutions.

Sentry, Datadog, or custom logging — what do you use for error tracking? Share below!

Top comments (0)