type LogLevel = 'debug' | 'info' | 'warning' | 'error' | 'fatal'; type EventLevel = 'debug' | 'info' | 'warning' | 'error' | 'fatal'; type EventPayload = Record; type BeforeSend = (payload: EventPayload) => EventPayload | null; type DiagnosticEvent = 'enqueue' | 'send' | 'drop' | 'timeout' | 'shutdown'; type DropReason = 'sample_rate' | 'before_send' | 'error' | 'queue_full' | 'response' | 'network'; interface StatsSnapshot { enqueued: number; sent: number; dropped: number; failed: number; timeout: number; reasons: Record; } interface DiagnosticDetails { reason?: DropReason; status?: number; error?: string; path?: string; batch?: number; stats?: StatsSnapshot; } type OnDiagnostic = (event: DiagnosticEvent, details: DiagnosticDetails) => void; type TracePropagationTarget = string | RegExp; type TraceCarrier = Headers | Record | ((name: string) => string | null | undefined); interface CaptureHint { contexts?: Record; handled?: boolean; level?: EventLevel; } interface UserContext { id: string | number; [key: string]: unknown; } interface AutoBreadcrumbsOptions { click?: boolean; navigation?: boolean; console?: boolean; http?: boolean; } interface CloseYourItOptions { endpointUrl: string; token?: string; publicKey?: string; projectId: string; environment?: string; release?: string; sampleRate?: number; beforeSend?: BeforeSend; onDiagnostic?: OnDiagnostic; debug?: boolean; autoInstall?: boolean; breadcrumbs?: boolean; autoBreadcrumbs?: AutoBreadcrumbsOptions; maxBreadcrumbs?: number; sendPii?: boolean; sendServerName?: boolean; maxQueue?: number; excludedExceptions?: string[]; captureRequest?: boolean; trackPageviews?: boolean; replay?: boolean; replayMaskAllInputs?: boolean; replayBlockSelector?: string; replayMaskTextSelector?: string; replayFlushIntervalMs?: number; logsEnabled?: boolean; logsSampleRate?: number; logsBatchSize?: number; logsFlushIntervalMs?: number; logsMinLevel?: LogLevel; slowMethodThresholdMs?: number; captureMethodArguments?: boolean; detectPerformanceIssues?: boolean; captureExternalHttp?: boolean; slowExternalThresholdMs?: number; repeatedHttpThreshold?: number; repeatedHttpWindowMs?: number; detectJank?: boolean; jankThresholdMs?: number; trackWebVitals?: boolean; webVitalsSampleRate?: number; captureResourceErrors?: boolean; tracePropagationTargets?: TracePropagationTarget[]; enabled?: boolean; } interface BreadcrumbInput { message?: string; category?: string; type?: string; level?: string; data?: Record; } declare class Breadcrumb { readonly timestamp: string; readonly message: string | undefined; readonly category: string | undefined; readonly type: string; readonly level: string; readonly data: Record | undefined; constructor(input: BreadcrumbInput); toJSON(): EventPayload; } declare class BreadcrumbBuffer { private readonly capacity; private items; constructor(capacity?: number); get maxSize(): number; get length(): number; add(crumb: Breadcrumb): void; clear(): void; toList(): Breadcrumb[]; toJSON(): EventPayload | null; } declare class Deduplicator { private readonly windowMs; private readonly now; private readonly seen; private readonly captured; constructor(windowMs?: number, now?: () => number); wasCaptured(error: unknown): boolean; markCaptured(error: unknown): void; isDuplicate(key: string): boolean; private prune; } declare class LogBuffer { private readonly onFlush; private readonly batchSize; private readonly flushIntervalMs; private events; private timer; private disposed; constructor(onFlush: (batch: EventPayload[]) => void, batchSize?: number, flushIntervalMs?: number); get length(): number; add(event: EventPayload): void; flush(): void; private ensureTimer; dispose(): void; } interface ResolvedOptions { endpointUrl: string; token: string; publicKey: string; projectId: string; environment: string; release: string | undefined; sampleRate: number; beforeSend: BeforeSend | undefined; onDiagnostic: OnDiagnostic | undefined; debug: boolean; autoInstall: boolean; breadcrumbs: boolean; autoBreadcrumbs: { click: boolean; navigation: boolean; console: boolean; http: boolean; }; maxBreadcrumbs: number; sendPii: boolean; sendServerName: boolean; maxQueue: number; excludedExceptions: string[]; captureRequest: boolean; trackPageviews: boolean; replay: boolean; replayMaskAllInputs: boolean; replayBlockSelector: string | undefined; replayMaskTextSelector: string | undefined; replayFlushIntervalMs: number; logsEnabled: boolean; logsSampleRate: number; logsBatchSize: number; logsFlushIntervalMs: number; logsMinLevel: LogLevel; slowMethodThresholdMs: number; captureMethodArguments: boolean; detectPerformanceIssues: boolean; captureExternalHttp: boolean; slowExternalThresholdMs: number; repeatedHttpThreshold: number; repeatedHttpWindowMs: number; detectJank: boolean; jankThresholdMs: number; trackWebVitals: boolean; webVitalsSampleRate: number; captureResourceErrors: boolean; tracePropagationTargets: TracePropagationTarget[]; enabled: boolean; } type TransportAuth = { kind: 'bearer'; secret: string; } | { kind: 'dsn'; publicKey: string; }; declare class Diagnostics { private readonly hook; constructor(hook?: OnDiagnostic); get suppressed(): boolean; notify(event: DiagnosticEvent, details?: DiagnosticDetails): void; } declare class Scope { readonly breadcrumbs: BreadcrumbBuffer; private user; private tags; private extra; private contexts; private request; traceId: string | undefined; replaySessionId: string | undefined; traceParentId: string | undefined; traceSampled: boolean | undefined; traceState: string | undefined; traceBaggage: string | undefined; constructor(maxBreadcrumbs?: number); setUser(user: UserContext | null): void; get userId(): string | undefined; setTag(key: string, value: string): void; setTags(tags: Record): void; setExtra(key: string, value: unknown): void; setContext(key: string, value: Record): void; setTraceId(id: string | undefined): void; continueTrace(ctx: { traceId: string; parentId: string; sampled: boolean; tracestate?: string | undefined; baggage?: string | undefined; }): void; setReplaySessionId(id: string | undefined): void; setRequest(request: Record | null): void; addBreadcrumb(input: BreadcrumbInput): void; fork(opts?: { freshTrace?: boolean; }): Scope; clear(): void; toEventHash(opts?: { sendPii?: boolean; }): EventPayload; } type StatKey = 'enqueued' | 'sent' | 'dropped' | 'failed' | 'timeout'; declare class Stats { private counts; private reasons; increment(key: StatKey): void; get(key: StatKey): number; record(reason: DropReason): void; recordTimeout(): void; toObject(): StatsSnapshot; reset(): void; } type NotifyDiagnostic = (event: DiagnosticEvent, details?: DiagnosticDetails) => void; type FetchImpl = typeof fetch; type BeaconImpl = (url: string, body: BodyInit) => boolean; interface TransportOptions { auth: TransportAuth; stats: Stats; fetchImpl?: FetchImpl | undefined; beaconImpl?: BeaconImpl | undefined; maxQueue?: number; timeoutMs?: number; debug?: (message: string, error?: unknown) => void; diagnostic?: NotifyDiagnostic; } declare class Transport { private readonly auth; private readonly stats; private readonly fetchImpl; private readonly beaconImpl; private readonly maxQueue; private readonly timeoutMs; private readonly debug; private readonly diagnostic; private inFlight; private readonly pending; private pageHiding; constructor(options: TransportOptions); setPageHiding(hiding: boolean): void; send(payload: unknown, url: string): boolean; flush(): Promise; private beaconEligible; private sendViaBeacon; private perform; private headers; private withAuth; } interface ClientDeps { transport?: Transport; logBuffer?: LogBuffer; stats?: Stats; scope?: Scope; dedup?: Deduplicator; random?: () => number; requestProvider?: () => Record | undefined; nowMs?: () => number; } declare class Client { readonly options: ResolvedOptions; readonly stats: Stats; readonly diagnostics: Diagnostics; private readonly baseScope; private readonly als; private syncScope; private readonly transport; private readonly auth; private readonly logBuffer; private readonly dedup; private readonly random; private readonly requestProvider; readonly nowMs: () => number; private readonly serverName; private shutdownNotified; private webVitalsSampled; constructor(rawOptions: CloseYourItOptions, deps?: ClientDeps); get scope(): Scope; get enabled(): boolean; get disabledReason(): string | null; private get eventsIngestUri(); get endpointHost(): string | undefined; get slowExternalThresholdMs(): number; captureException(error: unknown, hint?: CaptureHint): void; captureMessage(message: string, level?: EventLevel): void; log(level: LogLevel, message: string, attributes?: Record, logger?: string): void; measure(label: string, body: () => T, opts?: { args?: Record; }): T; recordExternalHttp(host: string, url: string, durationMs: number): void; recordRepeatedHttp(host: string, url: string, count: number): void; recordJank(durationMs: number, route: string): void; capturePageview(overrides?: { path?: string; }): void; captureEvent(name: string, overrides?: { path?: string; }): void; captureWebVitals(measures: EventPayload[]): void; setReplaySessionId(id: string | undefined): void; captureReplayChunk(chunk: EventPayload): void; setUser(user: UserContext | null): void; setTag(key: string, value: string): void; setTags(tags: Record): void; setExtra(key: string, value: unknown): void; setContext(key: string, value: Record): void; setTraceId(id: string | undefined): void; addBreadcrumb(input: BreadcrumbInput): void; clearScope(): void; continueTrace(carrier: TraceCarrier): void; getTraceHeaders(target?: string): Record; private isPropagationAllowed; runWithScope(fn: (scope: Scope) => T): T; withScope(fn: (scope: Scope) => T): T; private runInScope; notifyPageHiding(hiding: boolean): void; flush(): Promise; close(): Promise; private noteDrop; private enqueue; private applyBeforeSend; private flushLogs; private recordSlowMethod; private perfEnabled; private scopeHash; private autoRequest; private sampled; private sampledForWebVitals; private debugLog; } declare class CloseYourItLogger { private readonly getClient; private readonly name?; constructor(getClient: () => Client | null, name?: string | undefined); named(name: string): CloseYourItLogger; debug(message: string, attributes?: Record): void; info(message: string, attributes?: Record): void; warn(message: string, attributes?: Record): void; error(message: string, attributes?: Record): void; fatal(message: string, attributes?: Record): void; private emit; } declare const SDK_NAME = "closeyourit-js"; declare const SDK_VERSION = "0.10.0"; declare function init(options: CloseYourItOptions): Client; declare function captureException(error: unknown, hint?: CaptureHint): void; declare function captureMessage(message: string, level?: EventLevel): void; declare function log(level: LogLevel, message: string, attributes?: Record, loggerName?: string): void; declare const logger: CloseYourItLogger; declare function measure(label: string, body: () => T, opts?: { args?: Record; }): T; declare function capturePageview(overrides?: { path?: string; }): void; declare function captureEvent(name: string, overrides?: { path?: string; }): void; declare function setUser(user: UserContext | null): void; declare function setTag(key: string, value: string): void; declare function setTags(tags: Record): void; declare function setExtra(key: string, value: unknown): void; declare function setContext(key: string, value: Record): void; declare function setTraceId(id: string | undefined): void; declare function getTraceId(): string | undefined; declare function continueTrace(carrier: TraceCarrier): void; declare function getTraceHeaders(target?: string): Record; declare function getReplaySessionId(): string | undefined; declare function addBreadcrumb(input: { message?: string; category?: string; type?: string; level?: string; data?: Record; }): void; declare function clearScope(): void; declare function runWithScope(fn: (scope: Scope) => T): T; declare function withScope(fn: (scope: Scope) => T): T; declare function getStats(): StatsSnapshot; declare function isEnabled(): boolean; declare function flush(): Promise; declare function close(): Promise; export { type AutoBreadcrumbsOptions, type BeforeSend, type CaptureHint, Client, CloseYourItLogger, type CloseYourItOptions, type DiagnosticDetails, type DiagnosticEvent, type DropReason, type EventLevel, type EventPayload, type LogLevel, type OnDiagnostic, SDK_NAME, SDK_VERSION, Scope, type StatsSnapshot, type TraceCarrier, type TracePropagationTarget, type UserContext, addBreadcrumb, captureEvent, captureException, captureMessage, capturePageview, clearScope, close, continueTrace, flush, getReplaySessionId, getStats, getTraceHeaders, getTraceId, init, isEnabled, log, logger, measure, runWithScope, setContext, setExtra, setTag, setTags, setTraceId, setUser, withScope };