import { $ as StackFrame, A as AttributeValue, B as LogsEnvelope, C as createIdentityTagger, D as assertKey, F as EntryPointHandler, G as Report, H as OtelLogRecord, I as EntryPointType, J as Span, K as SamplingContext, L as Framework, M as BufferedLog, N as BufferedSpan, O as assert, P as Config, Q as SpanStatusCode, R as Glow, S as SdkTaggable, U as OtelSpan, V as MessageLevel, W as OverriddenGrouping, X as SpanOptions, Y as SpanEvent, Z as SpanStatus, at as SpanTypeName, b as extractCode, c as RejectionReporter, d as DEFAULT_URL_DENYLIST, et as TracesEnvelope, f as redactObjectValues, g as now, h as safeDecode, it as BrowserSpanType, j as Attributes, k as AnyValue, l as describeRejectionReason, m as resolveDenylist, n as urlAttributes, nt as User, o as SafeCloneOptions, ot as FrameworkName, p as redactUrlQuery, q as SdkInfo, r as toCustomContext, rt as BrowserSpanEventType, s as safeClone, tt as TracesSampler, u as routeRejection, v as glowsToEvents, w as convertToError, x as evictLruIfNew, y as flatJsonStringify, z as KeyValue } from "./urlAttributes-CU2Yr37w.cjs"; //#region src/api/Api.d.ts declare class Api { private pendingKeepaliveBytes; private pendingKeepaliveRequests; /** * How many keepalive bytes are still available. Logs and traces share one browser allowance and both * flush on page hide, so whichever goes second must pack against what is left, not the whole budget. */ keepaliveBudgetRemaining(): number; report(report: Report, url: string, key: string | null, reportBrowserExtensionErrors: boolean, debug?: boolean): Promise; logs(envelope: LogsEnvelope, url: string, key: string | null, debug?: boolean, keepalive?: boolean): Promise; traces(envelope: TracesEnvelope, url: string, key: string | null, debug?: boolean, keepalive?: boolean): Promise; private ingestHeaders; private send; } //#endregion //#region src/logging/FlushScheduler.d.ts type FlushFn = (opts?: { keepalive?: boolean; }) => void; /** * The seam through which a platform package wires the "drain on lifecycle end" * trigger (browser unload, Node process exit). Core ships a no-op default; the * count/weight/timer batching policy lives in `Logger` regardless. */ interface FlushScheduler { register(flush: FlushFn): void; } declare class NoopFlushScheduler implements FlushScheduler { register(): void; } //#endregion //#region src/logging/Logger.d.ts type LoggerDeps = { api: Api; getConfig: () => Config; getSdkInfo: () => SdkInfo; getFramework: () => Framework | null; buildLogAttributes: (userAttributes: Attributes) => { record: Attributes; resource: Attributes; }; track: (p: Promise) => Promise; scheduler: FlushScheduler; }; declare class Logger { private deps; private inner; private resourceAttributes; constructor(deps: LoggerDeps); debug(message: string, context?: Attributes, attributes?: Attributes): void; info(message: string, context?: Attributes, attributes?: Attributes): void; notice(message: string, context?: Attributes, attributes?: Attributes): void; warning(message: string, context?: Attributes, attributes?: Attributes): void; error(message: string, context?: Attributes, attributes?: Attributes): void; critical(message: string, context?: Attributes, attributes?: Attributes): void; alert(message: string, context?: Attributes, attributes?: Attributes): void; emergency(message: string, context?: Attributes, attributes?: Attributes): void; bufferLength(): number; flush(opts?: { keepalive?: boolean; }): void; clear(): void; private record; private resourceForFlush; private estimateBytes; } //#endregion //#region src/Scope.d.ts /** Every key `Flare.setUser` owns. Consumers stamping identity outside core's report pipeline (Electron's * forwarded-renderer path) reuse this exact set. */ declare const USER_IDENTITY_KEYS: readonly [...("user.id" | "user.email" | "user.full_name" | "client.address")[], "user.attributes"]; /** For reports that do not flow through `Flare.report()`, which would spread `pendingAttributes` itself. */ declare function userIdentityAttributes(scope: Scope): Attributes; /** * Per-call mutable state, split out of `Flare` so the consumer can choose one global `Scope` (browser, one * user at a time) or one per request via AsyncLocalStorage (Node, where concurrent requests must not leak * into each other). `@flareapp/node`'s `NodeScope` extends this with a `request` bucket. */ declare class Scope { glows: Glow[]; breadcrumbs: SpanEvent[]; pendingAttributes: Attributes; entryPoint: EntryPointHandler | null; /** Caps at `maxGlowsPerReport` by dropping the oldest, so the payload stays bounded. */ addGlow(glow: Glow, maxGlowsPerReport: number): void; clearGlows(): void; /** Drops the oldest when full. */ addBreadcrumb(breadcrumb: SpanEvent, maxBreadcrumbs: number): void; clearBreadcrumbs(): void; setAttribute(key: string, value: AttributeValue): void; /** Shallow: last write wins per key, nested objects are not deep-merged. */ mergeAttributes(partial: Attributes): void; } /** * The seam through which `Flare` reaches its current `Scope`; implementations decide what "current" means. * `@flareapp/node`'s returns the per-request `NodeScope` from `node:async_hooks`, falling back to a shared * scope outside any `runWithContext(...)`. */ interface ScopeProvider { active(): Scope; } /** One `Scope` for the provider's lifetime. The right default for a browser tab or a CLI script. */ declare class GlobalScopeProvider implements ScopeProvider { private scope; active(): Scope; } //#endregion //#region src/stacktrace/fileReader.d.ts interface FileReader { read(url: string): Promise; } type CodeSnippet = { [key: number]: string; }; type ReaderResponse = { codeSnippet: CodeSnippet; trimmedColumnNumber: number | null; }; declare function getCodeSnippet(fileReader: FileReader, url?: string, lineNumber?: number, columnNumber?: number): Promise; declare function readLinesFromFile(fileText: string, lineNumber: number, columnNumber?: number, maxSnippetLineLength?: number, maxSnippetLines?: number): ReaderResponse; //#endregion //#region src/tracing/context.d.ts interface ActiveSpanHolder { getActive(): Span | undefined; /** * Runs `fn` with `span` active, then restores the previous active span. Takes a callback, not a * setter, so a Node holder can implement it with `AsyncLocalStorage.run(...)`. */ withActive(span: Span, fn: () => T): T; /** * Fallback span that getActive() returns when no withActive scope is active. Long-lived * pageload/navigation roots use it so child spans auto-parent to them. Optional. */ setActiveRoot?(span: Span | undefined): void; } declare class InMemoryActiveSpanHolder implements ActiveSpanHolder { private active; private root; getActive(): Span | undefined; withActive(span: Span, fn: () => T): T; setActiveRoot(span: Span | undefined): void; } //#endregion //#region src/tracing/Tracer.d.ts declare function defaultNowNano(): number; type SpanPhase = 'start' | 'end'; type SpanLifecycleEvent = { phase: SpanPhase; span: Span; }; type SpanLifecycleListener = (event: SpanLifecycleEvent) => void; /** Bounded backstop for the live TraceState map: an app that never ends spans must not grow it forever. */ declare const DEFAULT_MAX_LIVE_TRACES = 1000; type TracerDeps = { api: Api; getConfig: () => Config; getSdkInfo: () => SdkInfo; getFramework: () => Framework | null; getScopeAttributes: () => Attributes; getResourceAttributes: () => Attributes; track: (p: Promise) => Promise; scheduler: FlushScheduler; activeSpanHolder?: ActiveSpanHolder; now?: () => number; rng?: () => number; maxLiveTraces?: number; }; declare class Tracer { private deps; private buffer; private holder; private traceStates; private closedTraces; private stateGeneration; private now; private rng; private maxLiveTraces; private epoch; private pendingContinuation; private spanListeners; constructor(deps: TracerDeps); getActiveSpan(): Span | undefined; setActiveRoot(span?: Span): void; /** * Claims a span slot before the span exists, for a caller that publishes a span id early (the * component profilers do; their descendants record first). Returns false when the trace is full. * Paired with `startSpan({ claimed: true })`. */ claimSpanSlot(traceId: string): boolean; addSpanListener(fn: SpanLifecycleListener): () => void; private emitSpanEvent; flush(opts?: { keepalive?: boolean; }): void; clear(): void; continueFromTraceparent(header: string): void; /** * Runs `fn` with the span active, so spans started inside it auto-parent to it, then ends the span. * Records an error status first if `fn` throws or its returned promise rejects. */ withSpan(name: string, fn: (span: Span) => T, opts?: SpanOptions): T; /** * Starts a span the caller must end. Unlike `withSpan`, it does not become the active span, so spans * started after it do not auto-parent to it. */ startSpan(name: string, opts?: SpanOptions): Span; private startInertSpan; private resolveTrace; private getOrSeedState; private createState; private makeSpan; private rememberClosed; private onSpanEnd; } //#endregion //#region src/Flare.d.ts type ContextCollector = (config: Readonly) => Attributes; declare class Flare { api: Api; private contextCollector; private fileReader; private scopeProvider; private inflight; private _logger; private _tracer; private _config; private sdkInfo; private framework; /** * @param api fetch transport for reports, logs and traces. Stateless: ingest url and * key are passed per call, so tests swap in a fake. * @param contextCollector per-report attributes (browser DOM, Node process). No-op by default. * @param fileReader source files for stack-trace snippets. Defaults to no snippets; * `@flareapp/js` injects a fetch reader, `@flareapp/node` a disk reader. * @param scopeProvider the current `Scope`. Browser uses one global scope; Node an * AsyncLocalStorage-backed provider so each request gets its own. * @param scheduler drains the log and span buffers when the host's lifecycle ends (browser * unload, process exit). No-op by default, leaving only size/timer flushes. * @param activeSpanHolder tracks the active span so new spans auto-parent to it. In-memory by * default; a platform can back it with AsyncLocalStorage instead. */ constructor(api?: Api, contextCollector?: ContextCollector, fileReader?: FileReader, scopeProvider?: ScopeProvider, scheduler?: FlushScheduler, activeSpanHolder?: ActiveSpanHolder); private track; /** * Waits until every in-flight report settles, or `timeoutMs` elapses. Always resolves, never rejects. * Used by `@flareapp/node`'s fatal handler to drain other reports before `process.exit`. * * Only reports already in flight are awaited, so a handler still emitting during shutdown cannot block * forever. Call flush again to catch those. */ flush(timeoutMs?: number): Promise; get config(): Readonly; get glows(): readonly Glow[]; get logger(): Logger; get tracer(): Tracer; /** Starts a span the caller must end. Unlike `withSpan`, it does not become the active span, * so spans started after it do not auto-parent to it. */ startSpan(name: string, opts?: SpanOptions): Span; /** * Runs `fn` with the span active, so spans started inside auto-parent to it, then ends it. * Records an error status first if `fn` throws or its returned promise rejects. */ withSpan(name: string, fn: (span: Span) => T, opts?: SpanOptions): T; light(key?: string, debug?: boolean): this; /** * Turn sending on or off for consent. Off blocks errors, logs, and traces, and drops telemetry * captured earlier so a later grant cannot ship it. On re-grant, flushes anything still buffered. */ setConsent(granted: boolean): this; configure(config: Partial): this; test(): Promise; private testInternal; glow(name: string, level?: MessageLevel, data?: Record | Record[]): this; protected addBreadcrumb(type: string, attributes: Attributes, startTimeUnixNano: number): void; clearGlows(): this; addContext(name: string, value: AttributeValue): this; addContextGroup(groupName: string, value: Record): this; /** * Maps the known fields onto the keys the Flare backend reads (see `USER_FIELD_KEYS`) and bundles * anything else into `user.attributes`. Pass `null` to clear. In Node this targets the per-request scope. */ setUser(user: User | null): this; setEntryPoint(handler: EntryPointHandler): this; setSdkInfo(info: SdkInfo): this; setFramework(framework: Framework): this; private shouldSkipCapture; report(error: Error, attributes?: Attributes): Promise; private reportInternal; reportSilently(error: Error, attributes?: Attributes): void; reportUnhandledRejection(message: string, attributes?: Attributes): Promise; private reportUnhandledRejectionInternal; reportMessage(message: string, level?: MessageLevel, attributes?: Attributes): Promise; private reportMessageInternal; createReportFromError(error: Error, attributes?: Attributes, seenAtUnixNano?: number): Promise; private buildBaseAttributes; private assembleAttributes; private buildLogAttributes; private getScopeAttributes; private spanResourceAttributes; private buildReport; sendReport(report: Report): Promise; } //#endregion //#region src/breadcrumbs/recordBreadcrumb.d.ts declare const MAX_BREADCRUMB_URL_LENGTH = 256; declare function breadcrumbUrl(href: string, denylist: RegExp): string; declare function recordBreadcrumb(scopeProvider: ScopeProvider, config: Config, type: string, attributes: Attributes, startTimeUnixNano: number): void; //#endregion //#region src/tracing/envelope.d.ts declare function buildTracesEnvelope(spans: BufferedSpan[], resourceAttributes: Attributes, scopeName: string, scopeVersion: string): TracesEnvelope; //#endregion //#region src/tracing/traceparent.d.ts declare function buildTraceparent(traceId: string, spanId: string, sampled: boolean): string; declare function parseTraceparent(header: string): { traceId: string; parentSpanId: string; sampled: boolean; } | null; //#endregion //#region src/tracing/ids.d.ts declare function spanId(): string; //#endregion //#region src/stacktrace/NullFileReader.d.ts /** * No-op `FileReader` returning `null` for every URL. Default for `Flare`'s `fileReader` param, so * `new Flare()` builds reports without picking an environment; stack frames just omit source snippets. * `@flareapp/js` and `@flareapp/node` inject a real fetch- or disk-based reader instead. */ declare class NullFileReader implements FileReader { read(_url: string): Promise; } //#endregion //#region src/device/types.d.ts /** Effective connection quality. The API never reports 5g: a 5g device reports '4g'. */ type EffectiveConnectionType = 'slow-2g' | '2g' | '3g' | '4g'; /** Normalised device info. Every field optional: each provider fills what it reads, the mapper drops the rest. */ type DeviceInfo = { os?: { name?: string; version?: string; }; runtime?: { name?: string; version?: string; }; device?: { type?: string; model?: string; memoryGb?: number; cpuCores?: number; screen?: { width?: number; height?: number; scale?: number; }; }; network?: { effectiveType?: EffectiveConnectionType; downlinkMbps?: number; rttMs?: number; online?: boolean; }; app?: { version?: string; id?: string; }; locale?: { language?: string; timezone?: string; }; }; //#endregion //#region src/device/DeviceInfoProvider.d.ts /** The seam each platform implements to read device info. A `ContextCollector` maps it with `deviceInfoToAttributes`. */ interface DeviceInfoProvider { collect(): DeviceInfo; } /** Default for platforms with no device info. */ declare class NullDeviceInfoProvider implements DeviceInfoProvider { collect(): DeviceInfo; } //#endregion //#region src/device/deviceInfoToAttributes.d.ts /** Map `DeviceInfo` to wire attributes: flat keys plus a `context.device` card. Shared by every SDK, so keys never drift. */ declare function deviceInfoToAttributes(info: DeviceInfo): Attributes; /** * `context.device` card for the error UI. Rendered one level deep, so values stay scalar. Built only when * a device or network signal exists (an os-only Node report gets none). */ declare function buildDeviceContextGroup(info: DeviceInfo): Record; //#endregion //#region src/stacktrace/createStackTrace.d.ts declare function createStackTrace(error: Error, debug: boolean, fileReader: FileReader): Promise>; //#endregion export { type ActiveSpanHolder, type AnyValue, Api, type AttributeValue, type Attributes, BrowserSpanEventType, BrowserSpanType, type BufferedLog, type BufferedSpan, type Config, type ContextCollector, DEFAULT_MAX_LIVE_TRACES, DEFAULT_URL_DENYLIST, type DeviceInfo, type DeviceInfoProvider, type EffectiveConnectionType, type EntryPointHandler, type EntryPointType, type FileReader, Flare, type FlushFn, type FlushScheduler, type Framework, FrameworkName, GlobalScopeProvider, type Glow, InMemoryActiveSpanHolder, type KeyValue, Logger, type LoggerDeps, type LogsEnvelope, MAX_BREADCRUMB_URL_LENGTH, type MessageLevel, NoopFlushScheduler, NullDeviceInfoProvider, NullFileReader, type OtelLogRecord, type OtelSpan, type OverriddenGrouping, type RejectionReporter, type Report, type SafeCloneOptions, type SamplingContext, Scope, type ScopeProvider, type SdkInfo, type SdkTaggable, type Span, type SpanEvent, type SpanLifecycleEvent, type SpanLifecycleListener, type SpanOptions, type SpanPhase, type SpanStatus, SpanStatusCode, type SpanTypeName, type StackFrame, Tracer, type TracerDeps, type TracesEnvelope, type TracesSampler, USER_IDENTITY_KEYS, type User, assert, assertKey, breadcrumbUrl, buildDeviceContextGroup, buildTraceparent, buildTracesEnvelope, convertToError, createIdentityTagger, createStackTrace, defaultNowNano, describeRejectionReason, deviceInfoToAttributes, evictLruIfNew, extractCode, flatJsonStringify, getCodeSnippet, glowsToEvents, now, parseTraceparent, readLinesFromFile, recordBreadcrumb, redactObjectValues, redactUrlQuery, resolveDenylist, routeRejection, safeClone, safeDecode, spanId, toCustomContext, urlAttributes, userIdentityAttributes };