@flareapp/js 2.12.2 → 2.13.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/browser.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_catchWindowErrors = require('./catchWindowErrors-DKd_oG1H.cjs');
2
+ const require_catchWindowErrors = require('./catchWindowErrors-CzjkrJCx.cjs');
3
3
  let _flareapp_core = require("@flareapp/core");
4
4
 
5
5
  //#region src/browser.ts
@@ -58,8 +58,10 @@ exports.collectBrowser = require_catchWindowErrors.collectBrowser;
58
58
  exports.createFlareResolver = require_catchWindowErrors.createFlareResolver;
59
59
  exports.currentHref = require_catchWindowErrors.currentHref;
60
60
  exports.currentPath = require_catchWindowErrors.currentPath;
61
+ exports.hashRouteBase = require_catchWindowErrors.hashRouteBase;
61
62
  exports.instrumentOnce = require_catchWindowErrors.instrumentOnce;
62
63
  exports.insulate = require_catchWindowErrors.insulate;
64
+ exports.normalizeRouteBase = require_catchWindowErrors.normalizeRouteBase;
63
65
  exports.nowNano = require_catchWindowErrors.nowNano;
64
66
  exports.recordComponentSpan = require_catchWindowErrors.recordComponentSpan;
65
67
  exports.registerNavigationSource = require_catchWindowErrors.registerNavigationSource;
@@ -67,4 +69,5 @@ exports.reserveSpanId = require_catchWindowErrors.reserveSpanId;
67
69
  exports.resolveComponentParent = require_catchWindowErrors.resolveComponentParent;
68
70
  exports.resolveHref = require_catchWindowErrors.resolveHref;
69
71
  exports.routeName = require_catchWindowErrors.routeName;
70
- exports.safeInvoke = require_catchWindowErrors.safeInvoke;
72
+ exports.safeInvoke = require_catchWindowErrors.safeInvoke;
73
+ exports.stripBasename = require_catchWindowErrors.stripBasename;
@@ -1,4 +1,4 @@
1
- import { C as FetchFileReader, E as createFlareResolver, S as BrowserFlushScheduler, T as catchWindowErrors, _ as currentPath, a as nowNano, b as NavigationSource, c as resolveComponentParent, d as insulate, f as safeInvoke, g as currentHref, h as registerNavigationSource, i as activeComponentRoot, l as TrackTeardown, m as absoluteUrl, n as ComponentSpanRecord, o as recordComponentSpan, p as absoluteHref, r as ComponentTraceContext, s as reserveSpanId, t as BrowserSpanType, u as instrumentOnce, v as resolveHref, w as collectBrowser, x as RouteName, y as routeName } from "./spanTypes-Cdgtuu6-.cjs";
1
+ import { A as createFlareResolver, C as NavigationSource, D as FetchFileReader, E as BrowserFlushScheduler, O as collectBrowser, S as stripBasename, T as RouterTracingOptions, _ as currentPath, a as nowNano, b as resolveHref, c as resolveComponentParent, d as insulate, f as safeInvoke, g as currentHref, h as registerNavigationSource, i as activeComponentRoot, k as catchWindowErrors, l as TrackTeardown, m as absoluteUrl, n as ComponentSpanRecord, o as recordComponentSpan, p as absoluteHref, r as ComponentTraceContext, s as reserveSpanId, t as BrowserSpanType, u as instrumentOnce, v as hashRouteBase, w as RouteName, x as routeName, y as normalizeRouteBase } from "./spanTypes-DZsvl6US.cjs";
2
2
  import { Api, Config, ContextCollector, FileReader, Flare as Flare$1, ScopeProvider } from "@flareapp/core";
3
3
 
4
4
  //#region src/browser.d.ts
@@ -9,4 +9,4 @@ declare class Flare extends Flare$1 {
9
9
  configure(config: Partial<Config>): this;
10
10
  }
11
11
  //#endregion
12
- export { BrowserFlushScheduler, BrowserSpanType, type ComponentSpanRecord, type ComponentTraceContext, FetchFileReader, Flare, type NavigationSource, type RouteName, type TrackTeardown, absoluteHref, absoluteUrl, activeComponentRoot, catchWindowErrors, collectBrowser, createFlareResolver, currentHref, currentPath, instrumentOnce, insulate, nowNano, recordComponentSpan, registerNavigationSource, reserveSpanId, resolveComponentParent, resolveHref, routeName, safeInvoke };
12
+ export { BrowserFlushScheduler, BrowserSpanType, type ComponentSpanRecord, type ComponentTraceContext, FetchFileReader, Flare, type NavigationSource, type RouteName, type RouterTracingOptions, type TrackTeardown, absoluteHref, absoluteUrl, activeComponentRoot, catchWindowErrors, collectBrowser, createFlareResolver, currentHref, currentPath, hashRouteBase, instrumentOnce, insulate, normalizeRouteBase, nowNano, recordComponentSpan, registerNavigationSource, reserveSpanId, resolveComponentParent, resolveHref, routeName, safeInvoke, stripBasename };
@@ -1,4 +1,4 @@
1
- import { C as FetchFileReader, E as createFlareResolver, S as BrowserFlushScheduler, T as catchWindowErrors, _ as currentPath, a as nowNano, b as NavigationSource, c as resolveComponentParent, d as insulate, f as safeInvoke, g as currentHref, h as registerNavigationSource, i as activeComponentRoot, l as TrackTeardown, m as absoluteUrl, n as ComponentSpanRecord, o as recordComponentSpan, p as absoluteHref, r as ComponentTraceContext, s as reserveSpanId, t as BrowserSpanType, u as instrumentOnce, v as resolveHref, w as collectBrowser, x as RouteName, y as routeName } from "./spanTypes-RYeFN_pN.mjs";
1
+ import { A as createFlareResolver, C as NavigationSource, D as FetchFileReader, E as BrowserFlushScheduler, O as collectBrowser, S as stripBasename, T as RouterTracingOptions, _ as currentPath, a as nowNano, b as resolveHref, c as resolveComponentParent, d as insulate, f as safeInvoke, g as currentHref, h as registerNavigationSource, i as activeComponentRoot, k as catchWindowErrors, l as TrackTeardown, m as absoluteUrl, n as ComponentSpanRecord, o as recordComponentSpan, p as absoluteHref, r as ComponentTraceContext, s as reserveSpanId, t as BrowserSpanType, u as instrumentOnce, v as hashRouteBase, w as RouteName, x as routeName, y as normalizeRouteBase } from "./spanTypes-BndBPjyu.mjs";
2
2
  import { Api, Config, ContextCollector, FileReader, Flare as Flare$1, ScopeProvider } from "@flareapp/core";
3
3
 
4
4
  //#region src/browser.d.ts
@@ -9,4 +9,4 @@ declare class Flare extends Flare$1 {
9
9
  configure(config: Partial<Config>): this;
10
10
  }
11
11
  //#endregion
12
- export { BrowserFlushScheduler, BrowserSpanType, type ComponentSpanRecord, type ComponentTraceContext, FetchFileReader, Flare, type NavigationSource, type RouteName, type TrackTeardown, absoluteHref, absoluteUrl, activeComponentRoot, catchWindowErrors, collectBrowser, createFlareResolver, currentHref, currentPath, instrumentOnce, insulate, nowNano, recordComponentSpan, registerNavigationSource, reserveSpanId, resolveComponentParent, resolveHref, routeName, safeInvoke };
12
+ export { BrowserFlushScheduler, BrowserSpanType, type ComponentSpanRecord, type ComponentTraceContext, FetchFileReader, Flare, type NavigationSource, type RouteName, type RouterTracingOptions, type TrackTeardown, absoluteHref, absoluteUrl, activeComponentRoot, catchWindowErrors, collectBrowser, createFlareResolver, currentHref, currentPath, hashRouteBase, instrumentOnce, insulate, normalizeRouteBase, nowNano, recordComponentSpan, registerNavigationSource, reserveSpanId, resolveComponentParent, resolveHref, routeName, safeInvoke, stripBasename };
package/dist/browser.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { C as currentHref, D as absoluteHref, E as routeName, O as absoluteUrl, S as registerNavigationSource, T as resolveHref, _ as BrowserFlushScheduler, a as recordComponentSpan, b as browserUrlContext, c as startBrowserTracing, d as instrumentOnce, f as insulate, g as collectBrowser, h as FetchFileReader, i as nowNano, l as stopBrowserTracing, m as CLIENT_VERSION, n as createFlareResolver, o as reserveSpanId, p as safeInvoke, r as activeComponentRoot, s as resolveComponentParent, t as catchWindowErrors, u as BrowserSpanType, v as startBreadcrumbs, w as currentPath, x as withRequestPatches, y as traceRequests } from "./catchWindowErrors-BlQaHZl4.mjs";
1
+ import { A as absoluteHref, C as currentHref, D as resolveHref, E as normalizeRouteBase, O as routeName, S as registerNavigationSource, T as hashRouteBase, _ as BrowserFlushScheduler, a as recordComponentSpan, b as browserUrlContext, c as startBrowserTracing, d as instrumentOnce, f as insulate, g as collectBrowser, h as FetchFileReader, i as nowNano, j as absoluteUrl, k as stripBasename, l as stopBrowserTracing, m as CLIENT_VERSION, n as createFlareResolver, o as reserveSpanId, p as safeInvoke, r as activeComponentRoot, s as resolveComponentParent, t as catchWindowErrors, u as BrowserSpanType, v as startBreadcrumbs, w as currentPath, x as withRequestPatches, y as traceRequests } from "./catchWindowErrors-BFAg08Kl.mjs";
2
2
  import { Api, Flare as Flare$1, FrameworkName, GlobalScopeProvider } from "@flareapp/core";
3
3
 
4
4
  //#region src/browser.ts
@@ -40,4 +40,4 @@ var Flare = class extends Flare$1 {
40
40
  };
41
41
 
42
42
  //#endregion
43
- export { BrowserFlushScheduler, BrowserSpanType, FetchFileReader, Flare, absoluteHref, absoluteUrl, activeComponentRoot, catchWindowErrors, collectBrowser, createFlareResolver, currentHref, currentPath, instrumentOnce, insulate, nowNano, recordComponentSpan, registerNavigationSource, reserveSpanId, resolveComponentParent, resolveHref, routeName, safeInvoke };
43
+ export { BrowserFlushScheduler, BrowserSpanType, FetchFileReader, Flare, absoluteHref, absoluteUrl, activeComponentRoot, catchWindowErrors, collectBrowser, createFlareResolver, currentHref, currentPath, hashRouteBase, instrumentOnce, insulate, normalizeRouteBase, nowNano, recordComponentSpan, registerNavigationSource, reserveSpanId, resolveComponentParent, resolveHref, routeName, safeInvoke, stripBasename };
@@ -108,23 +108,57 @@ function currentHref() {
108
108
  /**
109
109
  * Prefers the router's route template (`/product/:id`) over the raw path, so all urls of one route
110
110
  * group together. If `derive` throws, the fallback path is used instead of breaking the app.
111
+ *
112
+ * `base` is a value from `normalizeRouteBase`. It goes in front of both the template and the fallback.
111
113
  */
112
- function routeName(derive, fallbackPath, url) {
114
+ function routeName(derive, fallbackPath, url, base = "") {
113
115
  try {
114
116
  const name = derive();
115
117
  if (name) return {
116
- name,
118
+ name: joinRouteBase(base, name),
117
119
  source: "route",
118
120
  url
119
121
  };
120
122
  } catch {}
121
123
  return {
122
- name: fallbackPath,
124
+ name: joinRouteBase(base, fallbackPath),
123
125
  source: "url",
124
126
  url
125
127
  };
126
128
  }
127
129
  /**
130
+ * Turns a router base into the prefix for a route name: `/app/` gives `/app`, `/shop/?q=1#` gives
131
+ * `/shop/#`, and `/` gives an empty string. The query string is removed, because a route name must
132
+ * not change per visit.
133
+ */
134
+ function normalizeRouteBase(base) {
135
+ if (!base) return "";
136
+ const hashIndex = base.indexOf("#");
137
+ const path = (hashIndex === -1 ? base : base.slice(0, hashIndex)).split("?")[0];
138
+ if (hashIndex === -1) return trimTrailingSlashes(path);
139
+ return `${path}#${trimTrailingSlashes(base.slice(hashIndex + 1))}`;
140
+ }
141
+ /** The base of a hash router: the page path in front of the `#`, then the router's own basename. */
142
+ function hashRouteBase(basename) {
143
+ return `${currentPath()}#${basename ?? ""}`;
144
+ }
145
+ /**
146
+ * Removes a router basename from the front of a path. Some routers keep it on the location path
147
+ * (React Router, older TanStack Router), and the base must not be added twice.
148
+ */
149
+ function stripBasename(pathname, basename) {
150
+ const trimmed = basename ? trimTrailingSlashes(basename) : "";
151
+ if (!trimmed || pathname !== trimmed && !pathname.startsWith(`${trimmed}/`)) return pathname;
152
+ return pathname.slice(trimmed.length) || "/";
153
+ }
154
+ function joinRouteBase(base, name) {
155
+ if (!base) return name;
156
+ return name.startsWith("/") ? base + name : `${base}/${name}`;
157
+ }
158
+ function trimTrailingSlashes(path) {
159
+ return path.replace(/\/+$/, "");
160
+ }
161
+ /**
128
162
  * `build` is the router's own href builder (vue-router `resolve`, React Router `createHref`). It restores
129
163
  * the app's base path and hash prefix, so an app served from `/app/` reports `/app/product/p01` instead
130
164
  * of `/product/p01`. Falls back to `fallbackHref` if `build` throws.
@@ -1044,7 +1078,7 @@ var FetchFileReader = class {
1044
1078
 
1045
1079
  //#endregion
1046
1080
  //#region src/env/index.ts
1047
- const CLIENT_VERSION = typeof process !== "undefined" && true ? "2.12.2" : "?";
1081
+ const CLIENT_VERSION = "2.13.0";
1048
1082
 
1049
1083
  //#endregion
1050
1084
  //#region src/tracing/utils/instrumentationGuard.ts
@@ -2558,4 +2592,4 @@ function catchWindowErrors() {
2558
2592
  }
2559
2593
 
2560
2594
  //#endregion
2561
- export { currentHref as C, absoluteHref as D, routeName as E, absoluteUrl as O, registerNavigationSource as S, resolveHref as T, BrowserFlushScheduler as _, recordComponentSpan as a, browserUrlContext as b, startBrowserTracing as c, instrumentOnce as d, insulate as f, collectBrowser as g, FetchFileReader as h, nowNano as i, stopBrowserTracing as l, CLIENT_VERSION as m, createFlareResolver as n, reserveSpanId as o, safeInvoke as p, activeComponentRoot as r, resolveComponentParent as s, catchWindowErrors as t, BrowserSpanType$1 as u, startBreadcrumbs as v, currentPath as w, withRequestPatches as x, traceRequests as y };
2595
+ export { absoluteHref as A, currentHref as C, resolveHref as D, normalizeRouteBase as E, routeName as O, registerNavigationSource as S, hashRouteBase as T, BrowserFlushScheduler as _, recordComponentSpan as a, browserUrlContext as b, startBrowserTracing as c, instrumentOnce as d, insulate as f, collectBrowser as g, FetchFileReader as h, nowNano as i, absoluteUrl as j, stripBasename as k, stopBrowserTracing as l, CLIENT_VERSION as m, createFlareResolver as n, reserveSpanId as o, safeInvoke as p, activeComponentRoot as r, resolveComponentParent as s, catchWindowErrors as t, BrowserSpanType$1 as u, startBreadcrumbs as v, currentPath as w, withRequestPatches as x, traceRequests as y };
@@ -108,23 +108,57 @@ function currentHref() {
108
108
  /**
109
109
  * Prefers the router's route template (`/product/:id`) over the raw path, so all urls of one route
110
110
  * group together. If `derive` throws, the fallback path is used instead of breaking the app.
111
+ *
112
+ * `base` is a value from `normalizeRouteBase`. It goes in front of both the template and the fallback.
111
113
  */
112
- function routeName(derive, fallbackPath, url) {
114
+ function routeName(derive, fallbackPath, url, base = "") {
113
115
  try {
114
116
  const name = derive();
115
117
  if (name) return {
116
- name,
118
+ name: joinRouteBase(base, name),
117
119
  source: "route",
118
120
  url
119
121
  };
120
122
  } catch {}
121
123
  return {
122
- name: fallbackPath,
124
+ name: joinRouteBase(base, fallbackPath),
123
125
  source: "url",
124
126
  url
125
127
  };
126
128
  }
127
129
  /**
130
+ * Turns a router base into the prefix for a route name: `/app/` gives `/app`, `/shop/?q=1#` gives
131
+ * `/shop/#`, and `/` gives an empty string. The query string is removed, because a route name must
132
+ * not change per visit.
133
+ */
134
+ function normalizeRouteBase(base) {
135
+ if (!base) return "";
136
+ const hashIndex = base.indexOf("#");
137
+ const path = (hashIndex === -1 ? base : base.slice(0, hashIndex)).split("?")[0];
138
+ if (hashIndex === -1) return trimTrailingSlashes(path);
139
+ return `${path}#${trimTrailingSlashes(base.slice(hashIndex + 1))}`;
140
+ }
141
+ /** The base of a hash router: the page path in front of the `#`, then the router's own basename. */
142
+ function hashRouteBase(basename) {
143
+ return `${currentPath()}#${basename ?? ""}`;
144
+ }
145
+ /**
146
+ * Removes a router basename from the front of a path. Some routers keep it on the location path
147
+ * (React Router, older TanStack Router), and the base must not be added twice.
148
+ */
149
+ function stripBasename(pathname, basename) {
150
+ const trimmed = basename ? trimTrailingSlashes(basename) : "";
151
+ if (!trimmed || pathname !== trimmed && !pathname.startsWith(`${trimmed}/`)) return pathname;
152
+ return pathname.slice(trimmed.length) || "/";
153
+ }
154
+ function joinRouteBase(base, name) {
155
+ if (!base) return name;
156
+ return name.startsWith("/") ? base + name : `${base}/${name}`;
157
+ }
158
+ function trimTrailingSlashes(path) {
159
+ return path.replace(/\/+$/, "");
160
+ }
161
+ /**
128
162
  * `build` is the router's own href builder (vue-router `resolve`, React Router `createHref`). It restores
129
163
  * the app's base path and hash prefix, so an app served from `/app/` reports `/app/product/p01` instead
130
164
  * of `/product/p01`. Falls back to `fallbackHref` if `build` throws.
@@ -1044,7 +1078,7 @@ var FetchFileReader = class {
1044
1078
 
1045
1079
  //#endregion
1046
1080
  //#region src/env/index.ts
1047
- const CLIENT_VERSION = typeof process !== "undefined" && true ? "2.12.2" : "?";
1081
+ const CLIENT_VERSION = "2.13.0";
1048
1082
 
1049
1083
  //#endregion
1050
1084
  //#region src/tracing/utils/instrumentationGuard.ts
@@ -2630,6 +2664,12 @@ Object.defineProperty(exports, 'currentPath', {
2630
2664
  return currentPath;
2631
2665
  }
2632
2666
  });
2667
+ Object.defineProperty(exports, 'hashRouteBase', {
2668
+ enumerable: true,
2669
+ get: function () {
2670
+ return hashRouteBase;
2671
+ }
2672
+ });
2633
2673
  Object.defineProperty(exports, 'instrumentOnce', {
2634
2674
  enumerable: true,
2635
2675
  get: function () {
@@ -2642,6 +2682,12 @@ Object.defineProperty(exports, 'insulate', {
2642
2682
  return insulate;
2643
2683
  }
2644
2684
  });
2685
+ Object.defineProperty(exports, 'normalizeRouteBase', {
2686
+ enumerable: true,
2687
+ get: function () {
2688
+ return normalizeRouteBase;
2689
+ }
2690
+ });
2645
2691
  Object.defineProperty(exports, 'nowNano', {
2646
2692
  enumerable: true,
2647
2693
  get: function () {
@@ -2708,6 +2754,12 @@ Object.defineProperty(exports, 'stopBrowserTracing', {
2708
2754
  return stopBrowserTracing;
2709
2755
  }
2710
2756
  });
2757
+ Object.defineProperty(exports, 'stripBasename', {
2758
+ enumerable: true,
2759
+ get: function () {
2760
+ return stripBasename;
2761
+ }
2762
+ });
2711
2763
  Object.defineProperty(exports, 'traceRequests', {
2712
2764
  enumerable: true,
2713
2765
  get: function () {
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_catchWindowErrors = require('./catchWindowErrors-DKd_oG1H.cjs');
2
+ const require_catchWindowErrors = require('./catchWindowErrors-CzjkrJCx.cjs');
3
3
  const require_browser = require('./browser.cjs');
4
4
  let _flareapp_core = require("@flareapp/core");
5
5
 
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { E as createFlareResolver } from "./spanTypes-Cdgtuu6-.cjs";
1
+ import { A as createFlareResolver } from "./spanTypes-DZsvl6US.cjs";
2
2
  import { Flare } from "./browser.cjs";
3
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";
4
4
 
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { E as createFlareResolver } from "./spanTypes-RYeFN_pN.mjs";
1
+ import { A as createFlareResolver } from "./spanTypes-BndBPjyu.mjs";
2
2
  import { Flare } from "./browser.mjs";
3
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";
4
4
 
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as createFlareResolver, t as catchWindowErrors } from "./catchWindowErrors-BlQaHZl4.mjs";
1
+ import { n as createFlareResolver, t as catchWindowErrors } from "./catchWindowErrors-BFAg08Kl.mjs";
2
2
  import { Flare } from "./browser.mjs";
3
3
  import { DEFAULT_URL_DENYLIST, FrameworkName, GlobalScopeProvider, Logger, NullFileReader, Scope, convertToError, redactObjectValues, redactUrlQuery, redactUrlQuery as redactFullPath, resolveDenylist, toCustomContext } from "@flareapp/core";
4
4
 
@@ -47,6 +47,13 @@ type RouteName = {
47
47
  source: 'route' | 'url'; /** Where the navigation ends. Set on a redirect so the report uses the final url, not the url the root opened with. */
48
48
  url?: string;
49
49
  };
50
+ type RouterTracingOptions = {
51
+ /**
52
+ * Puts the router base in front of the route name: `/agent/#/:id` instead of `/:id`. Use it when
53
+ * apps with different bases share one Flare project.
54
+ */
55
+ includeRouterBase?: boolean;
56
+ };
50
57
  type NavigationSource = {
51
58
  startNavigation(opts?: {
52
59
  path?: string;
@@ -65,8 +72,23 @@ declare function currentHref(): string;
65
72
  /**
66
73
  * Prefers the router's route template (`/product/:id`) over the raw path, so all urls of one route
67
74
  * group together. If `derive` throws, the fallback path is used instead of breaking the app.
75
+ *
76
+ * `base` is a value from `normalizeRouteBase`. It goes in front of both the template and the fallback.
77
+ */
78
+ declare function routeName(derive: () => string | undefined, fallbackPath: string, url?: string, base?: string): RouteName;
79
+ /**
80
+ * Turns a router base into the prefix for a route name: `/app/` gives `/app`, `/shop/?q=1#` gives
81
+ * `/shop/#`, and `/` gives an empty string. The query string is removed, because a route name must
82
+ * not change per visit.
83
+ */
84
+ declare function normalizeRouteBase(base: string | null | undefined): string;
85
+ /** The base of a hash router: the page path in front of the `#`, then the router's own basename. */
86
+ declare function hashRouteBase(basename?: string): string;
87
+ /**
88
+ * Removes a router basename from the front of a path. Some routers keep it on the location path
89
+ * (React Router, older TanStack Router), and the base must not be added twice.
68
90
  */
69
- declare function routeName(derive: () => string | undefined, fallbackPath: string, url?: string): RouteName;
91
+ declare function stripBasename(pathname: string, basename: string | undefined): string;
70
92
  /**
71
93
  * `build` is the router's own href builder (vue-router `resolve`, React Router `createHref`). It restores
72
94
  * the app's base path and hash prefix, so an app served from `/app/` reports `/app/product/p01` instead
@@ -155,4 +177,4 @@ type ComponentSpanRecord = {
155
177
  */
156
178
  declare function recordComponentSpan(record: ComponentSpanRecord): void;
157
179
  //#endregion
158
- 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 };
180
+ export { createFlareResolver as A, NavigationSource as C, FetchFileReader as D, BrowserFlushScheduler as E, collectBrowser as O, stripBasename as S, RouterTracingOptions as T, currentPath as _, nowNano as a, resolveHref as b, resolveComponentParent as c, insulate as d, safeInvoke as f, currentHref as g, registerNavigationSource as h, activeComponentRoot as i, catchWindowErrors as k, 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, hashRouteBase as v, RouteName as w, routeName as x, normalizeRouteBase as y };
@@ -47,6 +47,13 @@ type RouteName = {
47
47
  source: 'route' | 'url'; /** Where the navigation ends. Set on a redirect so the report uses the final url, not the url the root opened with. */
48
48
  url?: string;
49
49
  };
50
+ type RouterTracingOptions = {
51
+ /**
52
+ * Puts the router base in front of the route name: `/agent/#/:id` instead of `/:id`. Use it when
53
+ * apps with different bases share one Flare project.
54
+ */
55
+ includeRouterBase?: boolean;
56
+ };
50
57
  type NavigationSource = {
51
58
  startNavigation(opts?: {
52
59
  path?: string;
@@ -65,8 +72,23 @@ declare function currentHref(): string;
65
72
  /**
66
73
  * Prefers the router's route template (`/product/:id`) over the raw path, so all urls of one route
67
74
  * group together. If `derive` throws, the fallback path is used instead of breaking the app.
75
+ *
76
+ * `base` is a value from `normalizeRouteBase`. It goes in front of both the template and the fallback.
77
+ */
78
+ declare function routeName(derive: () => string | undefined, fallbackPath: string, url?: string, base?: string): RouteName;
79
+ /**
80
+ * Turns a router base into the prefix for a route name: `/app/` gives `/app`, `/shop/?q=1#` gives
81
+ * `/shop/#`, and `/` gives an empty string. The query string is removed, because a route name must
82
+ * not change per visit.
83
+ */
84
+ declare function normalizeRouteBase(base: string | null | undefined): string;
85
+ /** The base of a hash router: the page path in front of the `#`, then the router's own basename. */
86
+ declare function hashRouteBase(basename?: string): string;
87
+ /**
88
+ * Removes a router basename from the front of a path. Some routers keep it on the location path
89
+ * (React Router, older TanStack Router), and the base must not be added twice.
68
90
  */
69
- declare function routeName(derive: () => string | undefined, fallbackPath: string, url?: string): RouteName;
91
+ declare function stripBasename(pathname: string, basename: string | undefined): string;
70
92
  /**
71
93
  * `build` is the router's own href builder (vue-router `resolve`, React Router `createHref`). It restores
72
94
  * the app's base path and hash prefix, so an app served from `/app/` reports `/app/product/p01` instead
@@ -155,4 +177,4 @@ type ComponentSpanRecord = {
155
177
  */
156
178
  declare function recordComponentSpan(record: ComponentSpanRecord): void;
157
179
  //#endregion
158
- 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 };
180
+ export { createFlareResolver as A, NavigationSource as C, FetchFileReader as D, BrowserFlushScheduler as E, collectBrowser as O, stripBasename as S, RouterTracingOptions as T, currentPath as _, nowNano as a, resolveHref as b, resolveComponentParent as c, insulate as d, safeInvoke as f, currentHref as g, registerNavigationSource as h, activeComponentRoot as i, catchWindowErrors as k, 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, hashRouteBase as v, RouteName as w, routeName as x, normalizeRouteBase as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flareapp/js",
3
- "version": "2.12.2",
3
+ "version": "2.13.0",
4
4
  "description": "JavaScript client for flareapp.io",
5
5
  "homepage": "https://flareapp.io",
6
6
  "bugs": {
@@ -59,7 +59,7 @@
59
59
  "release": "release-it"
60
60
  },
61
61
  "dependencies": {
62
- "@flareapp/core": "2.12.2"
62
+ "@flareapp/core": "2.13.0"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@flareapp/test-helpers": "*",