@flareapp/js 2.6.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_catchWindowErrors = require('./catchWindowErrors-_IlVo06V.cjs');
2
+ const require_componentProfiler = require('./componentProfiler-C6qY96Bt.cjs');
3
3
  const require_browser = require('./browser.cjs');
4
4
  let _flareapp_core = require("@flareapp/core");
5
5
 
@@ -7,7 +7,7 @@ let _flareapp_core = require("@flareapp/core");
7
7
  const flare = new require_browser.Flare();
8
8
  if (typeof window !== "undefined" && window) {
9
9
  window.flare = flare;
10
- require_catchWindowErrors.catchWindowErrors();
10
+ require_componentProfiler.catchWindowErrors();
11
11
  }
12
12
 
13
13
  //#endregion
@@ -18,6 +18,12 @@ Object.defineProperty(exports, 'DEFAULT_URL_DENYLIST', {
18
18
  }
19
19
  });
20
20
  exports.Flare = require_browser.Flare;
21
+ Object.defineProperty(exports, 'FrameworkName', {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _flareapp_core.FrameworkName;
25
+ }
26
+ });
21
27
  Object.defineProperty(exports, 'GlobalScopeProvider', {
22
28
  enumerable: true,
23
29
  get: function () {
@@ -48,6 +54,7 @@ Object.defineProperty(exports, 'convertToError', {
48
54
  return _flareapp_core.convertToError;
49
55
  }
50
56
  });
57
+ exports.createFlareResolver = require_componentProfiler.createFlareResolver;
51
58
  exports.flare = flare;
52
59
  Object.defineProperty(exports, 'redactFullPath', {
53
60
  enumerable: true,
@@ -55,6 +62,12 @@ Object.defineProperty(exports, 'redactFullPath', {
55
62
  return _flareapp_core.redactUrlQuery;
56
63
  }
57
64
  });
65
+ Object.defineProperty(exports, 'redactObjectValues', {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _flareapp_core.redactObjectValues;
69
+ }
70
+ });
58
71
  Object.defineProperty(exports, 'redactUrlQuery', {
59
72
  enumerable: true,
60
73
  get: function () {
@@ -66,4 +79,10 @@ Object.defineProperty(exports, 'resolveDenylist', {
66
79
  get: function () {
67
80
  return _flareapp_core.resolveDenylist;
68
81
  }
82
+ });
83
+ Object.defineProperty(exports, 'toCustomContext', {
84
+ enumerable: true,
85
+ get: function () {
86
+ return _flareapp_core.toCustomContext;
87
+ }
69
88
  });
package/dist/index.d.cts CHANGED
@@ -1,7 +1,8 @@
1
+ import { T as createFlareResolver } from "./spanTypes-iA1RdfLw.cjs";
1
2
  import { Flare } from "./browser.cjs";
2
- import { AttributeValue, Attributes, Config, ContextCollector, DEFAULT_URL_DENYLIST, EntryPointHandler, FileReader, FlushFn, FlushScheduler, Framework, GlobalScopeProvider, Glow, Logger, MessageLevel, NullFileReader, OverriddenGrouping, Report, Scope, ScopeProvider, SdkInfo, SpanEvent, StackFrame, User, convertToError, redactUrlQuery, redactUrlQuery as redactFullPath, resolveDenylist } from "@flareapp/core";
3
+ import { AttributeValue, Attributes, Config, ContextCollector, DEFAULT_URL_DENYLIST, EntryPointHandler, FileReader, FlushFn, FlushScheduler, Framework, FrameworkName, GlobalScopeProvider, Glow, Logger, MessageLevel, NullFileReader, OverriddenGrouping, Report, Scope, ScopeProvider, SdkInfo, SpanEvent, StackFrame, User, convertToError, redactObjectValues, redactUrlQuery, redactUrlQuery as redactFullPath, resolveDenylist, toCustomContext } from "@flareapp/core";
3
4
 
4
5
  //#region src/index.d.ts
5
6
  declare const flare: Flare;
6
7
  //#endregion
7
- export { type AttributeValue, type Attributes, type Config, type ContextCollector, DEFAULT_URL_DENYLIST, type EntryPointHandler, type FileReader, Flare, type FlushFn, type FlushScheduler, type Framework, GlobalScopeProvider, type Glow, Logger, type MessageLevel, NullFileReader, type OverriddenGrouping, type Report, Scope, type ScopeProvider, type SdkInfo, type SpanEvent, type StackFrame, type User, convertToError, flare, redactFullPath, redactUrlQuery, resolveDenylist };
8
+ export { type AttributeValue, type Attributes, type Config, type ContextCollector, DEFAULT_URL_DENYLIST, type EntryPointHandler, type FileReader, Flare, type FlushFn, type FlushScheduler, type Framework, FrameworkName, GlobalScopeProvider, type Glow, Logger, type MessageLevel, NullFileReader, type OverriddenGrouping, type Report, Scope, type ScopeProvider, type SdkInfo, type SpanEvent, type StackFrame, type User, convertToError, createFlareResolver, flare, redactFullPath, redactObjectValues, redactUrlQuery, resolveDenylist, toCustomContext };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
+ import { T as createFlareResolver } from "./spanTypes-CjF1_Uqi.mjs";
1
2
  import { Flare } from "./browser.mjs";
2
- import { AttributeValue, Attributes, Config, ContextCollector, DEFAULT_URL_DENYLIST, EntryPointHandler, FileReader, FlushFn, FlushScheduler, Framework, GlobalScopeProvider, Glow, Logger, MessageLevel, NullFileReader, OverriddenGrouping, Report, Scope, ScopeProvider, SdkInfo, SpanEvent, StackFrame, User, convertToError, redactUrlQuery, redactUrlQuery as redactFullPath, resolveDenylist } from "@flareapp/core";
3
+ import { AttributeValue, Attributes, Config, ContextCollector, DEFAULT_URL_DENYLIST, EntryPointHandler, FileReader, FlushFn, FlushScheduler, Framework, FrameworkName, GlobalScopeProvider, Glow, Logger, MessageLevel, NullFileReader, OverriddenGrouping, Report, Scope, ScopeProvider, SdkInfo, SpanEvent, StackFrame, User, convertToError, redactObjectValues, redactUrlQuery, redactUrlQuery as redactFullPath, resolveDenylist, toCustomContext } from "@flareapp/core";
3
4
 
4
5
  //#region src/index.d.ts
5
6
  declare const flare: Flare;
6
7
  //#endregion
7
- export { type AttributeValue, type Attributes, type Config, type ContextCollector, DEFAULT_URL_DENYLIST, type EntryPointHandler, type FileReader, Flare, type FlushFn, type FlushScheduler, type Framework, GlobalScopeProvider, type Glow, Logger, type MessageLevel, NullFileReader, type OverriddenGrouping, type Report, Scope, type ScopeProvider, type SdkInfo, type SpanEvent, type StackFrame, type User, convertToError, flare, redactFullPath, redactUrlQuery, resolveDenylist };
8
+ export { type AttributeValue, type Attributes, type Config, type ContextCollector, DEFAULT_URL_DENYLIST, type EntryPointHandler, type FileReader, Flare, type FlushFn, type FlushScheduler, type Framework, FrameworkName, GlobalScopeProvider, type Glow, Logger, type MessageLevel, NullFileReader, type OverriddenGrouping, type Report, Scope, type ScopeProvider, type SdkInfo, type SpanEvent, type StackFrame, type User, convertToError, createFlareResolver, flare, redactFullPath, redactObjectValues, redactUrlQuery, resolveDenylist, toCustomContext };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { t as catchWindowErrors } from "./catchWindowErrors-DaCqd2yC.mjs";
1
+ import { o as catchWindowErrors, s as createFlareResolver } from "./componentProfiler-CoH2m13n.mjs";
2
2
  import { Flare } from "./browser.mjs";
3
- import { DEFAULT_URL_DENYLIST, GlobalScopeProvider, Logger, NullFileReader, Scope, convertToError, redactUrlQuery, redactUrlQuery as redactFullPath, resolveDenylist } from "@flareapp/core";
3
+ import { DEFAULT_URL_DENYLIST, FrameworkName, GlobalScopeProvider, Logger, NullFileReader, Scope, convertToError, redactObjectValues, redactUrlQuery, redactUrlQuery as redactFullPath, resolveDenylist, toCustomContext } from "@flareapp/core";
4
4
 
5
5
  //#region src/index.ts
6
6
  const flare = new Flare();
@@ -10,4 +10,4 @@ if (typeof window !== "undefined" && window) {
10
10
  }
11
11
 
12
12
  //#endregion
13
- export { DEFAULT_URL_DENYLIST, Flare, GlobalScopeProvider, Logger, NullFileReader, Scope, convertToError, flare, redactFullPath, redactUrlQuery, resolveDenylist };
13
+ export { DEFAULT_URL_DENYLIST, Flare, FrameworkName, GlobalScopeProvider, Logger, NullFileReader, Scope, convertToError, createFlareResolver, flare, redactFullPath, redactObjectValues, redactUrlQuery, resolveDenylist, toCustomContext };
@@ -0,0 +1,161 @@
1
+ import { Flare as Flare$1 } from "./browser.mjs";
2
+ import { Attributes, BrowserSpanType, Config, ContextCollector, FileReader, FlushFn, FlushScheduler, defaultNowNano } from "@flareapp/core";
3
+
4
+ //#region src/createFlareResolver.d.ts
5
+ /**
6
+ * Builds a per-package Flare resolver: `registerDefaultFlare` (wired once by the web entry) and
7
+ * `resolveFlare` (called at wiring time). Each call holds its own default-provider state. The check
8
+ * that warns about the Electron `__flare` bridge uses `packageName` in its message;
9
+ * `injectInstruction` replaces the closing hint for packages whose advice differs (for example
10
+ * svelte, which points at the preprocessor's importSource).
11
+ */
12
+ declare function createFlareResolver(config: {
13
+ packageName: string;
14
+ injectInstruction?: string;
15
+ }): {
16
+ registerDefaultFlare(provider: () => Flare$1): void;
17
+ resolveFlare(explicit?: Flare$1): Flare$1;
18
+ };
19
+ //#endregion
20
+ //#region src/browser/catchWindowErrors.d.ts
21
+ /**
22
+ * Wire up global `error` and `unhandledrejection` listeners, routing reports through `window.flare`
23
+ * (assigned by Flare.light()/configure()). Events are dropped, not queued, when the global is absent.
24
+ */
25
+ declare function catchWindowErrors(): void;
26
+ //#endregion
27
+ //#region src/browser/context/collectBrowser.d.ts
28
+ declare const collectBrowser: ContextCollector;
29
+ //#endregion
30
+ //#region src/browser/FetchFileReader.d.ts
31
+ /**
32
+ * Fetches source files so the stack-trace builder can render a snippet around the offending line.
33
+ * Only http(s) is fetched: other schemes (chrome-extension://, file://, blob:, data:) would cross a
34
+ * privilege boundary or hit a CORS/CSP wall for nothing. Returns null on any failure, never throws.
35
+ */
36
+ declare class FetchFileReader implements FileReader {
37
+ read(url: string): Promise<string | null>;
38
+ }
39
+ //#endregion
40
+ //#region src/browser/BrowserFlushScheduler.d.ts
41
+ declare class BrowserFlushScheduler implements FlushScheduler {
42
+ register(flush: FlushFn): void;
43
+ }
44
+ //#endregion
45
+ //#region src/tracing/navigation.d.ts
46
+ type RouteName = {
47
+ name: string;
48
+ source: 'route' | 'url';
49
+ /**
50
+ * Where the navigation is going. Re-stamps the root's `url.full` alongside the name, so a redirected
51
+ * or superseded navigation reports where it ended rather than where it opened. Omit to keep the url
52
+ * the root started with.
53
+ */
54
+ url?: string;
55
+ };
56
+ type NavigationSource = {
57
+ startNavigation(opts?: {
58
+ path?: string;
59
+ url?: string;
60
+ hold?: boolean;
61
+ }): void;
62
+ setActiveRouteName(route: RouteName): void;
63
+ settleNavigation(route: RouteName): void;
64
+ unregister(): void;
65
+ };
66
+ /** The path the address bar is on, or '' outside a browser. */
67
+ declare function currentPath(): string;
68
+ /**
69
+ * Prefers the router's parameterized template over the raw path, so names aggregate per route rather
70
+ * than per url. `derive` runs inside a try: a router that throws on an unresolved match chain falls back
71
+ * to the url name instead of taking the host down.
72
+ */
73
+ declare function routeName(derive: () => string | undefined, fallbackPath: string, url?: string): RouteName;
74
+ /**
75
+ * `build` is the router's own href builder (vue-router's `resolve`, React Router's `createHref`), which
76
+ * is what puts the app's base path and hash prefix back on. Without it an app served from `/app/` reports
77
+ * `/product/p01` for the real `/app/product/p01`. A router that throws still gets a url from `fallback`.
78
+ */
79
+ declare function resolveHref(build: () => string | null | undefined, fallback: string): string | undefined;
80
+ //#endregion
81
+ //#region src/tracing/browserTracing.d.ts
82
+ /**
83
+ * While registered, the built-in History detection opens no roots and the caller drives navigation
84
+ * through the returned handle. Last-wins, and a stale handle no-ops, so an HMR-replaced bootstrap
85
+ * cannot tear down a newer registration.
86
+ */
87
+ declare function registerNavigationSource(): NavigationSource;
88
+ //#endregion
89
+ //#region src/tracing/instrumentationGuard.d.ts
90
+ /** For a callback the host invokes: a router guard, a store subscriber, ... */
91
+ declare function insulate<A extends unknown[]>(fn: (...a: A) => void): (...a: A) => void;
92
+ /** Invoke a teardown fn now (if present), swallowing any throw. For cleanup chains. */
93
+ declare function safeInvoke(fn: (() => void) | null | undefined): void;
94
+ /** Hands one teardown to `instrumentOnce`. Accepts nothing, for a listener an install chose to skip. */
95
+ type TrackTeardown = (teardown: (() => void) | null | undefined) => void;
96
+ /**
97
+ * Instrument `target` at most once at a time, tearing down any prior instrumentation of the same object
98
+ * first. Vite HMR re-runs boot code against a router that survives the reload, so without this every
99
+ * cycle appends another listener set that is never removed. Keyed on the object, so a genuinely new
100
+ * router is unaffected.
101
+ *
102
+ * `install` hands each teardown to `track` as it produces it. A router's own `subscribe` / `on` / guard
103
+ * registration can throw, and `install` runs during the host's bootstrap, so a throw part-way through
104
+ * unwinds what already succeeded (newest first) and stops here rather than reaching the host.
105
+ *
106
+ * @returns the cleanup, or a no-op when the install failed and already unwound itself.
107
+ */
108
+ declare function instrumentOnce<T extends object>(target: T, install: (track: TrackTeardown) => void): () => void;
109
+ //#endregion
110
+ //#region src/tracing/absoluteHref.d.ts
111
+ /**
112
+ * Resolve a router-reported href against the page we are on. Returns the `URL`, so a caller that
113
+ * wants the pathname as well as the href does not parse it a second time.
114
+ *
115
+ * Undefined outside a browser or for an unparseable href, so the caller can leave its attribute alone.
116
+ */
117
+ declare function absoluteUrl(href: string | null | undefined): URL | undefined;
118
+ /**
119
+ * The href form of `absoluteUrl`. Pass one built by the router's own `createHref`/`resolve` (see
120
+ * `resolveHref`), not a bare path: routers strip the app's base path, so `origin + path` yields an
121
+ * address the server does not have.
122
+ */
123
+ declare function absoluteHref(href: string | null | undefined): string | undefined;
124
+ //#endregion
125
+ //#region src/tracing/componentProfiler.d.ts
126
+ type ComponentTraceContext = {
127
+ traceId: string;
128
+ parentSpanId: string;
129
+ };
130
+ /** Unix nanos on the same clock the tracer uses for span timestamps. */
131
+ declare const nowNano: typeof defaultNowNano;
132
+ /**
133
+ * Reserved up front so descendants can point at a span before it is recorded. Null when the trace is at
134
+ * its span cap: descendants record before this span does, so an id the cap will refuse orphans them.
135
+ */
136
+ declare function reserveSpanId(traceId?: string): string | null;
137
+ /** The root a top-level component nests under. Null when tracing is off or no root is recording. */
138
+ declare function activeComponentRoot(): ComponentTraceContext | null;
139
+ /**
140
+ * An ancestor's context is only usable while it still belongs to the live trace. A profiled component
141
+ * that survives a navigation (a layout around a swapped page body) froze its context under the pageload
142
+ * trace, and `recordComponentSpan` would drop anything pointing at that closed root.
143
+ */
144
+ declare function resolveComponentParent(inherited: ComponentTraceContext | null | undefined, live: ComponentTraceContext | null): ComponentTraceContext | null;
145
+ /** What a profiler hands back for one component mount. */
146
+ type ComponentSpanRecord = {
147
+ name: string;
148
+ spanId: string;
149
+ parent: ComponentTraceContext;
150
+ startTimeUnixNano: number;
151
+ endTimeUnixNano: number;
152
+ attributes?: Attributes;
153
+ };
154
+ /**
155
+ * Records only while the reserved root is still the live recording root, and drops the span otherwise.
156
+ * Dropping avoids starting a fresh TraceState for a dead trace, which would re-run the sampler, and
157
+ * avoids adding a child to a root that already shipped.
158
+ */
159
+ declare function recordComponentSpan(record: ComponentSpanRecord): void;
160
+ //#endregion
161
+ export { collectBrowser as C, FetchFileReader as S, createFlareResolver as T, RouteName as _, nowNano as a, routeName as b, resolveComponentParent as c, TrackTeardown as d, instrumentOnce as f, NavigationSource as g, registerNavigationSource as h, activeComponentRoot as i, absoluteHref as l, safeInvoke as m, ComponentSpanRecord as n, recordComponentSpan as o, insulate as p, ComponentTraceContext as r, reserveSpanId as s, BrowserSpanType as t, absoluteUrl as u, currentPath as v, catchWindowErrors as w, BrowserFlushScheduler as x, resolveHref as y };
@@ -0,0 +1,161 @@
1
+ import { Flare as Flare$1 } from "./browser.cjs";
2
+ import { Attributes, BrowserSpanType, Config, ContextCollector, FileReader, FlushFn, FlushScheduler, defaultNowNano } from "@flareapp/core";
3
+
4
+ //#region src/createFlareResolver.d.ts
5
+ /**
6
+ * Builds a per-package Flare resolver: `registerDefaultFlare` (wired once by the web entry) and
7
+ * `resolveFlare` (called at wiring time). Each call holds its own default-provider state. The check
8
+ * that warns about the Electron `__flare` bridge uses `packageName` in its message;
9
+ * `injectInstruction` replaces the closing hint for packages whose advice differs (for example
10
+ * svelte, which points at the preprocessor's importSource).
11
+ */
12
+ declare function createFlareResolver(config: {
13
+ packageName: string;
14
+ injectInstruction?: string;
15
+ }): {
16
+ registerDefaultFlare(provider: () => Flare$1): void;
17
+ resolveFlare(explicit?: Flare$1): Flare$1;
18
+ };
19
+ //#endregion
20
+ //#region src/browser/catchWindowErrors.d.ts
21
+ /**
22
+ * Wire up global `error` and `unhandledrejection` listeners, routing reports through `window.flare`
23
+ * (assigned by Flare.light()/configure()). Events are dropped, not queued, when the global is absent.
24
+ */
25
+ declare function catchWindowErrors(): void;
26
+ //#endregion
27
+ //#region src/browser/context/collectBrowser.d.ts
28
+ declare const collectBrowser: ContextCollector;
29
+ //#endregion
30
+ //#region src/browser/FetchFileReader.d.ts
31
+ /**
32
+ * Fetches source files so the stack-trace builder can render a snippet around the offending line.
33
+ * Only http(s) is fetched: other schemes (chrome-extension://, file://, blob:, data:) would cross a
34
+ * privilege boundary or hit a CORS/CSP wall for nothing. Returns null on any failure, never throws.
35
+ */
36
+ declare class FetchFileReader implements FileReader {
37
+ read(url: string): Promise<string | null>;
38
+ }
39
+ //#endregion
40
+ //#region src/browser/BrowserFlushScheduler.d.ts
41
+ declare class BrowserFlushScheduler implements FlushScheduler {
42
+ register(flush: FlushFn): void;
43
+ }
44
+ //#endregion
45
+ //#region src/tracing/navigation.d.ts
46
+ type RouteName = {
47
+ name: string;
48
+ source: 'route' | 'url';
49
+ /**
50
+ * Where the navigation is going. Re-stamps the root's `url.full` alongside the name, so a redirected
51
+ * or superseded navigation reports where it ended rather than where it opened. Omit to keep the url
52
+ * the root started with.
53
+ */
54
+ url?: string;
55
+ };
56
+ type NavigationSource = {
57
+ startNavigation(opts?: {
58
+ path?: string;
59
+ url?: string;
60
+ hold?: boolean;
61
+ }): void;
62
+ setActiveRouteName(route: RouteName): void;
63
+ settleNavigation(route: RouteName): void;
64
+ unregister(): void;
65
+ };
66
+ /** The path the address bar is on, or '' outside a browser. */
67
+ declare function currentPath(): string;
68
+ /**
69
+ * Prefers the router's parameterized template over the raw path, so names aggregate per route rather
70
+ * than per url. `derive` runs inside a try: a router that throws on an unresolved match chain falls back
71
+ * to the url name instead of taking the host down.
72
+ */
73
+ declare function routeName(derive: () => string | undefined, fallbackPath: string, url?: string): RouteName;
74
+ /**
75
+ * `build` is the router's own href builder (vue-router's `resolve`, React Router's `createHref`), which
76
+ * is what puts the app's base path and hash prefix back on. Without it an app served from `/app/` reports
77
+ * `/product/p01` for the real `/app/product/p01`. A router that throws still gets a url from `fallback`.
78
+ */
79
+ declare function resolveHref(build: () => string | null | undefined, fallback: string): string | undefined;
80
+ //#endregion
81
+ //#region src/tracing/browserTracing.d.ts
82
+ /**
83
+ * While registered, the built-in History detection opens no roots and the caller drives navigation
84
+ * through the returned handle. Last-wins, and a stale handle no-ops, so an HMR-replaced bootstrap
85
+ * cannot tear down a newer registration.
86
+ */
87
+ declare function registerNavigationSource(): NavigationSource;
88
+ //#endregion
89
+ //#region src/tracing/instrumentationGuard.d.ts
90
+ /** For a callback the host invokes: a router guard, a store subscriber, ... */
91
+ declare function insulate<A extends unknown[]>(fn: (...a: A) => void): (...a: A) => void;
92
+ /** Invoke a teardown fn now (if present), swallowing any throw. For cleanup chains. */
93
+ declare function safeInvoke(fn: (() => void) | null | undefined): void;
94
+ /** Hands one teardown to `instrumentOnce`. Accepts nothing, for a listener an install chose to skip. */
95
+ type TrackTeardown = (teardown: (() => void) | null | undefined) => void;
96
+ /**
97
+ * Instrument `target` at most once at a time, tearing down any prior instrumentation of the same object
98
+ * first. Vite HMR re-runs boot code against a router that survives the reload, so without this every
99
+ * cycle appends another listener set that is never removed. Keyed on the object, so a genuinely new
100
+ * router is unaffected.
101
+ *
102
+ * `install` hands each teardown to `track` as it produces it. A router's own `subscribe` / `on` / guard
103
+ * registration can throw, and `install` runs during the host's bootstrap, so a throw part-way through
104
+ * unwinds what already succeeded (newest first) and stops here rather than reaching the host.
105
+ *
106
+ * @returns the cleanup, or a no-op when the install failed and already unwound itself.
107
+ */
108
+ declare function instrumentOnce<T extends object>(target: T, install: (track: TrackTeardown) => void): () => void;
109
+ //#endregion
110
+ //#region src/tracing/absoluteHref.d.ts
111
+ /**
112
+ * Resolve a router-reported href against the page we are on. Returns the `URL`, so a caller that
113
+ * wants the pathname as well as the href does not parse it a second time.
114
+ *
115
+ * Undefined outside a browser or for an unparseable href, so the caller can leave its attribute alone.
116
+ */
117
+ declare function absoluteUrl(href: string | null | undefined): URL | undefined;
118
+ /**
119
+ * The href form of `absoluteUrl`. Pass one built by the router's own `createHref`/`resolve` (see
120
+ * `resolveHref`), not a bare path: routers strip the app's base path, so `origin + path` yields an
121
+ * address the server does not have.
122
+ */
123
+ declare function absoluteHref(href: string | null | undefined): string | undefined;
124
+ //#endregion
125
+ //#region src/tracing/componentProfiler.d.ts
126
+ type ComponentTraceContext = {
127
+ traceId: string;
128
+ parentSpanId: string;
129
+ };
130
+ /** Unix nanos on the same clock the tracer uses for span timestamps. */
131
+ declare const nowNano: typeof defaultNowNano;
132
+ /**
133
+ * Reserved up front so descendants can point at a span before it is recorded. Null when the trace is at
134
+ * its span cap: descendants record before this span does, so an id the cap will refuse orphans them.
135
+ */
136
+ declare function reserveSpanId(traceId?: string): string | null;
137
+ /** The root a top-level component nests under. Null when tracing is off or no root is recording. */
138
+ declare function activeComponentRoot(): ComponentTraceContext | null;
139
+ /**
140
+ * An ancestor's context is only usable while it still belongs to the live trace. A profiled component
141
+ * that survives a navigation (a layout around a swapped page body) froze its context under the pageload
142
+ * trace, and `recordComponentSpan` would drop anything pointing at that closed root.
143
+ */
144
+ declare function resolveComponentParent(inherited: ComponentTraceContext | null | undefined, live: ComponentTraceContext | null): ComponentTraceContext | null;
145
+ /** What a profiler hands back for one component mount. */
146
+ type ComponentSpanRecord = {
147
+ name: string;
148
+ spanId: string;
149
+ parent: ComponentTraceContext;
150
+ startTimeUnixNano: number;
151
+ endTimeUnixNano: number;
152
+ attributes?: Attributes;
153
+ };
154
+ /**
155
+ * Records only while the reserved root is still the live recording root, and drops the span otherwise.
156
+ * Dropping avoids starting a fresh TraceState for a dead trace, which would re-run the sampler, and
157
+ * avoids adding a child to a root that already shipped.
158
+ */
159
+ declare function recordComponentSpan(record: ComponentSpanRecord): void;
160
+ //#endregion
161
+ export { collectBrowser as C, FetchFileReader as S, createFlareResolver as T, RouteName as _, nowNano as a, routeName as b, resolveComponentParent as c, TrackTeardown as d, instrumentOnce as f, NavigationSource as g, registerNavigationSource as h, activeComponentRoot as i, absoluteHref as l, safeInvoke as m, ComponentSpanRecord as n, recordComponentSpan as o, insulate as p, ComponentTraceContext as r, reserveSpanId as s, BrowserSpanType as t, absoluteUrl as u, currentPath as v, catchWindowErrors as w, BrowserFlushScheduler as x, resolveHref as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flareapp/js",
3
- "version": "2.6.0",
3
+ "version": "2.8.0",
4
4
  "description": "JavaScript client for flareapp.io",
5
5
  "homepage": "https://flareapp.io",
6
6
  "bugs": {
@@ -59,9 +59,10 @@
59
59
  "release": "release-it"
60
60
  },
61
61
  "dependencies": {
62
- "@flareapp/core": "2.6.0"
62
+ "@flareapp/core": "2.8.0"
63
63
  },
64
64
  "devDependencies": {
65
+ "@flareapp/test-helpers": "*",
65
66
  "error-stack-parser": "^2.0.2",
66
67
  "tsdown": "^0.20.3",
67
68
  "typescript": "^5.7.0",
@@ -1,43 +0,0 @@
1
- import { ContextCollector, FileReader, FlushFn, FlushScheduler } from "@flareapp/core";
2
-
3
- //#region src/browser/catchWindowErrors.d.ts
4
- declare function catchWindowErrors(): void;
5
- //#endregion
6
- //#region src/browser/context/collectBrowser.d.ts
7
- declare const collectBrowser: ContextCollector;
8
- //#endregion
9
- //#region src/browser/FetchFileReader.d.ts
10
- /**
11
- * Browser `FileReader` implementation that fetches source files over HTTP(S).
12
- *
13
- * Wired into `@flareapp/js`'s singleton so the stack-trace builder can pull
14
- * the original source for each frame and render a code snippet around the
15
- * offending line. The source URL comes from the frame (usually the URL of
16
- * the JS bundle that produced the error, post-sourcemap resolution).
17
- *
18
- * Three safety gates:
19
- *
20
- * 1. **Scheme allowlist.** Only `http:` and `https:` URLs are fetched. Other
21
- * schemes (`chrome-extension://`, `file://`, `blob:`, `data:`) return
22
- * `null` immediately. This avoids surprise privilege boundaries (e.g.,
23
- * pages should not read extension-internal files) and dodges CORS/CSP
24
- * walls that would error noisily.
25
- * 2. **Status check.** Only `200 OK` responses are used. 3xx redirects are
26
- * handled transparently by `fetch`; 4xx/5xx fall back to `null` so the
27
- * snippet is simply omitted from the report.
28
- * 3. **Catch-all.** Network failures, CORS errors, and aborted requests
29
- * return `null`. We never let a source-fetch failure leak as an error
30
- * that the consumer page would see.
31
- *
32
- * The `read()` contract returns `null` on any failure path, never throws.
33
- */
34
- declare class FetchFileReader implements FileReader {
35
- read(url: string): Promise<string | null>;
36
- }
37
- //#endregion
38
- //#region src/browser/BrowserFlushScheduler.d.ts
39
- declare class BrowserFlushScheduler implements FlushScheduler {
40
- register(flush: FlushFn): void;
41
- }
42
- //#endregion
43
- export { catchWindowErrors as i, FetchFileReader as n, collectBrowser as r, BrowserFlushScheduler as t };
@@ -1,43 +0,0 @@
1
- import { ContextCollector, FileReader, FlushFn, FlushScheduler } from "@flareapp/core";
2
-
3
- //#region src/browser/catchWindowErrors.d.ts
4
- declare function catchWindowErrors(): void;
5
- //#endregion
6
- //#region src/browser/context/collectBrowser.d.ts
7
- declare const collectBrowser: ContextCollector;
8
- //#endregion
9
- //#region src/browser/FetchFileReader.d.ts
10
- /**
11
- * Browser `FileReader` implementation that fetches source files over HTTP(S).
12
- *
13
- * Wired into `@flareapp/js`'s singleton so the stack-trace builder can pull
14
- * the original source for each frame and render a code snippet around the
15
- * offending line. The source URL comes from the frame (usually the URL of
16
- * the JS bundle that produced the error, post-sourcemap resolution).
17
- *
18
- * Three safety gates:
19
- *
20
- * 1. **Scheme allowlist.** Only `http:` and `https:` URLs are fetched. Other
21
- * schemes (`chrome-extension://`, `file://`, `blob:`, `data:`) return
22
- * `null` immediately. This avoids surprise privilege boundaries (e.g.,
23
- * pages should not read extension-internal files) and dodges CORS/CSP
24
- * walls that would error noisily.
25
- * 2. **Status check.** Only `200 OK` responses are used. 3xx redirects are
26
- * handled transparently by `fetch`; 4xx/5xx fall back to `null` so the
27
- * snippet is simply omitted from the report.
28
- * 3. **Catch-all.** Network failures, CORS errors, and aborted requests
29
- * return `null`. We never let a source-fetch failure leak as an error
30
- * that the consumer page would see.
31
- *
32
- * The `read()` contract returns `null` on any failure path, never throws.
33
- */
34
- declare class FetchFileReader implements FileReader {
35
- read(url: string): Promise<string | null>;
36
- }
37
- //#endregion
38
- //#region src/browser/BrowserFlushScheduler.d.ts
39
- declare class BrowserFlushScheduler implements FlushScheduler {
40
- register(flush: FlushFn): void;
41
- }
42
- //#endregion
43
- export { catchWindowErrors as i, FetchFileReader as n, collectBrowser as r, BrowserFlushScheduler as t };
@@ -1,124 +0,0 @@
1
- import { redactUrlQuery, routeRejection } from "@flareapp/core";
2
-
3
- //#region src/browser/BrowserFlushScheduler.ts
4
- var BrowserFlushScheduler = class {
5
- register(flush) {
6
- if (typeof document === "undefined" || !document) return;
7
- document.addEventListener("visibilitychange", () => {
8
- if (document.visibilityState === "hidden") flush({ keepalive: true });
9
- });
10
- }
11
- };
12
-
13
- //#endregion
14
- //#region src/browser/context/cookie.ts
15
- function cookie() {
16
- if (!window.document.cookie) return {};
17
- const cookies = {};
18
- window.document.cookie.split("; ").forEach((rawCookie) => {
19
- const idx = rawCookie.indexOf("=");
20
- if (idx === -1) {
21
- cookies[rawCookie] = "";
22
- return;
23
- }
24
- const name = rawCookie.slice(0, idx);
25
- cookies[name] = rawCookie.slice(idx + 1);
26
- });
27
- return { "http.request.cookies": cookies };
28
- }
29
-
30
- //#endregion
31
- //#region src/browser/context/request.ts
32
- function request(urlDenylist) {
33
- return {
34
- "url.full": redactUrlQuery(window.location.href, urlDenylist),
35
- "user_agent.original": window.navigator.userAgent,
36
- "http.request.referrer": redactUrlQuery(window.document.referrer, urlDenylist),
37
- "document.ready_state": window.document.readyState
38
- };
39
- }
40
-
41
- //#endregion
42
- //#region src/browser/context/requestData.ts
43
- function requestData(urlDenylist) {
44
- if (!window.location.search) return {};
45
- return { "url.query": redactUrlQuery(window.location.search, urlDenylist).replace(/^\?/, "") };
46
- }
47
-
48
- //#endregion
49
- //#region src/browser/context/collectBrowser.ts
50
- const collectBrowser = (config) => {
51
- if (typeof window === "undefined") return { "flare.entry_point.type": "server" };
52
- const attrs = { "flare.entry_point.type": "web" };
53
- if (window?.location?.href) {
54
- attrs["flare.entry_point.value"] = redactUrlQuery(window.location.href, config.urlDenylist);
55
- if (window.location.pathname) {
56
- attrs["flare.entry_point.handler.identifier"] = window.location.pathname;
57
- attrs["flare.entry_point.handler.type"] = "browser";
58
- }
59
- }
60
- if (window?.location?.hostname) attrs["host.name"] = window.location.hostname;
61
- Object.assign(attrs, request(config.urlDenylist));
62
- Object.assign(attrs, requestData(config.urlDenylist));
63
- Object.assign(attrs, cookie());
64
- return attrs;
65
- };
66
-
67
- //#endregion
68
- //#region src/browser/FetchFileReader.ts
69
- /**
70
- * Browser `FileReader` implementation that fetches source files over HTTP(S).
71
- *
72
- * Wired into `@flareapp/js`'s singleton so the stack-trace builder can pull
73
- * the original source for each frame and render a code snippet around the
74
- * offending line. The source URL comes from the frame (usually the URL of
75
- * the JS bundle that produced the error, post-sourcemap resolution).
76
- *
77
- * Three safety gates:
78
- *
79
- * 1. **Scheme allowlist.** Only `http:` and `https:` URLs are fetched. Other
80
- * schemes (`chrome-extension://`, `file://`, `blob:`, `data:`) return
81
- * `null` immediately. This avoids surprise privilege boundaries (e.g.,
82
- * pages should not read extension-internal files) and dodges CORS/CSP
83
- * walls that would error noisily.
84
- * 2. **Status check.** Only `200 OK` responses are used. 3xx redirects are
85
- * handled transparently by `fetch`; 4xx/5xx fall back to `null` so the
86
- * snippet is simply omitted from the report.
87
- * 3. **Catch-all.** Network failures, CORS errors, and aborted requests
88
- * return `null`. We never let a source-fetch failure leak as an error
89
- * that the consumer page would see.
90
- *
91
- * The `read()` contract returns `null` on any failure path, never throws.
92
- */
93
- var FetchFileReader = class {
94
- read(url) {
95
- if (!/^https?:\/\//i.test(url)) return Promise.resolve(null);
96
- return fetch(url).then((response) => {
97
- if (response.status !== 200) return null;
98
- return response.text();
99
- }).catch(() => null);
100
- }
101
- };
102
-
103
- //#endregion
104
- //#region src/env/index.ts
105
- const CLIENT_VERSION = typeof process !== "undefined" && true ? "2.6.0" : "?";
106
-
107
- //#endregion
108
- //#region src/browser/catchWindowErrors.ts
109
- function catchWindowErrors() {
110
- if (typeof window === "undefined") return;
111
- window.addEventListener("error", (event) => {
112
- const flare = window.flare;
113
- if (!flare) return;
114
- if (event.error instanceof Error) flare.reportSilently(event.error);
115
- });
116
- window.addEventListener("unhandledrejection", (event) => {
117
- const flare = window.flare;
118
- if (!flare) return;
119
- routeRejection(flare, event.reason);
120
- });
121
- }
122
-
123
- //#endregion
124
- export { BrowserFlushScheduler as a, collectBrowser as i, CLIENT_VERSION as n, FetchFileReader as r, catchWindowErrors as t };