@kenkaiiii/error-mom 0.3.3 → 0.3.5

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
@@ -1,17 +1,124 @@
1
1
  # @kenkaiiii/error-mom
2
2
 
3
- Automatic browser and Node.js error capture for a self-hosted Error Mom deployment.
3
+ Automatic browser and Node.js error capture for a self-hosted [Error Mom](https://github.com/KenKaiii/error-mom) deployment.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @kenkaiiii/error-mom
9
+ ```
10
+
11
+ Create a project and generate framework-specific setup with the Error Mom CLI:
12
+
13
+ ```bash
14
+ npm install --global error-mom
15
+ error-mom login https://errors.example.com --token "$ERROR_MOM_ADMIN_TOKEN"
16
+ error-mom init
17
+ ```
18
+
19
+ `error-mom init` detects your framework and prints the exact wiring step for its official error hook. The generated project key is write-only and safe to ship; the admin token must stay private.
20
+
21
+ ## Browser setup
4
22
 
5
23
  ```ts
6
24
  import { initErrorMom } from "@kenkaiiii/error-mom";
7
25
 
8
- initErrorMom({
26
+ export const errorMom = initErrorMom({
9
27
  server: "https://errors.example.com",
10
28
  projectKey: "em_ingest_...",
11
- release: "1.0.0",
29
+ environment: import.meta.env.MODE,
30
+ release: import.meta.env.VITE_APP_VERSION,
31
+ });
32
+ ```
33
+
34
+ The browser entry point captures uncaught errors, unhandled rejections, `console.error`, failed requests, and up to 50 preceding breadcrumbs. Failed sends queue in local storage and retry without blocking the app.
35
+
36
+ ## Node.js setup
37
+
38
+ ```ts
39
+ import { initErrorMom } from "@kenkaiiii/error-mom/node";
40
+
41
+ export const errorMom = initErrorMom({
42
+ server: process.env.ERROR_MOM_SERVER!,
43
+ projectKey: process.env.ERROR_MOM_PROJECT_KEY!,
44
+ environment: process.env.NODE_ENV,
45
+ release: process.env.APP_VERSION,
46
+ });
47
+ ```
48
+
49
+ The Node entry point captures uncaught errors, unhandled rejections, `console.error`, and failed requests. Events are written to a private JSONL spool under `~/.error-mom/spool` before upload so an outage or restart does not discard them.
50
+
51
+ Initialize the SDK separately in every process: browser UI, Electron main process, workers, sidecars, and server processes.
52
+
53
+ ## Capture handled errors
54
+
55
+ ```ts
56
+ try {
57
+ await exportVideo();
58
+ } catch (error) {
59
+ errorMom.captureError(error, {
60
+ culprit: "video.export",
61
+ tags: { job: "render" },
62
+ context: { videoId },
63
+ });
64
+ throw error;
65
+ }
66
+ ```
67
+
68
+ Wrap handlers that are caught by a framework, queue, webhook runner, or MCP host:
69
+
70
+ ```ts
71
+ export const handler = errorMom.wrap(runJob, {
72
+ culprit: "jobs.render-video",
12
73
  });
13
74
  ```
14
75
 
15
- Use `@kenkaiiii/error-mom/node` for Node.js. The browser adapter retries through local storage; the Node adapter writes a private JSONL spool before upload.
76
+ Add application breadcrumbs when they help explain a later failure:
77
+
78
+ ```ts
79
+ errorMom.addBreadcrumb({
80
+ category: "checkout",
81
+ level: "info",
82
+ message: "Payment submitted",
83
+ data: { provider: "stripe" },
84
+ });
85
+ ```
86
+
87
+ Use `await errorMom.flush()` before a controlled shutdown. Call `dispose()` during teardown to restore patched global handlers.
88
+
89
+ ## Options
90
+
91
+ | Option | Required | Description |
92
+ | ----------------------- | --------- | -------------------------------------------------------------------- |
93
+ | `server` | yes | Base URL of your Error Mom deployment. |
94
+ | `projectKey` | yes | Write-only project ingest key. Safe to include in shipped clients. |
95
+ | `environment` | no | Deployment environment; defaults to `production`. |
96
+ | `release` | no | App version used for regression detection and source maps. |
97
+ | `tags` | no | String tags attached to every event. |
98
+ | `installationId` | no | Optional anonymous installation identifier. Only its hash is stored. |
99
+ | `captureConsoleErrors` | no | Capture `console.error`; defaults to `true`. |
100
+ | `captureFailedRequests` | no | Capture failed requests; defaults to `true`. |
101
+ | `flushIntervalMs` | no | Retry interval; defaults to 5 seconds. |
102
+ | `maxQueueSize` | no | Browser default: 100. Node default: 1,000. |
103
+ | `spoolDirectory` | Node only | Override the Node JSONL spool directory. |
104
+
105
+ ## Automatic request capture
106
+
107
+ Network failures and HTTP 5xx responses are captured automatically. Errors from known AI providers are named and tagged by provider; provider 4xx responses are captured as well. Captured request failures include sanitized method, URL, status, provider, and retryability context.
108
+
109
+ ## Privacy and safety
110
+
111
+ Capture and upload failures never throw into the host application. Before sending, the SDK recursively scrubs secret-keyed fields, emails, query credentials, URL userinfo, Telegram bot tokens, Discord and Slack webhook credentials, and explicitly labeled credential path segments such as `/token/<value>` and `/api-key/<value>`. The collector repeats redaction before persistence.
112
+
113
+ ## Source maps and verification
114
+
115
+ For minified production builds, report a `release`, enable source maps, and upload them after the build:
116
+
117
+ ```bash
118
+ error-mom sourcemaps <build-directory> --release <app-version> --project <project-slug>
119
+ error-mom doctor --symbolication
120
+ ```
121
+
122
+ Source-map upload requires the private admin token. Ingest keys cannot upload or read data.
16
123
 
17
- See the repository README for framework setup, privacy controls, and deployment instructions.
124
+ See the [repository README](https://github.com/KenKaiii/error-mom#readme) for deployment, framework setup, dashboard, CLI, and MCP instructions.
@@ -3,7 +3,7 @@ import {
3
3
  redactStringCredentials
4
4
  } from "@kenkaiiii/error-mom-protocol";
5
5
  var SDK_NAME = "@kenkaiiii/error-mom";
6
- var SDK_VERSION = "0.3.3";
6
+ var SDK_VERSION = "0.3.5";
7
7
  var MAX_BREADCRUMBS = 50;
8
8
  var SECRET_KEY = /authorization|cookie|password|passwd|secret|token|api[-_]?key|session/i;
9
9
  function wrapFunction(capture, fn, context) {
@@ -156,6 +156,7 @@ function describeFailedRequest(method, url, status) {
156
156
  const relevant = status >= 500 || provider !== void 0 && status >= 400;
157
157
  if (!relevant) return void 0;
158
158
  const cleanUrl = redactString(url);
159
+ const retryable = status === 408 || status === 429 || status >= 500;
159
160
  const error = new Error(`${method} ${cleanUrl} returned ${status}`);
160
161
  if (provider) {
161
162
  const label = provider.charAt(0).toUpperCase() + provider.slice(1);
@@ -168,7 +169,11 @@ function describeFailedRequest(method, url, status) {
168
169
  tags: {
169
170
  statusCode: String(status),
170
171
  method,
172
+ retryable: String(retryable),
171
173
  ...provider ? { provider } : {}
174
+ },
175
+ context: {
176
+ request: { method, url: cleanUrl, status, retryable }
172
177
  }
173
178
  }
174
179
  };
package/dist/index.cjs CHANGED
@@ -27,7 +27,7 @@ module.exports = __toCommonJS(index_exports);
27
27
  // src/shared.ts
28
28
  var import_error_mom_protocol = require("@kenkaiiii/error-mom-protocol");
29
29
  var SDK_NAME = "@kenkaiiii/error-mom";
30
- var SDK_VERSION = "0.3.3";
30
+ var SDK_VERSION = "0.3.5";
31
31
  var MAX_BREADCRUMBS = 50;
32
32
  var SECRET_KEY = /authorization|cookie|password|passwd|secret|token|api[-_]?key|session/i;
33
33
  function wrapFunction(capture, fn, context) {
@@ -180,6 +180,7 @@ function describeFailedRequest(method, url, status) {
180
180
  const relevant = status >= 500 || provider !== void 0 && status >= 400;
181
181
  if (!relevant) return void 0;
182
182
  const cleanUrl = redactString(url);
183
+ const retryable = status === 408 || status === 429 || status >= 500;
183
184
  const error = new Error(`${method} ${cleanUrl} returned ${status}`);
184
185
  if (provider) {
185
186
  const label = provider.charAt(0).toUpperCase() + provider.slice(1);
@@ -192,7 +193,11 @@ function describeFailedRequest(method, url, status) {
192
193
  tags: {
193
194
  statusCode: String(status),
194
195
  method,
196
+ retryable: String(retryable),
195
197
  ...provider ? { provider } : {}
198
+ },
199
+ context: {
200
+ request: { method, url: cleanUrl, status, retryable }
196
201
  }
197
202
  }
198
203
  };
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  printable,
9
9
  redactString,
10
10
  wrapFunction
11
- } from "./chunk-UNG24UNX.js";
11
+ } from "./chunk-OWVVPGEQ.js";
12
12
 
13
13
  // src/index.ts
14
14
  var clients = /* @__PURE__ */ new Map();
package/dist/node.cjs CHANGED
@@ -32,7 +32,7 @@ var import_node_path = require("path");
32
32
  // src/shared.ts
33
33
  var import_error_mom_protocol = require("@kenkaiiii/error-mom-protocol");
34
34
  var SDK_NAME = "@kenkaiiii/error-mom";
35
- var SDK_VERSION = "0.3.3";
35
+ var SDK_VERSION = "0.3.5";
36
36
  var MAX_BREADCRUMBS = 50;
37
37
  var SECRET_KEY = /authorization|cookie|password|passwd|secret|token|api[-_]?key|session/i;
38
38
  function wrapFunction(capture, fn, context) {
@@ -185,6 +185,7 @@ function describeFailedRequest(method, url, status) {
185
185
  const relevant = status >= 500 || provider !== void 0 && status >= 400;
186
186
  if (!relevant) return void 0;
187
187
  const cleanUrl = redactString(url);
188
+ const retryable = status === 408 || status === 429 || status >= 500;
188
189
  const error = new Error(`${method} ${cleanUrl} returned ${status}`);
189
190
  if (provider) {
190
191
  const label = provider.charAt(0).toUpperCase() + provider.slice(1);
@@ -197,7 +198,11 @@ function describeFailedRequest(method, url, status) {
197
198
  tags: {
198
199
  statusCode: String(status),
199
200
  method,
201
+ retryable: String(retryable),
200
202
  ...provider ? { provider } : {}
203
+ },
204
+ context: {
205
+ request: { method, url: cleanUrl, status, retryable }
201
206
  }
202
207
  }
203
208
  };
package/dist/node.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  printable,
9
9
  redactString,
10
10
  wrapFunction
11
- } from "./chunk-UNG24UNX.js";
11
+ } from "./chunk-OWVVPGEQ.js";
12
12
 
13
13
  // src/node.ts
14
14
  import { createHash } from "crypto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenkaiiii/error-mom",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Automatic browser and Node.js error capture for self-hosted Error Mom",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -22,7 +22,7 @@
22
22
  "README.md"
23
23
  ],
24
24
  "dependencies": {
25
- "@kenkaiiii/error-mom-protocol": "0.1.1"
25
+ "@kenkaiiii/error-mom-protocol": "0.1.3"
26
26
  },
27
27
  "devDependencies": {
28
28
  "tsup": "^8.5.1",