Deprecated TypeScript type definitions for all Sentry JavaScript SDKs, now re-exported from @sentry/core
npx @tessl/cli install tessl/npm-sentry--types@10.10.0DEPRECATED: The @sentry/types package is deprecated. All exports have been moved to @sentry/core. This package serves as a backward compatibility layer for existing consumers and should not be used in new projects.
This package provides TypeScript type definitions for all Sentry JavaScript SDKs, containing common interfaces, types, and contracts used across the Sentry ecosystem for error monitoring and performance tracking.
npm install @sentry/types (deprecated - use @sentry/core instead)Deprecated approach:
import type { Event, Breadcrumb, Span, User } from "@sentry/types";Recommended approach:
import type { Event, Breadcrumb, Span, User } from "@sentry/core";For CommonJS:
// Deprecated
const { Event, Breadcrumb } = require("@sentry/types");
// Recommended
const { Event, Breadcrumb } = require("@sentry/core");// Import types from @sentry/core (recommended)
import type { Event, User, Breadcrumb, Span } from "@sentry/core";
// Define user data with type safety
const user: User = {
id: "123",
email: "user@example.com",
username: "john_doe"
};
// Define breadcrumb with type safety
const breadcrumb: Breadcrumb = {
message: "User clicked button",
category: "ui",
level: "info",
timestamp: Date.now() / 1000
};
// Define event with type safety
const event: Event = {
message: "Something went wrong",
level: "error",
user,
breadcrumbs: [breadcrumb]
};All types in this package have been moved to @sentry/core. Update your imports:
// Before (deprecated)
import type {
Event,
Breadcrumb,
User,
Span,
Client,
Scope
} from "@sentry/types";
// After (recommended)
import type {
Event,
Breadcrumb,
User,
Span,
Client,
Scope
} from "@sentry/core";Type definitions for Sentry events, errors, and transactions.
/** Core event interface for all Sentry events */
interface Event {
event_id?: string;
message?: string;
timestamp?: number;
level?: SeverityLevel;
logger?: string;
transaction?: string;
server_name?: string;
release?: string;
dist?: string;
environment?: string;
sdk?: SdkInfo;
request?: Request;
exception?: {
values?: Exception[];
};
stacktrace?: Stacktrace;
breadcrumbs?: Breadcrumb[];
contexts?: Contexts;
tags?: { [key: string]: string };
extra?: Extras;
user?: User;
fingerprint?: string[];
modules?: { [key: string]: string };
platform?: string;
start_timestamp?: number;
spans?: Span[];
transaction_info?: {
source: TransactionSource;
};
}
/** Error-specific event interface */
interface ErrorEvent extends Event {
exception: {
values: Exception[];
};
}
/** Transaction event interface for performance monitoring */
interface TransactionEvent extends Event {
type: "transaction";
transaction: string;
start_timestamp: number;
spans?: Span[];
contexts?: Contexts & {
trace?: TraceContext;
};
}
/** Severity levels for events */
type SeverityLevel = "fatal" | "error" | "warning" | "log" | "info" | "debug";
/** Event processing hints */
interface EventHint {
event_id?: string;
captureContext?: CaptureContext;
mechanism?: Partial<Mechanism>;
syntheticException?: Error;
originalException?: Error | string;
data?: any;
}
/** Event processor function interface */
interface EventProcessor {
(event: Event, hint?: EventHint): PromiseLike<Event | null> | Event | null;
}Type definitions for user identification and contextual data.
/** User identification and metadata */
interface User {
id?: string;
ip_address?: string;
email?: string;
username?: string;
name?: string;
segment?: string;
data?: { [key: string]: any };
}
/** Generic context interface */
interface Context {
[key: string]: any;
}
/** Collection of context data */
interface Contexts {
app?: AppContext;
device?: DeviceContext;
os?: OsContext;
culture?: CultureContext;
trace?: TraceContext;
cloud_resource?: CloudResourceContext;
[key: string]: Context | undefined;
}
/** Application context */
interface AppContext extends Context {
app_name?: string;
app_start_time?: string;
app_version?: string;
app_identifier?: string;
build_type?: string;
app_memory?: number;
}
/** Device context */
interface DeviceContext extends Context {
name?: string;
family?: string;
model?: string;
model_id?: string;
arch?: string;
battery_level?: number;
battery_temperature?: number;
orientation?: "portrait" | "landscape";
manufacturer?: string;
brand?: string;
screen_resolution?: string;
screen_height_pixels?: number;
screen_width_pixels?: number;
screen_density?: number;
screen_dpi?: number;
online?: boolean;
charging?: boolean;
low_memory?: boolean;
simulator?: boolean;
memory_size?: number;
free_memory?: number;
usable_memory?: number;
storage_size?: number;
free_storage?: number;
external_storage_size?: number;
external_free_storage?: number;
boot_time?: string;
timezone?: string;
}
/** Operating system context */
interface OsContext extends Context {
name?: string;
version?: string;
build?: string;
kernel_version?: string;
rooted?: boolean;
raw_description?: string;
}
/** Localization context */
interface CultureContext extends Context {
calendar?: string;
display_name?: string;
locale?: string;
is_24_hour_format?: boolean;
timezone?: string;
}
/** Distributed tracing context */
interface TraceContext extends Context {
trace_id?: string;
span_id?: string;
parent_span_id?: string;
op?: string;
description?: string;
status?: SpanStatus;
tags?: { [key: string]: string };
data?: { [key: string]: any };
}Type definitions for user action tracking through breadcrumbs.
/** Breadcrumb interface for tracking user actions */
interface Breadcrumb {
timestamp?: number;
message?: string;
category?: string;
level?: SeverityLevel;
type?: string;
data?: { [key: string]: any };
}
/** Additional breadcrumb metadata */
interface BreadcrumbHint {
[key: string]: any;
}
/** Fetch request breadcrumb data */
interface FetchBreadcrumbData {
method: string;
url: string;
status_code?: number;
reason?: string;
request_body_size?: number;
response_body_size?: number;
}
/** XHR request breadcrumb data */
interface XhrBreadcrumbData {
method?: string;
url?: string;
status_code?: number;
request_body_size?: number;
response_body_size?: number;
}
/** Fetch breadcrumb hint */
interface FetchBreadcrumbHint extends BreadcrumbHint {
input: RequestInfo;
data?: any;
response?: Response;
}
/** XHR breadcrumb hint */
interface XhrBreadcrumbHint extends BreadcrumbHint {
xhr?: XMLHttpRequest;
}Type definitions for distributed tracing and performance monitoring.
/** Distributed tracing span interface */
interface Span {
spanId: string;
traceId: string;
parentSpanId?: string;
status?: SpanStatus;
description?: string;
op?: string;
origin?: SpanOrigin;
data?: { [key: string]: any };
tags?: { [key: string]: string };
attributes?: SpanAttributes;
startTimestamp: number;
endTimestamp?: number;
isRecording(): boolean;
setStatus(status: SpanStatus): this;
setData(key: string, value: any): this;
setTag(key: string, value: string): this;
setAttribute(key: string, value: SpanAttributeValue): this;
setAttributes(attributes: SpanAttributes): this;
updateName(name: string): this;
end(endTimestamp?: number): void;
}
/** Span attributes collection */
interface SpanAttributes {
[key: string]: SpanAttributeValue;
}
/** Span attribute value types */
type SpanAttributeValue = string | number | boolean | Array<null | undefined | string> | Array<null | undefined | number> | Array<null | undefined | boolean>;
/** Span status enumeration */
type SpanStatus = "ok" | "deadline_exceeded" | "unauthenticated" | "permission_denied" | "not_found" | "resource_exhausted" | "invalid_argument" | "unimplemented" | "unavailable" | "internal_error" | "unknown_error" | "cancelled" | "already_exists" | "failed_precondition" | "aborted" | "out_of_range" | "data_loss";
/** Span origin information */
type SpanOrigin = "manual" | "auto" | string;
/** Time input for spans */
type SpanTimeInput = number | Date;
/** Options for starting spans */
interface StartSpanOptions {
name: string;
op?: string;
description?: string;
parentSpan?: Span;
attributes?: SpanAttributes;
startTime?: SpanTimeInput;
scope?: Scope;
onlyIfParent?: boolean;
forceTransaction?: boolean;
}
/** Arguments for Sentry span creation */
interface SentrySpanArguments {
spanId?: string;
traceId?: string;
parentSpanId?: string;
startTimestamp?: number;
endTimestamp?: number;
description?: string;
op?: string;
origin?: SpanOrigin;
status?: SpanStatus;
data?: { [key: string]: any };
tags?: { [key: string]: string };
attributes?: SpanAttributes;
}
/** Span JSON serialization format */
interface SpanJSON {
span_id: string;
trace_id: string;
parent_span_id?: string;
op?: string;
description?: string;
start_timestamp: number;
timestamp?: number;
status?: SpanStatus;
tags?: { [key: string]: string };
data?: { [key: string]: any };
origin?: SpanOrigin;
}
/** Span context data */
interface SpanContextData {
spanId: string;
traceId: string;
parentSpanId?: string;
}Type definitions for Sentry client and scope management.
/** Main Sentry client interface */
interface Client<O extends ClientOptions = ClientOptions> {
getOptions(): O;
captureException(exception: any, hint?: EventHint, scope?: Scope): string;
captureMessage(message: string, level?: SeverityLevel, hint?: EventHint, scope?: Scope): string;
captureEvent(event: Event, hint?: EventHint, scope?: Scope): string;
captureSession?(session: Session): void;
getDsn(): DsnComponents | undefined;
getTransport(): Transport;
flush(timeout?: number): PromiseLike<boolean>;
close(timeout?: number): PromiseLike<boolean>;
setupIntegrations(): void;
getIntegrationById(integrationId: string): Integration | null;
recordDroppedEvent(reason: EventDropReason, category: DataCategory, eventType?: EventType): void;
}
/** Client configuration options */
interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOptions> {
dsn?: DsnLike;
debug?: boolean;
release?: string;
environment?: string;
dist?: string;
maxBreadcrumbs?: number;
attachStacktrace?: boolean;
sendDefaultPii?: boolean;
maxValueLength?: number;
normalizeDepth?: number;
normalizeMaxBreadth?: number;
maxEventBytes?: number;
beforeSend?: (event: Event, hint: EventHint) => PromiseLike<Event | null> | Event | null;
beforeSendTransaction?: (event: TransactionEvent, hint: EventHint) => PromiseLike<TransactionEvent | null> | TransactionEvent | null;
beforeBreadcrumb?: (breadcrumb: Breadcrumb, hint?: BreadcrumbHint) => Breadcrumb | null;
integrations?: Integration[];
defaultIntegrations?: Integration[] | false;
transport?: TransportClass<TO>;
transportOptions?: TO;
stackParser?: StackParser;
sampleRate?: number;
tracesSampleRate?: number;
tracesSampler?: (samplingContext: SamplingContext) => number | boolean;
profilesSampleRate?: number;
profilesSampler?: (samplingContext: SamplingContext) => number | boolean;
replaysSessionSampleRate?: number;
replaysOnErrorSampleRate?: number;
sendClientReports?: boolean;
tunnel?: string;
_experiments?: { [key: string]: any };
_metadata?: SdkMetadata;
ignoreErrors?: Array<string | RegExp>;
denyUrls?: Array<string | RegExp>;
allowUrls?: Array<string | RegExp>;
autoSessionTracking?: boolean;
initialScope?: CaptureContext;
enabled?: boolean;
}
/** Transport class interface */
interface TransportClass<T extends BaseTransportOptions = BaseTransportOptions> {
new (options: T): Transport;
}
/** Request session interface */
interface RequestSession {
status?: SessionStatus;
requestSession?: Session;
}
/** Hub interface for integration setup */
interface Hub {
captureException(exception: any, hint?: EventHint): string;
captureMessage(message: string, level?: SeverityLevel, hint?: EventHint): string;
captureEvent(event: Event, hint?: EventHint): string;
getClient<C extends Client>(): C | undefined;
getScope(): Scope;
getStackTop(): Layer;
withScope(callback: (scope: Scope) => void): void;
pushScope(): Scope;
popScope(): boolean;
}
/** Hub layer interface */
interface Layer {
client?: Client;
scope: Scope;
}
/** Current scope interface */
interface Scope {
addScopeListener(callback: (scope: Scope) => void): void;
addEventProcessor(callback: EventProcessor): this;
setUser(user: User | null): this;
getUser(): User | undefined;
getRequestSession(): RequestSession | undefined;
setRequestSession(requestSession?: RequestSession): this;
setTags(tags: { [key: string]: string }): this;
setTag(key: string, value: string): this;
setExtras(extras: Extras): this;
setExtra(key: string, extra: Extra): this;
setFingerprint(fingerprint: string[]): this;
setLevel(level: SeverityLevel): this;
getLevel(): SeverityLevel | undefined;
setTransactionName(name?: string): this;
setTransaction(name?: string): this;
getTransaction(): string | undefined;
setContext(key: string, context: Context | null): this;
setSpan(span?: Span): this;
getSpan(): Span | undefined;
getTraceContext(): TraceContext;
getSession(): Session | undefined;
setSession(session?: Session): this;
update(captureContext?: CaptureContext): this;
clear(): this;
addBreadcrumb(breadcrumb: Breadcrumb, maxBreadcrumbs?: number): this;
getBreadcrumbs(): Breadcrumb[];
clearBreadcrumbs(): this;
applyToEvent(event: Event, hint?: EventHint, additionalEventProcessors?: EventProcessor[]): PromiseLike<Event | null>;
captureException(exception: any, hint?: EventHint): string;
captureMessage(message: string, level?: SeverityLevel, hint?: EventHint): string;
captureEvent(event: Event, hint?: EventHint): string;
clone(): Scope;
setSDKProcessingMetadata(newData: { [key: string]: unknown }): this;
}
/** Scope context data */
interface ScopeContext {
user?: User;
level?: SeverityLevel;
extra?: Extras;
contexts?: Contexts;
tags?: { [key: string]: string };
fingerprint?: string[];
requestSession?: RequestSession;
propagationContext?: PropagationContext;
}
/** Scope data structure */
interface ScopeData {
eventProcessors: EventProcessor[];
breadcrumbs: Breadcrumb[];
user: User;
tags: { [key: string]: string };
extra: Extras;
contexts: Contexts;
attachments: Attachment[];
propagationContext: PropagationContext;
sdkProcessingMetadata: { [key: string]: unknown };
fingerprint: string[];
level?: SeverityLevel;
transactionName?: string;
span?: Span;
}
/** Context for capturing events */
type CaptureContext = Scope | ScopeContext | ((scope: Scope) => Scope) | undefined;Type definitions for data transport and envelope system.
/** Transport layer interface */
interface Transport {
send(request: TransportRequest): PromiseLike<TransportMakeRequestResponse>;
flush(timeout?: number): PromiseLike<boolean>;
}
/** Transport request structure */
interface TransportRequest {
body: string | Uint8Array;
type: TransportRequestType;
url?: string;
}
/** Transport request type */
type TransportRequestType = "event" | "transaction" | "session" | "attachment";
/** Transport response */
interface TransportMakeRequestResponse {
statusCode?: number;
headers?: {
[key: string]: string | null;
'retry-after'?: string | null;
'x-sentry-rate-limits'?: string | null;
};
}
/** Base transport configuration */
interface BaseTransportOptions {
url?: string;
headers?: { [key: string]: string };
caCerts?: string | Buffer | Array<string | Buffer>;
proxy?: string;
httpsProxy?: string;
httpProxy?: string;
}
/** Envelope container for multiple items */
interface Envelope {
0: EnvelopeHeaders;
1: EnvelopeItem[];
}
/** Individual envelope item */
interface EnvelopeItem {
0: EnvelopeItemHeaders;
1: any;
}
/** Envelope item type enumeration */
type EnvelopeItemType = "session" | "sessions" | "transaction" | "event" | "client_report" | "user_report" | "profile" | "profile_chunk" | "replay_event" | "replay_recording" | "check_in" | "feedback" | "span" | "statsd" | "attachment";
/** Envelope headers */
type EnvelopeHeaders = BaseEnvelopeHeaders;
/** Envelope item headers */
type EnvelopeItemHeaders = BaseEnvelopeItemHeaders;
/** Base envelope headers */
interface BaseEnvelopeHeaders {
dsn?: string;
sdk?: SdkInfo;
sent_at?: string;
trace?: TraceparentData & { transaction?: string; public_key?: DsnComponents['publicKey']; sample_rate?: string; sampled?: string };
}
/** Base envelope item headers */
interface BaseEnvelopeItemHeaders {
type: EnvelopeItemType;
length?: number;
filename?: string;
content_type?: string;
attachment_type?: string;
}Type definitions for Sentry integrations.
/** Base integration interface */
interface Integration {
name: string;
setupOnce?(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void;
setup?(client: Client): void;
afterAllSetup?(client: Client): void;
processEvent?(event: Event, hint: EventHint, client: Client): Event;
}
/** Integration factory function */
interface IntegrationFn<T = Integration> {
(...args: any[]): T;
id?: string;
}Type definitions for error handling and stack traces.
/** Exception data structure */
interface Exception {
type?: string;
value?: string;
module?: string;
thread_id?: number;
stacktrace?: Stacktrace;
mechanism?: Mechanism;
}
/** Enhanced error interface with Sentry metadata */
interface ExtendedError extends Error {
name: string;
message: string;
stack?: string;
cause?: unknown;
[key: string]: unknown;
}
/** Error mechanism information */
interface Mechanism {
type: string;
description?: string;
help_link?: string;
handled?: boolean;
synthetic?: boolean;
data?: { [key: string]: string | boolean };
meta?: { [key: string]: any };
}
/** Complete stack trace */
interface Stacktrace {
frames?: StackFrame[];
frames_omitted?: [number, number];
}
/** Stack frame information */
interface StackFrame {
filename?: string;
function?: string;
module?: string;
platform?: string;
lineno?: number;
colno?: number;
abs_path?: string;
context_line?: string;
pre_context?: string[];
post_context?: string[];
in_app?: boolean;
instruction_addr?: string;
addr_mode?: string;
package?: string;
symbol?: string;
symbol_addr?: string;
image_addr?: string;
vars?: { [key: string]: any };
}
/** Stack trace parser interface */
interface StackParser {
(stack: string, skipFirst?: number): StackFrame[];
}
/** Single line parser interface */
interface StackLineParser {
(line: string): StackFrame | undefined;
}
/** Parser function type */
type StackLineParserFn = (line: string) => StackFrame | undefined;Type definitions for session tracking and user feedback.
/** User session interface */
interface Session {
sid: string;
did?: string | number;
init: boolean;
timestamp: number;
started: number;
duration?: number;
status: SessionStatus;
release?: string;
environment?: string;
userAgent?: string;
ipAddress?: string;
errors: number;
user?: User | null;
ignoreDuration: boolean;
abnormal_mechanism?: string;
toJSON(): {
sid: string;
init: boolean;
started: string;
timestamp: string;
status: SessionStatus;
errors: number;
did?: string | number;
duration?: number;
abnormal_mechanism?: string;
attrs?: {
release?: string;
environment?: string;
user_agent?: string;
ip_address?: string;
};
};
}
/** Session status enumeration */
type SessionStatus = "ok" | "exited" | "crashed" | "abnormal";
/** Session context data */
interface SessionContext {
sid?: string;
did?: string | number;
init?: boolean;
timestamp?: number;
started?: number;
duration?: number;
status?: SessionStatus;
release?: string;
environment?: string;
userAgent?: string;
ipAddress?: string;
errors?: number;
user?: User | null;
ignoreDuration?: boolean;
abnormal_mechanism?: string;
}
/** Serialized session format */
interface SerializedSession {
sid: string;
init: boolean;
started: string;
timestamp: string;
status: SessionStatus;
errors: number;
did?: string | number;
duration?: number;
abnormal_mechanism?: string;
attrs?: {
release?: string;
environment?: string;
user_agent?: string;
ip_address?: string;
};
}
/** User feedback interface */
interface UserFeedback {
event_id: string;
name: string;
email: string;
comments: string;
}
/** Feedback event structure */
interface FeedbackEvent {
type: "feedback";
event_id: string;
timestamp: number;
dist?: string;
platform: string;
environment?: string;
release?: string;
request?: RequestEventData;
contexts?: {
feedback?: {
message: string;
contact_email?: string;
name?: string;
replay_id?: string;
url?: string;
source?: string;
associated_event_id?: string;
};
trace?: TraceContext;
};
tags?: { [key: string]: string };
user?: User;
breadcrumbs?: Breadcrumb[];
}
/** Feedback form data */
interface FeedbackFormData {
name?: string;
email?: string;
message: string;
source?: string;
url?: string;
associated_event_id?: string;
}Type definitions for SDK metadata and DSN components.
/** SDK information */
interface SdkInfo {
name: string;
version: string;
integrations?: string[];
packages?: Array<{
name: string;
version: string;
}>;
}
/** SDK metadata */
interface SdkMetadata {
sdk?: SdkInfo;
[key: string]: any;
}
/** DSN component breakdown */
interface DsnComponents {
protocol: DsnProtocol;
publicKey: string;
pass: string;
host: string;
port: string;
path: string;
projectId: string;
}
/** DSN protocol enumeration */
type DsnProtocol = "http" | "https";
/** DSN-like identifier */
type DsnLike = string | DsnComponents;
/** W3C traceparent data */
interface TraceparentData {
traceId: string;
parentSpanId: string;
traceFlags: number;
}
/** Context for sampling decisions */
interface SamplingContext {
transactionContext: {
name: string;
op?: string;
};
location?: Location;
request?: any;
[key: string]: any;
}
/** File attachment interface */
interface Attachment {
filename: string;
data: string | Uint8Array;
contentType?: string;
attachmentType?: string;
}
/** Trace propagation context */
interface PropagationContext {
traceId: string;
spanId: string;
parentSpanId?: string;
sampled?: boolean;
baggage?: string;
dsc?: DynamicSamplingContext;
}
/** Dynamic sampling context */
interface DynamicSamplingContext {
trace_id: string;
public_key: string;
sample_rate?: string;
release?: string;
environment?: string;
transaction?: string;
replay_id?: string;
sampled?: string;
}
/** Transaction source enumeration */
type TransactionSource = "custom" | "url" | "route" | "view" | "component" | "task";Commonly used utility types and primitives.
/** Primitive value types */
type Primitive = number | string | boolean | bigint | symbol | null | undefined;
/** Additional data interface */
type Extra = unknown;
/** Collection of extra data */
type Extras = Record<string, Extra>;
/** Generic event interface */
interface PolymorphicEvent {
[key: string]: any;
type?: string;
}
/** Function wrapper interface */
interface WrappedFunction<T extends Function = Function> extends Function {
__sentry_original__?: T;
__sentry_wrapped__?: WrappedFunction<T>;
}
/** Web Worker location interface */
interface WorkerLocation {
protocol: string;
hostname: string;
port: string;
pathname: string;
search: string;
hash: string;
href: string;
origin: string;
host: string;
}
/** Parameterized string type */
type ParameterizedString = string;
/** Data category enumeration */
type DataCategory = "default" | "error" | "transaction" | "replay" | "security" | "attachment" | "session" | "internal" | "profile" | "monitor" | "feedback" | "span" | "statsd" | "metric_bucket";
/** Event processing outcome */
type Outcome = "before_send" | "event_processor" | "network_error" | "queue_overflow" | "ratelimit_backoff" | "sample_rate" | "send_error" | "internal_sdk_error";
/** Reason for dropping events */
type EventDropReason = "before_send" | "event_processor" | "network_error" | "queue_overflow" | "ratelimit_backoff" | "sample_rate" | "send_error" | "internal_sdk_error";
/** Console log level enumeration */
type ConsoleLevel = "debug" | "info" | "warn" | "error" | "log" | "assert" | "trace";All types are deprecated and re-exported from @sentry/core. Use the migration guide above to update your imports.
The package contains 353 type definitions covering:
@sentry/core@sentry/core