@error-explorer/node 1.1.1
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/dist/index.cjs +1720 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +261 -0
- package/dist/index.d.ts +261 -0
- package/dist/index.js +1674 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/express.cjs +1625 -0
- package/dist/middleware/express.cjs.map +1 -0
- package/dist/middleware/express.d.cts +60 -0
- package/dist/middleware/express.d.ts +60 -0
- package/dist/middleware/express.js +1597 -0
- package/dist/middleware/express.js.map +1 -0
- package/dist/middleware/http.cjs +1587 -0
- package/dist/middleware/http.cjs.map +1 -0
- package/dist/middleware/http.d.cts +29 -0
- package/dist/middleware/http.d.ts +29 -0
- package/dist/middleware/http.js +1560 -0
- package/dist/middleware/http.js.map +1 -0
- package/dist/types-D5NSSblm.d.cts +255 -0
- package/dist/types-D5NSSblm.d.ts +255 -0
- package/package.json +78 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Core types for @error-explorer/node SDK
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
interface InitOptions {
|
|
8
|
+
/** Webhook token (required) - format: ee_xxx */
|
|
9
|
+
token?: string;
|
|
10
|
+
/** Full DSN URL (alternative to token) - format: http(s)://token@host/path */
|
|
11
|
+
dsn?: string;
|
|
12
|
+
/** Environment name (production, staging, development) */
|
|
13
|
+
environment?: string;
|
|
14
|
+
/** Application release/version */
|
|
15
|
+
release?: string;
|
|
16
|
+
/** Server/hostname name */
|
|
17
|
+
serverName?: string;
|
|
18
|
+
/** API endpoint URL (auto-detected from token/dsn) */
|
|
19
|
+
endpoint?: string;
|
|
20
|
+
/** Auto capture settings */
|
|
21
|
+
autoCapture?: {
|
|
22
|
+
/** Capture uncaughtException (default: true) */
|
|
23
|
+
uncaughtExceptions?: boolean;
|
|
24
|
+
/** Capture unhandledRejection (default: true) */
|
|
25
|
+
unhandledRejections?: boolean;
|
|
26
|
+
/** Capture console.error calls (default: false) */
|
|
27
|
+
console?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/** Breadcrumbs settings */
|
|
30
|
+
breadcrumbs?: {
|
|
31
|
+
/** Enable breadcrumbs (default: true) */
|
|
32
|
+
enabled?: boolean;
|
|
33
|
+
/** Maximum breadcrumbs to keep (default: 50) */
|
|
34
|
+
maxBreadcrumbs?: number;
|
|
35
|
+
/** Track HTTP requests (default: true) */
|
|
36
|
+
http?: boolean;
|
|
37
|
+
/** Track console logs (default: true) */
|
|
38
|
+
console?: boolean;
|
|
39
|
+
};
|
|
40
|
+
/** Hook to modify/filter events before sending */
|
|
41
|
+
beforeSend?: (event: ErrorEvent) => ErrorEvent | null | Promise<ErrorEvent | null>;
|
|
42
|
+
/** Error messages to ignore */
|
|
43
|
+
ignoreErrors?: (string | RegExp)[];
|
|
44
|
+
/** Maximum retries for failed requests (default: 3) */
|
|
45
|
+
maxRetries?: number;
|
|
46
|
+
/** Request timeout in ms (default: 5000) */
|
|
47
|
+
timeout?: number;
|
|
48
|
+
/** Enable debug mode (default: false) */
|
|
49
|
+
debug?: boolean;
|
|
50
|
+
/** HMAC secret for signed requests (optional) */
|
|
51
|
+
hmacSecret?: string;
|
|
52
|
+
/** Exit on uncaughtException (default: true) - recommended to leave as true */
|
|
53
|
+
exitOnUncaughtException?: boolean;
|
|
54
|
+
}
|
|
55
|
+
interface UserContext {
|
|
56
|
+
id?: string;
|
|
57
|
+
email?: string;
|
|
58
|
+
username?: string;
|
|
59
|
+
name?: string;
|
|
60
|
+
ip_address?: string;
|
|
61
|
+
role?: string;
|
|
62
|
+
[key: string]: unknown;
|
|
63
|
+
}
|
|
64
|
+
type BreadcrumbType = 'http' | 'console' | 'query' | 'navigation' | 'error' | 'debug' | 'custom';
|
|
65
|
+
type BreadcrumbLevel = 'debug' | 'info' | 'warning' | 'error';
|
|
66
|
+
interface Breadcrumb {
|
|
67
|
+
type: BreadcrumbType;
|
|
68
|
+
category?: string;
|
|
69
|
+
message?: string;
|
|
70
|
+
level?: BreadcrumbLevel;
|
|
71
|
+
data?: Record<string, unknown>;
|
|
72
|
+
timestamp?: number;
|
|
73
|
+
}
|
|
74
|
+
interface InternalBreadcrumb extends Breadcrumb {
|
|
75
|
+
timestamp: number;
|
|
76
|
+
}
|
|
77
|
+
type SeverityLevel = 'critical' | 'error' | 'warning' | 'info' | 'notice' | 'debug';
|
|
78
|
+
interface StackFrame {
|
|
79
|
+
filename?: string;
|
|
80
|
+
function?: string;
|
|
81
|
+
lineno?: number;
|
|
82
|
+
colno?: number;
|
|
83
|
+
in_app?: boolean;
|
|
84
|
+
context_line?: string;
|
|
85
|
+
pre_context?: string[];
|
|
86
|
+
post_context?: string[];
|
|
87
|
+
abs_path?: string;
|
|
88
|
+
module?: string;
|
|
89
|
+
}
|
|
90
|
+
interface ErrorEvent {
|
|
91
|
+
/** Error message */
|
|
92
|
+
message: string;
|
|
93
|
+
/** Exception class name (TypeError, Error, etc.) */
|
|
94
|
+
exception_class?: string;
|
|
95
|
+
/** Source file */
|
|
96
|
+
file?: string;
|
|
97
|
+
/** Line number */
|
|
98
|
+
line?: number;
|
|
99
|
+
/** Column number */
|
|
100
|
+
column?: number;
|
|
101
|
+
/** Full stack trace as string */
|
|
102
|
+
stack_trace?: string;
|
|
103
|
+
/** Parsed stack frames */
|
|
104
|
+
frames?: StackFrame[];
|
|
105
|
+
/** Severity level */
|
|
106
|
+
severity: SeverityLevel;
|
|
107
|
+
/** Environment */
|
|
108
|
+
environment?: string;
|
|
109
|
+
/** Release version */
|
|
110
|
+
release?: string;
|
|
111
|
+
/** ISO timestamp */
|
|
112
|
+
timestamp: string;
|
|
113
|
+
/** User context */
|
|
114
|
+
user?: UserContext;
|
|
115
|
+
/** Request context (from HTTP middleware) */
|
|
116
|
+
request?: RequestContext;
|
|
117
|
+
/** Server context */
|
|
118
|
+
server?: ServerContext;
|
|
119
|
+
/** Runtime context (Node.js info) */
|
|
120
|
+
runtime?: RuntimeContext;
|
|
121
|
+
/** OS context */
|
|
122
|
+
os?: OsContext;
|
|
123
|
+
/** Process context */
|
|
124
|
+
process?: ProcessContext;
|
|
125
|
+
/** Breadcrumbs (last N actions before error) */
|
|
126
|
+
breadcrumbs?: InternalBreadcrumb[];
|
|
127
|
+
/** Custom tags */
|
|
128
|
+
tags?: Record<string, string>;
|
|
129
|
+
/** Extra data */
|
|
130
|
+
extra?: Record<string, unknown>;
|
|
131
|
+
/** Custom contexts */
|
|
132
|
+
contexts?: Record<string, Record<string, unknown>>;
|
|
133
|
+
/** SDK info */
|
|
134
|
+
sdk: SdkInfo;
|
|
135
|
+
/** Event fingerprint for grouping */
|
|
136
|
+
fingerprint?: string[];
|
|
137
|
+
/** Transaction/request ID */
|
|
138
|
+
transaction?: string;
|
|
139
|
+
}
|
|
140
|
+
interface RequestContext {
|
|
141
|
+
url?: string;
|
|
142
|
+
method?: string;
|
|
143
|
+
headers?: Record<string, string | string[] | undefined>;
|
|
144
|
+
query_string?: string;
|
|
145
|
+
data?: unknown;
|
|
146
|
+
cookies?: Record<string, string>;
|
|
147
|
+
env?: Record<string, string>;
|
|
148
|
+
}
|
|
149
|
+
interface ServerContext {
|
|
150
|
+
name?: string;
|
|
151
|
+
hostname?: string;
|
|
152
|
+
}
|
|
153
|
+
interface RuntimeContext {
|
|
154
|
+
name: string;
|
|
155
|
+
version: string;
|
|
156
|
+
}
|
|
157
|
+
interface OsContext {
|
|
158
|
+
name?: string;
|
|
159
|
+
version?: string;
|
|
160
|
+
arch?: string;
|
|
161
|
+
kernel_version?: string;
|
|
162
|
+
}
|
|
163
|
+
interface ProcessContext {
|
|
164
|
+
pid: number;
|
|
165
|
+
ppid?: number;
|
|
166
|
+
uptime?: number;
|
|
167
|
+
memory?: {
|
|
168
|
+
rss: number;
|
|
169
|
+
heapTotal: number;
|
|
170
|
+
heapUsed: number;
|
|
171
|
+
external: number;
|
|
172
|
+
arrayBuffers?: number;
|
|
173
|
+
};
|
|
174
|
+
cpu?: {
|
|
175
|
+
user: number;
|
|
176
|
+
system: number;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
interface SdkInfo {
|
|
180
|
+
name: string;
|
|
181
|
+
version: string;
|
|
182
|
+
}
|
|
183
|
+
interface CaptureContext {
|
|
184
|
+
tags?: Record<string, string>;
|
|
185
|
+
extra?: Record<string, unknown>;
|
|
186
|
+
user?: UserContext;
|
|
187
|
+
level?: SeverityLevel;
|
|
188
|
+
fingerprint?: string[];
|
|
189
|
+
request?: IncomingMessage;
|
|
190
|
+
}
|
|
191
|
+
interface TransportOptions {
|
|
192
|
+
endpoint: string;
|
|
193
|
+
token: string;
|
|
194
|
+
timeout: number;
|
|
195
|
+
maxRetries: number;
|
|
196
|
+
hmacSecret?: string;
|
|
197
|
+
debug?: boolean;
|
|
198
|
+
}
|
|
199
|
+
interface QueuedEvent {
|
|
200
|
+
event: ErrorEvent;
|
|
201
|
+
retries: number;
|
|
202
|
+
timestamp: number;
|
|
203
|
+
}
|
|
204
|
+
interface ResolvedConfig {
|
|
205
|
+
token: string;
|
|
206
|
+
endpoint: string;
|
|
207
|
+
environment: string;
|
|
208
|
+
release: string;
|
|
209
|
+
serverName: string;
|
|
210
|
+
autoCapture: {
|
|
211
|
+
uncaughtExceptions: boolean;
|
|
212
|
+
unhandledRejections: boolean;
|
|
213
|
+
console: boolean;
|
|
214
|
+
};
|
|
215
|
+
breadcrumbs: {
|
|
216
|
+
enabled: boolean;
|
|
217
|
+
maxBreadcrumbs: number;
|
|
218
|
+
http: boolean;
|
|
219
|
+
console: boolean;
|
|
220
|
+
};
|
|
221
|
+
beforeSend?: (event: ErrorEvent) => ErrorEvent | null | Promise<ErrorEvent | null>;
|
|
222
|
+
ignoreErrors: (string | RegExp)[];
|
|
223
|
+
maxRetries: number;
|
|
224
|
+
timeout: number;
|
|
225
|
+
debug: boolean;
|
|
226
|
+
hmacSecret?: string;
|
|
227
|
+
exitOnUncaughtException: boolean;
|
|
228
|
+
}
|
|
229
|
+
interface RequestWithErrorExplorer extends IncomingMessage {
|
|
230
|
+
errorExplorer?: {
|
|
231
|
+
transaction?: string;
|
|
232
|
+
user?: UserContext;
|
|
233
|
+
tags?: Record<string, string>;
|
|
234
|
+
extra?: Record<string, unknown>;
|
|
235
|
+
startTime?: number;
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
type ExpressRequest = RequestWithErrorExplorer & {
|
|
239
|
+
body?: unknown;
|
|
240
|
+
query?: Record<string, string>;
|
|
241
|
+
params?: Record<string, string>;
|
|
242
|
+
cookies?: Record<string, string>;
|
|
243
|
+
path?: string;
|
|
244
|
+
originalUrl?: string;
|
|
245
|
+
ip?: string;
|
|
246
|
+
ips?: string[];
|
|
247
|
+
};
|
|
248
|
+
type ExpressResponse = ServerResponse & {
|
|
249
|
+
statusCode: number;
|
|
250
|
+
};
|
|
251
|
+
type ExpressNextFunction = (error?: Error | unknown) => void;
|
|
252
|
+
type ExpressMiddleware = (req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction) => void;
|
|
253
|
+
type ExpressErrorMiddleware = (error: Error, req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction) => void;
|
|
254
|
+
|
|
255
|
+
export type { Breadcrumb as B, CaptureContext as C, ExpressRequest as E, InitOptions as I, OsContext as O, ProcessContext as P, QueuedEvent as Q, ResolvedConfig as R, SeverityLevel as S, TransportOptions as T, UserContext as U, InternalBreadcrumb as a, RuntimeContext as b, ServerContext as c, RequestContext as d, StackFrame as e, BreadcrumbType as f, BreadcrumbLevel as g, ErrorEvent as h, SdkInfo as i, ExpressResponse as j, ExpressNextFunction as k, ExpressMiddleware as l, ExpressErrorMiddleware as m };
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@error-explorer/node",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Error Explorer SDK for Node.js - Automatic error tracking and monitoring",
|
|
6
|
+
"main": "dist/index.cjs",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./express": {
|
|
16
|
+
"types": "./dist/middleware/express.d.ts",
|
|
17
|
+
"import": "./dist/middleware/express.js",
|
|
18
|
+
"require": "./dist/middleware/express.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./http": {
|
|
21
|
+
"types": "./dist/middleware/http.d.ts",
|
|
22
|
+
"import": "./dist/middleware/http.js",
|
|
23
|
+
"require": "./dist/middleware/http.cjs"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsup",
|
|
31
|
+
"build:watch": "tsup --watch",
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"test:watch": "vitest",
|
|
34
|
+
"test:coverage": "vitest run --coverage",
|
|
35
|
+
"lint": "eslint src --ext .ts",
|
|
36
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"clean": "rm -rf dist",
|
|
39
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"error",
|
|
43
|
+
"tracking",
|
|
44
|
+
"monitoring",
|
|
45
|
+
"nodejs",
|
|
46
|
+
"express",
|
|
47
|
+
"error-explorer",
|
|
48
|
+
"breadcrumbs",
|
|
49
|
+
"logging",
|
|
50
|
+
"crash-reporting",
|
|
51
|
+
"exception-handling"
|
|
52
|
+
],
|
|
53
|
+
"author": "Error Explorer",
|
|
54
|
+
"license": "MIT",
|
|
55
|
+
"repository": {
|
|
56
|
+
"type": "git",
|
|
57
|
+
"url": "https://github.com/Error-Explorer/SDKs.git",
|
|
58
|
+
"directory": "core/node"
|
|
59
|
+
},
|
|
60
|
+
"bugs": {
|
|
61
|
+
"url": "https://github.com/Error-Explorer/SDKs/issues"
|
|
62
|
+
},
|
|
63
|
+
"homepage": "https://github.com/Error-Explorer/SDKs/tree/main/core/node#readme",
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@types/node": "^20.10.0",
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "^6.13.0",
|
|
67
|
+
"@typescript-eslint/parser": "^6.13.0",
|
|
68
|
+
"@vitest/coverage-v8": "^1.1.0",
|
|
69
|
+
"eslint": "^8.55.0",
|
|
70
|
+
"tsup": "^8.0.1",
|
|
71
|
+
"typescript": "^5.3.0",
|
|
72
|
+
"vitest": "^1.1.0"
|
|
73
|
+
},
|
|
74
|
+
"engines": {
|
|
75
|
+
"node": ">=18.0.0"
|
|
76
|
+
},
|
|
77
|
+
"sideEffects": false
|
|
78
|
+
}
|