import { $ as User, A as BufferedSpan, B as OtelSpan, D as AttributeValue, E as AnyValue, F as Glow, G as Span, H as Report, I as KeyValue, J as SpanStatus, K as SpanEvent, L as LogsEnvelope, M as EntryPointHandler, N as EntryPointType, O as Attributes, P as Framework, Q as TracesSampler, R as MessageLevel, T as assert, U as SamplingContext, V as OverriddenGrouping, W as SdkInfo, X as StackFrame, Y as SpanStatusCode, Z as TracesEnvelope, _ as flatJsonStringify, a as SafeCloneOptions, b as createIdentityTagger, c as describeRejectionReason, d as redactObjectValues, et as BrowserSpanType, f as redactUrlQuery, g as glowsToEvents, h as now, j as Config, k as BufferedLog, l as routeRejection, m as safeDecode, n as urlAttributes, nt as FrameworkName, o as safeClone, p as resolveDenylist, q as SpanOptions, r as toCustomContext, s as RejectionReporter, tt as SpanTypeName, u as DEFAULT_URL_DENYLIST, v as extractCode, w as assertKey, x as convertToError, y as SdkTaggable, z as OtelLogRecord } from "./urlAttributes-B9BlkrfW.mjs"; //#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 has to pack against what is left rather than assume the * whole budget, or it exceeds the gate in send() and silently degrades to a cancellable fetch. */ 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[]; 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; 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; /** * Run `fn` with `span` active, restoring the prior active span afterward. A callback (not a bare setter) so a Node * holder can back it with AsyncLocalStorage.run(...) to preserve async-scoped context. */ withActive(span: Span, fn: () => T): T; /** * Persistent "active root" that getActive() falls back to when no withActive scope is on the stack. Used by * long-lived pageload/navigation roots so child spans (e.g. fetches) auto-parent to them. Optional; a holder that * omits it simply has no active-root support. */ 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; /** * Take one span against `traceId`'s cap up front, for a caller that publishes a span id before the * span exists (the component profilers do; their descendants record first). False means the trace is * full and the caller should stay transparent instead of handing out an id the cap will refuse. * Consumed by the matching `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 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; /** 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; /** A real Span handle that records nothing, so callers never have to branch on whether tracing is on. */ private startInertSpan; private resolveTrace; private getOrSeedState; private createState; private makeSpan; /** Bounded, LRU by insertion order, like traceStates. Holds primitives only, never a span. */ 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); /** * Register an in-flight report so `flush()` can wait for it. Every entry point wraps its whole async * pipeline, from beforeEvaluate through api.report, so flush() waits on all of it. * * What goes in the Set is a shadow promise that mirrors `p`'s timing but cannot reject, so a failed * report never surfaces as an unhandled rejection warning. `p` itself is returned untouched, so the * caller still observes real success or failure. */ private track; /** * Wait until every in-flight report settles or `timeoutMs` elapses. Always resolves, never rejects. * Written for `@flareapp/node`'s fatal handler, which awaits the fatal report itself then flushes to * drain any other concurrent reports before `process.exit`. * * Snapshotting the Set bounds the wait: reports started after this line are not awaited, so a handler * that keeps emitting during shutdown cannot block the process forever. Call flush again for 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; configure(config: Partial): this; test(): Promise; private testInternal; glow(name: string, level?: MessageLevel, data?: Record | Record[]): this; 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; 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; /** * Local roots only, snapshotted by the Tracer at span START so a long-lived root does not drift into * the next page's scope. Children get none, and no span ever runs the DOM collector. * * Everything assembled is inherited except user identity (excluding the opaque `user.id`): a root span * goes out for every page view, so email, full name, IP and `user.attributes` would turn normal * browsing into PII traffic. The rest — `context.custom`, `addContextGroup` bags — stays in, because * the trace viewer renders any span attribute whose key does not start with `flare.`. */ private getScopeAttributes; private spanResourceAttributes; private buildReport; sendReport(report: Report): Promise; } //#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. Consumer packages inject the real * ones: `@flareapp/js` a fetch-based reader, `@flareapp/node` a disk reader. The `read(url) -> Promise` * interface lets the stack-trace builder treat all three the same (render on text, skip on null), so core needs no * environment checks. */ declare class NullFileReader implements FileReader { read(_url: string): Promise; } //#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, BrowserSpanType, type BufferedLog, type BufferedSpan, type Config, type ContextCollector, DEFAULT_MAX_LIVE_TRACES, DEFAULT_URL_DENYLIST, 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, type MessageLevel, NoopFlushScheduler, 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, buildTraceparent, buildTracesEnvelope, convertToError, createIdentityTagger, createStackTrace, defaultNowNano, describeRejectionReason, extractCode, flatJsonStringify, getCodeSnippet, glowsToEvents, now, parseTraceparent, readLinesFromFile, redactObjectValues, redactUrlQuery, resolveDenylist, routeRejection, safeClone, safeDecode, spanId, toCustomContext, urlAttributes, userIdentityAttributes };