@futurewindai/wotchi 0.1.0-beta.1 → 0.1.0-beta.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 +182 -56
- package/SECURITY.md +2 -2
- package/dist/cjs/core/client.js +380 -21
- package/dist/cjs/core/config.js +177 -18
- package/dist/cjs/core/diagnostics.js +12 -1
- package/dist/cjs/core/group-store.js +15 -1
- package/dist/cjs/core/incident-builder.js +18 -0
- package/dist/cjs/core/incident-policy.js +2 -7
- package/dist/cjs/core/limits.js +13 -0
- package/dist/cjs/core/normalize.js +10 -5
- package/dist/cjs/core/notification-queue.js +20 -3
- package/dist/cjs/core/redact.js +83 -8
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/integrations/express/error-handler.js +4 -1
- package/dist/cjs/integrations/express/index.js +4 -1
- package/dist/cjs/integrations/express/state.js +30 -0
- package/dist/cjs/integrations/express/status-observer.js +86 -0
- package/dist/cjs/integrations/nest/exception-filter.js +9 -1
- package/dist/cjs/integrations/nest/index.js +3 -1
- package/dist/cjs/integrations/nest/register.js +9 -0
- package/dist/cjs/integrations/request-context.js +83 -1
- package/dist/cjs/notifiers/alert-payload.js +20 -0
- package/dist/cjs/notifiers/console.js +100 -10
- package/dist/cjs/notifiers/telegram-format.js +75 -5
- package/dist/cjs/notifiers/webhook-http.js +394 -0
- package/dist/cjs/notifiers/webhook.js +28 -0
- package/dist/esm/core/client.js +380 -21
- package/dist/esm/core/config.js +177 -18
- package/dist/esm/core/diagnostics.js +12 -1
- package/dist/esm/core/group-store.js +15 -1
- package/dist/esm/core/incident-builder.js +18 -0
- package/dist/esm/core/incident-policy.js +2 -7
- package/dist/esm/core/limits.js +10 -0
- package/dist/esm/core/normalize.js +10 -5
- package/dist/esm/core/notification-queue.js +20 -3
- package/dist/esm/core/redact.js +83 -8
- package/dist/esm/index.js +2 -1
- package/dist/esm/integrations/express/error-handler.js +4 -1
- package/dist/esm/integrations/express/index.js +2 -1
- package/dist/esm/integrations/express/state.js +26 -0
- package/dist/esm/integrations/express/status-observer.js +83 -0
- package/dist/esm/integrations/nest/exception-filter.js +9 -1
- package/dist/esm/integrations/nest/index.js +2 -2
- package/dist/esm/integrations/nest/register.js +8 -0
- package/dist/esm/integrations/request-context.js +83 -1
- package/dist/esm/notifiers/alert-payload.js +16 -0
- package/dist/esm/notifiers/console.js +100 -10
- package/dist/esm/notifiers/telegram-format.js +75 -5
- package/dist/esm/notifiers/webhook-http.js +387 -0
- package/dist/esm/notifiers/webhook.js +24 -0
- package/dist/types/core/config.d.ts +7 -1
- package/dist/types/core/diagnostics.d.ts +5 -1
- package/dist/types/core/limits.d.ts +10 -0
- package/dist/types/core/notification-queue.d.ts +5 -1
- package/dist/types/core/types.d.ts +97 -1
- package/dist/types/index.d.ts +4 -2
- package/dist/types/integrations/express/index.d.ts +4 -2
- package/dist/types/integrations/express/state.d.ts +2 -0
- package/dist/types/integrations/express/status-observer.d.ts +11 -0
- package/dist/types/integrations/nest/index.d.ts +4 -3
- package/dist/types/integrations/nest/register.d.ts +3 -0
- package/dist/types/integrations/request-context.d.ts +3 -0
- package/dist/types/notifiers/alert-payload.d.ts +5 -0
- package/dist/types/notifiers/console.d.ts +1 -1
- package/dist/types/notifiers/webhook-http.d.ts +37 -0
- package/dist/types/notifiers/webhook.d.ts +4 -0
- package/dist/types-cjs/core/client.d.cts +2 -0
- package/dist/types-cjs/core/config.d.cts +35 -0
- package/dist/types-cjs/core/diagnostics.d.cts +11 -0
- package/dist/types-cjs/core/errors.d.cts +3 -0
- package/dist/types-cjs/core/fingerprint.d.cts +3 -0
- package/dist/types-cjs/core/group-store.d.cts +15 -0
- package/dist/types-cjs/core/incident-builder.d.cts +3 -0
- package/dist/types-cjs/core/incident-policy.d.cts +15 -0
- package/dist/types-cjs/core/limits.d.cts +10 -0
- package/dist/types-cjs/core/normalize.d.cts +17 -0
- package/dist/types-cjs/core/notification-queue.d.cts +20 -0
- package/dist/types-cjs/core/process-monitor.d.cts +5 -0
- package/dist/types-cjs/core/redact.d.cts +11 -0
- package/dist/types-cjs/core/rolling-window.d.cts +12 -0
- package/dist/types-cjs/core/stack-frame.d.cts +2 -0
- package/dist/types-cjs/core/types.d.cts +205 -0
- package/dist/types-cjs/index.d.cts +11 -0
- package/dist/types-cjs/integrations/express/error-handler.d.cts +4 -0
- package/dist/types-cjs/integrations/express/index.d.cts +9 -0
- package/dist/types-cjs/integrations/express/request-context.d.cts +5 -0
- package/dist/types-cjs/integrations/express/state.d.cts +2 -0
- package/dist/types-cjs/integrations/express/status-observer.d.cts +11 -0
- package/dist/types-cjs/integrations/nest/exception-filter.d.cts +10 -0
- package/dist/types-cjs/integrations/nest/index.d.cts +5 -0
- package/dist/types-cjs/integrations/nest/register.d.cts +13 -0
- package/dist/types-cjs/integrations/nest/request-context.d.cts +5 -0
- package/dist/types-cjs/integrations/request-context.d.cts +16 -0
- package/dist/types-cjs/notifiers/alert-payload.d.cts +5 -0
- package/dist/types-cjs/notifiers/console.d.cts +3 -0
- package/dist/types-cjs/notifiers/telegram-format.d.cts +2 -0
- package/dist/types-cjs/notifiers/telegram-http.d.cts +21 -0
- package/dist/types-cjs/notifiers/telegram.d.cts +4 -0
- package/dist/types-cjs/notifiers/webhook-http.d.cts +37 -0
- package/dist/types-cjs/notifiers/webhook.d.cts +4 -0
- package/package.json +28 -6
package/README.md
CHANGED
|
@@ -1,26 +1,89 @@
|
|
|
1
1
|
# Wotchi
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Low-noise error alerts for Node.js services.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> **Status:** Public beta (`0.1.0-beta.5`). Install with the `beta` tag; the API may evolve before the first stable release.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
[](https://github.com/FutureWindAI/Wotchi/actions/workflows/ci.yml)
|
|
8
|
+
[](https://github.com/FutureWindAI/Wotchi/actions/workflows/codeql.yml)
|
|
9
|
+
[](https://www.npmjs.com/package/@futurewindai/wotchi)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
[](https://nodejs.org/en/about/previous-releases)
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
Wotchi captures application errors in-process, removes sensitive values, groups repeated failures, and delivers bounded console, Telegram, or HTTPS webhook alerts without changing framework response handling. It is a signal-conditioning layer, not a replacement for a full observability platform.
|
|
10
14
|
|
|
11
|
-
##
|
|
15
|
+
## Quick start
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
17
|
+
```bash
|
|
18
|
+
npm install @futurewindai/wotchi@beta
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { consoleNotifier, createWotchi } from "@futurewindai/wotchi";
|
|
23
|
+
|
|
24
|
+
const wotchi = createWotchi({
|
|
25
|
+
service: "orders-api",
|
|
26
|
+
environment: "development",
|
|
27
|
+
grouping: { alertThreshold: 1 },
|
|
28
|
+
notifiers: [consoleNotifier()],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
wotchi.captureException(new Error("database query failed"));
|
|
32
|
+
await wotchi.flush();
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The example uses a threshold of one so the alert is visible immediately. The default policy groups three matching errors in one minute and suppresses duplicate alerts during the cooldown. Capture is synchronous; call `flush()` when the host needs to wait for notifier work.
|
|
22
36
|
|
|
23
|
-
|
|
37
|
+
To validate a notifier without deliberately throwing an application error, call `const result = await wotchi.testAlert()` in a controlled setup. The structured result reports whether the alert was queued, flushed, delivered, or rejected by a notifier; configuration errors still throw during `createWotchi`.
|
|
38
|
+
|
|
39
|
+
Example console output:
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
Wotchi — Medium incident
|
|
43
|
+
Service: orders-api
|
|
44
|
+
Environment: development
|
|
45
|
+
Summary: Observed 1 occurrences of Error: database query failed.
|
|
46
|
+
Occurrences: 1
|
|
47
|
+
First seen: 2026-08-08T12:00:00.000Z
|
|
48
|
+
Last seen: 2026-08-08T12:00:00.000Z
|
|
49
|
+
Suggested checks:
|
|
50
|
+
- Check database availability, connection saturation, and recent schema changes.
|
|
51
|
+
- Check the affected query and its dependency health before increasing capacity.
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Timestamps and the fingerprint vary for each run. The alert is sanitized before it reaches a
|
|
55
|
+
notifier.
|
|
56
|
+
|
|
57
|
+
## What you get
|
|
58
|
+
|
|
59
|
+
| Capability | Result |
|
|
60
|
+
| ----------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
61
|
+
| Bounded capture and queueing | Repeated failures cannot create unbounded in-memory work. |
|
|
62
|
+
| Redaction before processing | Sensitive values are removed before grouping, logging, or transmission. |
|
|
63
|
+
| Grouping and cooldowns | Repeated failures produce a small number of useful alerts. |
|
|
64
|
+
| Express 4/5 and NestJS 10/11 adapters | Errors are observed while the framework keeps response ownership. |
|
|
65
|
+
| ESM, CommonJS, and TypeScript types | Use the package with common Node.js module setups. |
|
|
66
|
+
| Console and optional Telegram notifiers | Start locally or self-host delivery without a Wotchi control plane. |
|
|
67
|
+
| Generic HTTPS webhook notifier | Route bounded JSON alerts to an existing internal alert destination. |
|
|
68
|
+
| Actionable context and trace passthrough | Include route, release, request/correlation IDs, operation/job, safe tags, links, and existing trace/span IDs. |
|
|
69
|
+
| Optional status observation and JSON logs | Observe direct `401`/`403`/`429`/`5xx` responses and emit collector-friendly JSON. |
|
|
70
|
+
|
|
71
|
+
## How it works
|
|
72
|
+
|
|
73
|
+
```text
|
|
74
|
+
Application error
|
|
75
|
+
-> normalize and redact
|
|
76
|
+
-> stable fingerprint and optional user rule
|
|
77
|
+
-> threshold and cooldown
|
|
78
|
+
-> bounded notification queue
|
|
79
|
+
-> console, Telegram, or HTTPS webhook
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The same bounded capture path can be called from HTTP handlers, background workers, and queue
|
|
83
|
+
processors. Wotchi does not replace the host application's response, retry, or acknowledgement
|
|
84
|
+
logic.
|
|
85
|
+
|
|
86
|
+
## Framework integrations
|
|
24
87
|
|
|
25
88
|
Express applications install the middleware after routes and before the existing final error handler:
|
|
26
89
|
|
|
@@ -47,7 +110,11 @@ import { registerWotchiNest } from "@futurewindai/wotchi/nest";
|
|
|
47
110
|
registerWotchiNest(app, wotchi);
|
|
48
111
|
```
|
|
49
112
|
|
|
50
|
-
|
|
113
|
+
The package keeps compatibility with Node.js `>=18.18.0` and is tested across Node.js 18–26. Node.js 22 or 24 LTS is recommended for production. Express and NestJS adapters are optional subpath integrations, so applications only load the framework adapter they use.
|
|
114
|
+
|
|
115
|
+
## Telegram alerts
|
|
116
|
+
|
|
117
|
+
Telegram is an optional self-hosted notifier. Create a bot with BotFather, start or add it to the destination chat, and keep both values outside source control:
|
|
51
118
|
|
|
52
119
|
```ts
|
|
53
120
|
import { consoleNotifier, createWotchi, telegramNotifier } from "@futurewindai/wotchi";
|
|
@@ -58,71 +125,130 @@ const wotchi = createWotchi({
|
|
|
58
125
|
notifiers: [
|
|
59
126
|
consoleNotifier(),
|
|
60
127
|
telegramNotifier({
|
|
61
|
-
botToken:
|
|
62
|
-
chatId:
|
|
128
|
+
botToken: requiredEnv("WOTCHI_TELEGRAM_BOT_TOKEN"),
|
|
129
|
+
chatId: requiredEnv("WOTCHI_TELEGRAM_CHAT_ID"),
|
|
63
130
|
}),
|
|
64
131
|
],
|
|
65
132
|
});
|
|
133
|
+
|
|
134
|
+
function requiredEnv(name: string): string {
|
|
135
|
+
const value = process.env[name];
|
|
136
|
+
if (value === undefined || value.trim() === "") {
|
|
137
|
+
throw new Error(`${name} must be configured before enabling Telegram`);
|
|
138
|
+
}
|
|
139
|
+
return value;
|
|
140
|
+
}
|
|
66
141
|
```
|
|
67
142
|
|
|
68
|
-
Wotchi does not ship a shared bot token.
|
|
143
|
+
Wotchi does not ship a shared bot token. Delivery is queued outside the request path and sends only the sanitized incident alert. See [configuration](docs/CONFIGURATION.md) for notifier and security options.
|
|
69
144
|
|
|
70
|
-
|
|
145
|
+
## HTTPS webhook alerts
|
|
71
146
|
|
|
72
|
-
|
|
73
|
-
import { registerWotchiProcessMonitor } from "@futurewindai/wotchi";
|
|
74
|
-
|
|
75
|
-
const monitor = registerWotchiProcessMonitor(wotchi);
|
|
76
|
-
// monitor.unregister() when the host intentionally stops observing crashes
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
The implemented core can be exercised directly:
|
|
147
|
+
Use the generic webhook when an existing internal alerting or automation endpoint accepts JSON. Wotchi requires HTTPS by default, bounds headers and payloads, emits a versioned `{ version: 1, type: "incident.alert", sentAt, alert }` envelope, times out delivery, and retries one `429`/`5xx` response. Explicit loopback HTTP can be enabled for a local collector with `allowHttpLoopback: true`:
|
|
80
148
|
|
|
81
149
|
```ts
|
|
82
|
-
import {
|
|
150
|
+
import { createWotchi, webhookNotifier } from "@futurewindai/wotchi";
|
|
83
151
|
|
|
84
152
|
const wotchi = createWotchi({
|
|
85
153
|
service: "orders-api",
|
|
86
154
|
environment: "production",
|
|
87
|
-
notifiers: [
|
|
155
|
+
notifiers: [
|
|
156
|
+
webhookNotifier({
|
|
157
|
+
url: requiredEnv("WOTCHI_WEBHOOK_URL"),
|
|
158
|
+
headers: { Authorization: requiredEnv("WOTCHI_WEBHOOK_AUTH") },
|
|
159
|
+
payloadBuilder: (alert) => ({
|
|
160
|
+
incident: alert.fingerprint,
|
|
161
|
+
summary: alert.summary,
|
|
162
|
+
}),
|
|
163
|
+
}),
|
|
164
|
+
],
|
|
88
165
|
});
|
|
89
166
|
|
|
90
|
-
|
|
91
|
-
|
|
167
|
+
function requiredEnv(name: string): string {
|
|
168
|
+
const value = process.env[name];
|
|
169
|
+
if (value === undefined || value.trim() === "") {
|
|
170
|
+
throw new Error(`${name} must be configured before enabling the webhook`);
|
|
171
|
+
}
|
|
172
|
+
return value;
|
|
173
|
+
}
|
|
92
174
|
```
|
|
93
175
|
|
|
94
|
-
|
|
176
|
+
Keep the URL and authentication header outside source control. `payloadBuilder` receives a frozen, sanitized alert and its output is redacted and bounded before transport; it is not a hosted Wotchi collector.
|
|
177
|
+
|
|
178
|
+
## Context, filtering, and existing traces
|
|
95
179
|
|
|
96
|
-
|
|
180
|
+
Pass safe operational context and an existing OpenTelemetry trace/span ID explicitly; Wotchi does not install an OpenTelemetry SDK:
|
|
97
181
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
182
|
+
```ts
|
|
183
|
+
wotchi.captureEvent({
|
|
184
|
+
level: "error",
|
|
185
|
+
message: "payment provider failed",
|
|
186
|
+
error,
|
|
187
|
+
request: {
|
|
188
|
+
method: "POST",
|
|
189
|
+
route: "/orders/:id",
|
|
190
|
+
requestId: "req-123",
|
|
191
|
+
correlationId: "corr-456",
|
|
192
|
+
trace: { traceId, spanId },
|
|
193
|
+
},
|
|
194
|
+
operation: "orders.pay",
|
|
195
|
+
job: "payment-retry",
|
|
196
|
+
tags: { component: "checkout" },
|
|
197
|
+
context: { provider: "stripe" },
|
|
198
|
+
});
|
|
199
|
+
```
|
|
103
200
|
|
|
104
|
-
|
|
201
|
+
Use `filter`, `fingerprint`, `beforeSend`, and bounded exact-match `rules` for service-specific noise and grouping controls. `filter` and fingerprint callbacks receive frozen, normalized, redacted events. `beforeSend` receives a frozen, sanitized `IncidentAlert`; return `null` to suppress it or a bounded alert to transform it. Hook failures are isolated and counted in diagnostics. Optional `links.log` and `links.trace` templates can use placeholders such as `{{service}}`, `{{requestId}}`, and `{{traceId}}`.
|
|
105
202
|
|
|
106
|
-
|
|
107
|
-
- a hosted dashboard, collector, or persistent incident history;
|
|
108
|
-
- AI-generated summaries;
|
|
109
|
-
- Slack, Discord, email, or generic webhook notifiers;
|
|
110
|
-
- logger transports, Docker collectors, Kubernetes agents, or Helm charts in the npm SDK itself; a separate future collector/relay deployment may receive its own Docker and Helm milestone;
|
|
111
|
-
- automatic remediation.
|
|
203
|
+
## Deployment boundaries
|
|
112
204
|
|
|
113
|
-
|
|
205
|
+
Wotchi keeps grouping and cooldown state in one process. Replicas have independent state, restarts
|
|
206
|
+
reset groups, and a serverless instance can terminate before asynchronous delivery completes. An
|
|
207
|
+
in-process SDK cannot reliably detect an OOM kill, frozen event loop, host failure, or unavailable
|
|
208
|
+
network. Pair it with an external uptime monitor and keep graceful shutdown explicit; see the
|
|
209
|
+
[production recipe](examples/production-recipe/README.md).
|
|
114
210
|
|
|
115
|
-
##
|
|
211
|
+
## Process monitoring
|
|
116
212
|
|
|
117
|
-
|
|
118
|
-
|
|
213
|
+
Crash observation is opt-in:
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
import { registerWotchiProcessMonitor } from "@futurewindai/wotchi";
|
|
217
|
+
|
|
218
|
+
const monitor = registerWotchiProcessMonitor(wotchi);
|
|
219
|
+
// monitor.unregister() when the host intentionally stops observing crashes
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## What it is not
|
|
223
|
+
|
|
224
|
+
- A full observability, APM, or log-management platform.
|
|
225
|
+
- A hosted dashboard, collector, or persistent incident database.
|
|
226
|
+
- An AI-generated incident-summary service in this release.
|
|
227
|
+
- A Slack, Discord, email, or full incident-workflow platform.
|
|
228
|
+
- A Docker, Kubernetes, or Helm collector bundled into the npm SDK.
|
|
229
|
+
- An automatic-remediation system.
|
|
230
|
+
|
|
231
|
+
## Documentation
|
|
232
|
+
|
|
233
|
+
- [Getting started](docs/GETTING_STARTED.md)
|
|
234
|
+
- [Examples](docs/EXAMPLES.md)
|
|
235
|
+
- [API reference](docs/API.md)
|
|
119
236
|
- [Configuration](docs/CONFIGURATION.md)
|
|
120
|
-
- [
|
|
121
|
-
- [
|
|
122
|
-
- [
|
|
123
|
-
- [
|
|
124
|
-
- [
|
|
237
|
+
- [Compatibility](docs/COMPATIBILITY.md)
|
|
238
|
+
- [Performance](docs/PERFORMANCE.md)
|
|
239
|
+
- [Architecture](docs/ARCHITECTURE.md)
|
|
240
|
+
- [Roadmap](docs/ROADMAP.md)
|
|
241
|
+
- [Troubleshooting](docs/TROUBLESHOOTING.md)
|
|
242
|
+
- [FAQ](docs/FAQ.md)
|
|
243
|
+
- [Security and privacy](docs/SECURITY.md)
|
|
244
|
+
- [Threat model](docs/THREAT_MODEL.md)
|
|
245
|
+
- [Contributing](CONTRIBUTING.md)
|
|
125
246
|
- [Changelog](CHANGELOG.md)
|
|
247
|
+
- [GitHub releases](https://github.com/FutureWindAI/Wotchi/releases)
|
|
126
248
|
- [Apache License 2.0](LICENSE)
|
|
127
249
|
|
|
128
|
-
|
|
250
|
+
## Security
|
|
251
|
+
|
|
252
|
+
Do not include real secrets or customer error data in issues, examples, or test fixtures. Report security vulnerabilities privately using [SECURITY.md](SECURITY.md).
|
|
253
|
+
|
|
254
|
+
Wotchi is open source and maintained by FutureWind AI.
|
package/SECURITY.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## Supported Versions
|
|
4
4
|
|
|
5
|
-
Wotchi
|
|
5
|
+
Wotchi targets applications running Node.js `>=18.18.0` and is built and tested across the Node.js 18–26 matrix. Node.js versions below 18.18 are not supported.
|
|
6
6
|
|
|
7
|
-
The current
|
|
7
|
+
The current package contains the framework-independent capture core, console and Telegram notifiers, Express 4/5 middleware, NestJS 10/11 exception-filter integration, and opt-in process monitoring. Supported runtime and framework combinations are documented after packed-tarball compatibility and release-security checks.
|
|
8
8
|
|
|
9
9
|
## Reporting a Vulnerability
|
|
10
10
|
|