@watchdog-sdk/node 0.0.0-stage → 0.4.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Watchdog contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,36 @@
1
- # Temporary Holding Version
1
+ # @watchdog-sdk/node
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Watchdog for Node.js. It captures uncaught exceptions and unhandled rejections, reads the source lines around each failing frame from disk, and integrates with Express and NestJS.
4
+
5
+ ```bash
6
+ bun add @watchdog-sdk/node
7
+ ```
8
+
9
+ ```ts
10
+ import * as Watchdog from '@watchdog-sdk/node';
11
+
12
+ Watchdog.init({
13
+ dsn: 'https://<key>@your-watchdog-host/<project-id>',
14
+ release: process.env.APP_VERSION,
15
+ environment: process.env.NODE_ENV,
16
+ });
17
+
18
+ // Express
19
+ app.use(Watchdog.expressErrorHandler());
20
+ ```
21
+
22
+ ## NestJS
23
+
24
+ ```ts
25
+ import { APP_FILTER } from '@nestjs/core';
26
+ import { WatchdogExceptionFilter } from '@watchdog-sdk/node/nest';
27
+
28
+ @Module({
29
+ providers: [{ provide: APP_FILTER, useClass: WatchdogExceptionFilter }],
30
+ })
31
+ export class AppModule {}
32
+ ```
33
+
34
+ Client errors (4xx) are not reported. Request headers such as `authorization` and `cookie` are never sent.
35
+
36
+ Watchdog is an open source, self-hosted error tracker. Documentation and server: https://github.com/Yassinos-coder/watchdog
@@ -0,0 +1,272 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+
12
+ // src/node-sdk.ts
13
+ import { hostname, platform, arch } from "os";
14
+ import {
15
+ WatchdogClient
16
+ } from "@watchdog-sdk/core";
17
+
18
+ // src/context-lines.ts
19
+ import { readFileSync, statSync } from "fs";
20
+ import { fileURLToPath } from "url";
21
+ var CONTEXT_RADIUS = 5;
22
+ var MAX_FILE_BYTES = 2 * 1024 * 1024;
23
+ var MAX_CACHED_FILES = 100;
24
+ var MAX_LINE_LENGTH = 400;
25
+ var ContextLines = class _ContextLines {
26
+ static cache = /* @__PURE__ */ new Map();
27
+ static enrich(frames) {
28
+ return frames.map((frame) => _ContextLines.enrichFrame(frame));
29
+ }
30
+ static resolvePath(filename) {
31
+ if (/^https?:\/\//.test(filename) || filename.startsWith("node:")) {
32
+ return null;
33
+ }
34
+ if (filename.startsWith("file://")) {
35
+ try {
36
+ return fileURLToPath(filename);
37
+ } catch {
38
+ return null;
39
+ }
40
+ }
41
+ return filename;
42
+ }
43
+ static clearCache() {
44
+ _ContextLines.cache.clear();
45
+ }
46
+ static enrichFrame(frame) {
47
+ if (frame.inApp === false || !frame.filename || frame.lineno === void 0) {
48
+ return frame;
49
+ }
50
+ const path = _ContextLines.resolvePath(frame.filename);
51
+ const lines = path ? _ContextLines.readLines(path) : null;
52
+ if (!lines || frame.lineno < 1 || frame.lineno > lines.length) {
53
+ return frame;
54
+ }
55
+ const index = frame.lineno - 1;
56
+ return {
57
+ ...frame,
58
+ contextLine: _ContextLines.clip(lines[index]),
59
+ preContext: lines.slice(Math.max(index - CONTEXT_RADIUS, 0), index).map(_ContextLines.clip),
60
+ postContext: lines.slice(index + 1, index + 1 + CONTEXT_RADIUS).map(_ContextLines.clip)
61
+ };
62
+ }
63
+ static readLines(path) {
64
+ if (_ContextLines.cache.has(path)) {
65
+ return _ContextLines.cache.get(path) ?? null;
66
+ }
67
+ const lines = _ContextLines.load(path);
68
+ if (_ContextLines.cache.size >= MAX_CACHED_FILES) {
69
+ const oldest = _ContextLines.cache.keys().next().value;
70
+ if (oldest !== void 0) {
71
+ _ContextLines.cache.delete(oldest);
72
+ }
73
+ }
74
+ _ContextLines.cache.set(path, lines);
75
+ return lines;
76
+ }
77
+ static load(path) {
78
+ try {
79
+ if (statSync(path).size > MAX_FILE_BYTES) {
80
+ return null;
81
+ }
82
+ return readFileSync(path, "utf8").split(/\r?\n/);
83
+ } catch {
84
+ return null;
85
+ }
86
+ }
87
+ static clip(line) {
88
+ return line.length > MAX_LINE_LENGTH ? line.slice(0, MAX_LINE_LENGTH) : line;
89
+ }
90
+ };
91
+
92
+ // src/request-context.ts
93
+ var SAFE_HEADERS = /* @__PURE__ */ new Set([
94
+ "user-agent",
95
+ "referer",
96
+ "content-type",
97
+ "content-length",
98
+ "accept",
99
+ "accept-language",
100
+ "host",
101
+ "x-request-id"
102
+ ]);
103
+ var RequestContextBuilder = class _RequestContextBuilder {
104
+ static from(request) {
105
+ const headers = {};
106
+ for (const [name, value] of Object.entries(request.headers ?? {})) {
107
+ if (SAFE_HEADERS.has(name.toLowerCase()) && value !== void 0) {
108
+ headers[name.toLowerCase()] = Array.isArray(value) ? value.join(", ") : value;
109
+ }
110
+ }
111
+ return {
112
+ url: _RequestContextBuilder.stripQuery(request.originalUrl ?? request.url),
113
+ method: request.method,
114
+ headers
115
+ };
116
+ }
117
+ static stripQuery(url) {
118
+ return url?.split("?")[0];
119
+ }
120
+ };
121
+
122
+ // src/node-sdk.ts
123
+ var SDK = { name: "watchdog.node", version: "0.4.3" };
124
+ var DEFAULT_FLUSH_TIMEOUT_MS = 2e3;
125
+ var EXIT_CODE_UNCAUGHT = 1;
126
+ var client = null;
127
+ var uninstallers = [];
128
+ function init(options) {
129
+ close();
130
+ const {
131
+ captureUncaughtExceptions = true,
132
+ captureUnhandledRejections = true,
133
+ onUnhandledRejection = "warn",
134
+ contextLines = true,
135
+ flushTimeoutMs = DEFAULT_FLUSH_TIMEOUT_MS,
136
+ ...coreOptions
137
+ } = options;
138
+ const created = new WatchdogClient(
139
+ {
140
+ ...coreOptions,
141
+ platform: "node",
142
+ beforeSend: (event) => {
143
+ const enriched = contextLines ? withContextLines(event) : event;
144
+ return coreOptions.beforeSend ? coreOptions.beforeSend(enriched) : enriched;
145
+ }
146
+ },
147
+ SDK
148
+ );
149
+ created.setContext("runtime", { name: "node", version: process.version });
150
+ created.setContext("os", { platform: platform(), arch: arch() });
151
+ created.setTag("server_name", hostname());
152
+ client = created;
153
+ if (captureUncaughtExceptions) {
154
+ uninstallers.push(installUncaughtException(created, flushTimeoutMs));
155
+ }
156
+ if (captureUnhandledRejections) {
157
+ uninstallers.push(installUnhandledRejection(created, onUnhandledRejection, flushTimeoutMs));
158
+ }
159
+ return created;
160
+ }
161
+ function close() {
162
+ for (const uninstall of uninstallers) {
163
+ uninstall();
164
+ }
165
+ uninstallers = [];
166
+ client = null;
167
+ }
168
+ function getClient() {
169
+ return client;
170
+ }
171
+ function captureException(error, context) {
172
+ return client?.captureException(error, context);
173
+ }
174
+ function captureMessage(message, level, context) {
175
+ return client?.captureMessage(message, level, context);
176
+ }
177
+ function captureRequestError(error, request, context) {
178
+ return client?.captureException(error, { ...context, request: RequestContextBuilder.from(request) });
179
+ }
180
+ function addBreadcrumb(breadcrumb) {
181
+ client?.addBreadcrumb(breadcrumb);
182
+ }
183
+ function setUser(user) {
184
+ client?.setUser(user);
185
+ }
186
+ function setTag(key, value) {
187
+ client?.setTag(key, value);
188
+ }
189
+ function setExtra(key, value) {
190
+ client?.setExtra(key, value);
191
+ }
192
+ function setContext(key, value) {
193
+ client?.setContext(key, value);
194
+ }
195
+ function flush(timeoutMs) {
196
+ return client ? client.flush(timeoutMs) : Promise.resolve(true);
197
+ }
198
+ function withContextLines(event) {
199
+ if (!event.exception) {
200
+ return event;
201
+ }
202
+ return {
203
+ ...event,
204
+ exception: {
205
+ ...event.exception,
206
+ stacktrace: { frames: ContextLines.enrich(event.exception.stacktrace.frames) }
207
+ }
208
+ };
209
+ }
210
+ function installUncaughtException(target, flushTimeoutMs) {
211
+ const handler = (error) => {
212
+ target.captureException(error, { handled: false, level: "fatal", tags: { mechanism: "uncaughtException" } });
213
+ void target.flush(flushTimeoutMs).finally(() => {
214
+ if (process.listenerCount("uncaughtException") <= 1) {
215
+ process.exit(EXIT_CODE_UNCAUGHT);
216
+ }
217
+ });
218
+ };
219
+ process.on("uncaughtException", handler);
220
+ return () => process.off("uncaughtException", handler);
221
+ }
222
+ function installUnhandledRejection(target, mode, flushTimeoutMs) {
223
+ const handler = (reason) => {
224
+ target.captureException(reason, { handled: false, tags: { mechanism: "unhandledRejection" } });
225
+ if (mode === "exit") {
226
+ void target.flush(flushTimeoutMs).finally(() => process.exit(EXIT_CODE_UNCAUGHT));
227
+ return;
228
+ }
229
+ console.warn("[watchdog] unhandled promise rejection:", reason);
230
+ };
231
+ process.on("unhandledRejection", handler);
232
+ return () => process.off("unhandledRejection", handler);
233
+ }
234
+
235
+ // src/exception-policy.ts
236
+ var SERVER_ERROR_STATUS = 500;
237
+ var ExceptionPolicy = class _ExceptionPolicy {
238
+ static shouldReport(exception) {
239
+ const status = _ExceptionPolicy.statusOf(exception);
240
+ return status === void 0 || status >= SERVER_ERROR_STATUS;
241
+ }
242
+ static statusOf(exception) {
243
+ if (typeof exception !== "object" || exception === null) {
244
+ return void 0;
245
+ }
246
+ const candidate = exception;
247
+ if (typeof candidate.getStatus === "function") {
248
+ const status2 = candidate.getStatus.call(exception);
249
+ return typeof status2 === "number" ? status2 : void 0;
250
+ }
251
+ const status = candidate.status ?? candidate.statusCode;
252
+ return typeof status === "number" ? status : void 0;
253
+ }
254
+ };
255
+
256
+ export {
257
+ __decorateClass,
258
+ init,
259
+ close,
260
+ getClient,
261
+ captureException,
262
+ captureMessage,
263
+ captureRequestError,
264
+ addBreadcrumb,
265
+ setUser,
266
+ setTag,
267
+ setExtra,
268
+ setContext,
269
+ flush,
270
+ ExceptionPolicy
271
+ };
272
+ //# sourceMappingURL=chunk-EC2UJND6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/node-sdk.ts","../src/context-lines.ts","../src/request-context.ts","../src/exception-policy.ts"],"sourcesContent":["import { hostname, platform, arch } from 'node:os';\nimport {\n Breadcrumb,\n CaptureContext,\n Level,\n UserContext,\n WatchdogClient,\n WatchdogEvent,\n} from '@watchdog-sdk/core';\nimport { ContextLines } from './context-lines';\nimport { HttpRequestLike, NodeOptions, Uninstall } from './interfaces';\nimport { RequestContextBuilder } from './request-context';\n\nconst SDK = { name: 'watchdog.node', version: '0.4.3' };\nconst DEFAULT_FLUSH_TIMEOUT_MS = 2_000;\nconst EXIT_CODE_UNCAUGHT = 1;\n\nlet client: WatchdogClient | null = null;\nlet uninstallers: Uninstall[] = [];\n\nexport function init(options: NodeOptions): WatchdogClient {\n close();\n const {\n captureUncaughtExceptions = true,\n captureUnhandledRejections = true,\n onUnhandledRejection = 'warn',\n contextLines = true,\n flushTimeoutMs = DEFAULT_FLUSH_TIMEOUT_MS,\n ...coreOptions\n } = options;\n\n const created = new WatchdogClient(\n {\n ...coreOptions,\n platform: 'node',\n beforeSend: (event) => {\n const enriched = contextLines ? withContextLines(event) : event;\n return coreOptions.beforeSend ? coreOptions.beforeSend(enriched) : enriched;\n },\n },\n SDK,\n );\n created.setContext('runtime', { name: 'node', version: process.version });\n created.setContext('os', { platform: platform(), arch: arch() });\n created.setTag('server_name', hostname());\n client = created;\n\n if (captureUncaughtExceptions) {\n uninstallers.push(installUncaughtException(created, flushTimeoutMs));\n }\n if (captureUnhandledRejections) {\n uninstallers.push(installUnhandledRejection(created, onUnhandledRejection, flushTimeoutMs));\n }\n return created;\n}\n\nexport function close(): void {\n for (const uninstall of uninstallers) {\n uninstall();\n }\n uninstallers = [];\n client = null;\n}\n\nexport function getClient(): WatchdogClient | null {\n return client;\n}\n\nexport function captureException(error: unknown, context?: CaptureContext): string | undefined {\n return client?.captureException(error, context);\n}\n\nexport function captureMessage(message: string, level?: Level, context?: CaptureContext): string | undefined {\n return client?.captureMessage(message, level, context);\n}\n\nexport function captureRequestError(error: unknown, request: HttpRequestLike, context?: CaptureContext): string | undefined {\n return client?.captureException(error, { ...context, request: RequestContextBuilder.from(request) });\n}\n\nexport function addBreadcrumb(breadcrumb: Breadcrumb): void {\n client?.addBreadcrumb(breadcrumb);\n}\n\nexport function setUser(user: UserContext | undefined): void {\n client?.setUser(user);\n}\n\nexport function setTag(key: string, value: string): void {\n client?.setTag(key, value);\n}\n\nexport function setExtra(key: string, value: unknown): void {\n client?.setExtra(key, value);\n}\n\nexport function setContext(key: string, value: unknown): void {\n client?.setContext(key, value);\n}\n\nexport function flush(timeoutMs?: number): Promise<boolean> {\n return client ? client.flush(timeoutMs) : Promise.resolve(true);\n}\n\nfunction withContextLines(event: WatchdogEvent): WatchdogEvent {\n if (!event.exception) {\n return event;\n }\n return {\n ...event,\n exception: {\n ...event.exception,\n stacktrace: { frames: ContextLines.enrich(event.exception.stacktrace.frames) },\n },\n };\n}\n\nfunction installUncaughtException(target: WatchdogClient, flushTimeoutMs: number): Uninstall {\n const handler = (error: Error): void => {\n target.captureException(error, { handled: false, level: 'fatal', tags: { mechanism: 'uncaughtException' } });\n void target.flush(flushTimeoutMs).finally(() => {\n if (process.listenerCount('uncaughtException') <= 1) {\n process.exit(EXIT_CODE_UNCAUGHT);\n }\n });\n };\n process.on('uncaughtException', handler);\n return () => process.off('uncaughtException', handler);\n}\n\nfunction installUnhandledRejection(\n target: WatchdogClient,\n mode: 'warn' | 'exit',\n flushTimeoutMs: number,\n): Uninstall {\n const handler = (reason: unknown): void => {\n target.captureException(reason, { handled: false, tags: { mechanism: 'unhandledRejection' } });\n if (mode === 'exit') {\n void target.flush(flushTimeoutMs).finally(() => process.exit(EXIT_CODE_UNCAUGHT));\n return;\n }\n console.warn('[watchdog] unhandled promise rejection:', reason);\n };\n process.on('unhandledRejection', handler);\n return () => process.off('unhandledRejection', handler);\n}\n","import { readFileSync, statSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport type { Frame } from '@watchdog-sdk/core';\n\nconst CONTEXT_RADIUS = 5;\nconst MAX_FILE_BYTES = 2 * 1024 * 1024;\nconst MAX_CACHED_FILES = 100;\nconst MAX_LINE_LENGTH = 400;\n\nexport class ContextLines {\n private static readonly cache = new Map<string, string[] | null>();\n\n static enrich(frames: Frame[]): Frame[] {\n return frames.map((frame) => ContextLines.enrichFrame(frame));\n }\n\n static resolvePath(filename: string): string | null {\n if (/^https?:\\/\\//.test(filename) || filename.startsWith('node:')) {\n return null;\n }\n if (filename.startsWith('file://')) {\n try {\n return fileURLToPath(filename);\n } catch {\n return null;\n }\n }\n return filename;\n }\n\n static clearCache(): void {\n ContextLines.cache.clear();\n }\n\n private static enrichFrame(frame: Frame): Frame {\n if (frame.inApp === false || !frame.filename || frame.lineno === undefined) {\n return frame;\n }\n const path = ContextLines.resolvePath(frame.filename);\n const lines = path ? ContextLines.readLines(path) : null;\n if (!lines || frame.lineno < 1 || frame.lineno > lines.length) {\n return frame;\n }\n const index = frame.lineno - 1;\n return {\n ...frame,\n contextLine: ContextLines.clip(lines[index]),\n preContext: lines.slice(Math.max(index - CONTEXT_RADIUS, 0), index).map(ContextLines.clip),\n postContext: lines.slice(index + 1, index + 1 + CONTEXT_RADIUS).map(ContextLines.clip),\n };\n }\n\n private static readLines(path: string): string[] | null {\n if (ContextLines.cache.has(path)) {\n return ContextLines.cache.get(path) ?? null;\n }\n const lines = ContextLines.load(path);\n if (ContextLines.cache.size >= MAX_CACHED_FILES) {\n const oldest = ContextLines.cache.keys().next().value;\n if (oldest !== undefined) {\n ContextLines.cache.delete(oldest);\n }\n }\n ContextLines.cache.set(path, lines);\n return lines;\n }\n\n private static load(path: string): string[] | null {\n try {\n if (statSync(path).size > MAX_FILE_BYTES) {\n return null;\n }\n return readFileSync(path, 'utf8').split(/\\r?\\n/);\n } catch {\n return null;\n }\n }\n\n private static clip(line: string): string {\n return line.length > MAX_LINE_LENGTH ? line.slice(0, MAX_LINE_LENGTH) : line;\n }\n}\n","import type { RequestContext } from '@watchdog-sdk/core';\nimport { HttpRequestLike } from './interfaces';\n\nconst SAFE_HEADERS = new Set([\n 'user-agent',\n 'referer',\n 'content-type',\n 'content-length',\n 'accept',\n 'accept-language',\n 'host',\n 'x-request-id',\n]);\n\nexport class RequestContextBuilder {\n static from(request: HttpRequestLike): RequestContext {\n const headers: Record<string, string> = {};\n for (const [name, value] of Object.entries(request.headers ?? {})) {\n if (SAFE_HEADERS.has(name.toLowerCase()) && value !== undefined) {\n headers[name.toLowerCase()] = Array.isArray(value) ? value.join(', ') : value;\n }\n }\n return {\n url: RequestContextBuilder.stripQuery(request.originalUrl ?? request.url),\n method: request.method,\n headers,\n };\n }\n\n private static stripQuery(url: string | undefined): string | undefined {\n return url?.split('?')[0];\n }\n}\n","const SERVER_ERROR_STATUS = 500;\n\nexport class ExceptionPolicy {\n static shouldReport(exception: unknown): boolean {\n const status = ExceptionPolicy.statusOf(exception);\n return status === undefined || status >= SERVER_ERROR_STATUS;\n }\n\n private static statusOf(exception: unknown): number | undefined {\n if (typeof exception !== 'object' || exception === null) {\n return undefined;\n }\n const candidate = exception as { getStatus?: unknown; status?: unknown; statusCode?: unknown };\n if (typeof candidate.getStatus === 'function') {\n const status = (candidate.getStatus as () => unknown).call(exception);\n return typeof status === 'number' ? status : undefined;\n }\n const status = candidate.status ?? candidate.statusCode;\n return typeof status === 'number' ? status : undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,UAAU,UAAU,YAAY;AACzC;AAAA,EAKE;AAAA,OAEK;;;ACRP,SAAS,cAAc,gBAAgB;AACvC,SAAS,qBAAqB;AAG9B,IAAM,iBAAiB;AACvB,IAAM,iBAAiB,IAAI,OAAO;AAClC,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AAEjB,IAAM,eAAN,MAAM,cAAa;AAAA,EACxB,OAAwB,QAAQ,oBAAI,IAA6B;AAAA,EAEjE,OAAO,OAAO,QAA0B;AACtC,WAAO,OAAO,IAAI,CAAC,UAAU,cAAa,YAAY,KAAK,CAAC;AAAA,EAC9D;AAAA,EAEA,OAAO,YAAY,UAAiC;AAClD,QAAI,eAAe,KAAK,QAAQ,KAAK,SAAS,WAAW,OAAO,GAAG;AACjE,aAAO;AAAA,IACT;AACA,QAAI,SAAS,WAAW,SAAS,GAAG;AAClC,UAAI;AACF,eAAO,cAAc,QAAQ;AAAA,MAC/B,QAAQ;AACN,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,aAAmB;AACxB,kBAAa,MAAM,MAAM;AAAA,EAC3B;AAAA,EAEA,OAAe,YAAY,OAAqB;AAC9C,QAAI,MAAM,UAAU,SAAS,CAAC,MAAM,YAAY,MAAM,WAAW,QAAW;AAC1E,aAAO;AAAA,IACT;AACA,UAAM,OAAO,cAAa,YAAY,MAA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C3C;AAAA,EAEA,OAAe,SAAS,WAAwC;AAC9D,QAAI,OAAO,cAAc,YAAY,cAAc,MAAM;AACvD,aAAO;AAAA,IACT;AACA,UAAM,YAAY;AAClB,QAAI,OAAO,UAAU,cAAc,YAAY;AAC7C,YAAMA,UAAU,UAAU,UAA4B,KAAK,SAAS;AACpE,aAAO,OAAOA,YAAW,WAAWA,UAAS;AAAA,IAC/C;AACA,UAAM,SAAS,UAAU,UAAU,UAAU;AAC7C,WAAO,OAAO,WAAW,WAAW,SAAS;AAAA,EAC/C;AACF;","names":["status"]}
@@ -0,0 +1,272 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+
12
+ // src/node-sdk.ts
13
+ var _os = require('os');
14
+
15
+
16
+ var _core = require('@watchdog-sdk/core');
17
+
18
+ // src/context-lines.ts
19
+ var _fs = require('fs');
20
+ var _url = require('url');
21
+ var CONTEXT_RADIUS = 5;
22
+ var MAX_FILE_BYTES = 2 * 1024 * 1024;
23
+ var MAX_CACHED_FILES = 100;
24
+ var MAX_LINE_LENGTH = 400;
25
+ var ContextLines = (_class = class _ContextLines {
26
+ static __initStatic() {this.cache = /* @__PURE__ */ new Map()}
27
+ static enrich(frames) {
28
+ return frames.map((frame) => _ContextLines.enrichFrame(frame));
29
+ }
30
+ static resolvePath(filename) {
31
+ if (/^https?:\/\//.test(filename) || filename.startsWith("node:")) {
32
+ return null;
33
+ }
34
+ if (filename.startsWith("file://")) {
35
+ try {
36
+ return _url.fileURLToPath.call(void 0, filename);
37
+ } catch (e) {
38
+ return null;
39
+ }
40
+ }
41
+ return filename;
42
+ }
43
+ static clearCache() {
44
+ _ContextLines.cache.clear();
45
+ }
46
+ static enrichFrame(frame) {
47
+ if (frame.inApp === false || !frame.filename || frame.lineno === void 0) {
48
+ return frame;
49
+ }
50
+ const path = _ContextLines.resolvePath(frame.filename);
51
+ const lines = path ? _ContextLines.readLines(path) : null;
52
+ if (!lines || frame.lineno < 1 || frame.lineno > lines.length) {
53
+ return frame;
54
+ }
55
+ const index = frame.lineno - 1;
56
+ return {
57
+ ...frame,
58
+ contextLine: _ContextLines.clip(lines[index]),
59
+ preContext: lines.slice(Math.max(index - CONTEXT_RADIUS, 0), index).map(_ContextLines.clip),
60
+ postContext: lines.slice(index + 1, index + 1 + CONTEXT_RADIUS).map(_ContextLines.clip)
61
+ };
62
+ }
63
+ static readLines(path) {
64
+ if (_ContextLines.cache.has(path)) {
65
+ return _nullishCoalesce(_ContextLines.cache.get(path), () => ( null));
66
+ }
67
+ const lines = _ContextLines.load(path);
68
+ if (_ContextLines.cache.size >= MAX_CACHED_FILES) {
69
+ const oldest = _ContextLines.cache.keys().next().value;
70
+ if (oldest !== void 0) {
71
+ _ContextLines.cache.delete(oldest);
72
+ }
73
+ }
74
+ _ContextLines.cache.set(path, lines);
75
+ return lines;
76
+ }
77
+ static load(path) {
78
+ try {
79
+ if (_fs.statSync.call(void 0, path).size > MAX_FILE_BYTES) {
80
+ return null;
81
+ }
82
+ return _fs.readFileSync.call(void 0, path, "utf8").split(/\r?\n/);
83
+ } catch (e2) {
84
+ return null;
85
+ }
86
+ }
87
+ static clip(line) {
88
+ return line.length > MAX_LINE_LENGTH ? line.slice(0, MAX_LINE_LENGTH) : line;
89
+ }
90
+ }, _class.__initStatic(), _class);
91
+
92
+ // src/request-context.ts
93
+ var SAFE_HEADERS = /* @__PURE__ */ new Set([
94
+ "user-agent",
95
+ "referer",
96
+ "content-type",
97
+ "content-length",
98
+ "accept",
99
+ "accept-language",
100
+ "host",
101
+ "x-request-id"
102
+ ]);
103
+ var RequestContextBuilder = class _RequestContextBuilder {
104
+ static from(request) {
105
+ const headers = {};
106
+ for (const [name, value] of Object.entries(_nullishCoalesce(request.headers, () => ( {})))) {
107
+ if (SAFE_HEADERS.has(name.toLowerCase()) && value !== void 0) {
108
+ headers[name.toLowerCase()] = Array.isArray(value) ? value.join(", ") : value;
109
+ }
110
+ }
111
+ return {
112
+ url: _RequestContextBuilder.stripQuery(_nullishCoalesce(request.originalUrl, () => ( request.url))),
113
+ method: request.method,
114
+ headers
115
+ };
116
+ }
117
+ static stripQuery(url) {
118
+ return _optionalChain([url, 'optionalAccess', _ => _.split, 'call', _2 => _2("?"), 'access', _3 => _3[0]]);
119
+ }
120
+ };
121
+
122
+ // src/node-sdk.ts
123
+ var SDK = { name: "watchdog.node", version: "0.4.3" };
124
+ var DEFAULT_FLUSH_TIMEOUT_MS = 2e3;
125
+ var EXIT_CODE_UNCAUGHT = 1;
126
+ var client = null;
127
+ var uninstallers = [];
128
+ function init(options) {
129
+ close();
130
+ const {
131
+ captureUncaughtExceptions = true,
132
+ captureUnhandledRejections = true,
133
+ onUnhandledRejection = "warn",
134
+ contextLines = true,
135
+ flushTimeoutMs = DEFAULT_FLUSH_TIMEOUT_MS,
136
+ ...coreOptions
137
+ } = options;
138
+ const created = new (0, _core.WatchdogClient)(
139
+ {
140
+ ...coreOptions,
141
+ platform: "node",
142
+ beforeSend: (event) => {
143
+ const enriched = contextLines ? withContextLines(event) : event;
144
+ return coreOptions.beforeSend ? coreOptions.beforeSend(enriched) : enriched;
145
+ }
146
+ },
147
+ SDK
148
+ );
149
+ created.setContext("runtime", { name: "node", version: process.version });
150
+ created.setContext("os", { platform: _os.platform.call(void 0, ), arch: _os.arch.call(void 0, ) });
151
+ created.setTag("server_name", _os.hostname.call(void 0, ));
152
+ client = created;
153
+ if (captureUncaughtExceptions) {
154
+ uninstallers.push(installUncaughtException(created, flushTimeoutMs));
155
+ }
156
+ if (captureUnhandledRejections) {
157
+ uninstallers.push(installUnhandledRejection(created, onUnhandledRejection, flushTimeoutMs));
158
+ }
159
+ return created;
160
+ }
161
+ function close() {
162
+ for (const uninstall of uninstallers) {
163
+ uninstall();
164
+ }
165
+ uninstallers = [];
166
+ client = null;
167
+ }
168
+ function getClient() {
169
+ return client;
170
+ }
171
+ function captureException(error, context) {
172
+ return _optionalChain([client, 'optionalAccess', _4 => _4.captureException, 'call', _5 => _5(error, context)]);
173
+ }
174
+ function captureMessage(message, level, context) {
175
+ return _optionalChain([client, 'optionalAccess', _6 => _6.captureMessage, 'call', _7 => _7(message, level, context)]);
176
+ }
177
+ function captureRequestError(error, request, context) {
178
+ return _optionalChain([client, 'optionalAccess', _8 => _8.captureException, 'call', _9 => _9(error, { ...context, request: RequestContextBuilder.from(request) })]);
179
+ }
180
+ function addBreadcrumb(breadcrumb) {
181
+ _optionalChain([client, 'optionalAccess', _10 => _10.addBreadcrumb, 'call', _11 => _11(breadcrumb)]);
182
+ }
183
+ function setUser(user) {
184
+ _optionalChain([client, 'optionalAccess', _12 => _12.setUser, 'call', _13 => _13(user)]);
185
+ }
186
+ function setTag(key, value) {
187
+ _optionalChain([client, 'optionalAccess', _14 => _14.setTag, 'call', _15 => _15(key, value)]);
188
+ }
189
+ function setExtra(key, value) {
190
+ _optionalChain([client, 'optionalAccess', _16 => _16.setExtra, 'call', _17 => _17(key, value)]);
191
+ }
192
+ function setContext(key, value) {
193
+ _optionalChain([client, 'optionalAccess', _18 => _18.setContext, 'call', _19 => _19(key, value)]);
194
+ }
195
+ function flush(timeoutMs) {
196
+ return client ? client.flush(timeoutMs) : Promise.resolve(true);
197
+ }
198
+ function withContextLines(event) {
199
+ if (!event.exception) {
200
+ return event;
201
+ }
202
+ return {
203
+ ...event,
204
+ exception: {
205
+ ...event.exception,
206
+ stacktrace: { frames: ContextLines.enrich(event.exception.stacktrace.frames) }
207
+ }
208
+ };
209
+ }
210
+ function installUncaughtException(target, flushTimeoutMs) {
211
+ const handler = (error) => {
212
+ target.captureException(error, { handled: false, level: "fatal", tags: { mechanism: "uncaughtException" } });
213
+ void target.flush(flushTimeoutMs).finally(() => {
214
+ if (process.listenerCount("uncaughtException") <= 1) {
215
+ process.exit(EXIT_CODE_UNCAUGHT);
216
+ }
217
+ });
218
+ };
219
+ process.on("uncaughtException", handler);
220
+ return () => process.off("uncaughtException", handler);
221
+ }
222
+ function installUnhandledRejection(target, mode, flushTimeoutMs) {
223
+ const handler = (reason) => {
224
+ target.captureException(reason, { handled: false, tags: { mechanism: "unhandledRejection" } });
225
+ if (mode === "exit") {
226
+ void target.flush(flushTimeoutMs).finally(() => process.exit(EXIT_CODE_UNCAUGHT));
227
+ return;
228
+ }
229
+ console.warn("[watchdog] unhandled promise rejection:", reason);
230
+ };
231
+ process.on("unhandledRejection", handler);
232
+ return () => process.off("unhandledRejection", handler);
233
+ }
234
+
235
+ // src/exception-policy.ts
236
+ var SERVER_ERROR_STATUS = 500;
237
+ var ExceptionPolicy = class _ExceptionPolicy {
238
+ static shouldReport(exception) {
239
+ const status = _ExceptionPolicy.statusOf(exception);
240
+ return status === void 0 || status >= SERVER_ERROR_STATUS;
241
+ }
242
+ static statusOf(exception) {
243
+ if (typeof exception !== "object" || exception === null) {
244
+ return void 0;
245
+ }
246
+ const candidate = exception;
247
+ if (typeof candidate.getStatus === "function") {
248
+ const status2 = candidate.getStatus.call(exception);
249
+ return typeof status2 === "number" ? status2 : void 0;
250
+ }
251
+ const status = _nullishCoalesce(candidate.status, () => ( candidate.statusCode));
252
+ return typeof status === "number" ? status : void 0;
253
+ }
254
+ };
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+ exports.__decorateClass = __decorateClass; exports.init = init; exports.close = close; exports.getClient = getClient; exports.captureException = captureException; exports.captureMessage = captureMessage; exports.captureRequestError = captureRequestError; exports.addBreadcrumb = addBreadcrumb; exports.setUser = setUser; exports.setTag = setTag; exports.setExtra = setExtra; exports.setContext = setContext; exports.flush = flush; exports.ExceptionPolicy = ExceptionPolicy;
272
+ //# sourceMappingURL=chunk-S6H6O6BV.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/watchdog/watchdog/packages/node/dist/chunk-S6H6O6BV.cjs","../src/node-sdk.ts","../src/context-lines.ts","../src/request-context.ts","../src/exception-policy.ts"],"names":["status"],"mappings":"AAAA,isBAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,iBAAiB,EAAE,MAAM,CAAC,wBAAwB;AACtD,IAAI,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG;AACzD,EAAE,IAAI,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,MAAM;AAChF,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE;AAC5D,IAAI,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;AACjC,MAAM,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM;AACpF,EAAE,GAA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;AAClB,IAAA,GAAA,CAAI,OAAO,SAAA,CAAU,UAAA,IAAc,UAAA,EAAY;AAC7C,MAAA,MAAMA,QAAAA,EAAU,SAAA,CAAU,SAAA,CAA4B,IAAA,CAAK,SAAS,CAAA;AACpE,MAAA,OAAO,OAAOA,QAAAA,IAAW,SAAA,EAAWA,QAAAA,EAAS,KAAA,CAAA;AAAA,IAC/C;AACA,IAAA,MAAM,OAAA,mBAAS,SAAA,CAAU,MAAA,UAAU,SAAA,CAAU,YAAA;AAC7C,IAAA,OAAO,OAAO,OAAA,IAAW,SAAA,EAAW,OAAA,EAAS,KAAA,CAAA;AAAA,EAC/C;AACF,CAAA;AJ0OA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,ydAAC","file":"/home/runner/work/watchdog/watchdog/packages/node/dist/chunk-S6H6O6BV.cjs","sourcesContent":[null,"import { hostname, platform, arch } from 'node:os';\nimport {\n Breadcrumb,\n CaptureContext,\n Level,\n UserContext,\n WatchdogClient,\n WatchdogEvent,\n} from '@watchdog-sdk/core';\nimport { ContextLines } from './context-lines';\nimport { HttpRequestLike, NodeOptions, Uninstall } from './interfaces';\nimport { RequestContextBuilder } from './request-context';\n\nconst SDK = { name: 'watchdog.node', version: '0.4.3' };\nconst DEFAULT_FLUSH_TIMEOUT_MS = 2_000;\nconst EXIT_CODE_UNCAUGHT = 1;\n\nlet client: WatchdogClient | null = null;\nlet uninstallers: Uninstall[] = [];\n\nexport function init(options: NodeOptions): WatchdogClient {\n close();\n const {\n captureUncaughtExceptions = true,\n captureUnhandledRejections = true,\n onUnhandledRejection = 'warn',\n contextLines = true,\n flushTimeoutMs = DEFAULT_FLUSH_TIMEOUT_MS,\n ...coreOptions\n } = options;\n\n const created = new WatchdogClient(\n {\n ...coreOptions,\n platform: 'node',\n beforeSend: (event) => {\n const enriched = contextLines ? withContextLines(event) : event;\n return coreOptions.beforeSend ? coreOptions.beforeSend(enriched) : enriched;\n },\n },\n SDK,\n );\n created.setContext('runtime', { name: 'node', version: process.version });\n created.setContext('os', { platform: platform(), arch: arch() });\n created.setTag('server_name', hostname());\n client = created;\n\n if (captureUncaughtExceptions) {\n uninstallers.push(installUncaughtException(created, flushTimeoutMs));\n }\n if (captureUnhandledRejections) {\n uninstallers.push(installUnhandledRejection(created, onUnhandledRejection, flushTimeoutMs));\n }\n return created;\n}\n\nexport function close(): void {\n for (const uninstall of uninstallers) {\n uninstall();\n }\n uninstallers = [];\n client = null;\n}\n\nexport function getClient(): WatchdogClient | null {\n return client;\n}\n\nexport function captureException(error: unknown, context?: CaptureContext): string | undefined {\n return client?.captureException(error, context);\n}\n\nexport function captureMessage(message: string, level?: Level, context?: CaptureContext): string | undefined {\n return client?.captureMessage(message, level, context);\n}\n\nexport function captureRequestError(error: unknown, request: HttpRequestLike, context?: CaptureContext): string | undefined {\n return client?.captureException(error, { ...context, request: RequestContextBuilder.from(request) });\n}\n\nexport function addBreadcrumb(breadcrumb: Breadcrumb): void {\n client?.addBreadcrumb(breadcrumb);\n}\n\nexport function setUser(user: UserContext | undefined): void {\n client?.setUser(user);\n}\n\nexport function setTag(key: string, value: string): void {\n client?.setTag(key, value);\n}\n\nexport function setExtra(key: string, value: unknown): void {\n client?.setExtra(key, value);\n}\n\nexport function setContext(key: string, value: unknown): void {\n client?.setContext(key, value);\n}\n\nexport function flush(timeoutMs?: number): Promise<boolean> {\n return client ? client.flush(timeoutMs) : Promise.resolve(true);\n}\n\nfunction withContextLines(event: WatchdogEvent): WatchdogEvent {\n if (!event.exception) {\n return event;\n }\n return {\n ...event,\n exception: {\n ...event.exception,\n stacktrace: { frames: ContextLines.enrich(event.exception.stacktrace.frames) },\n },\n };\n}\n\nfunction installUncaughtException(target: WatchdogClient, flushTimeoutMs: number): Uninstall {\n const handler = (error: Error): void => {\n target.captureException(error, { handled: false, level: 'fatal', tags: { mechanism: 'uncaughtException' } });\n void target.flush(flushTimeoutMs).finally(() => {\n if (process.listenerCount('uncaughtException') <= 1) {\n process.exit(EXIT_CODE_UNCAUGHT);\n }\n });\n };\n process.on('uncaughtException', handler);\n return () => process.off('uncaughtException', handler);\n}\n\nfunction installUnhandledRejection(\n target: WatchdogClient,\n mode: 'warn' | 'exit',\n flushTimeoutMs: number,\n): Uninstall {\n const handler = (reason: unknown): void => {\n target.captureException(reason, { handled: false, tags: { mechanism: 'unhandledRejection' } });\n if (mode === 'exit') {\n void target.flush(flushTimeoutMs).finally(() => process.exit(EXIT_CODE_UNCAUGHT));\n return;\n }\n console.warn('[watchdog] unhandled promise rejection:', reason);\n };\n process.on('unhandledRejection', handler);\n return () => process.off('unhandledRejection', handler);\n}\n","import { readFileSync, statSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport type { Frame } from '@watchdog-sdk/core';\n\nconst CONTEXT_RADIUS = 5;\nconst MAX_FILE_BYTES = 2 * 1024 * 1024;\nconst MAX_CACHED_FILES = 100;\nconst MAX_LINE_LENGTH = 400;\n\nexport class ContextLines {\n private static readonly cache = new Map<string, string[] | null>();\n\n static enrich(frames: Frame[]): Frame[] {\n return frames.map((frame) => ContextLines.enrichFrame(frame));\n }\n\n static resolvePath(filename: string): string | null {\n if (/^https?:\\/\\//.test(filename) || filename.startsWith('node:')) {\n return null;\n }\n if (filename.startsWith('file://')) {\n try {\n return fileURLToPath(filename);\n } catch {\n return null;\n }\n }\n return filename;\n }\n\n static clearCache(): void {\n ContextLines.cache.clear();\n }\n\n private static enrichFrame(frame: Frame): Frame {\n if (frame.inApp === false || !frame.filename || frame.lineno === undefined) {\n return frame;\n }\n const path = ContextLines.resolvePath(frame.filename);\n const lines = path ? ContextLines.readLines(path) : null;\n if (!lines || frame.lineno < 1 || frame.lineno > lines.length) {\n return frame;\n }\n const index = frame.lineno - 1;\n return {\n ...frame,\n contextLine: ContextLines.clip(lines[index]),\n preContext: lines.slice(Math.max(index - CONTEXT_RADIUS, 0), index).map(ContextLines.clip),\n postContext: lines.slice(index + 1, index + 1 + CONTEXT_RADIUS).map(ContextLines.clip),\n };\n }\n\n private static readLines(path: string): string[] | null {\n if (ContextLines.cache.has(path)) {\n return ContextLines.cache.get(path) ?? null;\n }\n const lines = ContextLines.load(path);\n if (ContextLines.cache.size >= MAX_CACHED_FILES) {\n const oldest = ContextLines.cache.keys().next().value;\n if (oldest !== undefined) {\n ContextLines.cache.delete(oldest);\n }\n }\n ContextLines.cache.set(path, lines);\n return lines;\n }\n\n private static load(path: string): string[] | null {\n try {\n if (statSync(path).size > MAX_FILE_BYTES) {\n return null;\n }\n return readFileSync(path, 'utf8').split(/\\r?\\n/);\n } catch {\n return null;\n }\n }\n\n private static clip(line: string): string {\n return line.length > MAX_LINE_LENGTH ? line.slice(0, MAX_LINE_LENGTH) : line;\n }\n}\n","import type { RequestContext } from '@watchdog-sdk/core';\nimport { HttpRequestLike } from './interfaces';\n\nconst SAFE_HEADERS = new Set([\n 'user-agent',\n 'referer',\n 'content-type',\n 'content-length',\n 'accept',\n 'accept-language',\n 'host',\n 'x-request-id',\n]);\n\nexport class RequestContextBuilder {\n static from(request: HttpRequestLike): RequestContext {\n const headers: Record<string, string> = {};\n for (const [name, value] of Object.entries(request.headers ?? {})) {\n if (SAFE_HEADERS.has(name.toLowerCase()) && value !== undefined) {\n headers[name.toLowerCase()] = Array.isArray(value) ? value.join(', ') : value;\n }\n }\n return {\n url: RequestContextBuilder.stripQuery(request.originalUrl ?? request.url),\n method: request.method,\n headers,\n };\n }\n\n private static stripQuery(url: string | undefined): string | undefined {\n return url?.split('?')[0];\n }\n}\n","const SERVER_ERROR_STATUS = 500;\n\nexport class ExceptionPolicy {\n static shouldReport(exception: unknown): boolean {\n const status = ExceptionPolicy.statusOf(exception);\n return status === undefined || status >= SERVER_ERROR_STATUS;\n }\n\n private static statusOf(exception: unknown): number | undefined {\n if (typeof exception !== 'object' || exception === null) {\n return undefined;\n }\n const candidate = exception as { getStatus?: unknown; status?: unknown; statusCode?: unknown };\n if (typeof candidate.getStatus === 'function') {\n const status = (candidate.getStatus as () => unknown).call(exception);\n return typeof status === 'number' ? status : undefined;\n }\n const status = candidate.status ?? candidate.statusCode;\n return typeof status === 'number' ? status : undefined;\n }\n}\n"]}
package/dist/index.cjs ADDED
@@ -0,0 +1,42 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+ var _chunkS6H6O6BVcjs = require('./chunk-S6H6O6BV.cjs');
16
+
17
+ // src/express.ts
18
+ function expressErrorHandler() {
19
+ return (error, request, _response, next) => {
20
+ if (_chunkS6H6O6BVcjs.ExceptionPolicy.shouldReport(error)) {
21
+ _chunkS6H6O6BVcjs.captureRequestError.call(void 0, error, request, { handled: true, tags: { mechanism: "express" } });
22
+ }
23
+ next(error);
24
+ };
25
+ }
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+ exports.ExceptionPolicy = _chunkS6H6O6BVcjs.ExceptionPolicy; exports.addBreadcrumb = _chunkS6H6O6BVcjs.addBreadcrumb; exports.captureException = _chunkS6H6O6BVcjs.captureException; exports.captureMessage = _chunkS6H6O6BVcjs.captureMessage; exports.captureRequestError = _chunkS6H6O6BVcjs.captureRequestError; exports.close = _chunkS6H6O6BVcjs.close; exports.expressErrorHandler = expressErrorHandler; exports.flush = _chunkS6H6O6BVcjs.flush; exports.getClient = _chunkS6H6O6BVcjs.getClient; exports.init = _chunkS6H6O6BVcjs.init; exports.setContext = _chunkS6H6O6BVcjs.setContext; exports.setExtra = _chunkS6H6O6BVcjs.setExtra; exports.setTag = _chunkS6H6O6BVcjs.setTag; exports.setUser = _chunkS6H6O6BVcjs.setUser;
42
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/watchdog/watchdog/packages/node/dist/index.cjs","../src/express.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACVO,SAAS,mBAAA,CAAA,EAAsB;AACpC,EAAA,OAAO,CAAC,KAAA,EAAgB,OAAA,EAA0B,SAAA,EAAoB,IAAA,EAAA,GAA6B;AACjG,IAAA,GAAA,CAAI,iCAAA,CAAgB,YAAA,CAAa,KAAK,CAAA,EAAG;AACvC,MAAA,mDAAA,KAAoB,EAAO,OAAA,EAAS,EAAE,OAAA,EAAS,IAAA,EAAM,IAAA,EAAM,EAAE,SAAA,EAAW,UAAU,EAAE,CAAC,CAAA;AAAA,IACvF;AACA,IAAA,IAAA,CAAK,KAAK,CAAA;AAAA,EACZ,CAAA;AACF;ADYA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,2sBAAC","file":"/home/runner/work/watchdog/watchdog/packages/node/dist/index.cjs","sourcesContent":[null,"import { HttpRequestLike } from './interfaces';\nimport { captureRequestError } from './node-sdk';\nimport { ExceptionPolicy } from './exception-policy';\n\ntype NextFunction = (error?: unknown) => void;\n\nexport function expressErrorHandler() {\n return (error: unknown, request: HttpRequestLike, _response: unknown, next: NextFunction): void => {\n if (ExceptionPolicy.shouldReport(error)) {\n captureRequestError(error, request, { handled: true, tags: { mechanism: 'express' } });\n }\n next(error);\n };\n}\n"]}
@@ -0,0 +1,40 @@
1
+ import { WatchdogOptions, Breadcrumb, CaptureContext, Level, WatchdogClient, UserContext } from '@watchdog-sdk/core';
2
+ export { Breadcrumb, CaptureContext, Level, UserContext, WatchdogEvent } from '@watchdog-sdk/core';
3
+
4
+ interface NodeOptions extends WatchdogOptions {
5
+ captureUncaughtExceptions?: boolean;
6
+ captureUnhandledRejections?: boolean;
7
+ onUnhandledRejection?: 'warn' | 'exit';
8
+ contextLines?: boolean;
9
+ flushTimeoutMs?: number;
10
+ }
11
+ interface HttpRequestLike {
12
+ originalUrl?: string;
13
+ url?: string;
14
+ method?: string;
15
+ headers?: Record<string, string | string[] | undefined>;
16
+ }
17
+
18
+ declare function init(options: NodeOptions): WatchdogClient;
19
+ declare function close(): void;
20
+ declare function getClient(): WatchdogClient | null;
21
+ declare function captureException(error: unknown, context?: CaptureContext): string | undefined;
22
+ declare function captureMessage(message: string, level?: Level, context?: CaptureContext): string | undefined;
23
+ declare function captureRequestError(error: unknown, request: HttpRequestLike, context?: CaptureContext): string | undefined;
24
+ declare function addBreadcrumb(breadcrumb: Breadcrumb): void;
25
+ declare function setUser(user: UserContext | undefined): void;
26
+ declare function setTag(key: string, value: string): void;
27
+ declare function setExtra(key: string, value: unknown): void;
28
+ declare function setContext(key: string, value: unknown): void;
29
+ declare function flush(timeoutMs?: number): Promise<boolean>;
30
+
31
+ type NextFunction = (error?: unknown) => void;
32
+ declare function expressErrorHandler(): (error: unknown, request: HttpRequestLike, _response: unknown, next: NextFunction) => void;
33
+
34
+ declare class ExceptionPolicy {
35
+ static shouldReport(exception: unknown): boolean;
36
+ private static statusOf;
37
+ }
38
+
39
+ export { ExceptionPolicy, addBreadcrumb, captureException, captureMessage, captureRequestError, close, expressErrorHandler, flush, getClient, init, setContext, setExtra, setTag, setUser };
40
+ export type { HttpRequestLike, NodeOptions };
@@ -0,0 +1,40 @@
1
+ import { WatchdogOptions, Breadcrumb, CaptureContext, Level, WatchdogClient, UserContext } from '@watchdog-sdk/core';
2
+ export { Breadcrumb, CaptureContext, Level, UserContext, WatchdogEvent } from '@watchdog-sdk/core';
3
+
4
+ interface NodeOptions extends WatchdogOptions {
5
+ captureUncaughtExceptions?: boolean;
6
+ captureUnhandledRejections?: boolean;
7
+ onUnhandledRejection?: 'warn' | 'exit';
8
+ contextLines?: boolean;
9
+ flushTimeoutMs?: number;
10
+ }
11
+ interface HttpRequestLike {
12
+ originalUrl?: string;
13
+ url?: string;
14
+ method?: string;
15
+ headers?: Record<string, string | string[] | undefined>;
16
+ }
17
+
18
+ declare function init(options: NodeOptions): WatchdogClient;
19
+ declare function close(): void;
20
+ declare function getClient(): WatchdogClient | null;
21
+ declare function captureException(error: unknown, context?: CaptureContext): string | undefined;
22
+ declare function captureMessage(message: string, level?: Level, context?: CaptureContext): string | undefined;
23
+ declare function captureRequestError(error: unknown, request: HttpRequestLike, context?: CaptureContext): string | undefined;
24
+ declare function addBreadcrumb(breadcrumb: Breadcrumb): void;
25
+ declare function setUser(user: UserContext | undefined): void;
26
+ declare function setTag(key: string, value: string): void;
27
+ declare function setExtra(key: string, value: unknown): void;
28
+ declare function setContext(key: string, value: unknown): void;
29
+ declare function flush(timeoutMs?: number): Promise<boolean>;
30
+
31
+ type NextFunction = (error?: unknown) => void;
32
+ declare function expressErrorHandler(): (error: unknown, request: HttpRequestLike, _response: unknown, next: NextFunction) => void;
33
+
34
+ declare class ExceptionPolicy {
35
+ static shouldReport(exception: unknown): boolean;
36
+ private static statusOf;
37
+ }
38
+
39
+ export { ExceptionPolicy, addBreadcrumb, captureException, captureMessage, captureRequestError, close, expressErrorHandler, flush, getClient, init, setContext, setExtra, setTag, setUser };
40
+ export type { HttpRequestLike, NodeOptions };
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ import {
2
+ ExceptionPolicy,
3
+ addBreadcrumb,
4
+ captureException,
5
+ captureMessage,
6
+ captureRequestError,
7
+ close,
8
+ flush,
9
+ getClient,
10
+ init,
11
+ setContext,
12
+ setExtra,
13
+ setTag,
14
+ setUser
15
+ } from "./chunk-EC2UJND6.js";
16
+
17
+ // src/express.ts
18
+ function expressErrorHandler() {
19
+ return (error, request, _response, next) => {
20
+ if (ExceptionPolicy.shouldReport(error)) {
21
+ captureRequestError(error, request, { handled: true, tags: { mechanism: "express" } });
22
+ }
23
+ next(error);
24
+ };
25
+ }
26
+ export {
27
+ ExceptionPolicy,
28
+ addBreadcrumb,
29
+ captureException,
30
+ captureMessage,
31
+ captureRequestError,
32
+ close,
33
+ expressErrorHandler,
34
+ flush,
35
+ getClient,
36
+ init,
37
+ setContext,
38
+ setExtra,
39
+ setTag,
40
+ setUser
41
+ };
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/express.ts"],"sourcesContent":["import { HttpRequestLike } from './interfaces';\nimport { captureRequestError } from './node-sdk';\nimport { ExceptionPolicy } from './exception-policy';\n\ntype NextFunction = (error?: unknown) => void;\n\nexport function expressErrorHandler() {\n return (error: unknown, request: HttpRequestLike, _response: unknown, next: NextFunction): void => {\n if (ExceptionPolicy.shouldReport(error)) {\n captureRequestError(error, request, { handled: true, tags: { mechanism: 'express' } });\n }\n next(error);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAMO,SAAS,sBAAsB;AACpC,SAAO,CAAC,OAAgB,SAA0B,WAAoB,SAA6B;AACjG,QAAI,gBAAgB,aAAa,KAAK,GAAG;AACvC,0BAAoB,OAAO,SAAS,EAAE,SAAS,MAAM,MAAM,EAAE,WAAW,UAAU,EAAE,CAAC;AAAA,IACvF;AACA,SAAK,KAAK;AAAA,EACZ;AACF;","names":[]}
package/dist/nest.cjs ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkS6H6O6BVcjs = require('./chunk-S6H6O6BV.cjs');
6
+
7
+ // src/nest.ts
8
+ var _common = require('@nestjs/common');
9
+ var _core = require('@nestjs/core');
10
+ var WatchdogExceptionFilter = class extends _core.BaseExceptionFilter {
11
+ catch(exception, host) {
12
+ if (_chunkS6H6O6BVcjs.ExceptionPolicy.shouldReport(exception) && host.getType() === "http") {
13
+ const request = host.switchToHttp().getRequest();
14
+ _chunkS6H6O6BVcjs.captureRequestError.call(void 0, exception, request, { handled: true, tags: { mechanism: "nestjs" } });
15
+ }
16
+ super.catch(exception, host);
17
+ }
18
+ };
19
+ WatchdogExceptionFilter = exports.WatchdogExceptionFilter = _chunkS6H6O6BVcjs.__decorateClass.call(void 0, [
20
+ _common.Catch.call(void 0, )
21
+ ], WatchdogExceptionFilter);
22
+
23
+
24
+ exports.WatchdogExceptionFilter = WatchdogExceptionFilter;
25
+ //# sourceMappingURL=nest.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/watchdog/watchdog/packages/node/dist/nest.cjs","../src/nest.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACNA,wCAAqC;AACrC,oCAAoC;AAK7B,IAAM,wBAAA,EAAN,MAAA,QAAsC,0BAAoB;AAAA,EAC/D,KAAA,CAAM,SAAA,EAAoB,IAAA,EAA2B;AACnD,IAAA,GAAA,CAAI,iCAAA,CAAgB,YAAA,CAAa,SAAS,EAAA,GAAK,IAAA,CAAK,OAAA,CAAQ,EAAA,IAAM,MAAA,EAAQ;AACxE,MAAA,MAAM,QAAA,EAAU,IAAA,CAAK,YAAA,CAAa,CAAA,CAAE,UAAA,CAAW,CAAA;AAC/C,MAAA,mDAAA,SAAoB,EAAW,OAAA,EAAS,EAAE,OAAA,EAAS,IAAA,EAAM,IAAA,EAAM,EAAE,SAAA,EAAW,SAAS,EAAE,CAAC,CAAA;AAAA,IAC1F;AACA,IAAA,KAAA,CAAM,KAAA,CAAM,SAAA,EAAW,IAAI,CAAA;AAAA,EAC7B;AACF,CAAA;AARa,wBAAA,oCAAN,+CAAA;AAAA,EADN,2BAAA;AAAM,CAAA,EACM,uBAAA,CAAA;ADeb;AACE;AACF,0DAAC","file":"/home/runner/work/watchdog/watchdog/packages/node/dist/nest.cjs","sourcesContent":[null,"import { ArgumentsHost, Catch } from '@nestjs/common';\nimport { BaseExceptionFilter } from '@nestjs/core';\nimport { ExceptionPolicy } from './exception-policy';\nimport { captureRequestError } from './node-sdk';\n\n@Catch()\nexport class WatchdogExceptionFilter extends BaseExceptionFilter {\n catch(exception: unknown, host: ArgumentsHost): void {\n if (ExceptionPolicy.shouldReport(exception) && host.getType() === 'http') {\n const request = host.switchToHttp().getRequest();\n captureRequestError(exception, request, { handled: true, tags: { mechanism: 'nestjs' } });\n }\n super.catch(exception, host);\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { ArgumentsHost } from '@nestjs/common';
2
+ import { BaseExceptionFilter } from '@nestjs/core';
3
+
4
+ declare class WatchdogExceptionFilter extends BaseExceptionFilter {
5
+ catch(exception: unknown, host: ArgumentsHost): void;
6
+ }
7
+
8
+ export { WatchdogExceptionFilter };
package/dist/nest.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { ArgumentsHost } from '@nestjs/common';
2
+ import { BaseExceptionFilter } from '@nestjs/core';
3
+
4
+ declare class WatchdogExceptionFilter extends BaseExceptionFilter {
5
+ catch(exception: unknown, host: ArgumentsHost): void;
6
+ }
7
+
8
+ export { WatchdogExceptionFilter };
package/dist/nest.js ADDED
@@ -0,0 +1,25 @@
1
+ import {
2
+ ExceptionPolicy,
3
+ __decorateClass,
4
+ captureRequestError
5
+ } from "./chunk-EC2UJND6.js";
6
+
7
+ // src/nest.ts
8
+ import { Catch } from "@nestjs/common";
9
+ import { BaseExceptionFilter } from "@nestjs/core";
10
+ var WatchdogExceptionFilter = class extends BaseExceptionFilter {
11
+ catch(exception, host) {
12
+ if (ExceptionPolicy.shouldReport(exception) && host.getType() === "http") {
13
+ const request = host.switchToHttp().getRequest();
14
+ captureRequestError(exception, request, { handled: true, tags: { mechanism: "nestjs" } });
15
+ }
16
+ super.catch(exception, host);
17
+ }
18
+ };
19
+ WatchdogExceptionFilter = __decorateClass([
20
+ Catch()
21
+ ], WatchdogExceptionFilter);
22
+ export {
23
+ WatchdogExceptionFilter
24
+ };
25
+ //# sourceMappingURL=nest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/nest.ts"],"sourcesContent":["import { ArgumentsHost, Catch } from '@nestjs/common';\nimport { BaseExceptionFilter } from '@nestjs/core';\nimport { ExceptionPolicy } from './exception-policy';\nimport { captureRequestError } from './node-sdk';\n\n@Catch()\nexport class WatchdogExceptionFilter extends BaseExceptionFilter {\n catch(exception: unknown, host: ArgumentsHost): void {\n if (ExceptionPolicy.shouldReport(exception) && host.getType() === 'http') {\n const request = host.switchToHttp().getRequest();\n captureRequestError(exception, request, { handled: true, tags: { mechanism: 'nestjs' } });\n }\n super.catch(exception, host);\n }\n}\n"],"mappings":";;;;;;;AAAA,SAAwB,aAAa;AACrC,SAAS,2BAA2B;AAK7B,IAAM,0BAAN,cAAsC,oBAAoB;AAAA,EAC/D,MAAM,WAAoB,MAA2B;AACnD,QAAI,gBAAgB,aAAa,SAAS,KAAK,KAAK,QAAQ,MAAM,QAAQ;AACxE,YAAM,UAAU,KAAK,aAAa,EAAE,WAAW;AAC/C,0BAAoB,WAAW,SAAS,EAAE,SAAS,MAAM,MAAM,EAAE,WAAW,SAAS,EAAE,CAAC;AAAA,IAC1F;AACA,UAAM,MAAM,WAAW,IAAI;AAAA,EAC7B;AACF;AARa,0BAAN;AAAA,EADN,MAAM;AAAA,GACM;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,96 @@
1
1
  {
2
2
  "name": "@watchdog-sdk/node",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.4.3",
4
+ "description": "Watchdog SDK for Node.js, Express and NestJS with source code context for every frame",
5
+ "keywords": [
6
+ "watchdog",
7
+ "error-tracking",
8
+ "node",
9
+ "express",
10
+ "nestjs",
11
+ "exception-filter",
12
+ "sdk"
13
+ ],
14
+ "license": "MIT",
15
+ "author": "Watchdog contributors",
16
+ "homepage": "https://github.com/Yassinos-coder/watchdog#readme",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/Yassinos-coder/watchdog.git",
20
+ "directory": "packages/node"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/Yassinos-coder/watchdog/issues"
24
+ },
25
+ "type": "module",
26
+ "sideEffects": false,
27
+ "main": "./dist/index.cjs",
28
+ "module": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "import": {
33
+ "types": "./dist/index.d.ts",
34
+ "default": "./dist/index.js"
35
+ },
36
+ "require": {
37
+ "types": "./dist/index.d.cts",
38
+ "default": "./dist/index.cjs"
39
+ }
40
+ },
41
+ "./nest": {
42
+ "import": {
43
+ "types": "./dist/nest.d.ts",
44
+ "default": "./dist/nest.js"
45
+ },
46
+ "require": {
47
+ "types": "./dist/nest.d.cts",
48
+ "default": "./dist/nest.cjs"
49
+ }
50
+ }
51
+ },
52
+ "files": [
53
+ "dist",
54
+ "README.md",
55
+ "LICENSE"
56
+ ],
57
+ "engines": {
58
+ "node": ">=18"
59
+ },
60
+ "publishConfig": {
61
+ "access": "public",
62
+ "provenance": true
63
+ },
64
+ "scripts": {
65
+ "build": "tsup",
66
+ "typecheck": "tsc --noEmit",
67
+ "test": "vitest run",
68
+ "clean": "rimraf dist .turbo"
69
+ },
70
+ "dependencies": {
71
+ "@watchdog-sdk/core": "0.4.3"
72
+ },
73
+ "peerDependencies": {
74
+ "@nestjs/common": ">=10",
75
+ "@nestjs/core": ">=10"
76
+ },
77
+ "peerDependenciesMeta": {
78
+ "@nestjs/common": {
79
+ "optional": true
80
+ },
81
+ "@nestjs/core": {
82
+ "optional": true
83
+ }
84
+ },
85
+ "devDependencies": {
86
+ "rimraf": "^6.1.3",
87
+ "tsup": "^9.0.0",
88
+ "typescript": "^6.0.3",
89
+ "vitest": "^5.1.0",
90
+ "@types/node": "^26.6.6",
91
+ "@nestjs/common": "^12.0.0",
92
+ "@nestjs/core": "^12.0.0",
93
+ "reflect-metadata": "^0.2.2",
94
+ "rxjs": "^7.8.2"
95
+ }
96
+ }