@flareapp/node 0.7.0 → 0.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.d.cts CHANGED
@@ -32,22 +32,15 @@ declare class NodeScope extends Scope$1 {
32
32
  * Node.js-specific `Flare` singleton, exposed from `@flareapp/node` as `flare`.
33
33
  *
34
34
  * Subclasses core's `Flare` and wires the Node-only seams in its constructor:
35
- *
36
- * - `AsyncLocalStorageScopeProvider` so each `runWithContext(...)` callback
37
- * gets its own `NodeScope` (glows, attributes, entry-point, request),
35
+ * - `AsyncLocalStorageScopeProvider` so each `runWithContext(...)` callback gets its own `NodeScope`,
38
36
  * isolated from concurrent requests.
39
- * - `makeNodeContextCollector(...)` to project the current `NodeScope` and
40
- * process info into report attributes (http.request.*, url.path, etc).
41
- * - `DiskFileReader` to read source files for stack-trace snippets via
42
- * `node:fs/promises` instead of the browser's `fetch`.
43
- * - `ProcessHandlerManager` to attach/detach `uncaughtException` and
44
- * `unhandledRejection` listeners based on the current `NodeOptions`.
37
+ * - `makeNodeContextCollector(...)` turns the current `NodeScope` + process info into report attributes.
38
+ * - `DiskFileReader` reads source for stack-trace snippets via `node:fs/promises`, not `fetch`.
39
+ * - `ProcessHandlerManager` attaches/detaches the fatal process listeners per `NodeOptions`.
45
40
  *
46
- * Also adds Node-only API surface on top of core: `configureNode(...)`,
47
- * `runWithContext(...)`, `mergeContext(...)`, `getContext()`,
48
- * `removeProcessListeners()`. Inherited core methods (`light`, `configure`,
49
- * `addContext`, `glow`, etc.) return `this`, so chaining keeps the
50
- * `NodeFlare` type and `configureNode(...)` stays callable mid-chain.
41
+ * Adds Node-only API on top of core: `configureNode`, `runWithContext`, `mergeContext`, `getContext`,
42
+ * `removeProcessListeners`. Inherited core methods return `this`, so chaining keeps the `NodeFlare`
43
+ * type and `configureNode(...)` stays callable mid-chain.
51
44
  */
52
45
  declare class NodeFlare extends Flare$1 {
53
46
  private nodeOptions;
@@ -55,66 +48,27 @@ declare class NodeFlare extends Flare$1 {
55
48
  private nodeScopeProvider;
56
49
  private handlerManager;
57
50
  constructor();
58
- /**
59
- * Set the API key (and optional debug flag), then reconcile process
60
- * listeners with the current `nodeOptions`. Reconcile runs on EVERY call,
61
- * not just the first, so `light()` is the right escape hatch to re-attach
62
- * after `removeProcessListeners()`.
63
- */
51
+ /** Reconcile runs on every call, so `light()` re-attaches after `removeProcessListeners()`. */
64
52
  light(key?: string, debug?: boolean): this;
65
53
  /**
66
- * Merge Node-only options (fatal-handler modes, header/body redaction
67
- * config, shutdown timeout) into the active configuration. Safe to call
68
- * before or after `light()`:
69
- *
70
- * - Before `light()`: options are stored; listeners are attached when
71
- * `light()` runs.
72
- * - After `light()`: options are stored AND listeners are reconciled
73
- * immediately, so flipping a mode to `'off'` detaches the handler and
74
- * flipping it back to `'report'`/`'report-and-exit'` re-attaches.
75
- *
76
- * Regex options (`headerAllowlist`, `bodyAllowedContentTypes`,
77
- * `bodyKeyDenylist`) are passed through `sanitizeRegex` to strip stateful
78
- * `g`/`y` flags; without that, `RegExp.prototype.test` would skip matches
79
- * across keys.
54
+ * Safe before or after `light()`. Before, the listeners attach on `light()`; after, they reconcile
55
+ * immediately, so flipping a mode to `'off'` detaches and flipping it back re-attaches.
80
56
  */
81
57
  configureNode(partial: Partial<NodeOptions>): NodeFlare;
82
58
  /**
83
- * Run `fn` inside a fresh `NodeScope` carrying the supplied request
84
- * metadata. Inside `fn` (and any async work it awaits), `flare.glow(...)`,
85
- * `flare.addContext(...)`, `flare.setUser(...)`, and `flare.report(...)`
86
- * see a scope that is isolated from other concurrent requests.
87
- *
88
- * Mirrors a typical web-framework middleware: call once per request,
89
- * wrapping the request handler, and the SDK will attribute any error
90
- * reported inside the chain to the right request.
59
+ * Use as web-framework middleware, once per request around the handler. Inside `fn` and any async
60
+ * work it awaits, reports are attributed to that request rather than to a concurrent one.
91
61
  */
92
62
  runWithContext<T>(request: RequestContext, fn: () => T): T;
93
63
  /**
94
- * Patch the request metadata on the active scope after `runWithContext(...)`
95
- * has already started. Useful when fields become known partway through a
96
- * request (e.g., the resolved absolute URL after proxy headers are parsed).
97
- *
98
- * Outside any `runWithContext(...)` callback, this writes to the fallback
99
- * scope; the patch is visible to subsequent reports issued from outside a
100
- * request scope but is NOT inherited by future `runWithContext(...)` calls.
64
+ * For fields that only become known partway through a request, such as the absolute URL once proxy
65
+ * headers are parsed. Outside `runWithContext(...)` this writes to the fallback scope, which future
66
+ * `runWithContext(...)` calls do not inherit.
101
67
  */
102
68
  mergeContext(partial: Partial<RequestContext>): void;
103
- /**
104
- * Returns the request scope when called inside `runWithContext(...)`, or
105
- * `null` outside. Intentionally returns `null` (not the fallback scope)
106
- * when no request is active, so callers can distinguish "we are inside a
107
- * request" from "we are not". Primarily useful for debugging.
108
- */
69
+ /** Null (not the fallback scope) outside a request, so callers can tell the two apart. Debugging aid. */
109
70
  getContext(): NodeScope | null;
110
- /**
111
- * Detach the `uncaughtException` and `unhandledRejection` listeners
112
- * without changing `nodeOptions`. Intended for tests and for graceful
113
- * shutdown paths where you want to take ownership of process exit
114
- * yourself.
115
- *
116
- * Calling `light()` afterwards re-attaches based on the current options.
117
- */
71
+ /** Leaves `nodeOptions` alone, so a later `light()` re-attaches. For tests and graceful shutdown. */
118
72
  removeProcessListeners(): void;
119
73
  }
120
74
  //#endregion
package/dist/index.d.mts CHANGED
@@ -32,22 +32,15 @@ declare class NodeScope extends Scope$1 {
32
32
  * Node.js-specific `Flare` singleton, exposed from `@flareapp/node` as `flare`.
33
33
  *
34
34
  * Subclasses core's `Flare` and wires the Node-only seams in its constructor:
35
- *
36
- * - `AsyncLocalStorageScopeProvider` so each `runWithContext(...)` callback
37
- * gets its own `NodeScope` (glows, attributes, entry-point, request),
35
+ * - `AsyncLocalStorageScopeProvider` so each `runWithContext(...)` callback gets its own `NodeScope`,
38
36
  * isolated from concurrent requests.
39
- * - `makeNodeContextCollector(...)` to project the current `NodeScope` and
40
- * process info into report attributes (http.request.*, url.path, etc).
41
- * - `DiskFileReader` to read source files for stack-trace snippets via
42
- * `node:fs/promises` instead of the browser's `fetch`.
43
- * - `ProcessHandlerManager` to attach/detach `uncaughtException` and
44
- * `unhandledRejection` listeners based on the current `NodeOptions`.
37
+ * - `makeNodeContextCollector(...)` turns the current `NodeScope` + process info into report attributes.
38
+ * - `DiskFileReader` reads source for stack-trace snippets via `node:fs/promises`, not `fetch`.
39
+ * - `ProcessHandlerManager` attaches/detaches the fatal process listeners per `NodeOptions`.
45
40
  *
46
- * Also adds Node-only API surface on top of core: `configureNode(...)`,
47
- * `runWithContext(...)`, `mergeContext(...)`, `getContext()`,
48
- * `removeProcessListeners()`. Inherited core methods (`light`, `configure`,
49
- * `addContext`, `glow`, etc.) return `this`, so chaining keeps the
50
- * `NodeFlare` type and `configureNode(...)` stays callable mid-chain.
41
+ * Adds Node-only API on top of core: `configureNode`, `runWithContext`, `mergeContext`, `getContext`,
42
+ * `removeProcessListeners`. Inherited core methods return `this`, so chaining keeps the `NodeFlare`
43
+ * type and `configureNode(...)` stays callable mid-chain.
51
44
  */
52
45
  declare class NodeFlare extends Flare$1 {
53
46
  private nodeOptions;
@@ -55,66 +48,27 @@ declare class NodeFlare extends Flare$1 {
55
48
  private nodeScopeProvider;
56
49
  private handlerManager;
57
50
  constructor();
58
- /**
59
- * Set the API key (and optional debug flag), then reconcile process
60
- * listeners with the current `nodeOptions`. Reconcile runs on EVERY call,
61
- * not just the first, so `light()` is the right escape hatch to re-attach
62
- * after `removeProcessListeners()`.
63
- */
51
+ /** Reconcile runs on every call, so `light()` re-attaches after `removeProcessListeners()`. */
64
52
  light(key?: string, debug?: boolean): this;
65
53
  /**
66
- * Merge Node-only options (fatal-handler modes, header/body redaction
67
- * config, shutdown timeout) into the active configuration. Safe to call
68
- * before or after `light()`:
69
- *
70
- * - Before `light()`: options are stored; listeners are attached when
71
- * `light()` runs.
72
- * - After `light()`: options are stored AND listeners are reconciled
73
- * immediately, so flipping a mode to `'off'` detaches the handler and
74
- * flipping it back to `'report'`/`'report-and-exit'` re-attaches.
75
- *
76
- * Regex options (`headerAllowlist`, `bodyAllowedContentTypes`,
77
- * `bodyKeyDenylist`) are passed through `sanitizeRegex` to strip stateful
78
- * `g`/`y` flags; without that, `RegExp.prototype.test` would skip matches
79
- * across keys.
54
+ * Safe before or after `light()`. Before, the listeners attach on `light()`; after, they reconcile
55
+ * immediately, so flipping a mode to `'off'` detaches and flipping it back re-attaches.
80
56
  */
81
57
  configureNode(partial: Partial<NodeOptions>): NodeFlare;
82
58
  /**
83
- * Run `fn` inside a fresh `NodeScope` carrying the supplied request
84
- * metadata. Inside `fn` (and any async work it awaits), `flare.glow(...)`,
85
- * `flare.addContext(...)`, `flare.setUser(...)`, and `flare.report(...)`
86
- * see a scope that is isolated from other concurrent requests.
87
- *
88
- * Mirrors a typical web-framework middleware: call once per request,
89
- * wrapping the request handler, and the SDK will attribute any error
90
- * reported inside the chain to the right request.
59
+ * Use as web-framework middleware, once per request around the handler. Inside `fn` and any async
60
+ * work it awaits, reports are attributed to that request rather than to a concurrent one.
91
61
  */
92
62
  runWithContext<T>(request: RequestContext, fn: () => T): T;
93
63
  /**
94
- * Patch the request metadata on the active scope after `runWithContext(...)`
95
- * has already started. Useful when fields become known partway through a
96
- * request (e.g., the resolved absolute URL after proxy headers are parsed).
97
- *
98
- * Outside any `runWithContext(...)` callback, this writes to the fallback
99
- * scope; the patch is visible to subsequent reports issued from outside a
100
- * request scope but is NOT inherited by future `runWithContext(...)` calls.
64
+ * For fields that only become known partway through a request, such as the absolute URL once proxy
65
+ * headers are parsed. Outside `runWithContext(...)` this writes to the fallback scope, which future
66
+ * `runWithContext(...)` calls do not inherit.
101
67
  */
102
68
  mergeContext(partial: Partial<RequestContext>): void;
103
- /**
104
- * Returns the request scope when called inside `runWithContext(...)`, or
105
- * `null` outside. Intentionally returns `null` (not the fallback scope)
106
- * when no request is active, so callers can distinguish "we are inside a
107
- * request" from "we are not". Primarily useful for debugging.
108
- */
69
+ /** Null (not the fallback scope) outside a request, so callers can tell the two apart. Debugging aid. */
109
70
  getContext(): NodeScope | null;
110
- /**
111
- * Detach the `uncaughtException` and `unhandledRejection` listeners
112
- * without changing `nodeOptions`. Intended for tests and for graceful
113
- * shutdown paths where you want to take ownership of process exit
114
- * yourself.
115
- *
116
- * Calling `light()` afterwards re-attaches based on the current options.
117
- */
71
+ /** Leaves `nodeOptions` alone, so a later `light()` re-attaches. For tests and graceful shutdown. */
118
72
  removeProcessListeners(): void;
119
73
  }
120
74
  //#endregion