Skip to content

Latest commit

 

History

History
141 lines (100 loc) · 2.94 KB

File metadata and controls

141 lines (100 loc) · 2.94 KB

Sentry

Developer-first application monitoring with error tracking, performance analysis, and session replay.

GitHub Education Access

Claim your free access at GitHub Education Pack - look for Sentry.

Dashboard

Features

  • Error Tracking: Capture errors with stack traces, breadcrumbs, and context
  • Performance Monitoring: Trace requests across services
  • Session Replay: Record user interactions before errors
  • Profiling: Identify slow functions
  • Cron Monitoring: Watch scheduled jobs
  • Logging: Application log collection

Quick Setup

JavaScript/Node.js

npm install @sentry/node
import * as Sentry from '@sentry/node';

Sentry.init({
  dsn: process.env.SENTRY_DSN,
  environment: process.env.NODE_ENV,
  tracesSampleRate: 1.0,
});

// Capture exception
Sentry.captureException(error);

React/Browser

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

Sentry.init({
  dsn: process.env.REACT_APP_SENTRY_DSN,
  integrations: [Sentry.browserTracingIntegration()],
  tracesSampleRate: 1.0,
});

Python

pip install sentry-sdk
import sentry_sdk

sentry_sdk.init(
    dsn=os.environ.get("SENTRY_DSN"),
    traces_sample_rate=1.0,
)

Go

go get github.com/getsentry/sentry-go
import "github.com/getsentry/sentry-go"

sentry.Init(sentry.ClientOptions{
    Dsn: os.Getenv("SENTRY_DSN"),
})

Configuration

Copy from templates/sentry/:

  • sentry.client.config.js - Browser SDK config
  • sentry.server.config.js - Server SDK config
  • .sentryclirc - CLI configuration
  • .env.example - Environment variables

Environment Variables

SENTRY_DSN=https://key@sentry.io/project
# Get from: https://sentry.io → Project Settings → Client Keys (DSN)

SENTRY_AUTH_TOKEN=your_auth_token
# Get from: https://sentry.io/settings/account/api/auth-tokens/

SENTRY_ORG=your-org-slug
SENTRY_PROJECT=your-project-slug

Sentry CLI

npm install @sentry/cli

# Create release
sentry-cli releases new v1.0.0

# Upload source maps
sentry-cli releases files v1.0.0 upload-sourcemaps ./dist

Best Practices

  1. Create releases: Track which version caused errors
  2. Upload source maps: Get readable stack traces
  3. Set sample rates: Adjust tracesSampleRate for volume control
  4. Add context: Include user info, tags, and custom data
  5. Configure environments: Separate staging from production

Integrations

  • GitHub, GitLab, Bitbucket (commit tracking)
  • Slack, PagerDuty, Jira
  • Vercel, Netlify (auto-releases)

Resources