triva 0.3.0 → 0.3.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/lib/error-tracker.js +8 -8
- package/package.json +1 -1
package/lib/error-tracker.js
CHANGED
|
@@ -14,7 +14,7 @@ class ErrorEntry {
|
|
|
14
14
|
this.id = this._generateId();
|
|
15
15
|
this.timestamp = Date.now();
|
|
16
16
|
this.datetime = new Date().toISOString();
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
// Error details
|
|
19
19
|
this.error = {
|
|
20
20
|
name: error.name || 'Error',
|
|
@@ -30,7 +30,7 @@ class ErrorEntry {
|
|
|
30
30
|
url: context.req?.url || null,
|
|
31
31
|
pathname: context.pathname || null,
|
|
32
32
|
ip: context.req?.socket?.remoteAddress || context.req?.connection?.remoteAddress || null,
|
|
33
|
-
userAgent: context.req?.headers
|
|
33
|
+
userAgent: context.req?.headers?.['user-agent'] || null,
|
|
34
34
|
headers: context.req ? this._sanitizeHeaders(context.req.headers) : null
|
|
35
35
|
};
|
|
36
36
|
|
|
@@ -55,7 +55,7 @@ class ErrorEntry {
|
|
|
55
55
|
|
|
56
56
|
// Error severity
|
|
57
57
|
this.severity = this._determineSeverity(error, context);
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
// Resolution status
|
|
60
60
|
this.status = 'unresolved';
|
|
61
61
|
this.resolved = false;
|
|
@@ -94,18 +94,18 @@ class ErrorEntry {
|
|
|
94
94
|
// Critical: System errors, crashes
|
|
95
95
|
if (error.name === 'Error' && error.message.includes('FATAL')) return 'critical';
|
|
96
96
|
if (error.code === 'ERR_OUT_OF_MEMORY') return 'critical';
|
|
97
|
-
|
|
97
|
+
|
|
98
98
|
// High: Unhandled errors, type errors in handlers
|
|
99
99
|
if (context.phase === 'uncaught') return 'high';
|
|
100
100
|
if (error.name === 'TypeError' || error.name === 'ReferenceError') return 'high';
|
|
101
|
-
|
|
101
|
+
|
|
102
102
|
// Medium: Route handler errors, middleware errors
|
|
103
103
|
if (context.phase === 'route' || context.phase === 'middleware') return 'medium';
|
|
104
|
-
|
|
104
|
+
|
|
105
105
|
// Low: Validation errors, expected errors
|
|
106
106
|
if (error.name === 'ValidationError') return 'low';
|
|
107
107
|
if (error.message?.includes('Invalid')) return 'low';
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
return 'medium';
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -252,7 +252,7 @@ class ErrorTracker {
|
|
|
252
252
|
// Search in error messages
|
|
253
253
|
if (filter.search) {
|
|
254
254
|
const search = filter.search.toLowerCase();
|
|
255
|
-
results = results.filter(e =>
|
|
255
|
+
results = results.filter(e =>
|
|
256
256
|
e.error.message.toLowerCase().includes(search) ||
|
|
257
257
|
e.error.name.toLowerCase().includes(search) ||
|
|
258
258
|
e.request.url?.toLowerCase().includes(search)
|
package/package.json
CHANGED