Skip to content

getsentry/error-generator

Repository files navigation

Error Generator

This is a simple Next.js application that sends sample errors to your Sentry project.

Getting Started

Prerequisites

  • Sentry account
  • Sentry project
  • Sentry auth token

Setup

Create a .env.local file in the root of the project and add the following variables:

SENTRY_ORG=your-sentry-org SENTRY_PROJECT=your-sentry-project SENTRY_AUTH_TOKEN=your-sentry-auth-token

Running the app

First, install the dependencies:

pnpm install

Next, run the development server:

pnpm dev

API Documentation

Generate Errors Endpoint

Generate test errors and send them to your Sentry project.

Endpoint: POST /api/generate-errors

Request Parameters

Parameter Type Required Default Description
dsn string Yes - Your Sentry project DSN (e.g., https://public_key@host/project_id)
errorCount number No 1 Number of events to generate per error
errorsToGenerate number No 1 Number of different errors to generate
fingerprintID string No - Custom fingerprint ID. If provided, only 1 error will be generated with this fingerprint
priority string No 'HIGH' Error priority level (HIGH, MEDIUM, LOW)
message string No - Custom error message. If not provided, uses default format with event ID and priority
tags object No {} Custom tags to attach to the errors

Priority Mapping

  • HIGH → Sentry level: fatal
  • MEDIUM → Sentry level: warning
  • LOW → Sentry level: info

Response Format

{ "success": true, "message": "Generated 2 errors with 3 events each (Priority: HIGH)", "results": [ { "event_id": "12345678-1234-1234-1234-123456789012", "status": "sent" }, { "event_id": "87654321-4321-4321-4321-210987654321", "status": "failed", "error": "Network error" } ] }

Example Requests

Basic Error Generation

Generate a single error with default settings:

curl -X POST https://error-generator.sentry.dev/api/generate-errors \ -H "Content-Type: application/json" \ -d '{  "dsn": "https://your-public-key@your-host.ingest.sentry.io/your-project-id"  }'
Multiple Errors with Custom Settings

Generate 3 different errors, each with 2 events, with high priority:

curl -X POST https://error-generator.sentry.dev/api/generate-errors \ -H "Content-Type: application/json" \ -d '{  "dsn": "https://your-public-key@your-host.ingest.sentry.io/your-project-id",  "errorsToGenerate": 3,  "errorCount": 2,  "priority": "HIGH"  }'
Error with Custom Tags

Generate an error with custom tags and medium priority:

curl -X POST https://error-generator.sentry.dev/api/generate-errors \ -H "Content-Type: application/json" \ -d '{  "dsn": "https://your-public-key@your-host.ingest.sentry.io/your-project-id",  "priority": "MEDIUM",  "tags": {  "team": "frontend",  "feature": "user-authentication",  "environment": "staging"  }  }'
Error with Custom Message

Generate an error with a custom message:

curl -X POST https://error-generator.sentry.dev/api/generate-errors \ -H "Content-Type: application/json" \ -d '{  "dsn": "https://your-public-key@your-host.ingest.sentry.io/your-project-id",  "message": "Payment processing failed for user transaction",  "priority": "HIGH",  "tags": {  "service": "payment-gateway",  "user_id": "12345"  }  }'
Error with Custom Fingerprint

Generate an error with a specific fingerprint for grouping:

curl -X POST https://error-generator.sentry.dev/api/generate-errors \ -H "Content-Type: application/json" \ -d '{  "dsn": "https://your-public-key@your-host.ingest.sentry.io/your-project-id",  "fingerprintID": "custom-error-group-123",  "errorCount": 5,  "priority": "LOW"  }'

Error Responses

If the request fails, you'll receive an error response:

{ "error": "DSN is required" }

Common error scenarios:

  • 400 Bad Request: Missing or invalid DSN format

Notes

  • Custom tags will override default tags (including environment)
  • When using fingerprintID, only 1 error will be generated regardless of errorsToGenerate value
  • Custom message, if provided, will replace the default message format
  • All errors are automatically tagged with generated_by: 'error-generator.sentry.dev'

About

Send sample sentry errors to your Sentry Project

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

Contributors