Skip to main content
The captureEvent function allows you to manually create and send custom events to Sentry with complete control over the event structure.

Function Signature

Parameters

Event
required
The event object to capture. See Event Types for the complete structure.
CaptureContext
Additional context to merge with the event. Can be:
  • A Scope object
  • A partial ScopeContext object
  • A callback function receiving the current scope

Returns

string
The unique ID of the captured event.

Basic Usage

Event Structure

Custom Event Examples

Application Performance Event

Business Event

Security Event

Custom Exception Event

With Request Context

With Breadcrumbs

With Attachments

Implementation Details

From packages/core/src/client.ts:

Event Types

Error Event

Transaction Event

Fingerprinting

Control event grouping with fingerprints:

Context Merging

When using captureContext, data is merged with the event:

Best Practices

1. Include Timestamps

2. Use Appropriate Levels

3. Add Context

4. Tag for Filtering

Validation

Events are validated before sending: