//#region src/framework.d.ts /** * Framework names the Flare backend recognizes. Wire format: these values never change, since they * ship as `flare.framework.name` and (lowercased) as `context.custom.framework`. * * `Js` and `Node` are fallback claims from the base SDKs, overwritten when a framework package sets * its own name. `NodeElectron` is the Electron main process; renderers report their own name. */ declare const FrameworkName: { readonly Js: "js"; readonly Node: "node"; readonly NodeElectron: "node-electron"; readonly React: "react"; readonly Vue: "vue"; readonly Svelte: "svelte"; readonly SvelteKit: "sveltekit"; readonly ReactNative: "react-native"; }; type FrameworkName = (typeof FrameworkName)[keyof typeof FrameworkName]; //#endregion //#region src/spanTypes.d.ts /** * Span types the Flare backend recognizes. Wire format, so the values never change: they ship as the * `flare.span_type` attribute and the backend groups performance data by them. * * These are the browser client's set. They live in core because core's `SpanOptions.spanType` needs * to name them and core cannot import from `@flareapp/js`. */ declare const BrowserSpanType: { readonly Pageload: "browser_pageload"; readonly Navigation: "browser_navigation"; readonly Fetch: "browser_fetch"; readonly Xhr: "browser_xhr"; readonly Component: "browser_component"; readonly WebVital: "browser_web_vital"; }; type BrowserSpanType = (typeof BrowserSpanType)[keyof typeof BrowserSpanType]; /** Any other value stays legal, so a host SDK can stamp its own without a core release. */ type SpanTypeName = BrowserSpanType | (string & {}); /** * Span event types on an error report. Kept apart from `BrowserSpanType`: these are points in time, * not spans with a duration. That is also why a route change is not called `browser_navigation`. */ declare const BrowserSpanEventType: { readonly Click: "browser_click"; readonly Input: "browser_input"; readonly RouteChange: "browser_route_change"; }; type BrowserSpanEventType = (typeof BrowserSpanEventType)[keyof typeof BrowserSpanEventType]; //#endregion //#region src/types.d.ts type MessageLevel = 'debug' | 'info' | 'notice' | 'warning' | 'error' | 'critical' | 'alert' | 'emergency'; type AttributeValue = string | number | boolean | null | AttributeValue[] | { [key: string]: AttributeValue; }; type Attributes = Record; /** * An identified user passed to `Flare.setUser`. Known fields map to the backend keys: `id`->`user.id`, * `email`->`user.email`, `fullName`->`user.full_name`, `ipAddress`->`client.address`. Any other key lands in * `user.attributes`. Caveat: the open index signature means a misspelled known field (e.g. `full_name` for `fullName`) * silently lands in `user.attributes` with no type error. Spell the four known fields exactly. */ type User = { id?: string | number; email?: string; fullName?: string; ipAddress?: string; [key: string]: AttributeValue | undefined; }; type Config = { key: string | null; /** When false, the SDK sends nothing: no errors, logs, or traces. Flip it with `setConsent()`. * Default true, so setups without a consent tool are unchanged. */ hasConsent: boolean; version: string; sourcemapVersionId: string; stage: string; maxGlowsPerReport: number; enableBreadcrumbs: boolean; maxBreadcrumbs: number; reportBrowserExtensionErrors: boolean; ingestUrl: string; debug: boolean; urlDenylist: RegExp; replaceDefaultUrlDenylist: boolean; sampleRate: number; enableLogs: boolean; logsIngestUrl: string; minimumLogLevel?: MessageLevel; serviceName?: string; maxLogBufferSize: number; logFlushIntervalMs: number; logFlushMaxBytes: number; keepaliveMaxBytes: number; enableTracing: boolean; tracesIngestUrl: string; tracesSampleRate: number; tracesSampler?: TracesSampler; /** * URLs a W3C `traceparent` header may be attached to on outgoing requests. Default (unset): same-origin + relative * only; `[]` disables all injection. Each entry matches by String.includes (string) or RegExp.test. Attaching * cross-origin forces a CORS preflight; the target server must allow the `traceparent` request header. */ tracePropagationTargets?: (string | RegExp)[]; /** Idle-span: ms of no open child spans before a pageload/navigation root closes. Browser default 1000. */ idleTimeout?: number; /** Idle-span: hard cap in ms from root start before it closes regardless of activity. Browser default 30000. */ finalTimeout?: number; /** Idle-span: if a child span stays open this many ms, the root closes anyway. Browser default 15000. */ childSpanTimeout?: number; maxSpanBufferSize: number; spanFlushIntervalMs: number; spanFlushMaxBytes: number; maxSpansPerTrace: number; maxAttributesPerSpan: number; maxEventsPerSpan: number; maxAttributesPerSpanEvent: number; beforeEvaluate: (error: Error) => Error | false | null | Promise; beforeSubmit: (report: Report) => Report | false | null | Promise; }; type StackFrame = { file: string; lineNumber: number; columnNumber?: number; method?: string; class?: string; codeSnippet?: { [line: number]: string; }; isApplicationFrame?: boolean; arguments?: unknown[]; }; type SpanEvent = { type: string; startTimeUnixNano: number; endTimeUnixNano: number | null; attributes: Attributes; }; type OverriddenGrouping = 'exception_class' | 'exception_message' | 'exception_message_and_class' | 'full_stacktrace_and_exception_class_and_code'; type Report = { exceptionClass?: string | null; message?: string | null; code?: string; seenAtUnixNano: number; isLog?: boolean; level?: MessageLevel; sourcemapVersionId?: string; trackingUuid?: string; handled?: boolean; openFrameIndex?: number; applicationPath?: string; overriddenGrouping?: OverriddenGrouping | null; stacktrace: StackFrame[]; events: SpanEvent[]; attributes: Attributes; }; type Glow = { time: number; microtime: number; name: string; messageLevel: MessageLevel; metaData: Record | Record[]; }; /** The values the backend accepts for `flare.entry_point.type`. Anything else is dropped. */ type EntryPointType = 'web' | 'queue' | 'cli'; type EntryPointHandler = { identifier?: string; name?: string; type?: string; }; type SdkInfo = { name: string; version: string; }; /** * The framework identity an SDK reports. `name` is wire format, not a display string: first-party * SDKs use a `FrameworkName`. A host app may call `setFramework` with its own value (e.g. `express`), * which the backend treats as unknown rather than rejecting, so the type stays open. */ type Framework = { name: FrameworkName | (string & {}); version?: string; }; type AnyValue = { stringValue: string; } | { boolValue: boolean; } | { intValue: number; } | { doubleValue: number; } | { arrayValue: { values: AnyValue[]; }; } | { kvlistValue: { values: KeyValue[]; }; }; type KeyValue = { key: string; value: AnyValue; }; type OtelResource = { attributes: KeyValue[]; droppedAttributesCount: number; }; type OtelScope = { name: string; version: string; attributes: KeyValue[]; droppedAttributesCount: number; }; type OtelLogRecord = { timeUnixNano: string; observedTimeUnixNano: string; severityNumber: number; severityText: string; body: AnyValue; attributes: KeyValue[]; flags: number; droppedAttributesCount: number; }; type LogsEnvelope = { resourceLogs: Array<{ resource: OtelResource; scopeLogs: Array<{ scope: OtelScope; logRecords: OtelLogRecord[]; }>; }>; }; type BufferedLog = { timeUnixNano: string; severityNumber: number; severityText: string; message: string; recordAttributes: KeyValue[]; resourceAttributes: Attributes; }; /** OTel status codes. Wire format: these numbers ship in the span envelope, so the values never change. */ declare const SpanStatusCode: { readonly Unset: 0; readonly Ok: 1; readonly Error: 2; }; type SpanStatusCode = (typeof SpanStatusCode)[keyof typeof SpanStatusCode]; type SpanStatus = { code: SpanStatusCode; message?: string; }; type SpanOptions = { parent?: Span | { traceId: string; spanId: string; }; attributes?: Attributes; startTimeUnixNano?: number; spanType?: SpanTypeName; /** * Start this span as a new trace root, ignoring any ambient active span, so a * root opened inside `withSpan(...)` does not become a mid-trace child. */ forceRoot?: boolean; /** Use this exact span id instead of generating one (manual span stitching). */ spanId?: string; /** This span's slot against `maxSpansPerTrace` was already taken by `Tracer.claimSpanSlot`. */ claimed?: boolean; }; interface Span { readonly traceId: string; readonly spanId: string; readonly parentSpanId: string | null; name: string; readonly isRecording: boolean; readonly endTimeUnixNano: number; setAttribute(key: string, value: AttributeValue): this; setStatus(status: SpanStatus): this; addEvent(name: string, attributes?: Attributes): this; end(endTimeUnixNano?: number): void; } type SamplingContext = { name: string; parentSampled?: boolean; attributes: Attributes; spanType?: SpanTypeName; }; type TracesSampler = (ctx: SamplingContext) => number | boolean; type BufferedSpanEvent = { name: string; timeUnixNano: number; attributes: KeyValue[]; droppedAttributesCount: number; }; type BufferedSpan = { traceId: string; spanId: string; parentSpanId: string | null; name: string; startTimeUnixNano: number; endTimeUnixNano: number; status: SpanStatus; recordAttributes: KeyValue[]; droppedAttributesCount: number; droppedEventsCount: number; events: BufferedSpanEvent[]; }; type OtelSpan = { traceId: string; spanId: string; parentSpanId: string | null; name: string; startTimeUnixNano: number; endTimeUnixNano: number; status: SpanStatus; attributes: KeyValue[]; events: BufferedSpanEvent[]; droppedAttributesCount: number; droppedEventsCount: number; links: never[]; droppedLinksCount: number; }; type TracesEnvelope = { resourceSpans: Array<{ resource: OtelResource; scopeSpans: Array<{ scope: OtelScope; spans: OtelSpan[]; }>; }>; }; //#endregion //#region src/util/assert.d.ts declare function assert(value: unknown, message: string, debug: boolean): boolean; //#endregion //#region src/util/assertKey.d.ts declare function assertKey(key: unknown, debug: boolean): boolean; //#endregion //#region src/util/componentMatcher.d.ts /** What a framework integration's `profileComponents` option accepts. */ type ProfileComponentsOption = boolean | (string | RegExp)[]; /** * Built once so a mount costs one name resolution and one match. Strings match exactly, regexes by * `test()`. */ declare function createComponentMatcher(option: ProfileComponentsOption): (name: string) => boolean; //#endregion //#region src/util/convertToError.d.ts declare function convertToError(error: unknown): Error; //#endregion //#region src/util/createIdentityTagger.d.ts /** Minimal surface the tagger needs; the browser Flare and any subclass satisfy it structurally. */ interface SdkTaggable { setSdkInfo(info: SdkInfo): unknown; setFramework(framework: Framework): unknown; } /** * A per-package SDK/framework identity tagger. Holds its own WeakSet guards, so each Flare instance * (singleton or injected renderer) gets each of the two tags at most once. * * `frameworkName` is `FrameworkName` rather than `string` because those are the exact values the backend * recognises, so a first-party package cannot invent one. A host app that needs its own name calls * `setFramework` directly. */ declare function createIdentityTagger(config: { sdkName: string; sdkVersion: string; frameworkName: FrameworkName; }): { registerSdkIdentity(flare: SdkTaggable): void; tagFramework(flare: SdkTaggable, frameworkVersion?: string): void; }; //#endregion //#region src/util/evictLruIfNew.d.ts declare function evictLruIfNew(map: Map, key: string, cap: number): void; //#endregion //#region src/util/extractCode.d.ts declare function extractCode(error: Error): string | undefined; //#endregion //#region src/util/flatJsonStringify.d.ts /** * JSON.stringify hardened for untrusted glow / addContext data: cycles become "[Circular]", a BigInt * its decimal string, and a throwing getter "[Getter threw]", each of which would otherwise throw and * drop the whole report. */ declare function flatJsonStringify(json: object): string; //#endregion //#region src/util/glowsToEvents.d.ts declare function glowsToEvents(glows: Glow[]): SpanEvent[]; //#endregion //#region src/util/timelineEvents.d.ts declare function timelineEvents(glows: Glow[], breadcrumbs: SpanEvent[]): SpanEvent[]; //#endregion //#region src/util/now.d.ts declare function now(): number; //#endregion //#region src/util/redactUrl.d.ts /** * Matched against query-string keys, cookie names, and (in framework SDKs) prop/route-param keys. Values for * matching keys are replaced with [redacted] before sending so credentials/PII don't leak in error reports. */ declare const DEFAULT_URL_DENYLIST: RegExp; declare function resolveDenylist(custom?: RegExp, replaceDefault?: boolean, defaultDenylist?: RegExp): RegExp; /** * Strips userinfo (`user:pass@`) from an absolute URL and replaces query-string values whose key * matches `denylist` with `[redacted]`. Path segments are left untouched. */ declare function redactUrlQuery(fullPath: string, denylist?: RegExp): string; /** * Value-side mirror of `redactUrlQuery`: a new object where any value whose key matches `denylist` * becomes `[redacted]`. Null-prototype result so a `__proto__` key is stored, not swallowed. */ declare function redactObjectValues(obj: Record, denylist?: RegExp): Record; /** * decodeURIComponent throws on malformed escape sequences (`%E0`, lone `%`, etc). Falls back to the * raw key in that case rather than aborting the whole redaction pass. */ declare function safeDecode(value: string): string; //#endregion //#region src/util/rejection.d.ts type RejectionReporter = { /** Error / stack-bearing reasons: preserve the stack. */reportSilently: (error: Error) => void; /** Stackless reasons. May return a promise; `routeRejection` swallows any rejection from it. */ reportUnhandledRejection: (message: string) => unknown; }; /** Best-effort human-readable description of an arbitrary rejection reason. */ declare function describeRejectionReason(reason: unknown): string; /** * Routes by whether `reason` carries a stack: stack-bearing reasons go to `reportSilently`, stackless * ones to `reportUnhandledRejection`. The `.catch` stops a transport failure from surfacing as a second * unhandled rejection. `reportSilently` is assumed async and left unwrapped, so a synchronous throw there * still propagates. */ declare function routeRejection(reporter: RejectionReporter, reason: unknown): void; //#endregion //#region src/util/safeClone.d.ts type SafeCloneOptions = { mode: 'json'; } | { mode: 'display'; maxDepth: number; arrayCap: number; objectKeyCap: number; stringCap: number; denylist: RegExp; }; /** * One JSON-safe recursive clone shared by flatJsonStringify (json mode) and vue serializeProps * (display mode). Cycles become "[Circular]", a BigInt its decimal string, and a throwing getter * "[Getter threw]" in both modes. json mode passes functions / symbols / non-plain objects through * (so JSON.stringify still drops functions and calls Date.toJSON); display mode replaces them with * placeholders and applies the depth / array / key / string caps and the key denylist. */ declare function safeClone(value: unknown, options: SafeCloneOptions): unknown; //#endregion //#region src/util/setDefined.d.ts /** Assign the value only when it is neither undefined nor null. */ declare function setDefined(target: Attributes, key: string, value: AttributeValue | undefined): void; //#endregion //#region src/util/statelessRegExp.d.ts /** * A `/g` or `/y` regex carries `lastIndex` between `test()` calls, so every other call misses. Returns * a copy rather than mutating what the caller handed us. */ declare function withoutStatefulFlags(pattern: RegExp): RegExp; declare function withoutStatefulFlags(pattern: RegExp | undefined): RegExp | undefined; //#endregion //#region src/util/toCustomContext.d.ts /** Wraps a framework payload as the `context.custom` attribute a report expects. */ declare function toCustomContext(framework: string, payload: AttributeValue): Attributes; //#endregion //#region src/util/urlAttributes.d.ts /** Well past any routable URL, but short enough that an inline `data:` payload cannot ride along. */ declare const MAX_URL_LENGTH = 2048; /** * Builds the OTel `url.*` attributes for one absolute URL. * * Redacts the URL first and splits it after, so `url.full` and `url.query` always show the same * redacted values. * * Leaves out `url.query` when there is no query string. Returns only `url.full` when the URL cannot * be parsed, for example a relative one. */ declare function urlAttributes(url: string, denylist?: RegExp): Attributes; //#endregion export { StackFrame as $, AttributeValue as A, LogsEnvelope as B, createIdentityTagger as C, assertKey as D, createComponentMatcher as E, EntryPointHandler as F, Report as G, OtelLogRecord as H, EntryPointType as I, Span as J, SamplingContext as K, Framework as L, BufferedLog as M, BufferedSpan as N, assert as O, Config as P, SpanStatusCode as Q, Glow as R, SdkTaggable as S, ProfileComponentsOption as T, OtelSpan as U, MessageLevel as V, OverriddenGrouping as W, SpanOptions as X, SpanEvent as Y, SpanStatus as Z, timelineEvents as _, setDefined as a, SpanTypeName as at, extractCode as b, RejectionReporter as c, DEFAULT_URL_DENYLIST as d, TracesEnvelope as et, redactObjectValues as f, now as g, safeDecode as h, withoutStatefulFlags as i, BrowserSpanType as it, Attributes as j, AnyValue as k, describeRejectionReason as l, resolveDenylist as m, urlAttributes as n, User as nt, SafeCloneOptions as o, FrameworkName as ot, redactUrlQuery as p, SdkInfo as q, toCustomContext as r, BrowserSpanEventType as rt, safeClone as s, MAX_URL_LENGTH as t, TracesSampler as tt, routeRejection as u, glowsToEvents as v, convertToError as w, evictLruIfNew as x, flatJsonStringify as y, KeyValue as z };