@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/README.md CHANGED
@@ -51,6 +51,23 @@ flare.logger.info('Checkout started', { cartId: cart.id, total: cart.total });
51
51
  Logs are buffered and batched, and flushed when the tab is hidden so buffered logs survive a page unload. The optional
52
52
  second argument is structured, searchable attributes.
53
53
 
54
+ ## What happens when someone leaves the page
55
+
56
+ Logs and spans are batched, so there's usually something unsent when a visitor leaves. The client flushes it when
57
+ the tab is hidden or the page closes.
58
+
59
+ Browsers cap what you can send at that moment: roughly 64KB across every request still in flight. The client stays
60
+ under 60KB, and logs and spans share that budget.
61
+
62
+ Switching tabs is safe. Hiding a tab triggers the same flush, and whatever didn't fit goes out when the visitor
63
+ comes back.
64
+
65
+ If nothing fits, the batch is still sent, as a normal request instead of a keepalive one. That usually lands, but
66
+ it can be cancelled if the page closes right then.
67
+
68
+ You'll only hit the limit on pages that produce a lot of telemetry before the visitor leaves. Log less on those
69
+ pages rather than raising the limits.
70
+
54
71
  ## Documentation
55
72
 
56
73
  Full documentation on configuration, hooks, context, breadcrumbs, solution providers, and more is available
package/dist/browser.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
  let _flareapp_core = require("@flareapp/core");
4
4
 
5
5
  //#region src/browser.ts
@@ -10,12 +10,62 @@ var Flare = class extends _flareapp_core.Flare {
10
10
  name: "@flareapp/js",
11
11
  version: require_catchWindowErrors.CLIENT_VERSION
12
12
  });
13
+ this.setFramework({ name: _flareapp_core.FrameworkName.Js });
14
+ }
15
+ /** Held so a later disable can give the mutation slot back. */
16
+ removeTracingSubscription = null;
17
+ stopBreadcrumbs = null;
18
+ configure(config) {
19
+ const wasTracing = this.config.enableTracing;
20
+ const wasBreadcrumbs = this.config.enableBreadcrumbs;
21
+ super.configure(config);
22
+ const nowTracing = this.config.enableTracing;
23
+ const nowBreadcrumbs = this.config.enableBreadcrumbs;
24
+ if (!wasBreadcrumbs && nowBreadcrumbs) this.stopBreadcrumbs = require_catchWindowErrors.startBreadcrumbs({
25
+ config: () => this.config,
26
+ record: (type, attributes, startTimeUnixNano) => this.addBreadcrumb(type, attributes, startTimeUnixNano)
27
+ });
28
+ else if (wasBreadcrumbs && !nowBreadcrumbs) {
29
+ this.stopBreadcrumbs?.();
30
+ this.stopBreadcrumbs = null;
31
+ }
32
+ if (!wasTracing && nowTracing) {
33
+ this.removeTracingSubscription = require_catchWindowErrors.withRequestPatches(() => require_catchWindowErrors.traceRequests(this, require_catchWindowErrors.browserUrlContext()));
34
+ require_catchWindowErrors.startBrowserTracing(this);
35
+ } else if (wasTracing && !nowTracing) {
36
+ require_catchWindowErrors.stopBrowserTracing();
37
+ this.removeTracingSubscription?.();
38
+ this.removeTracingSubscription = null;
39
+ }
40
+ return this;
13
41
  }
14
42
  };
15
43
 
16
44
  //#endregion
17
45
  exports.BrowserFlushScheduler = require_catchWindowErrors.BrowserFlushScheduler;
46
+ Object.defineProperty(exports, 'BrowserSpanType', {
47
+ enumerable: true,
48
+ get: function () {
49
+ return _flareapp_core.BrowserSpanType;
50
+ }
51
+ });
18
52
  exports.FetchFileReader = require_catchWindowErrors.FetchFileReader;
19
53
  exports.Flare = Flare;
54
+ exports.absoluteHref = require_catchWindowErrors.absoluteHref;
55
+ exports.absoluteUrl = require_catchWindowErrors.absoluteUrl;
56
+ exports.activeComponentRoot = require_catchWindowErrors.activeComponentRoot;
20
57
  exports.catchWindowErrors = require_catchWindowErrors.catchWindowErrors;
21
- exports.collectBrowser = require_catchWindowErrors.collectBrowser;
58
+ exports.collectBrowser = require_catchWindowErrors.collectBrowser;
59
+ exports.createFlareResolver = require_catchWindowErrors.createFlareResolver;
60
+ exports.currentHref = require_catchWindowErrors.currentHref;
61
+ exports.currentPath = require_catchWindowErrors.currentPath;
62
+ exports.instrumentOnce = require_catchWindowErrors.instrumentOnce;
63
+ exports.insulate = require_catchWindowErrors.insulate;
64
+ exports.nowNano = require_catchWindowErrors.nowNano;
65
+ exports.recordComponentSpan = require_catchWindowErrors.recordComponentSpan;
66
+ exports.registerNavigationSource = require_catchWindowErrors.registerNavigationSource;
67
+ exports.reserveSpanId = require_catchWindowErrors.reserveSpanId;
68
+ exports.resolveComponentParent = require_catchWindowErrors.resolveComponentParent;
69
+ exports.resolveHref = require_catchWindowErrors.resolveHref;
70
+ exports.routeName = require_catchWindowErrors.routeName;
71
+ exports.safeInvoke = require_catchWindowErrors.safeInvoke;
@@ -1,9 +1,13 @@
1
- import { i as catchWindowErrors, n as FetchFileReader, r as collectBrowser, t as BrowserFlushScheduler } from "./BrowserFlushScheduler-CR7L8-z6.cjs";
2
- import { Api, ContextCollector, FileReader, Flare as Flare$1, ScopeProvider } from "@flareapp/core";
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-TMgJEZ7G.cjs";
2
+ import { Api, Config, ContextCollector, FileReader, Flare as Flare$1, ScopeProvider } from "@flareapp/core";
3
3
 
4
4
  //#region src/browser.d.ts
5
5
  declare class Flare extends Flare$1 {
6
6
  constructor(api?: Api, contextCollector?: ContextCollector, fileReader?: FileReader, scopeProvider?: ScopeProvider);
7
+ /** Held so a later disable can give the mutation slot back. */
8
+ private removeTracingSubscription;
9
+ private stopBreadcrumbs;
10
+ configure(config: Partial<Config>): this;
7
11
  }
8
12
  //#endregion
9
- export { BrowserFlushScheduler, FetchFileReader, Flare, catchWindowErrors, collectBrowser };
13
+ 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 };
@@ -1,9 +1,13 @@
1
- import { i as catchWindowErrors, n as FetchFileReader, r as collectBrowser, t as BrowserFlushScheduler } from "./BrowserFlushScheduler-CZiDvxtf.mjs";
2
- import { Api, ContextCollector, FileReader, Flare as Flare$1, ScopeProvider } from "@flareapp/core";
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-7-nEycOc.mjs";
2
+ import { Api, Config, ContextCollector, FileReader, Flare as Flare$1, ScopeProvider } from "@flareapp/core";
3
3
 
4
4
  //#region src/browser.d.ts
5
5
  declare class Flare extends Flare$1 {
6
6
  constructor(api?: Api, contextCollector?: ContextCollector, fileReader?: FileReader, scopeProvider?: ScopeProvider);
7
+ /** Held so a later disable can give the mutation slot back. */
8
+ private removeTracingSubscription;
9
+ private stopBreadcrumbs;
10
+ configure(config: Partial<Config>): this;
7
11
  }
8
12
  //#endregion
9
- export { BrowserFlushScheduler, FetchFileReader, Flare, catchWindowErrors, collectBrowser };
13
+ 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 };
package/dist/browser.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { a as BrowserFlushScheduler, i as collectBrowser, n as CLIENT_VERSION, r as FetchFileReader, t as catchWindowErrors } from "./catchWindowErrors-CSc-dC37.mjs";
2
- import { Api, Flare as Flare$1, GlobalScopeProvider } from "@flareapp/core";
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-C0gSVGiF.mjs";
2
+ import { Api, Flare as Flare$1, FrameworkName, GlobalScopeProvider } from "@flareapp/core";
3
3
 
4
4
  //#region src/browser.ts
5
5
  var Flare = class extends Flare$1 {
@@ -9,8 +9,36 @@ var Flare = class extends Flare$1 {
9
9
  name: "@flareapp/js",
10
10
  version: CLIENT_VERSION
11
11
  });
12
+ this.setFramework({ name: FrameworkName.Js });
13
+ }
14
+ /** Held so a later disable can give the mutation slot back. */
15
+ removeTracingSubscription = null;
16
+ stopBreadcrumbs = null;
17
+ configure(config) {
18
+ const wasTracing = this.config.enableTracing;
19
+ const wasBreadcrumbs = this.config.enableBreadcrumbs;
20
+ super.configure(config);
21
+ const nowTracing = this.config.enableTracing;
22
+ const nowBreadcrumbs = this.config.enableBreadcrumbs;
23
+ if (!wasBreadcrumbs && nowBreadcrumbs) this.stopBreadcrumbs = startBreadcrumbs({
24
+ config: () => this.config,
25
+ record: (type, attributes, startTimeUnixNano) => this.addBreadcrumb(type, attributes, startTimeUnixNano)
26
+ });
27
+ else if (wasBreadcrumbs && !nowBreadcrumbs) {
28
+ this.stopBreadcrumbs?.();
29
+ this.stopBreadcrumbs = null;
30
+ }
31
+ if (!wasTracing && nowTracing) {
32
+ this.removeTracingSubscription = withRequestPatches(() => traceRequests(this, browserUrlContext()));
33
+ startBrowserTracing(this);
34
+ } else if (wasTracing && !nowTracing) {
35
+ stopBrowserTracing();
36
+ this.removeTracingSubscription?.();
37
+ this.removeTracingSubscription = null;
38
+ }
39
+ return this;
12
40
  }
13
41
  };
14
42
 
15
43
  //#endregion
16
- export { BrowserFlushScheduler, FetchFileReader, Flare, catchWindowErrors, collectBrowser };
44
+ export { BrowserFlushScheduler, BrowserSpanType, FetchFileReader, Flare, absoluteHref, absoluteUrl, activeComponentRoot, catchWindowErrors, collectBrowser, createFlareResolver, currentHref, currentPath, instrumentOnce, insulate, nowNano, recordComponentSpan, registerNavigationSource, reserveSpanId, resolveComponentParent, resolveHref, routeName, safeInvoke };