Documentation Index
Fetch the complete documentation index at: https://mintlify.com/getsentry/sentry-javascript/llms.txt
Use this file to discover all available pages before exploring further.
Event types define the structure of events sent to Sentry.
Event Interface
From packages/core/src/types-hoist/event.ts:
export interface Event {
event_id?: string;
message?: string;
logentry?: {
message?: string;
params?: unknown[];
};
timestamp?: number;
start_timestamp?: number;
level?: SeverityLevel;
platform?: string;
logger?: string;
server_name?: string;
release?: string;
dist?: string;
environment?: string;
sdk?: SdkInfo;
request?: RequestEventData;
transaction?: string;
modules?: { [key: string]: string };
fingerprint?: string[];
exception?: {
values?: Exception[];
};
breadcrumbs?: Breadcrumb[];
contexts?: Contexts;
tags?: { [key: string]: Primitive };
extra?: Extras;
user?: User;
type?: EventType;
spans?: SpanJSON[];
measurements?: Measurements;
}
Fields
event_id
Unique identifier for the event (UUID format).event_id: '1234567890abcdef1234567890abcdef'
message
The log message or event description.message: 'User login failed'
timestamp
Unix timestamp (seconds) when the event occurred.timestamp: 1234567890.123
level
Event severity: 'fatal', 'error', 'warning', 'info', 'debug', or 'log'.
Platform identifier (e.g., 'javascript', 'node', 'python').
release
Release version of the application.
environment
Environment name (e.g., 'production', 'staging').environment: 'production'
tags
Record<string, Primitive>
Key-value pairs for filtering and grouping.tags: {
transaction: 'checkout',
user_type: 'premium',
region: 'us-west'
}
Additional arbitrary data.extra: {
request_id: '12345',
user_metadata: {
plan: 'premium',
signup_date: '2024-01-01'
}
}
user
User information. See User Types for details.user: {
id: '123',
email: 'user@example.com',
username: 'johndoe',
ip_address: '192.168.1.1'
}
contexts
Additional context data organized by type.contexts: {
os: {
name: 'Linux',
version: '5.4.0'
},
runtime: {
name: 'node',
version: '18.0.0'
},
device: {
family: 'Desktop',
model: 'MacBook Pro'
}
}
breadcrumbs
Trail of events leading to the error. See Breadcrumb Types.breadcrumbs: [
{
type: 'http',
category: 'fetch',
message: 'GET /api/users',
level: 'info',
timestamp: 1234567890
}
]
exception
Exception information.Array of exception objects.exception: {
values: [{
type: 'TypeError',
value: 'Cannot read property of undefined',
stacktrace: {
frames: [/* ... */]
},
mechanism: {
type: 'generic',
handled: true
}
}]
}
request
HTTP request information.request: {
url: 'https://example.com/api/users',
method: 'GET',
headers: {
'Content-Type': 'application/json'
},
query_string: 'page=1&limit=10',
data: { /* request body */ },
cookies: { /* cookies */ }
}
fingerprint
Custom grouping fingerprint.fingerprint: ['{{ default }}', 'database', 'connection-error']
Event Types
export type EventType =
| 'transaction'
| 'profile'
| 'replay_event'
| 'feedback'
| undefined;
Error Event
export interface ErrorEvent extends Event {
type: undefined;
}
Default event type for errors:
const errorEvent: ErrorEvent = {
message: 'Something went wrong',
level: 'error',
exception: {
values: [{
type: 'Error',
value: 'Something went wrong'
}]
}
};
Transaction Event
export interface TransactionEvent extends Event {
type: 'transaction';
spans?: SpanJSON[];
start_timestamp: number;
timestamp: number;
transaction: string;
}
Performance tracking event:
const transactionEvent: TransactionEvent = {
type: 'transaction',
transaction: 'GET /api/users',
start_timestamp: 1234567890.0,
timestamp: 1234567891.5,
spans: [/* child spans */],
measurements: {
'lcp': { value: 2500, unit: 'millisecond' }
}
};
EventHint
Additional context passed with events:
export interface EventHint {
event_id?: string;
captureContext?: CaptureContext;
mechanism?: Partial<Mechanism>;
syntheticException?: Error | null;
originalException?: unknown;
attachments?: Attachment[];
data?: any;
integrations?: string[];
}
Fields
The original exception object.Sentry.captureException(error, {
originalException: error
});
Synthetic exception for stack traces.Sentry.captureMessage('Message', {
syntheticException: new Error('Stack trace')
});
File attachments to include.Sentry.captureException(error, {
attachments: [{
filename: 'log.txt',
data: logData,
contentType: 'text/plain'
}]
});
Exception
export interface Exception {
type?: string;
value?: string;
mechanism?: Mechanism;
module?: string;
thread_id?: number;
stacktrace?: Stacktrace;
}
Example
const exception: Exception = {
type: 'TypeError',
value: 'Cannot read property "name" of undefined',
mechanism: {
type: 'generic',
handled: true,
data: {
function: 'processUser'
}
},
stacktrace: {
frames: [
{
filename: 'app.js',
function: 'processUser',
lineno: 42,
colno: 15
}
]
}
};
Mechanism
export interface Mechanism {
type: string;
handled?: boolean;
data?: Record<string, any>;
synthetic?: boolean;
help_link?: string;
meta?: Record<string, any>;
}
Example
const mechanism: Mechanism = {
type: 'promise',
handled: false,
data: {
function: 'fetchData'
}
};
Complete Example
import * as Sentry from '@sentry/node';
const event: Event = {
event_id: Sentry.uuid4(),
timestamp: Date.now() / 1000,
level: 'error',
platform: 'node',
release: 'myapp@1.0.0',
environment: 'production',
message: 'Payment processing failed',
exception: {
values: [{
type: 'PaymentError',
value: 'Credit card declined',
mechanism: {
type: 'generic',
handled: true
}
}]
},
user: {
id: 'user-123',
email: 'user@example.com'
},
tags: {
payment_method: 'credit_card',
amount: '99.99',
currency: 'USD'
},
extra: {
order_id: 'order-456',
attempts: 3,
last_error: 'Insufficient funds'
},
contexts: {
payment: {
processor: 'stripe',
card_type: 'visa',
last_four: '4242'
}
},
breadcrumbs: [
{
type: 'user',
category: 'action',
message: 'User clicked checkout',
level: 'info',
timestamp: Date.now() / 1000 - 5
},
{
type: 'http',
category: 'fetch',
message: 'POST /api/payment',
level: 'info',
data: {
status_code: 400
},
timestamp: Date.now() / 1000 - 2
}
],
fingerprint: ['payment-error', 'credit-card-declined']
};
Sentry.captureEvent(event);