@flareapp/node 0.1.1 → 0.2.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 +20 -2
- package/dist/index.cjs +16 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +12 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# @flareapp/node
|
|
2
2
|
|
|
3
3
|
Node.js SDK for [flareapp.io](https://flareapp.io). Capture uncaught
|
|
4
|
-
exceptions, unhandled rejections,
|
|
5
|
-
your Node servers. Per-request context isolation via
|
|
4
|
+
exceptions, unhandled rejections, explicit `flare.report(err)` calls, and
|
|
5
|
+
structured logs in your Node servers. Per-request context isolation via
|
|
6
|
+
AsyncLocalStorage.
|
|
6
7
|
|
|
7
8
|
> **Status: unstable (0.x).** This package is pre-1.0 and its API may change
|
|
8
9
|
> between minor releases. Pin an exact version in production
|
|
@@ -28,6 +29,23 @@ flare.light('your-flare-api-key');
|
|
|
28
29
|
That's it. Crashes and unhandled rejections are reported automatically (the
|
|
29
30
|
default behavior is to report, flush, and exit with code 1).
|
|
30
31
|
|
|
32
|
+
## Logging
|
|
33
|
+
|
|
34
|
+
Beyond errors, the SDK can send structured logs. Logs are opt-in: enable them
|
|
35
|
+
with `enableLogs`, then call any of the eight syslog levels (`debug`, `info`,
|
|
36
|
+
`notice`, `warning`, `error`, `critical`, `alert`, `emergency`).
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
flare.configure({ enableLogs: true });
|
|
40
|
+
|
|
41
|
+
flare.logger.info('Order processed', { orderId: order.id, total: order.total });
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Logs are buffered and batched, and flushed on `beforeExit`. A log recorded
|
|
45
|
+
inside a `runWithContext` scope carries that request's context. `beforeExit`
|
|
46
|
+
does not fire on `SIGTERM` or `process.exit()`, so call `flare.flush()` during
|
|
47
|
+
graceful shutdown to drain buffered logs.
|
|
48
|
+
|
|
31
49
|
## Per-request context
|
|
32
50
|
|
|
33
51
|
In an HTTP server, wrap each request handler with `runWithContext` so the
|
package/dist/index.cjs
CHANGED
|
@@ -354,6 +354,14 @@ function makeNodeContextCollector(provider, getOptions) {
|
|
|
354
354
|
};
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/logging/NodeFlushScheduler.ts
|
|
359
|
+
var NodeFlushScheduler = class {
|
|
360
|
+
register(flush) {
|
|
361
|
+
process.on("beforeExit", () => flush());
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
|
|
357
365
|
//#endregion
|
|
358
366
|
//#region src/process/fatal.ts
|
|
359
367
|
function buildFatalCallbacks(flare, getOpts, exit = process.exit.bind(process)) {
|
|
@@ -613,7 +621,7 @@ function isLocalFileUrl(url) {
|
|
|
613
621
|
//#endregion
|
|
614
622
|
//#region src/Flare.ts
|
|
615
623
|
const NODE_SDK_NAME = "@flareapp/node";
|
|
616
|
-
const NODE_SDK_VERSION = typeof process !== "undefined" && true ? "0.
|
|
624
|
+
const NODE_SDK_VERSION = typeof process !== "undefined" && true ? "0.2.0" : "?";
|
|
617
625
|
/**
|
|
618
626
|
* Strip the `g` and `y` flags from a user-supplied regex.
|
|
619
627
|
*
|
|
@@ -668,7 +676,7 @@ var NodeFlare = class extends _flareapp_core.Flare {
|
|
|
668
676
|
constructor() {
|
|
669
677
|
const scopeProvider = new AsyncLocalStorageScopeProvider();
|
|
670
678
|
const collector = makeNodeContextCollector(scopeProvider, () => this.nodeOptions);
|
|
671
|
-
super(new _flareapp_core.Api(), collector, new DiskFileReader(), scopeProvider);
|
|
679
|
+
super(new _flareapp_core.Api(), collector, new DiskFileReader(), scopeProvider, new NodeFlushScheduler());
|
|
672
680
|
this.nodeScopeProvider = scopeProvider;
|
|
673
681
|
this.setSdkInfo({
|
|
674
682
|
name: NODE_SDK_NAME,
|
|
@@ -799,6 +807,12 @@ Object.defineProperty(exports, 'GlobalScopeProvider', {
|
|
|
799
807
|
return _flareapp_core.GlobalScopeProvider;
|
|
800
808
|
}
|
|
801
809
|
});
|
|
810
|
+
Object.defineProperty(exports, 'Logger', {
|
|
811
|
+
enumerable: true,
|
|
812
|
+
get: function () {
|
|
813
|
+
return _flareapp_core.Logger;
|
|
814
|
+
}
|
|
815
|
+
});
|
|
802
816
|
exports.NodeFlare = NodeFlare;
|
|
803
817
|
exports.NodeScope = NodeScope;
|
|
804
818
|
Object.defineProperty(exports, 'NullFileReader', {
|
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, Framework, GlobalScopeProvider, Glow, 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, convertToError, redactUrlQuery, resolveDenylist } from "@flareapp/core";
|
|
2
2
|
|
|
3
3
|
//#region src/types.d.ts
|
|
4
4
|
type RequestContext = {
|
|
@@ -135,4 +135,4 @@ declare class NodeFlare extends Flare$1 {
|
|
|
135
135
|
//#region src/index.d.ts
|
|
136
136
|
declare const flare: NodeFlare;
|
|
137
137
|
//#endregion
|
|
138
|
-
export { type AttributeValue, type Attributes, type Config, type ContextCollector, DEFAULT_URL_DENYLIST, type EntryPointHandler, type FatalMode, type FileReader, Flare, type Framework, GlobalScopeProvider, type Glow, type MessageLevel, NodeFlare, type NodeOptions, NodeScope, NullFileReader, type OverriddenGrouping, type Report, type RequestContext, Scope, type ScopeProvider, type SdkInfo, type SpanEvent, type StackFrame, type User, convertToError, flare, redactUrlQuery, resolveDenylist };
|
|
138
|
+
export { type AttributeValue, type Attributes, type Config, type ContextCollector, DEFAULT_URL_DENYLIST, type EntryPointHandler, type FatalMode, type FileReader, Flare, type FlushFn, type FlushScheduler, type Framework, GlobalScopeProvider, type Glow, Logger, type MessageLevel, NodeFlare, type NodeOptions, NodeScope, NullFileReader, type OverriddenGrouping, type Report, type RequestContext, Scope, type ScopeProvider, type SdkInfo, type SpanEvent, type StackFrame, type User, convertToError, flare, redactUrlQuery, resolveDenylist };
|
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, Framework, GlobalScopeProvider, Glow, 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, convertToError, redactUrlQuery, resolveDenylist } from "@flareapp/core";
|
|
2
2
|
|
|
3
3
|
//#region src/types.d.ts
|
|
4
4
|
type RequestContext = {
|
|
@@ -135,4 +135,4 @@ declare class NodeFlare extends Flare$1 {
|
|
|
135
135
|
//#region src/index.d.ts
|
|
136
136
|
declare const flare: NodeFlare;
|
|
137
137
|
//#endregion
|
|
138
|
-
export { type AttributeValue, type Attributes, type Config, type ContextCollector, DEFAULT_URL_DENYLIST, type EntryPointHandler, type FatalMode, type FileReader, Flare, type Framework, GlobalScopeProvider, type Glow, type MessageLevel, NodeFlare, type NodeOptions, NodeScope, NullFileReader, type OverriddenGrouping, type Report, type RequestContext, Scope, type ScopeProvider, type SdkInfo, type SpanEvent, type StackFrame, type User, convertToError, flare, redactUrlQuery, resolveDenylist };
|
|
138
|
+
export { type AttributeValue, type Attributes, type Config, type ContextCollector, DEFAULT_URL_DENYLIST, type EntryPointHandler, type FatalMode, type FileReader, Flare, type FlushFn, type FlushScheduler, type Framework, GlobalScopeProvider, type Glow, Logger, type MessageLevel, NodeFlare, type NodeOptions, NodeScope, NullFileReader, type OverriddenGrouping, type Report, type RequestContext, Scope, type ScopeProvider, type SdkInfo, type SpanEvent, type StackFrame, type User, convertToError, flare, redactUrlQuery, resolveDenylist };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Api, DEFAULT_URL_DENYLIST, DEFAULT_URL_DENYLIST as DEFAULT_URL_DENYLIST$1, Flare, Flare as Flare$1, GlobalScopeProvider, NullFileReader, Scope, Scope as Scope$1, convertToError, redactUrlQuery, redactUrlQuery as redactUrlQuery$1, resolveDenylist } from "@flareapp/core";
|
|
1
|
+
import { Api, DEFAULT_URL_DENYLIST, DEFAULT_URL_DENYLIST as DEFAULT_URL_DENYLIST$1, Flare, Flare as Flare$1, GlobalScopeProvider, Logger, NullFileReader, Scope, Scope as Scope$1, convertToError, redactUrlQuery, redactUrlQuery as redactUrlQuery$1, resolveDenylist } from "@flareapp/core";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
@@ -325,6 +325,14 @@ function makeNodeContextCollector(provider, getOptions) {
|
|
|
325
325
|
};
|
|
326
326
|
}
|
|
327
327
|
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/logging/NodeFlushScheduler.ts
|
|
330
|
+
var NodeFlushScheduler = class {
|
|
331
|
+
register(flush) {
|
|
332
|
+
process.on("beforeExit", () => flush());
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
|
|
328
336
|
//#endregion
|
|
329
337
|
//#region src/process/fatal.ts
|
|
330
338
|
function buildFatalCallbacks(flare, getOpts, exit = process.exit.bind(process)) {
|
|
@@ -584,7 +592,7 @@ function isLocalFileUrl(url) {
|
|
|
584
592
|
//#endregion
|
|
585
593
|
//#region src/Flare.ts
|
|
586
594
|
const NODE_SDK_NAME = "@flareapp/node";
|
|
587
|
-
const NODE_SDK_VERSION = typeof process !== "undefined" && true ? "0.
|
|
595
|
+
const NODE_SDK_VERSION = typeof process !== "undefined" && true ? "0.2.0" : "?";
|
|
588
596
|
/**
|
|
589
597
|
* Strip the `g` and `y` flags from a user-supplied regex.
|
|
590
598
|
*
|
|
@@ -639,7 +647,7 @@ var NodeFlare = class extends Flare$1 {
|
|
|
639
647
|
constructor() {
|
|
640
648
|
const scopeProvider = new AsyncLocalStorageScopeProvider();
|
|
641
649
|
const collector = makeNodeContextCollector(scopeProvider, () => this.nodeOptions);
|
|
642
|
-
super(new Api(), collector, new DiskFileReader(), scopeProvider);
|
|
650
|
+
super(new Api(), collector, new DiskFileReader(), scopeProvider, new NodeFlushScheduler());
|
|
643
651
|
this.nodeScopeProvider = scopeProvider;
|
|
644
652
|
this.setSdkInfo({
|
|
645
653
|
name: NODE_SDK_NAME,
|
|
@@ -752,4 +760,4 @@ var NodeFlare = class extends Flare$1 {
|
|
|
752
760
|
const flare = new NodeFlare();
|
|
753
761
|
|
|
754
762
|
//#endregion
|
|
755
|
-
export { DEFAULT_URL_DENYLIST, Flare, GlobalScopeProvider, NodeFlare, NodeScope, NullFileReader, Scope, convertToError, flare, redactUrlQuery, resolveDenylist };
|
|
763
|
+
export { DEFAULT_URL_DENYLIST, Flare, GlobalScopeProvider, Logger, NodeFlare, NodeScope, NullFileReader, Scope, convertToError, flare, redactUrlQuery, resolveDenylist };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flareapp/node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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.
|
|
47
|
+
"@flareapp/core": "2.3.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"tsdown": "^0.20.3",
|