@flareapp/js 2.7.0 → 2.9.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-2a2z2zr2.cjs');
2
+ const require_catchWindowErrors = require('./catchWindowErrors-cR2D7kju.cjs');
3
3
  const require_browser = require('./browser.cjs');
4
4
  let _flareapp_core = require("@flareapp/core");
5
5
 
@@ -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_catchWindowErrors.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 { E as createFlareResolver } from "./spanTypes-TMgJEZ7G.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 { E as createFlareResolver } from "./spanTypes-7-nEycOc.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-CSc-dC37.mjs";
1
+ import { n as createFlareResolver, t as catchWindowErrors } from "./catchWindowErrors-C0gSVGiF.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,155 @@
1
+ import { Flare as Flare$1 } from "./browser.mjs";
2
+ import { Attributes, BrowserSpanType as BrowserSpanType$1, 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/instrumentation/navigation/types.d.ts
46
+ type RouteName = {
47
+ name: string;
48
+ source: 'route' | 'url';
49
+ /** Where the navigation ends. Set on a redirect so the final url is reported; leave out to keep
50
+ * the url the root opened with. */
51
+ url?: string;
52
+ };
53
+ type NavigationSource = {
54
+ startNavigation(opts?: {
55
+ path?: string;
56
+ url?: string;
57
+ hold?: boolean;
58
+ }): void;
59
+ setActiveRouteName(route: RouteName): void;
60
+ settleNavigation(route: RouteName): void;
61
+ unregister(): void;
62
+ };
63
+ //#endregion
64
+ //#region src/instrumentation/navigation/utils.d.ts
65
+ declare function currentPath(): string;
66
+ declare function currentHref(): string;
67
+ declare function routeName(derive: () => string | undefined, fallbackPath: string, url?: string): RouteName;
68
+ /**
69
+ * `build` is the router's own href builder (vue-router `resolve`, React Router `createHref`). It puts
70
+ * the app's base path and hash prefix back. Without it, an app served from `/app/` reports
71
+ * `/product/p01` instead of `/app/product/p01`. If `build` throws, we use `fallback`.
72
+ */
73
+ declare function resolveHref(build: () => string | null | undefined, fallbackHref: string): string | undefined;
74
+ //#endregion
75
+ //#region src/instrumentation/navigation/navigationBus.d.ts
76
+ /**
77
+ * Hands navigation to a framework router: while registered, the built-in History detection stays
78
+ * quiet and the router drives every step through the returned handle. The newest registration wins
79
+ * and a stale handle no-ops, because HMR can replace a router that still holds one.
80
+ */
81
+ declare function registerNavigationSource(): NavigationSource;
82
+ //#endregion
83
+ //#region src/tracing/utils/absoluteHref.d.ts
84
+ /**
85
+ * Resolve a router-reported href against the page we are on. Returns the `URL`, so a caller that
86
+ * wants the pathname as well as the href does not parse it a second time.
87
+ *
88
+ * Undefined outside a browser or for an unparseable href, so the caller can leave its attribute alone.
89
+ */
90
+ declare function absoluteUrl(href: string | null | undefined): URL | undefined;
91
+ /**
92
+ * The href form of `absoluteUrl`. Pass one built by the router's own `createHref`/`resolve` (see
93
+ * `resolveHref`), not a bare path: routers strip the app's base path, so `origin + path` yields an
94
+ * address the server does not have.
95
+ */
96
+ declare function absoluteHref(href: string | null | undefined): string | undefined;
97
+ //#endregion
98
+ //#region src/tracing/utils/instrumentationGuard.d.ts
99
+ /** For a callback the host invokes: a router guard, a store subscriber, ... */
100
+ declare function insulate<A extends unknown[]>(fn: (...a: A) => void): (...a: A) => void;
101
+ /** Invoke a teardown fn now (if present), swallowing any throw. For cleanup chains. */
102
+ declare function safeInvoke(fn: (() => void) | null | undefined): void;
103
+ /** Hands one teardown to `instrumentOnce`. Accepts nothing, for a listener an install chose to skip. */
104
+ type TrackTeardown = (teardown: (() => void) | null | undefined) => void;
105
+ /**
106
+ * Instrument `target` at most once at a time, tearing down any prior instrumentation of the same object
107
+ * first. Vite HMR re-runs boot code against a router that survives the reload, so without this every
108
+ * cycle appends another listener set that is never removed. Keyed on the object, so a genuinely new
109
+ * router is unaffected.
110
+ *
111
+ * `install` hands each teardown to `track` as it produces it. A router's own `subscribe` / `on` / guard
112
+ * registration can throw, and `install` runs during the host's bootstrap, so a throw part-way through
113
+ * unwinds what already succeeded (newest first) and stops here rather than reaching the host.
114
+ *
115
+ * @returns the cleanup, or a no-op when the install failed and already unwound itself.
116
+ */
117
+ declare function instrumentOnce<T extends object>(target: T, install: (track: TrackTeardown) => void): () => void;
118
+ //#endregion
119
+ //#region src/tracing/roots/componentProfiler.d.ts
120
+ type ComponentTraceContext = {
121
+ traceId: string;
122
+ parentSpanId: string;
123
+ };
124
+ /** Unix nanos on the same clock the tracer uses for span timestamps. */
125
+ declare const nowNano: typeof defaultNowNano;
126
+ /**
127
+ * Reserved up front so descendants can point at a span before it is recorded. Null when the trace is at
128
+ * its span cap: descendants record before this span does, so an id the cap will refuse orphans them.
129
+ */
130
+ declare function reserveSpanId(traceId?: string): string | null;
131
+ /** The root a top-level component nests under. Null when tracing is off or no root is recording. */
132
+ declare function activeComponentRoot(): ComponentTraceContext | null;
133
+ /**
134
+ * An ancestor's context is only usable while it still belongs to the live trace. A profiled component
135
+ * that survives a navigation (a layout around a swapped page body) froze its context under the pageload
136
+ * trace, and `recordComponentSpan` would drop anything pointing at that closed root.
137
+ */
138
+ declare function resolveComponentParent(inherited: ComponentTraceContext | null | undefined, live: ComponentTraceContext | null): ComponentTraceContext | null;
139
+ /** What a profiler hands back for one component mount. */
140
+ type ComponentSpanRecord = {
141
+ name: string;
142
+ spanId: string;
143
+ parent: ComponentTraceContext;
144
+ startTimeUnixNano: number;
145
+ endTimeUnixNano: number;
146
+ attributes?: Attributes;
147
+ };
148
+ /**
149
+ * Records only while the reserved root is still the live recording root, and drops the span otherwise.
150
+ * Dropping avoids starting a fresh TraceState for a dead trace, which would re-run the sampler, and
151
+ * avoids adding a child to a root that already shipped.
152
+ */
153
+ declare function recordComponentSpan(record: ComponentSpanRecord): void;
154
+ //#endregion
155
+ export { FetchFileReader as C, createFlareResolver as E, BrowserFlushScheduler as S, catchWindowErrors as T, currentPath as _, nowNano as a, NavigationSource as b, resolveComponentParent as c, insulate as d, safeInvoke as f, currentHref as g, registerNavigationSource as h, activeComponentRoot as i, TrackTeardown as l, absoluteUrl as m, ComponentSpanRecord as n, recordComponentSpan as o, absoluteHref as p, ComponentTraceContext as r, reserveSpanId as s, BrowserSpanType$1 as t, instrumentOnce as u, resolveHref as v, collectBrowser as w, RouteName as x, routeName as y };
@@ -0,0 +1,155 @@
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/instrumentation/navigation/types.d.ts
46
+ type RouteName = {
47
+ name: string;
48
+ source: 'route' | 'url';
49
+ /** Where the navigation ends. Set on a redirect so the final url is reported; leave out to keep
50
+ * the url the root opened with. */
51
+ url?: string;
52
+ };
53
+ type NavigationSource = {
54
+ startNavigation(opts?: {
55
+ path?: string;
56
+ url?: string;
57
+ hold?: boolean;
58
+ }): void;
59
+ setActiveRouteName(route: RouteName): void;
60
+ settleNavigation(route: RouteName): void;
61
+ unregister(): void;
62
+ };
63
+ //#endregion
64
+ //#region src/instrumentation/navigation/utils.d.ts
65
+ declare function currentPath(): string;
66
+ declare function currentHref(): string;
67
+ declare function routeName(derive: () => string | undefined, fallbackPath: string, url?: string): RouteName;
68
+ /**
69
+ * `build` is the router's own href builder (vue-router `resolve`, React Router `createHref`). It puts
70
+ * the app's base path and hash prefix back. Without it, an app served from `/app/` reports
71
+ * `/product/p01` instead of `/app/product/p01`. If `build` throws, we use `fallback`.
72
+ */
73
+ declare function resolveHref(build: () => string | null | undefined, fallbackHref: string): string | undefined;
74
+ //#endregion
75
+ //#region src/instrumentation/navigation/navigationBus.d.ts
76
+ /**
77
+ * Hands navigation to a framework router: while registered, the built-in History detection stays
78
+ * quiet and the router drives every step through the returned handle. The newest registration wins
79
+ * and a stale handle no-ops, because HMR can replace a router that still holds one.
80
+ */
81
+ declare function registerNavigationSource(): NavigationSource;
82
+ //#endregion
83
+ //#region src/tracing/utils/absoluteHref.d.ts
84
+ /**
85
+ * Resolve a router-reported href against the page we are on. Returns the `URL`, so a caller that
86
+ * wants the pathname as well as the href does not parse it a second time.
87
+ *
88
+ * Undefined outside a browser or for an unparseable href, so the caller can leave its attribute alone.
89
+ */
90
+ declare function absoluteUrl(href: string | null | undefined): URL | undefined;
91
+ /**
92
+ * The href form of `absoluteUrl`. Pass one built by the router's own `createHref`/`resolve` (see
93
+ * `resolveHref`), not a bare path: routers strip the app's base path, so `origin + path` yields an
94
+ * address the server does not have.
95
+ */
96
+ declare function absoluteHref(href: string | null | undefined): string | undefined;
97
+ //#endregion
98
+ //#region src/tracing/utils/instrumentationGuard.d.ts
99
+ /** For a callback the host invokes: a router guard, a store subscriber, ... */
100
+ declare function insulate<A extends unknown[]>(fn: (...a: A) => void): (...a: A) => void;
101
+ /** Invoke a teardown fn now (if present), swallowing any throw. For cleanup chains. */
102
+ declare function safeInvoke(fn: (() => void) | null | undefined): void;
103
+ /** Hands one teardown to `instrumentOnce`. Accepts nothing, for a listener an install chose to skip. */
104
+ type TrackTeardown = (teardown: (() => void) | null | undefined) => void;
105
+ /**
106
+ * Instrument `target` at most once at a time, tearing down any prior instrumentation of the same object
107
+ * first. Vite HMR re-runs boot code against a router that survives the reload, so without this every
108
+ * cycle appends another listener set that is never removed. Keyed on the object, so a genuinely new
109
+ * router is unaffected.
110
+ *
111
+ * `install` hands each teardown to `track` as it produces it. A router's own `subscribe` / `on` / guard
112
+ * registration can throw, and `install` runs during the host's bootstrap, so a throw part-way through
113
+ * unwinds what already succeeded (newest first) and stops here rather than reaching the host.
114
+ *
115
+ * @returns the cleanup, or a no-op when the install failed and already unwound itself.
116
+ */
117
+ declare function instrumentOnce<T extends object>(target: T, install: (track: TrackTeardown) => void): () => void;
118
+ //#endregion
119
+ //#region src/tracing/roots/componentProfiler.d.ts
120
+ type ComponentTraceContext = {
121
+ traceId: string;
122
+ parentSpanId: string;
123
+ };
124
+ /** Unix nanos on the same clock the tracer uses for span timestamps. */
125
+ declare const nowNano: typeof defaultNowNano;
126
+ /**
127
+ * Reserved up front so descendants can point at a span before it is recorded. Null when the trace is at
128
+ * its span cap: descendants record before this span does, so an id the cap will refuse orphans them.
129
+ */
130
+ declare function reserveSpanId(traceId?: string): string | null;
131
+ /** The root a top-level component nests under. Null when tracing is off or no root is recording. */
132
+ declare function activeComponentRoot(): ComponentTraceContext | null;
133
+ /**
134
+ * An ancestor's context is only usable while it still belongs to the live trace. A profiled component
135
+ * that survives a navigation (a layout around a swapped page body) froze its context under the pageload
136
+ * trace, and `recordComponentSpan` would drop anything pointing at that closed root.
137
+ */
138
+ declare function resolveComponentParent(inherited: ComponentTraceContext | null | undefined, live: ComponentTraceContext | null): ComponentTraceContext | null;
139
+ /** What a profiler hands back for one component mount. */
140
+ type ComponentSpanRecord = {
141
+ name: string;
142
+ spanId: string;
143
+ parent: ComponentTraceContext;
144
+ startTimeUnixNano: number;
145
+ endTimeUnixNano: number;
146
+ attributes?: Attributes;
147
+ };
148
+ /**
149
+ * Records only while the reserved root is still the live recording root, and drops the span otherwise.
150
+ * Dropping avoids starting a fresh TraceState for a dead trace, which would re-run the sampler, and
151
+ * avoids adding a child to a root that already shipped.
152
+ */
153
+ declare function recordComponentSpan(record: ComponentSpanRecord): void;
154
+ //#endregion
155
+ export { FetchFileReader as C, createFlareResolver as E, BrowserFlushScheduler as S, catchWindowErrors as T, currentPath as _, nowNano as a, NavigationSource as b, resolveComponentParent as c, insulate as d, safeInvoke as f, currentHref as g, registerNavigationSource as h, activeComponentRoot as i, TrackTeardown as l, absoluteUrl as m, ComponentSpanRecord as n, recordComponentSpan as o, absoluteHref as p, ComponentTraceContext as r, reserveSpanId as s, BrowserSpanType as t, instrumentOnce as u, resolveHref as v, collectBrowser as w, RouteName as x, routeName as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flareapp/js",
3
- "version": "2.7.0",
3
+ "version": "2.9.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.7.0"
62
+ "@flareapp/core": "2.9.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,153 +0,0 @@
1
- let _flareapp_core = require("@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": (0, _flareapp_core.redactUrlQuery)(window.location.href, urlDenylist),
35
- "user_agent.original": window.navigator.userAgent,
36
- "http.request.referrer": (0, _flareapp_core.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": (0, _flareapp_core.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"] = (0, _flareapp_core.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.7.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
- (0, _flareapp_core.routeRejection)(flare, event.reason);
120
- });
121
- }
122
-
123
- //#endregion
124
- Object.defineProperty(exports, 'BrowserFlushScheduler', {
125
- enumerable: true,
126
- get: function () {
127
- return BrowserFlushScheduler;
128
- }
129
- });
130
- Object.defineProperty(exports, 'CLIENT_VERSION', {
131
- enumerable: true,
132
- get: function () {
133
- return CLIENT_VERSION;
134
- }
135
- });
136
- Object.defineProperty(exports, 'FetchFileReader', {
137
- enumerable: true,
138
- get: function () {
139
- return FetchFileReader;
140
- }
141
- });
142
- Object.defineProperty(exports, 'catchWindowErrors', {
143
- enumerable: true,
144
- get: function () {
145
- return catchWindowErrors;
146
- }
147
- });
148
- Object.defineProperty(exports, 'collectBrowser', {
149
- enumerable: true,
150
- get: function () {
151
- return collectBrowser;
152
- }
153
- });