@flareapp/node 0.4.0 → 0.6.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
@@ -67,9 +67,11 @@ http.createServer((req, res) => {
67
67
  When your authentication middleware resolves a user, attach it:
68
68
 
69
69
  ```ts
70
- flare.setUser({ id: user.id, email: user.email });
70
+ flare.setUser({ id: user.id, email: user.email, fullName: user.name });
71
71
  ```
72
72
 
73
+ Recognised fields: `id`, `email`, `fullName`, `ipAddress`. Extra keys are collected under `user.attributes`. `setUser` is scoped per request inside `runWithContext(...)`. Pass `null` to clear.
74
+
73
75
  You can also patch the request context after it was first set:
74
76
 
75
77
  ```ts
package/dist/index.cjs CHANGED
@@ -305,9 +305,10 @@ function collectProcessAttributes() {
305
305
  *
306
306
  * 1. **Process info** — runtime version, pid, hostname, etc. Always present.
307
307
  * 2. **Active request scope** — method, path/url (with query-string keys
308
- * redacted), headers (with the denylist applied), optional body, and
309
- * authenticated user. Present when `runWithContext(...)` is active;
310
- * falls back to the shared scope otherwise (no request attrs emitted then).
308
+ * redacted), headers (with the denylist applied), and optional body. Present
309
+ * when `runWithContext(...)` is active; falls back to the shared scope
310
+ * otherwise (no request attrs emitted then). User identity is no longer
311
+ * projected here: `Flare.setUser` writes it straight to `pendingAttributes`.
311
312
  *
312
313
  * Both `provider` and `getOptions` are passed in (not captured by reference to
313
314
  * concrete instances) so the closure stays decoupled from `NodeFlare`'s
@@ -323,8 +324,7 @@ function makeNodeContextCollector(provider, getOptions) {
323
324
  "flare.entry_point.type": "server",
324
325
  ...collectProcessAttributes()
325
326
  };
326
- const scope = provider.active();
327
- const { request } = scope;
327
+ const { request } = provider.active();
328
328
  if (request.method) attrs["http.request.method"] = request.method;
329
329
  if (request.path) {
330
330
  const queryStart = request.path.indexOf("?");
@@ -344,12 +344,6 @@ function makeNodeContextCollector(provider, getOptions) {
344
344
  const body = captureBody(request.body, contentType, opts);
345
345
  if (body !== null) attrs["http.request.body"] = body;
346
346
  }
347
- if (scope.user) {
348
- if (scope.user.id !== void 0) attrs["enduser.id"] = String(scope.user.id);
349
- if (scope.user.email !== void 0) attrs["enduser.email"] = scope.user.email;
350
- if (scope.user.username !== void 0) attrs["enduser.username"] = scope.user.username;
351
- if (scope.user.ipAddress !== void 0) attrs["client.address"] = scope.user.ipAddress;
352
- }
353
347
  return attrs;
354
348
  };
355
349
  }
@@ -482,7 +476,6 @@ var ProcessHandlerManager = class {
482
476
  //#region src/scope/NodeScope.ts
483
477
  var NodeScope = class extends _flareapp_core.Scope {
484
478
  request = {};
485
- user = null;
486
479
  };
487
480
 
488
481
  //#endregion
@@ -555,14 +548,6 @@ var AsyncLocalStorageScopeProvider = class {
555
548
  ...partial
556
549
  };
557
550
  }
558
- /**
559
- * Set the authenticated user on the current scope. Same in-scope vs
560
- * fallback semantics as `mergeContext`.
561
- */
562
- setUser(user) {
563
- const scope = this.als.getStore() ?? this.fallback;
564
- scope.user = user;
565
- }
566
551
  };
567
552
 
568
553
  //#endregion
@@ -621,7 +606,7 @@ function isLocalFileUrl(url) {
621
606
  //#endregion
622
607
  //#region src/Flare.ts
623
608
  const NODE_SDK_NAME = "@flareapp/node";
624
- const NODE_SDK_VERSION = typeof process !== "undefined" && true ? "0.4.0" : "?";
609
+ const NODE_SDK_VERSION = typeof process !== "undefined" && true ? "0.6.0" : "?";
625
610
  /**
626
611
  * Strip the `g` and `y` flags from a user-supplied regex.
627
612
  *
@@ -653,7 +638,7 @@ const DEFAULT_NODE_OPTIONS = {
653
638
  * Subclasses core's `Flare` and wires the Node-only seams in its constructor:
654
639
  *
655
640
  * - `AsyncLocalStorageScopeProvider` so each `runWithContext(...)` callback
656
- * gets its own `NodeScope` (glows, attributes, user, entry-point, request),
641
+ * gets its own `NodeScope` (glows, attributes, entry-point, request),
657
642
  * isolated from concurrent requests.
658
643
  * - `makeNodeContextCollector(...)` to project the current `NodeScope` and
659
644
  * process info into report attributes (http.request.*, url.path, etc).
@@ -663,7 +648,7 @@ const DEFAULT_NODE_OPTIONS = {
663
648
  * `unhandledRejection` listeners based on the current `NodeOptions`.
664
649
  *
665
650
  * Also adds Node-only API surface on top of core: `configureNode(...)`,
666
- * `runWithContext(...)`, `mergeContext(...)`, `setUser(...)`, `getContext()`,
651
+ * `runWithContext(...)`, `mergeContext(...)`, `getContext()`,
667
652
  * `removeProcessListeners()`. Inherited core methods (`light`, `configure`,
668
653
  * `addContext`, `glow`, etc.) return `this`, so chaining keeps the
669
654
  * `NodeFlare` type and `configureNode(...)` stays callable mid-chain.
@@ -754,15 +739,6 @@ var NodeFlare = class extends _flareapp_core.Flare {
754
739
  this.nodeScopeProvider.mergeContext(partial);
755
740
  }
756
741
  /**
757
- * Attach an authenticated user to the active scope. Inside a request scope
758
- * this is per-request; outside it lands on the fallback scope. The fields
759
- * are projected to OTel-style keys (`enduser.id`, `enduser.email`,
760
- * `enduser.username`, `client.address`) by the Node context collector.
761
- */
762
- setUser(user) {
763
- this.nodeScopeProvider.setUser(user);
764
- }
765
- /**
766
742
  * Returns the request scope when called inside `runWithContext(...)`, or
767
743
  * `null` outside. Intentionally returns `null` (not the fallback scope)
768
744
  * when no request is active, so callers can distinguish "we are inside a
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { AttributeValue, Attributes, Config, ContextCollector, DEFAULT_URL_DENYLIST, EntryPointHandler, FileReader, Flare, Flare as Flare$1, FlushFn, FlushScheduler, Framework, GlobalScopeProvider, Glow, Logger, MessageLevel, NullFileReader, OverriddenGrouping, Report, Scope, Scope as Scope$1, ScopeProvider, SdkInfo, SpanEvent, StackFrame, convertToError, redactUrlQuery, resolveDenylist } from "@flareapp/core";
1
+ import { AttributeValue, Attributes, Config, ContextCollector, DEFAULT_URL_DENYLIST, EntryPointHandler, FileReader, Flare, Flare as Flare$1, FlushFn, FlushScheduler, Framework, GlobalScopeProvider, Glow, Logger, MessageLevel, NullFileReader, OverriddenGrouping, Report, Scope, Scope as Scope$1, ScopeProvider, SdkInfo, SpanEvent, StackFrame, User, convertToError, redactUrlQuery, resolveDenylist } from "@flareapp/core";
2
2
 
3
3
  //#region src/types.d.ts
4
4
  type RequestContext = {
@@ -8,12 +8,6 @@ type RequestContext = {
8
8
  headers?: Record<string, string | string[] | undefined>;
9
9
  body?: unknown;
10
10
  };
11
- type User = {
12
- id?: string | number;
13
- email?: string;
14
- username?: string;
15
- ipAddress?: string;
16
- };
17
11
  type FatalMode = 'off' | 'report' | 'report-and-exit';
18
12
  type NodeOptions = {
19
13
  uncaughtExceptionMode?: FatalMode;
@@ -31,7 +25,6 @@ type NodeOptions = {
31
25
  //#region src/scope/NodeScope.d.ts
32
26
  declare class NodeScope extends Scope$1 {
33
27
  request: RequestContext;
34
- user: User | null;
35
28
  }
36
29
  //#endregion
37
30
  //#region src/Flare.d.ts
@@ -41,7 +34,7 @@ declare class NodeScope extends Scope$1 {
41
34
  * Subclasses core's `Flare` and wires the Node-only seams in its constructor:
42
35
  *
43
36
  * - `AsyncLocalStorageScopeProvider` so each `runWithContext(...)` callback
44
- * gets its own `NodeScope` (glows, attributes, user, entry-point, request),
37
+ * gets its own `NodeScope` (glows, attributes, entry-point, request),
45
38
  * isolated from concurrent requests.
46
39
  * - `makeNodeContextCollector(...)` to project the current `NodeScope` and
47
40
  * process info into report attributes (http.request.*, url.path, etc).
@@ -51,7 +44,7 @@ declare class NodeScope extends Scope$1 {
51
44
  * `unhandledRejection` listeners based on the current `NodeOptions`.
52
45
  *
53
46
  * Also adds Node-only API surface on top of core: `configureNode(...)`,
54
- * `runWithContext(...)`, `mergeContext(...)`, `setUser(...)`, `getContext()`,
47
+ * `runWithContext(...)`, `mergeContext(...)`, `getContext()`,
55
48
  * `removeProcessListeners()`. Inherited core methods (`light`, `configure`,
56
49
  * `addContext`, `glow`, etc.) return `this`, so chaining keeps the
57
50
  * `NodeFlare` type and `configureNode(...)` stays callable mid-chain.
@@ -107,13 +100,6 @@ declare class NodeFlare extends Flare$1 {
107
100
  * request scope but is NOT inherited by future `runWithContext(...)` calls.
108
101
  */
109
102
  mergeContext(partial: Partial<RequestContext>): void;
110
- /**
111
- * Attach an authenticated user to the active scope. Inside a request scope
112
- * this is per-request; outside it lands on the fallback scope. The fields
113
- * are projected to OTel-style keys (`enduser.id`, `enduser.email`,
114
- * `enduser.username`, `client.address`) by the Node context collector.
115
- */
116
- setUser(user: User | null): void;
117
103
  /**
118
104
  * Returns the request scope when called inside `runWithContext(...)`, or
119
105
  * `null` outside. Intentionally returns `null` (not the fallback scope)
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { AttributeValue, Attributes, Config, ContextCollector, DEFAULT_URL_DENYLIST, EntryPointHandler, FileReader, Flare, Flare as Flare$1, FlushFn, FlushScheduler, Framework, GlobalScopeProvider, Glow, Logger, MessageLevel, NullFileReader, OverriddenGrouping, Report, Scope, Scope as Scope$1, ScopeProvider, SdkInfo, SpanEvent, StackFrame, convertToError, redactUrlQuery, resolveDenylist } from "@flareapp/core";
1
+ import { AttributeValue, Attributes, Config, ContextCollector, DEFAULT_URL_DENYLIST, EntryPointHandler, FileReader, Flare, Flare as Flare$1, FlushFn, FlushScheduler, Framework, GlobalScopeProvider, Glow, Logger, MessageLevel, NullFileReader, OverriddenGrouping, Report, Scope, Scope as Scope$1, ScopeProvider, SdkInfo, SpanEvent, StackFrame, User, convertToError, redactUrlQuery, resolveDenylist } from "@flareapp/core";
2
2
 
3
3
  //#region src/types.d.ts
4
4
  type RequestContext = {
@@ -8,12 +8,6 @@ type RequestContext = {
8
8
  headers?: Record<string, string | string[] | undefined>;
9
9
  body?: unknown;
10
10
  };
11
- type User = {
12
- id?: string | number;
13
- email?: string;
14
- username?: string;
15
- ipAddress?: string;
16
- };
17
11
  type FatalMode = 'off' | 'report' | 'report-and-exit';
18
12
  type NodeOptions = {
19
13
  uncaughtExceptionMode?: FatalMode;
@@ -31,7 +25,6 @@ type NodeOptions = {
31
25
  //#region src/scope/NodeScope.d.ts
32
26
  declare class NodeScope extends Scope$1 {
33
27
  request: RequestContext;
34
- user: User | null;
35
28
  }
36
29
  //#endregion
37
30
  //#region src/Flare.d.ts
@@ -41,7 +34,7 @@ declare class NodeScope extends Scope$1 {
41
34
  * Subclasses core's `Flare` and wires the Node-only seams in its constructor:
42
35
  *
43
36
  * - `AsyncLocalStorageScopeProvider` so each `runWithContext(...)` callback
44
- * gets its own `NodeScope` (glows, attributes, user, entry-point, request),
37
+ * gets its own `NodeScope` (glows, attributes, entry-point, request),
45
38
  * isolated from concurrent requests.
46
39
  * - `makeNodeContextCollector(...)` to project the current `NodeScope` and
47
40
  * process info into report attributes (http.request.*, url.path, etc).
@@ -51,7 +44,7 @@ declare class NodeScope extends Scope$1 {
51
44
  * `unhandledRejection` listeners based on the current `NodeOptions`.
52
45
  *
53
46
  * Also adds Node-only API surface on top of core: `configureNode(...)`,
54
- * `runWithContext(...)`, `mergeContext(...)`, `setUser(...)`, `getContext()`,
47
+ * `runWithContext(...)`, `mergeContext(...)`, `getContext()`,
55
48
  * `removeProcessListeners()`. Inherited core methods (`light`, `configure`,
56
49
  * `addContext`, `glow`, etc.) return `this`, so chaining keeps the
57
50
  * `NodeFlare` type and `configureNode(...)` stays callable mid-chain.
@@ -107,13 +100,6 @@ declare class NodeFlare extends Flare$1 {
107
100
  * request scope but is NOT inherited by future `runWithContext(...)` calls.
108
101
  */
109
102
  mergeContext(partial: Partial<RequestContext>): void;
110
- /**
111
- * Attach an authenticated user to the active scope. Inside a request scope
112
- * this is per-request; outside it lands on the fallback scope. The fields
113
- * are projected to OTel-style keys (`enduser.id`, `enduser.email`,
114
- * `enduser.username`, `client.address`) by the Node context collector.
115
- */
116
- setUser(user: User | null): void;
117
103
  /**
118
104
  * Returns the request scope when called inside `runWithContext(...)`, or
119
105
  * `null` outside. Intentionally returns `null` (not the fallback scope)
package/dist/index.mjs CHANGED
@@ -276,9 +276,10 @@ function collectProcessAttributes() {
276
276
  *
277
277
  * 1. **Process info** — runtime version, pid, hostname, etc. Always present.
278
278
  * 2. **Active request scope** — method, path/url (with query-string keys
279
- * redacted), headers (with the denylist applied), optional body, and
280
- * authenticated user. Present when `runWithContext(...)` is active;
281
- * falls back to the shared scope otherwise (no request attrs emitted then).
279
+ * redacted), headers (with the denylist applied), and optional body. Present
280
+ * when `runWithContext(...)` is active; falls back to the shared scope
281
+ * otherwise (no request attrs emitted then). User identity is no longer
282
+ * projected here: `Flare.setUser` writes it straight to `pendingAttributes`.
282
283
  *
283
284
  * Both `provider` and `getOptions` are passed in (not captured by reference to
284
285
  * concrete instances) so the closure stays decoupled from `NodeFlare`'s
@@ -294,8 +295,7 @@ function makeNodeContextCollector(provider, getOptions) {
294
295
  "flare.entry_point.type": "server",
295
296
  ...collectProcessAttributes()
296
297
  };
297
- const scope = provider.active();
298
- const { request } = scope;
298
+ const { request } = provider.active();
299
299
  if (request.method) attrs["http.request.method"] = request.method;
300
300
  if (request.path) {
301
301
  const queryStart = request.path.indexOf("?");
@@ -315,12 +315,6 @@ function makeNodeContextCollector(provider, getOptions) {
315
315
  const body = captureBody(request.body, contentType, opts);
316
316
  if (body !== null) attrs["http.request.body"] = body;
317
317
  }
318
- if (scope.user) {
319
- if (scope.user.id !== void 0) attrs["enduser.id"] = String(scope.user.id);
320
- if (scope.user.email !== void 0) attrs["enduser.email"] = scope.user.email;
321
- if (scope.user.username !== void 0) attrs["enduser.username"] = scope.user.username;
322
- if (scope.user.ipAddress !== void 0) attrs["client.address"] = scope.user.ipAddress;
323
- }
324
318
  return attrs;
325
319
  };
326
320
  }
@@ -453,7 +447,6 @@ var ProcessHandlerManager = class {
453
447
  //#region src/scope/NodeScope.ts
454
448
  var NodeScope = class extends Scope$1 {
455
449
  request = {};
456
- user = null;
457
450
  };
458
451
 
459
452
  //#endregion
@@ -526,14 +519,6 @@ var AsyncLocalStorageScopeProvider = class {
526
519
  ...partial
527
520
  };
528
521
  }
529
- /**
530
- * Set the authenticated user on the current scope. Same in-scope vs
531
- * fallback semantics as `mergeContext`.
532
- */
533
- setUser(user) {
534
- const scope = this.als.getStore() ?? this.fallback;
535
- scope.user = user;
536
- }
537
522
  };
538
523
 
539
524
  //#endregion
@@ -592,7 +577,7 @@ function isLocalFileUrl(url) {
592
577
  //#endregion
593
578
  //#region src/Flare.ts
594
579
  const NODE_SDK_NAME = "@flareapp/node";
595
- const NODE_SDK_VERSION = typeof process !== "undefined" && true ? "0.4.0" : "?";
580
+ const NODE_SDK_VERSION = typeof process !== "undefined" && true ? "0.6.0" : "?";
596
581
  /**
597
582
  * Strip the `g` and `y` flags from a user-supplied regex.
598
583
  *
@@ -624,7 +609,7 @@ const DEFAULT_NODE_OPTIONS = {
624
609
  * Subclasses core's `Flare` and wires the Node-only seams in its constructor:
625
610
  *
626
611
  * - `AsyncLocalStorageScopeProvider` so each `runWithContext(...)` callback
627
- * gets its own `NodeScope` (glows, attributes, user, entry-point, request),
612
+ * gets its own `NodeScope` (glows, attributes, entry-point, request),
628
613
  * isolated from concurrent requests.
629
614
  * - `makeNodeContextCollector(...)` to project the current `NodeScope` and
630
615
  * process info into report attributes (http.request.*, url.path, etc).
@@ -634,7 +619,7 @@ const DEFAULT_NODE_OPTIONS = {
634
619
  * `unhandledRejection` listeners based on the current `NodeOptions`.
635
620
  *
636
621
  * Also adds Node-only API surface on top of core: `configureNode(...)`,
637
- * `runWithContext(...)`, `mergeContext(...)`, `setUser(...)`, `getContext()`,
622
+ * `runWithContext(...)`, `mergeContext(...)`, `getContext()`,
638
623
  * `removeProcessListeners()`. Inherited core methods (`light`, `configure`,
639
624
  * `addContext`, `glow`, etc.) return `this`, so chaining keeps the
640
625
  * `NodeFlare` type and `configureNode(...)` stays callable mid-chain.
@@ -725,15 +710,6 @@ var NodeFlare = class extends Flare$1 {
725
710
  this.nodeScopeProvider.mergeContext(partial);
726
711
  }
727
712
  /**
728
- * Attach an authenticated user to the active scope. Inside a request scope
729
- * this is per-request; outside it lands on the fallback scope. The fields
730
- * are projected to OTel-style keys (`enduser.id`, `enduser.email`,
731
- * `enduser.username`, `client.address`) by the Node context collector.
732
- */
733
- setUser(user) {
734
- this.nodeScopeProvider.setUser(user);
735
- }
736
- /**
737
713
  * Returns the request scope when called inside `runWithContext(...)`, or
738
714
  * `null` outside. Intentionally returns `null` (not the fallback scope)
739
715
  * when no request is active, so callers can distinguish "we are inside a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flareapp/node",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Node.js SDK for flareapp.io",
5
5
  "homepage": "https://flareapp.io",
6
6
  "bugs": {
@@ -44,7 +44,7 @@
44
44
  "release": "release-it"
45
45
  },
46
46
  "dependencies": {
47
- "@flareapp/core": "2.5.0"
47
+ "@flareapp/core": "2.6.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "tsdown": "^0.20.3",