@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.
@@ -0,0 +1,261 @@
1
+ import { I as InitOptions, U as UserContext, B as Breadcrumb, C as CaptureContext, S as SeverityLevel, R as ResolvedConfig, a as InternalBreadcrumb, P as ProcessContext, O as OsContext, b as RuntimeContext, c as ServerContext, E as ExpressRequest, d as RequestContext, e as StackFrame } from './types-D5NSSblm.js';
2
+ export { g as BreadcrumbLevel, f as BreadcrumbType, h as ErrorEvent, m as ExpressErrorMiddleware, l as ExpressMiddleware, k as ExpressNextFunction, j as ExpressResponse, Q as QueuedEvent, i as SdkInfo, T as TransportOptions } from './types-D5NSSblm.js';
3
+ export { ErrorHandlerOptions, RequestHandlerOptions, errorHandler, requestHandler, setupExpress } from './middleware/express.js';
4
+ export { HttpHandlerOptions, createTrackedServer, wrapHandler } from './middleware/http.js';
5
+ import { IncomingMessage } from 'node:http';
6
+
7
+ /**
8
+ * Main ErrorExplorer client for Node.js
9
+ */
10
+
11
+ /**
12
+ * Main ErrorExplorer class - singleton pattern
13
+ */
14
+ declare class ErrorExplorerClient {
15
+ private config;
16
+ private transport;
17
+ private initialized;
18
+ private tags;
19
+ private extra;
20
+ private contexts;
21
+ /**
22
+ * Initialize the SDK
23
+ */
24
+ init(options: InitOptions): void;
25
+ /**
26
+ * Check if SDK is initialized
27
+ */
28
+ isInitialized(): boolean;
29
+ /**
30
+ * Set user context
31
+ */
32
+ setUser(user: UserContext | null): void;
33
+ /**
34
+ * Clear user context
35
+ */
36
+ clearUser(): void;
37
+ /**
38
+ * Set a single tag
39
+ */
40
+ setTag(key: string, value: string): void;
41
+ /**
42
+ * Set multiple tags
43
+ */
44
+ setTags(tags: Record<string, string>): void;
45
+ /**
46
+ * Set extra data
47
+ */
48
+ setExtra(key: string, value: unknown): void;
49
+ /**
50
+ * Set a named context
51
+ */
52
+ setContext(name: string, context: Record<string, unknown>): void;
53
+ /**
54
+ * Add a manual breadcrumb
55
+ */
56
+ addBreadcrumb(breadcrumb: Breadcrumb): void;
57
+ /**
58
+ * Capture an exception manually
59
+ */
60
+ captureException(error: Error | unknown, context?: CaptureContext): string;
61
+ /**
62
+ * Capture a message manually
63
+ */
64
+ captureMessage(message: string, level?: SeverityLevel): string;
65
+ /**
66
+ * Flush all pending events (best effort)
67
+ */
68
+ flush(timeout?: number): Promise<boolean>;
69
+ /**
70
+ * Close the SDK and cleanup
71
+ */
72
+ close(timeout?: number): Promise<boolean>;
73
+ /**
74
+ * Handle a captured error from auto-capture
75
+ */
76
+ private handleCapturedError;
77
+ /**
78
+ * Check if an error should be ignored
79
+ */
80
+ private shouldIgnoreError;
81
+ /**
82
+ * Build a complete error event
83
+ */
84
+ private buildEvent;
85
+ /**
86
+ * Process event through beforeSend and send
87
+ */
88
+ private processAndSend;
89
+ /**
90
+ * Start all breadcrumb trackers
91
+ */
92
+ private startBreadcrumbTrackers;
93
+ /**
94
+ * Stop all breadcrumb trackers
95
+ */
96
+ private stopAllTrackers;
97
+ }
98
+ declare const ErrorExplorer: ErrorExplorerClient;
99
+
100
+ /**
101
+ * Breadcrumb manager for @error-explorer/node SDK
102
+ */
103
+
104
+ /**
105
+ * Breadcrumb manager singleton
106
+ */
107
+ declare class BreadcrumbManager {
108
+ private breadcrumbs;
109
+ private maxBreadcrumbs;
110
+ /**
111
+ * Initialize with configuration
112
+ */
113
+ init(config: ResolvedConfig): void;
114
+ /**
115
+ * Add a breadcrumb
116
+ */
117
+ add(breadcrumb: Breadcrumb): void;
118
+ /**
119
+ * Get all breadcrumbs (oldest first)
120
+ */
121
+ getAll(): InternalBreadcrumb[];
122
+ /**
123
+ * Get the last N breadcrumbs
124
+ */
125
+ getLast(count: number): InternalBreadcrumb[];
126
+ /**
127
+ * Clear all breadcrumbs
128
+ */
129
+ clear(): void;
130
+ /**
131
+ * Reset manager
132
+ */
133
+ reset(): void;
134
+ }
135
+ declare function getBreadcrumbManager(): BreadcrumbManager | null;
136
+
137
+ /**
138
+ * Process context collector
139
+ */
140
+
141
+ /**
142
+ * Collect current process context
143
+ */
144
+ declare function collectProcessContext(): ProcessContext;
145
+
146
+ /**
147
+ * OS context collector
148
+ */
149
+
150
+ declare function collectOsContext(): OsContext;
151
+
152
+ /**
153
+ * Runtime context collector
154
+ */
155
+
156
+ declare function collectRuntimeContext(): RuntimeContext;
157
+
158
+ /**
159
+ * Server context collector
160
+ */
161
+
162
+ /**
163
+ * Get current server context
164
+ */
165
+ declare function getServerContext(): ServerContext;
166
+ /**
167
+ * Set server name
168
+ */
169
+ declare function setServerName(name: string): void;
170
+
171
+ /**
172
+ * Request context extractor
173
+ */
174
+
175
+ /**
176
+ * Extract request context from Node.js IncomingMessage or Express request
177
+ */
178
+ declare function extractRequestContext(req: IncomingMessage | ExpressRequest): RequestContext;
179
+
180
+ /**
181
+ * Stack trace parsing utilities for Node.js
182
+ */
183
+
184
+ /**
185
+ * Parse a V8 stack trace string into structured frames
186
+ */
187
+ declare function parseStackTrace(stack: string | undefined): StackFrame[];
188
+
189
+ /**
190
+ * UUID generation utilities
191
+ */
192
+ /**
193
+ * Generate a UUID v4
194
+ */
195
+ declare function generateUuid(): string;
196
+ /**
197
+ * Generate a short ID (8 chars)
198
+ */
199
+ declare function generateShortId(): string;
200
+ /**
201
+ * Generate a transaction ID
202
+ */
203
+ declare function generateTransactionId(): string;
204
+
205
+ /**
206
+ * HMAC signing for secure webhook requests
207
+ */
208
+ declare class HmacSigner {
209
+ private secret;
210
+ constructor(secret: string);
211
+ /**
212
+ * Sign a payload with HMAC-SHA256
213
+ * @param payload - The JSON payload string to sign
214
+ * @param timestamp - Unix timestamp (defaults to current time)
215
+ * @returns Hex-encoded signature
216
+ */
217
+ sign(payload: string, timestamp?: number): string;
218
+ /**
219
+ * Build headers for a signed request
220
+ * @param payload - The JSON payload string
221
+ * @returns Headers object with signature and timestamp
222
+ */
223
+ buildHeaders(payload: string): Record<string, string>;
224
+ /**
225
+ * Verify a signature (useful for testing)
226
+ * @param payload - The payload that was signed
227
+ * @param signature - The signature to verify
228
+ * @param timestamp - The timestamp used in signing
229
+ * @param maxAge - Maximum age in seconds (default: 5 minutes)
230
+ */
231
+ verify(payload: string, signature: string, timestamp: number, maxAge?: number): boolean;
232
+ }
233
+
234
+ /**
235
+ * @error-explorer/node - Error Explorer SDK for Node.js
236
+ *
237
+ * Usage:
238
+ * ```typescript
239
+ * import { ErrorExplorer } from '@error-explorer/node';
240
+ *
241
+ * ErrorExplorer.init({
242
+ * dsn: 'https://ee_xxx@error-explorer.com/api/v1/webhook',
243
+ * environment: 'production',
244
+ * release: '1.0.0',
245
+ * });
246
+ *
247
+ * // Manual capture
248
+ * try {
249
+ * // ... your code
250
+ * } catch (error) {
251
+ * ErrorExplorer.captureException(error);
252
+ * }
253
+ *
254
+ * // With Express
255
+ * import { requestHandler, errorHandler } from '@error-explorer/node/express';
256
+ * app.use(requestHandler());
257
+ * app.use(errorHandler());
258
+ * ```
259
+ */
260
+
261
+ export { Breadcrumb, CaptureContext, ErrorExplorer, ExpressRequest, HmacSigner, InitOptions, InternalBreadcrumb, OsContext, ProcessContext, RequestContext, ResolvedConfig, RuntimeContext, ServerContext, SeverityLevel, StackFrame, UserContext, collectOsContext, collectProcessContext, collectRuntimeContext, ErrorExplorer as default, extractRequestContext, generateShortId, generateTransactionId, generateUuid, getBreadcrumbManager, getServerContext, parseStackTrace, setServerName };