DEV Community

Alex Spinov
Alex Spinov

Posted on

Sentry Has a Free API — Here's How to Track Errors Like a Pro

A startup I know shipped a bug on Friday. Nobody noticed until Monday when a customer tweeted about it. 3 days of broken checkout, $12,000 in lost sales. If they had Sentry, they'd have known in 30 seconds.

What Sentry Offers for Free

Sentry Developer plan (free forever):

  • 5,000 errors/month — enough for most projects
  • 10,000 performance transactions/month
  • 1 GB attachments
  • All SDKs — JavaScript, Python, Go, Ruby, Java, .NET, etc.
  • Stack traces with source maps
  • Release tracking
  • Issue grouping and deduplication
  • Email alerts

Quick Start (JavaScript)

npm install @sentry/node
Enter fullscreen mode Exit fullscreen mode
const Sentry = require('@sentry/node');

Sentry.init({
  dsn: 'https://YOUR_KEY@o0.ingest.sentry.io/0',
  tracesSampleRate: 0.1, // 10% of transactions
  environment: process.env.NODE_ENV,
  release: 'myapp@1.0.0'
});

// Errors are automatically captured
// But you can also capture manually:
try {
  await riskyOperation();
} catch (error) {
  Sentry.captureException(error, {
    tags: { module: 'payments' },
    extra: { orderId: '12345', userId: 'abc' }
  });
}
Enter fullscreen mode Exit fullscreen mode

Express Integration

const express = require('express');
const Sentry = require('@sentry/node');

const app = express();

Sentry.init({ dsn: process.env.SENTRY_DSN });

// Request handler must be first
app.use(Sentry.Handlers.requestHandler());

// Performance monitoring
app.use(Sentry.Handlers.tracingHandler());

app.get('/api/users/:id', async (req, res) => {
  const user = await db.getUser(req.params.id);
  res.json(user);
});

// Error handler must be last
app.use(Sentry.Handlers.errorHandler());
Enter fullscreen mode Exit fullscreen mode

Sentry REST API

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

# Get issue details
curl 'https://sentry.io/api/0/issues/ISSUE_ID/' \
  -H 'Authorization: Bearer YOUR_AUTH_TOKEN'

# Resolve an issue
curl -X PUT 'https://sentry.io/api/0/issues/ISSUE_ID/' \
  -H 'Authorization: Bearer YOUR_AUTH_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"status": "resolved"}'

# Get error events
curl 'https://sentry.io/api/0/issues/ISSUE_ID/events/' \
  -H 'Authorization: Bearer YOUR_AUTH_TOKEN'
Enter fullscreen mode Exit fullscreen mode

Custom Context and Breadcrumbs

// Set user context
Sentry.setUser({ id: userId, email: user.email, plan: user.plan });

// Add breadcrumbs for debugging
Sentry.addBreadcrumb({
  category: 'payment',
  message: `Processing payment for order ${orderId}`,
  level: 'info',
  data: { amount: 99.99, currency: 'USD' }
});

// Custom tags for filtering
Sentry.setTag('feature', 'checkout');
Sentry.setTag('api_version', 'v2');
Enter fullscreen mode Exit fullscreen mode

Source Maps for Readable Stack Traces

# Upload source maps during build
npx @sentry/cli releases new myapp@1.0.0
npx @sentry/cli releases files myapp@1.0.0 upload-sourcemaps ./dist
npx @sentry/cli releases finalize myapp@1.0.0
Enter fullscreen mode Exit fullscreen mode

Performance Monitoring

// Custom transactions
const transaction = Sentry.startTransaction({ name: 'process-order' });

const span1 = transaction.startChild({ op: 'db.query', description: 'Get order' });
const order = await db.getOrder(orderId);
span1.finish();

const span2 = transaction.startChild({ op: 'http', description: 'Charge payment' });
await paymentGateway.charge(order.amount);
span2.finish();

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

Alert Rules

Set up in Sentry UI or via API:

  • New issue → Email immediately
  • Issue frequency > 100/hour → Slack alert
  • P95 latency > 2s → PagerDuty
  • New release has 5x error rate → All channels

Need to monitor your web scrapers? Check out my scraping actors on Apify — reliable data collection with built-in error handling.

Need custom monitoring for your data pipelines? Email me at spinov001@gmail.com — I build robust, observable systems.

Top comments (0)