reportli 1.0.3 → 1.0.4
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.d.ts +77 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +642 -305
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +642 -313
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
- package/src/index.ts +735 -366
package/dist/index.js
CHANGED
|
@@ -24,331 +24,668 @@ __export(src_exports, {
|
|
|
24
24
|
default: () => src_default
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(src_exports);
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
27
|
+
var REPORTLI_BASE_URL = "https://ais-dev-ohcojup63zslqou25sisle-541405064838.asia-east1.run.app";
|
|
28
|
+
var ReportliTracker = class _ReportliTracker {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.config = null;
|
|
31
|
+
this.isInitialized = false;
|
|
32
|
+
/**
|
|
33
|
+
* Express error handler middleware
|
|
34
|
+
*/
|
|
35
|
+
this.expressErrorHandler = (err, req, res, next) => {
|
|
36
|
+
if (this.isInitialized && this.config) {
|
|
37
|
+
try {
|
|
38
|
+
const errorObject = this.normalizeError(err);
|
|
39
|
+
const { errorType, severity } = this.classifyError(errorObject, "express");
|
|
40
|
+
const payload = {
|
|
41
|
+
apiKey: this.config.apiKey,
|
|
42
|
+
projectId: this.config.projectId || "express-server",
|
|
43
|
+
projectName: this.config.projectName || "Express App",
|
|
44
|
+
errorType: errorType || "Route handler error",
|
|
45
|
+
errorMessage: `${req.method} ${req.url} - ${errorObject.message}`,
|
|
46
|
+
errorStack: errorObject.stack || "",
|
|
47
|
+
framework: this.config.framework || "Express",
|
|
48
|
+
user_email: this.config.userEmail || req.user?.email || "anonymous",
|
|
49
|
+
severity: severity || "high",
|
|
50
|
+
status: "open"
|
|
51
|
+
};
|
|
52
|
+
this.sendCrashReport(payload);
|
|
53
|
+
} catch (e) {
|
|
54
|
+
console.error("[Reportli SDK] Failed to process express exception:", e);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
next(err);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Initializes the Reportli tracker with your secure project credentials.
|
|
62
|
+
*/
|
|
63
|
+
init(config) {
|
|
64
|
+
if (!config || !config.apiKey) {
|
|
65
|
+
console.error("[Reportli SDK] Initialization failed: 'apiKey' is required.");
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (this.isInitialized) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.config = {
|
|
72
|
+
environment: "production",
|
|
73
|
+
captureUnhandledRejections: true,
|
|
74
|
+
autoCreateGitHubIssues: true,
|
|
75
|
+
...config
|
|
76
|
+
};
|
|
77
|
+
this.isInitialized = true;
|
|
78
|
+
const isBrowser = typeof window !== "undefined";
|
|
79
|
+
const isNode = typeof process !== "undefined" && process.versions && process.versions.node;
|
|
80
|
+
if (_ReportliTracker._registrationSent) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this.sendRegistrationWebhook(isBrowser);
|
|
84
|
+
_ReportliTracker._registrationSent = true;
|
|
85
|
+
if (isBrowser) {
|
|
86
|
+
this.setupBrowserListeners();
|
|
87
|
+
} else if (isNode) {
|
|
88
|
+
this.setupNodeListeners();
|
|
89
|
+
}
|
|
90
|
+
console.log("[Reportli SDK] Exception listener successfully initialized.");
|
|
48
91
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Manually captures and files a custom application exception with custom severity.
|
|
94
|
+
*/
|
|
95
|
+
captureException(error, severityInput) {
|
|
96
|
+
if (!this.isInitialized || !this.config) {
|
|
97
|
+
console.warn("[Reportli SDK] Capture failed: SDK is not initialized yet.");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const errorObject = this.normalizeError(error);
|
|
101
|
+
const { errorType, severity } = this.classifyError(errorObject);
|
|
102
|
+
const payload = {
|
|
103
|
+
apiKey: this.config.apiKey,
|
|
104
|
+
projectId: this.config.projectId || "proj-sandbox",
|
|
105
|
+
projectName: this.config.projectName || "SaaS App",
|
|
106
|
+
errorType,
|
|
107
|
+
errorMessage: errorObject.message || "Manual trace reported",
|
|
108
|
+
errorStack: errorObject.stack || "",
|
|
109
|
+
framework: this.config.framework || (typeof window !== "undefined" ? "React/Next.js Client" : "Node.js Server"),
|
|
110
|
+
user_email: this.config.userEmail || "anonymous",
|
|
111
|
+
severity: severityInput || severity,
|
|
112
|
+
status: "open"
|
|
113
|
+
};
|
|
114
|
+
this.sendCrashReport(payload);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Registers global window listeners for DOM-based exceptions.
|
|
118
|
+
*/
|
|
119
|
+
setupBrowserListeners() {
|
|
120
|
+
if (typeof window === "undefined")
|
|
121
|
+
return;
|
|
122
|
+
window.addEventListener("error", (event) => {
|
|
123
|
+
if (event.filename && event.filename.includes("rapid-processor"))
|
|
124
|
+
return;
|
|
125
|
+
try {
|
|
126
|
+
const error = event.error || {
|
|
127
|
+
message: event.message,
|
|
128
|
+
filename: event.filename,
|
|
129
|
+
lineno: event.lineno,
|
|
130
|
+
colno: event.colno,
|
|
131
|
+
stack: `${event.message} at ${event.filename}:${event.lineno}:${event.colno}`
|
|
132
|
+
};
|
|
133
|
+
const errorObject = this.normalizeError(error);
|
|
134
|
+
const { errorType, severity } = this.classifyError(errorObject);
|
|
135
|
+
const payload = {
|
|
136
|
+
apiKey: this.config?.apiKey || "",
|
|
137
|
+
projectId: this.config?.projectId || "proj-sandbox",
|
|
138
|
+
projectName: this.config?.projectName || "SaaS App",
|
|
139
|
+
errorType,
|
|
140
|
+
errorMessage: errorObject.message,
|
|
141
|
+
errorStack: errorObject.stack || "",
|
|
142
|
+
framework: this.config?.framework || "React/Next.js Client",
|
|
143
|
+
user_email: this.config?.userEmail || "anonymous",
|
|
144
|
+
severity,
|
|
145
|
+
status: "open"
|
|
146
|
+
};
|
|
147
|
+
this.sendCrashReport(payload);
|
|
148
|
+
} catch (err) {
|
|
149
|
+
console.error("[Reportli SDK] Inner listener exception:", err);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
window.addEventListener("unhandledrejection", (event) => {
|
|
153
|
+
try {
|
|
154
|
+
const reason = event.reason;
|
|
155
|
+
const errorObject = this.normalizeError(reason);
|
|
156
|
+
const { errorType, severity } = this.classifyError(errorObject, "unhandledrejection");
|
|
157
|
+
const payload = {
|
|
158
|
+
apiKey: this.config?.apiKey || "",
|
|
159
|
+
projectId: this.config?.projectId || "proj-sandbox",
|
|
160
|
+
projectName: this.config?.projectName || "SaaS App",
|
|
161
|
+
errorType,
|
|
162
|
+
errorMessage: `Unhandled Promise: ${errorObject.message}`,
|
|
163
|
+
errorStack: errorObject.stack || "",
|
|
164
|
+
framework: this.config?.framework || "React/Next.js Client",
|
|
165
|
+
user_email: this.config?.userEmail || "anonymous",
|
|
166
|
+
severity,
|
|
167
|
+
status: "open"
|
|
168
|
+
};
|
|
169
|
+
this.sendCrashReport(payload);
|
|
170
|
+
} catch (err) {
|
|
171
|
+
console.error("[Reportli SDK] Promise rejection listener exception:", err);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
window.addEventListener(
|
|
175
|
+
"error",
|
|
176
|
+
(event) => {
|
|
177
|
+
try {
|
|
178
|
+
const target = event.target || event.srcElement;
|
|
179
|
+
if (!target)
|
|
180
|
+
return;
|
|
181
|
+
const tagName = target.tagName;
|
|
182
|
+
if (!tagName)
|
|
183
|
+
return;
|
|
184
|
+
let resourceType = "";
|
|
185
|
+
let sourceUrl = "";
|
|
186
|
+
if (tagName === "IMG") {
|
|
187
|
+
resourceType = "Image failed to load";
|
|
188
|
+
sourceUrl = target.src;
|
|
189
|
+
} else if (tagName === "SCRIPT") {
|
|
190
|
+
resourceType = "Script failed to load";
|
|
191
|
+
sourceUrl = target.src;
|
|
192
|
+
} else if (tagName === "LINK") {
|
|
193
|
+
resourceType = "CSS failed to load";
|
|
194
|
+
sourceUrl = target.href;
|
|
195
|
+
} else if (tagName === "VIDEO" || tagName === "AUDIO") {
|
|
196
|
+
resourceType = "Video failed to load";
|
|
197
|
+
sourceUrl = target.src;
|
|
198
|
+
}
|
|
199
|
+
if (resourceType) {
|
|
200
|
+
const payload = {
|
|
201
|
+
apiKey: this.config?.apiKey || "",
|
|
202
|
+
projectId: this.config?.projectId || "proj-sandbox",
|
|
203
|
+
projectName: this.config?.projectName || "SaaS App",
|
|
204
|
+
errorType: resourceType,
|
|
205
|
+
errorMessage: `Failed to load static resource asset: ${sourceUrl}`,
|
|
206
|
+
errorStack: `HTML Tag: <${tagName.toLowerCase()}> failed to download at location ${window.location.href}`,
|
|
207
|
+
framework: this.config?.framework || "React/Next.js Client",
|
|
208
|
+
user_email: this.config?.userEmail || "anonymous",
|
|
209
|
+
severity: "low",
|
|
210
|
+
status: "open"
|
|
211
|
+
};
|
|
212
|
+
this.sendCrashReport(payload);
|
|
213
|
+
}
|
|
214
|
+
} catch (err) {
|
|
215
|
+
console.error("[Reportli SDK] Resource load listener failure:", err);
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
true
|
|
219
|
+
// capture phase is required for element errors
|
|
220
|
+
);
|
|
221
|
+
this.interceptFetch();
|
|
222
|
+
this.interceptXhr();
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Registers node process listeners for server instances.
|
|
226
|
+
*/
|
|
227
|
+
setupNodeListeners() {
|
|
228
|
+
if (typeof process === "undefined")
|
|
229
|
+
return;
|
|
230
|
+
process.on("uncaughtException", (error) => {
|
|
231
|
+
try {
|
|
232
|
+
const errorObject = this.normalizeError(error);
|
|
233
|
+
const { errorType, severity } = this.classifyError(errorObject, "uncaughtexception");
|
|
234
|
+
const payload = {
|
|
235
|
+
apiKey: this.config?.apiKey || "",
|
|
236
|
+
projectId: this.config?.projectId || "node-server",
|
|
237
|
+
projectName: this.config?.projectName || "Node Server",
|
|
238
|
+
errorType,
|
|
239
|
+
errorMessage: `Uncaught Exception: ${errorObject.message}`,
|
|
240
|
+
errorStack: errorObject.stack || "",
|
|
241
|
+
framework: this.config?.framework || "NodeJS backend",
|
|
242
|
+
user_email: this.config?.userEmail || "anonymous",
|
|
243
|
+
severity,
|
|
244
|
+
status: "open"
|
|
245
|
+
};
|
|
246
|
+
this.sendCrashReport(payload);
|
|
247
|
+
} catch (err) {
|
|
248
|
+
console.error("[Reportli SDK] Node fatal uncaughtexception logging failed:", err);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
process.on("unhandledRejection", (reason) => {
|
|
252
|
+
try {
|
|
253
|
+
const errorObject = this.normalizeError(reason);
|
|
254
|
+
const { errorType, severity } = this.classifyError(errorObject, "unhandledrejection");
|
|
255
|
+
const payload = {
|
|
256
|
+
apiKey: this.config?.apiKey || "",
|
|
257
|
+
projectId: this.config?.projectId || "node-server",
|
|
258
|
+
projectName: this.config?.projectName || "Node Server",
|
|
259
|
+
errorType,
|
|
260
|
+
errorMessage: `Unhandled Rejection: ${errorObject.message}`,
|
|
261
|
+
errorStack: errorObject.stack || "",
|
|
262
|
+
framework: this.config?.framework || "NodeJS backend",
|
|
263
|
+
user_email: this.config?.userEmail || "anonymous",
|
|
264
|
+
severity,
|
|
265
|
+
status: "open"
|
|
266
|
+
};
|
|
267
|
+
this.sendCrashReport(payload);
|
|
268
|
+
} catch (err) {
|
|
269
|
+
console.error("[Reportli SDK] Node fatal unhandledrejection logging failed:", err);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Safe payload sender with retry limits.
|
|
275
|
+
*/
|
|
276
|
+
async sendCrashReport(payload) {
|
|
55
277
|
try {
|
|
56
|
-
|
|
278
|
+
if (payload.errorMessage && (payload.errorMessage.includes("rapid-processor") || payload.errorMessage.includes("api/error") || payload.errorMessage.includes("supabase"))) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
let destinationUrl = this.config?.endpoint || `${REPORTLI_BASE_URL}/api/error`;
|
|
282
|
+
const response = await fetch(destinationUrl, {
|
|
57
283
|
method: "POST",
|
|
58
284
|
headers: {
|
|
59
285
|
"Content-Type": "application/json",
|
|
60
|
-
"x-api-key":
|
|
286
|
+
"x-api-key": this.config?.apiKey || ""
|
|
61
287
|
},
|
|
62
288
|
body: JSON.stringify(payload)
|
|
63
289
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
} catch {
|
|
290
|
+
} catch (err) {
|
|
291
|
+
console.warn("[Reportli SDK] Failed to synchronize crash traces to diagnostics server:", err);
|
|
67
292
|
}
|
|
68
|
-
await sleep(1e3 * (i + 1));
|
|
69
293
|
}
|
|
70
|
-
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (queue.length >= 100)
|
|
76
|
-
return;
|
|
77
|
-
queue.push(payload);
|
|
78
|
-
scheduleFlush();
|
|
79
|
-
}
|
|
80
|
-
function sendImmediate(payload) {
|
|
81
|
-
sendNow(payload).catch(() => {
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
function getUrl() {
|
|
85
|
-
if (typeof window !== "undefined")
|
|
86
|
-
return window.location.href;
|
|
87
|
-
try {
|
|
88
|
-
return require("os").hostname();
|
|
89
|
-
} catch {
|
|
90
|
-
return "server";
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function getBrowser() {
|
|
94
|
-
if (typeof navigator !== "undefined")
|
|
95
|
-
return navigator.userAgent;
|
|
96
|
-
return `Node.js ${typeof process !== "undefined" ? process.version : "unknown"}`;
|
|
97
|
-
}
|
|
98
|
-
function getEnvironment() {
|
|
99
|
-
return _config?.environment ?? (typeof window !== "undefined" ? "browser" : "server");
|
|
100
|
-
}
|
|
101
|
-
function parseStack(stack) {
|
|
102
|
-
if (!stack)
|
|
103
|
-
return { file: "unknown", line: 0, column: 0 };
|
|
104
|
-
const match = stack.match(/at .+ \((.+):(\d+):(\d+)\)/) || stack.match(/at (.+):(\d+):(\d+)/);
|
|
105
|
-
return {
|
|
106
|
-
file: match?.[1]?.split("/")?.pop() || "unknown",
|
|
107
|
-
line: parseInt(match?.[2] || "0"),
|
|
108
|
-
column: parseInt(match?.[3] || "0")
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function getErrorCode(error) {
|
|
112
|
-
return error?.code || error?.status?.toString() || error?.statusCode?.toString() || error?.name || "ERR_UNKNOWN";
|
|
113
|
-
}
|
|
114
|
-
function classifyError(error, context) {
|
|
115
|
-
const msg = String(error?.message || error || "").toLowerCase();
|
|
116
|
-
const name = String(error?.name || "").toLowerCase();
|
|
117
|
-
if (msg.includes("stripe") || msg.includes("payment") || msg.includes("card declined") || msg.includes("checkout") || msg.includes("refund"))
|
|
118
|
-
return { category: "Payment Error", severity: "critical" };
|
|
119
|
-
if (msg.includes("jwt") || msg.includes("token expired") || msg.includes("unauthorized") || msg.includes("session") || msg.includes("oauth") || msg.includes("login failed"))
|
|
120
|
-
return { category: "Auth Error", severity: "high" };
|
|
121
|
-
if (msg.includes("supabase") || msg.includes("database") || msg.includes("query") || msg.includes("connection lost") || msg.includes("transaction") || msg.includes("duplicate key") || msg.includes("foreign key"))
|
|
122
|
-
return { category: "Database Error", severity: "critical" };
|
|
123
|
-
if (msg.includes("hydration") || msg.includes("does not match server"))
|
|
124
|
-
return { category: "Hydration Error", severity: "high" };
|
|
125
|
-
if (msg.includes("invalid hook") || msg.includes("rules of hooks"))
|
|
126
|
-
return { category: "Hook Error", severity: "critical" };
|
|
127
|
-
if (msg.includes("render") || msg.includes("error boundary"))
|
|
128
|
-
return { category: "Render Error", severity: "critical" };
|
|
129
|
-
if (msg.includes("dynamic import") || msg.includes("failed to fetch dynamically"))
|
|
130
|
-
return { category: "Import Error", severity: "high" };
|
|
131
|
-
if (msg.includes("cors") || msg.includes("cross-origin"))
|
|
132
|
-
return { category: "CORS Error", severity: "high" };
|
|
133
|
-
if (msg.includes("fetch failed") || msg.includes("failed to fetch") || name === "fetcherror")
|
|
134
|
-
return { category: "Network Error", severity: "high" };
|
|
135
|
-
if (msg.includes("timeout") || msg.includes("timed out") || msg.includes("etimedout"))
|
|
136
|
-
return { category: "Timeout Error", severity: "medium" };
|
|
137
|
-
if (msg.includes("websocket"))
|
|
138
|
-
return { category: "WebSocket Error", severity: "high" };
|
|
139
|
-
if (msg.includes("http 401") || msg.includes("xhr 401"))
|
|
140
|
-
return { category: "Auth Error", severity: "high" };
|
|
141
|
-
if (msg.includes("http 403") || msg.includes("xhr 403"))
|
|
142
|
-
return { category: "Auth Error", severity: "high" };
|
|
143
|
-
if (msg.includes("http 404") || msg.includes("xhr 404"))
|
|
144
|
-
return { category: "Not Found Error", severity: "medium" };
|
|
145
|
-
if (msg.includes("http 500") || msg.includes("xhr 500"))
|
|
146
|
-
return { category: "Server Error", severity: "critical" };
|
|
147
|
-
if (msg.includes("http 503") || msg.includes("xhr 503"))
|
|
148
|
-
return { category: "Server Error", severity: "critical" };
|
|
149
|
-
if (msg.includes("maximum call stack") || msg.includes("out of memory") || msg.includes("heap limit"))
|
|
150
|
-
return { category: "Memory Error", severity: "critical" };
|
|
151
|
-
if (msg.includes("cannot find module") || msg.includes("module not found"))
|
|
152
|
-
return { category: "Module Error", severity: "critical" };
|
|
153
|
-
if (msg.includes("econnrefused") || msg.includes("connection refused"))
|
|
154
|
-
return { category: "Connection Error", severity: "critical" };
|
|
155
|
-
if (msg.includes("email") || msg.includes("smtp") || msg.includes("sendgrid"))
|
|
156
|
-
return { category: "Email Error", severity: "high" };
|
|
157
|
-
if (msg.includes("cron") || msg.includes("webhook") || msg.includes("queue"))
|
|
158
|
-
return { category: "Job Error", severity: "high" };
|
|
159
|
-
if (msg.includes("upload") || msg.includes("file size") || msg.includes("invalid file"))
|
|
160
|
-
return { category: "File Error", severity: "medium" };
|
|
161
|
-
if (msg.includes("quota exceeded") || msg.includes("localstorage") || msg.includes("indexeddb"))
|
|
162
|
-
return { category: "Storage Error", severity: "medium" };
|
|
163
|
-
if (name === "typeerror")
|
|
164
|
-
return { category: "TypeError", severity: "high" };
|
|
165
|
-
if (name === "referenceerror")
|
|
166
|
-
return { category: "ReferenceError", severity: "critical" };
|
|
167
|
-
if (name === "rangeerror")
|
|
168
|
-
return { category: "RangeError", severity: "high" };
|
|
169
|
-
if (name === "syntaxerror")
|
|
170
|
-
return { category: "SyntaxError", severity: "high" };
|
|
171
|
-
if (context === "unhandledrejection")
|
|
172
|
-
return { category: "Promise Error", severity: "medium" };
|
|
173
|
-
if (context === "express")
|
|
174
|
-
return { category: "Server Error", severity: "high" };
|
|
175
|
-
if (context === "resource")
|
|
176
|
-
return { category: "Resource Error", severity: "low" };
|
|
177
|
-
return { category: "Unknown Error", severity: "medium" };
|
|
178
|
-
}
|
|
179
|
-
function buildErrorPayload(error, context) {
|
|
180
|
-
const message = error?.message || String(error) || "Unknown error";
|
|
181
|
-
const stack = error?.stack || "";
|
|
182
|
-
const { file, line, column } = parseStack(stack);
|
|
183
|
-
const { category, severity } = classifyError(error, context);
|
|
184
|
-
return {
|
|
185
|
-
type: "ERROR",
|
|
186
|
-
apiKey: _config?.apiKey,
|
|
187
|
-
message,
|
|
188
|
-
code: getErrorCode(error),
|
|
189
|
-
stack,
|
|
190
|
-
file,
|
|
191
|
-
line,
|
|
192
|
-
column,
|
|
193
|
-
url: getUrl(),
|
|
194
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
195
|
-
environment: getEnvironment(),
|
|
196
|
-
browser: getBrowser(),
|
|
197
|
-
error_category: category,
|
|
198
|
-
severity,
|
|
199
|
-
status: "open",
|
|
200
|
-
context: context || "auto"
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
function activateBrowserListeners() {
|
|
204
|
-
window.addEventListener("error", (event) => {
|
|
205
|
-
const target = event.target;
|
|
206
|
-
if (target && target.tagName && ["IMG", "SCRIPT", "LINK", "VIDEO", "AUDIO"].includes(target.tagName)) {
|
|
207
|
-
const src = target.src || target.href || "unknown";
|
|
208
|
-
enqueue(buildErrorPayload({ name: "ResourceError", message: `${target.tagName} failed to load: ${src}`, stack: "" }, "resource"));
|
|
294
|
+
/**
|
|
295
|
+
* Sends registration verification to user edge function on first install.
|
|
296
|
+
*/
|
|
297
|
+
sendRegistrationWebhook(isBrowser) {
|
|
298
|
+
if (!this.config)
|
|
209
299
|
return;
|
|
300
|
+
const key = `reportli_initialized_success_${this.config.apiKey}`;
|
|
301
|
+
if (isBrowser && typeof localStorage !== "undefined") {
|
|
302
|
+
if (localStorage.getItem(key)) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
localStorage.setItem(key, "true");
|
|
210
306
|
}
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
307
|
+
const deviceDetails = isBrowser ? typeof navigator !== "undefined" ? navigator.userAgent : "Browser sandbox" : typeof process !== "undefined" ? `NodeJS environment: ${process.version}` : "Cloud instance";
|
|
308
|
+
const welcomePayload = {
|
|
309
|
+
apiKey: this.config.apiKey,
|
|
310
|
+
projectId: this.config.projectId || "proj-sandbox",
|
|
311
|
+
projectName: this.config.projectName || "SaaS App Component",
|
|
312
|
+
errorType: "SDK_INITIALIZED",
|
|
313
|
+
errorMessage: "Reportli SDK successfully initialized! Error listener is active.",
|
|
314
|
+
errorStack: `SDK Active Diagnostics: Success registration from execution agent. Device context: ${deviceDetails}`,
|
|
315
|
+
framework: this.config.framework || (isBrowser ? "React/Next.js Client" : "Node.js Server"),
|
|
316
|
+
user_email: this.config.userEmail || "anonymous",
|
|
317
|
+
severity: "low",
|
|
318
|
+
status: "info"
|
|
215
319
|
};
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
enqueue(buildErrorPayload({
|
|
231
|
-
name: `HTTP_${response.status}`,
|
|
232
|
-
message: `HTTP ${response.status}: ${args[1]?.method || "GET"} ${url}`,
|
|
233
|
-
stack: `${args[1]?.method || "GET"} ${url} \u2192 ${response.status} ${response.statusText}`,
|
|
234
|
-
status: response.status
|
|
235
|
-
}, "fetch"));
|
|
320
|
+
this.sendCrashReport(welcomePayload);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Capture fetch network status deviations.
|
|
324
|
+
*/
|
|
325
|
+
interceptFetch() {
|
|
326
|
+
if (typeof window === "undefined" || typeof window.fetch !== "function")
|
|
327
|
+
return;
|
|
328
|
+
const originalFetch = window.fetch;
|
|
329
|
+
const self = this;
|
|
330
|
+
window.fetch = async function(input, init) {
|
|
331
|
+
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
332
|
+
if (url.includes("rapid-processor") || url.includes("api/error") || url.includes("supabase.co/functions")) {
|
|
333
|
+
return originalFetch.apply(this, arguments);
|
|
236
334
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
335
|
+
try {
|
|
336
|
+
const response = await originalFetch.apply(this, arguments);
|
|
337
|
+
if (response && !response.ok) {
|
|
338
|
+
self.logNetworkError(url, response.status, response.statusText, init?.method || "GET");
|
|
339
|
+
}
|
|
340
|
+
return response;
|
|
341
|
+
} catch (err) {
|
|
342
|
+
self.logNetworkFailure(url, err, init?.method || "GET");
|
|
343
|
+
throw err;
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Trace XHR status failures.
|
|
349
|
+
*/
|
|
350
|
+
interceptXhr() {
|
|
351
|
+
if (typeof window === "undefined" || typeof XMLHttpRequest === "undefined")
|
|
352
|
+
return;
|
|
353
|
+
const originalOpen = XMLHttpRequest.prototype.open;
|
|
354
|
+
const originalSend = XMLHttpRequest.prototype.send;
|
|
355
|
+
const self = this;
|
|
356
|
+
XMLHttpRequest.prototype.open = function(method, url) {
|
|
357
|
+
this._reportli_method = method;
|
|
358
|
+
this._reportli_url = url;
|
|
359
|
+
return originalOpen.apply(this, arguments);
|
|
360
|
+
};
|
|
361
|
+
XMLHttpRequest.prototype.send = function() {
|
|
362
|
+
const xhrInstance = this;
|
|
363
|
+
xhrInstance.addEventListener("loadend", () => {
|
|
364
|
+
try {
|
|
365
|
+
const url = xhrInstance._reportli_url || "";
|
|
366
|
+
const method = xhrInstance._reportli_method || "GET";
|
|
367
|
+
const status = xhrInstance.status;
|
|
368
|
+
if (url.includes("rapid-processor") || url.includes("supabase.co/functions")) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
if (status >= 400 || status === 0) {
|
|
372
|
+
if (status === 0) {
|
|
373
|
+
self.logNetworkFailure(url, new Error("CORS or Connection Refused"), method);
|
|
374
|
+
} else {
|
|
375
|
+
self.logNetworkError(url, status, xhrInstance.statusText || "XHR Error", method);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
} catch (e) {
|
|
379
|
+
console.error("[Reportli SDK] Failed to extract XHR statistics:", e);
|
|
266
380
|
}
|
|
267
381
|
});
|
|
382
|
+
return originalSend.apply(this, arguments);
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
logNetworkError(url, status, statusText, method) {
|
|
386
|
+
let errorType = `API ${status} Error`;
|
|
387
|
+
let severity = "medium";
|
|
388
|
+
if (status === 400)
|
|
389
|
+
errorType = "API 400 Bad Request";
|
|
390
|
+
else if (status === 401) {
|
|
391
|
+
errorType = "API 401 Unauthorized";
|
|
392
|
+
severity = "high";
|
|
393
|
+
} else if (status === 403) {
|
|
394
|
+
errorType = "API 403 Forbidden";
|
|
395
|
+
severity = "high";
|
|
396
|
+
} else if (status === 404)
|
|
397
|
+
errorType = "API 404 Not Found";
|
|
398
|
+
else if (status === 500) {
|
|
399
|
+
errorType = "API 500 Internal Server Error";
|
|
400
|
+
severity = "high";
|
|
401
|
+
} else if (status === 503) {
|
|
402
|
+
errorType = "API 503 Service Unavailable";
|
|
403
|
+
severity = "high";
|
|
268
404
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
"
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
const err = error instanceof Error ? error : { name: "ManualCapture", message: String(error), stack: new Error().stack };
|
|
338
|
-
enqueue(buildErrorPayload(err, "manual"));
|
|
339
|
-
},
|
|
340
|
-
captureMessage(message) {
|
|
341
|
-
if (!initialized)
|
|
342
|
-
return;
|
|
343
|
-
enqueue(buildErrorPayload({ name: "Message", message, stack: "" }, "manual"));
|
|
344
|
-
},
|
|
345
|
-
errorHandler() {
|
|
346
|
-
return function(err, _req, _res, next) {
|
|
347
|
-
enqueue(buildErrorPayload(err, "express"));
|
|
348
|
-
next(err);
|
|
405
|
+
const payload = {
|
|
406
|
+
apiKey: this.config?.apiKey || "",
|
|
407
|
+
projectId: this.config?.projectId || "proj-sandbox",
|
|
408
|
+
projectName: this.config?.projectName || "SaaS App",
|
|
409
|
+
errorType,
|
|
410
|
+
errorMessage: `HTTP API failed with code ${status}: ${method} ${url}`,
|
|
411
|
+
errorStack: `Network Request Header Context: [Method: ${method}] Url: ${url} Response Description: ${statusText || "Dev server returned error."}`,
|
|
412
|
+
framework: this.config?.framework || "React/Next.js Client",
|
|
413
|
+
user_email: this.config?.userEmail || "anonymous",
|
|
414
|
+
severity,
|
|
415
|
+
status: "open"
|
|
416
|
+
};
|
|
417
|
+
this.sendCrashReport(payload);
|
|
418
|
+
}
|
|
419
|
+
logNetworkFailure(url, error, method) {
|
|
420
|
+
const errorMsg = String(error.message || error || "");
|
|
421
|
+
let errorType = "Fetch failed error";
|
|
422
|
+
let severity = "high";
|
|
423
|
+
if (errorMsg.includes("timeout") || errorMsg.includes("abort")) {
|
|
424
|
+
errorType = "Request timeout error";
|
|
425
|
+
severity = "medium";
|
|
426
|
+
} else if (errorMsg.includes("CORS") || errorMsg.includes("origin") || errorMsg.includes("Access-Control")) {
|
|
427
|
+
errorType = "CORS error";
|
|
428
|
+
}
|
|
429
|
+
const payload = {
|
|
430
|
+
apiKey: this.config?.apiKey || "",
|
|
431
|
+
projectId: this.config?.projectId || "proj-sandbox",
|
|
432
|
+
projectName: this.config?.projectName || "SaaS App",
|
|
433
|
+
errorType,
|
|
434
|
+
errorMessage: `Failed to complete HTTP request: [${method}] ${url}`,
|
|
435
|
+
errorStack: `Network crash context: ${errorMsg}
|
|
436
|
+
Connection status: Failed to resolve.`,
|
|
437
|
+
framework: this.config?.framework || "React/Next.js Client",
|
|
438
|
+
user_email: this.config?.userEmail || "anonymous",
|
|
439
|
+
severity,
|
|
440
|
+
status: "open"
|
|
441
|
+
};
|
|
442
|
+
this.sendCrashReport(payload);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Helper to safely format raw objects / strings into structured Errors
|
|
446
|
+
*/
|
|
447
|
+
normalizeError(err) {
|
|
448
|
+
if (err instanceof Error) {
|
|
449
|
+
return {
|
|
450
|
+
name: err.name,
|
|
451
|
+
message: err.message,
|
|
452
|
+
stack: err.stack
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
if (typeof err === "string") {
|
|
456
|
+
return {
|
|
457
|
+
name: "Error",
|
|
458
|
+
message: err,
|
|
459
|
+
stack: new Error(err).stack
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
if (err && typeof err === "object") {
|
|
463
|
+
return {
|
|
464
|
+
name: err.name || err.code || "Error",
|
|
465
|
+
message: err.message || err.reason || JSON.stringify(err),
|
|
466
|
+
stack: err.stack || err.traceback || new Error(err.message).stack
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
return {
|
|
470
|
+
name: "Error",
|
|
471
|
+
message: "An unhandled execution trace slipped past standard boundaries.",
|
|
472
|
+
stack: new Error().stack
|
|
349
473
|
};
|
|
350
474
|
}
|
|
475
|
+
/**
|
|
476
|
+
* Comprehensive classification rules checking substring and classifications
|
|
477
|
+
*/
|
|
478
|
+
classifyError(error, context) {
|
|
479
|
+
const msg = String(error.message || error || "").toLowerCase();
|
|
480
|
+
const name = String(error.name || "").toLowerCase();
|
|
481
|
+
if (name.includes("quotaexceeded") || msg.includes("quota exceeded") || msg.includes("localstorage") || msg.includes("sessionstorage") || msg.includes("indexeddb")) {
|
|
482
|
+
return { errorType: "localStorage quota exceeded", severity: "medium" };
|
|
483
|
+
}
|
|
484
|
+
if (msg.includes("hydration") || msg.includes("does not match server") || msg.includes("text content did not match")) {
|
|
485
|
+
return { errorType: "React hydration error", severity: "high" };
|
|
486
|
+
}
|
|
487
|
+
if (msg.includes("invalid hook call") || msg.includes("rules of hooks")) {
|
|
488
|
+
return { errorType: "Invalid hook call error", severity: "critical" };
|
|
489
|
+
}
|
|
490
|
+
if (msg.includes("failed prop type") || msg.includes("invalid prop")) {
|
|
491
|
+
return { errorType: "Props type error", severity: "low" };
|
|
492
|
+
}
|
|
493
|
+
if (msg.includes("render") || msg.includes("react error boundary") || msg.includes("component render")) {
|
|
494
|
+
return { errorType: "Component render error", severity: "critical" };
|
|
495
|
+
}
|
|
496
|
+
if (msg.includes("route not found") || msg.includes("cannot find route") || msg.includes("404 route")) {
|
|
497
|
+
return { errorType: "Route not found error", severity: "medium" };
|
|
498
|
+
}
|
|
499
|
+
if (msg.includes("failed to fetch dynamically imported") || msg.includes("dynamic import")) {
|
|
500
|
+
return { errorType: "Dynamic import error", severity: "high" };
|
|
501
|
+
}
|
|
502
|
+
if (msg.includes("suspense") || msg.includes("fallback")) {
|
|
503
|
+
return { errorType: "Suspense boundary error", severity: "medium" };
|
|
504
|
+
}
|
|
505
|
+
if (name === "typeerror" || msg.startsWith("typeerror")) {
|
|
506
|
+
return { errorType: "TypeError", severity: "high" };
|
|
507
|
+
}
|
|
508
|
+
if (name === "referenceerror" || msg.startsWith("referenceerror")) {
|
|
509
|
+
return { errorType: "ReferenceError", severity: "critical" };
|
|
510
|
+
}
|
|
511
|
+
if (name === "rangeerror" || msg.startsWith("rangeerror")) {
|
|
512
|
+
if (msg.includes("maximum call stack") || msg.includes("stack overflow")) {
|
|
513
|
+
return { errorType: "Stack overflow error", severity: "critical" };
|
|
514
|
+
}
|
|
515
|
+
return { errorType: "RangeError", severity: "high" };
|
|
516
|
+
}
|
|
517
|
+
if (name === "syntaxerror" || msg.startsWith("syntaxerror")) {
|
|
518
|
+
return { errorType: "SyntaxError", severity: "high" };
|
|
519
|
+
}
|
|
520
|
+
if (name === "evalerror") {
|
|
521
|
+
return { errorType: "EvalError", severity: "medium" };
|
|
522
|
+
}
|
|
523
|
+
if (name === "urierror") {
|
|
524
|
+
return { errorType: "URIError", severity: "medium" };
|
|
525
|
+
}
|
|
526
|
+
if (msg.includes("stripe") && (msg.includes("key") || msg.includes("init") || msg.includes("key is required") || msg.includes("is not defined"))) {
|
|
527
|
+
return { errorType: "Stripe initialization error", severity: "critical" };
|
|
528
|
+
}
|
|
529
|
+
if (msg.includes("stripe") && (msg.includes("payment") || msg.includes("processing") || msg.includes("charge"))) {
|
|
530
|
+
return { errorType: "Payment processing error", severity: "critical" };
|
|
531
|
+
}
|
|
532
|
+
if (msg.includes("card declined") || msg.includes("card_declined") || msg.includes("declined")) {
|
|
533
|
+
return { errorType: "Card declined error", severity: "high" };
|
|
534
|
+
}
|
|
535
|
+
if (msg.includes("checkout session") || msg.includes("create checkout")) {
|
|
536
|
+
return { errorType: "Checkout session error", severity: "high" };
|
|
537
|
+
}
|
|
538
|
+
if (msg.includes("refund failed") || msg.includes("refund_failed")) {
|
|
539
|
+
return { errorType: "Refund failed error", severity: "high" };
|
|
540
|
+
}
|
|
541
|
+
if (msg.includes("supabase query") || msg.includes("postgresterror")) {
|
|
542
|
+
return { errorType: "Supabase query error", severity: "critical" };
|
|
543
|
+
}
|
|
544
|
+
if (msg.includes("unique constraint") || msg.includes("duplicate key")) {
|
|
545
|
+
return { errorType: "Unique constraint error", severity: "high" };
|
|
546
|
+
}
|
|
547
|
+
if (msg.includes("foreign key")) {
|
|
548
|
+
return { errorType: "Foreign key error", severity: "high" };
|
|
549
|
+
}
|
|
550
|
+
if (msg.includes("transaction failed") || msg.includes("rollback")) {
|
|
551
|
+
return { errorType: "Transaction failed error", severity: "critical" };
|
|
552
|
+
}
|
|
553
|
+
if (msg.includes("connection lost") || msg.includes("db connection") || msg.includes("connection refused") || msg.includes("econnrefused")) {
|
|
554
|
+
return { errorType: "Connection lost error", severity: "critical" };
|
|
555
|
+
}
|
|
556
|
+
if (msg.includes("query timeout") || msg.includes("statement timeout")) {
|
|
557
|
+
return { errorType: "Query timeout error", severity: "high" };
|
|
558
|
+
}
|
|
559
|
+
if (msg.includes("jwt expired") || msg.includes("token expired") || msg.includes("jsonwebtokenexpired")) {
|
|
560
|
+
return { errorType: "JWT expired error", severity: "high" };
|
|
561
|
+
}
|
|
562
|
+
if (msg.includes("jwt verification") || msg.includes("invalid signature") || msg.includes("jwt malformed")) {
|
|
563
|
+
return { errorType: "JWT verification error", severity: "high" };
|
|
564
|
+
}
|
|
565
|
+
if (msg.includes("firebase-admin") || msg.includes("firebase admin")) {
|
|
566
|
+
return { errorType: "Firebase admin error", severity: "critical" };
|
|
567
|
+
}
|
|
568
|
+
if (msg.includes("session creation") || msg.includes("create session")) {
|
|
569
|
+
return { errorType: "Session creation error", severity: "high" };
|
|
570
|
+
}
|
|
571
|
+
if (msg.includes("password hash") || msg.includes("bcrypt") || msg.includes("argon2")) {
|
|
572
|
+
return { errorType: "Password hash error", severity: "critical" };
|
|
573
|
+
}
|
|
574
|
+
if (msg.includes("auth/id-token-expired") || msg.includes("id token expired")) {
|
|
575
|
+
return { errorType: "Token expired error", severity: "high" };
|
|
576
|
+
}
|
|
577
|
+
if (msg.includes("invalid-credential") || msg.includes("auth/invalid-credential") || msg.includes("invalid token")) {
|
|
578
|
+
return { errorType: "Invalid token error", severity: "high" };
|
|
579
|
+
}
|
|
580
|
+
if (msg.includes("session ended") || msg.includes("session expired")) {
|
|
581
|
+
return { errorType: "Session ended error", severity: "medium" };
|
|
582
|
+
}
|
|
583
|
+
if (msg.includes("oauth callback") || msg.includes("oauth error")) {
|
|
584
|
+
return { errorType: "OAuth callback error", severity: "high" };
|
|
585
|
+
}
|
|
586
|
+
if (msg.includes("login failed") || msg.includes("invalid credentials")) {
|
|
587
|
+
return { errorType: "Login failed error", severity: "medium" };
|
|
588
|
+
}
|
|
589
|
+
if (msg.includes("unauthorized") || msg.includes("permission denied") || msg.includes("forbidden") || msg.includes("unauthorized access") || msg.includes("permission_denied")) {
|
|
590
|
+
return { errorType: "Unauthorized access error", severity: "high" };
|
|
591
|
+
}
|
|
592
|
+
if (msg.includes("cron job") || msg.includes("cron_failed") || msg.includes("cron failed")) {
|
|
593
|
+
return { errorType: "Cron job failed", severity: "high" };
|
|
594
|
+
}
|
|
595
|
+
if (msg.includes("queue processing") || msg.includes("bullmq") || msg.includes("redis queue") || msg.includes("celery error")) {
|
|
596
|
+
return { errorType: "Queue processing error", severity: "high" };
|
|
597
|
+
}
|
|
598
|
+
if (msg.includes("webhook delivery") || msg.includes("webhook_failed") || msg.includes("webhook failed")) {
|
|
599
|
+
return { errorType: "Webhook delivery failed", severity: "high" };
|
|
600
|
+
}
|
|
601
|
+
if (msg.includes("retry limit exceeded") || msg.includes("max retries")) {
|
|
602
|
+
return { errorType: "Retry limit exceeded", severity: "high" };
|
|
603
|
+
}
|
|
604
|
+
if (msg.includes("out of memory") || msg.includes("oom") || msg.includes("heap limit") || msg.includes("heap out of memory")) {
|
|
605
|
+
return { errorType: "Out of memory error", severity: "critical" };
|
|
606
|
+
}
|
|
607
|
+
if (msg.includes("cannot find module") || msg.includes("module_not_found") || msg.includes("module not found")) {
|
|
608
|
+
return { errorType: "Module not found error", severity: "critical" };
|
|
609
|
+
}
|
|
610
|
+
if (msg.includes("process crash") || msg.includes("sigterm") || msg.includes("sigint") || msg.includes("process.exit")) {
|
|
611
|
+
return { errorType: "Process crash error", severity: "critical" };
|
|
612
|
+
}
|
|
613
|
+
if (context === "express" || msg.includes("route handler") || msg.includes("api router")) {
|
|
614
|
+
return { errorType: "Route handler error", severity: "high" };
|
|
615
|
+
}
|
|
616
|
+
if (msg.includes("middleware")) {
|
|
617
|
+
return { errorType: "Middleware error", severity: "high" };
|
|
618
|
+
}
|
|
619
|
+
if (msg.includes("validation error") || msg.includes("zoderror") || msg.includes("joi validation")) {
|
|
620
|
+
return { errorType: "Request validation error", severity: "medium" };
|
|
621
|
+
}
|
|
622
|
+
if (msg.includes("body parser") || msg.includes("multer") || msg.includes("multipart") || msg.includes("body-parser")) {
|
|
623
|
+
return { errorType: "Body parser error", severity: "high" };
|
|
624
|
+
}
|
|
625
|
+
if (msg.includes("too many requests") || msg.includes("rate limit") || msg.includes("429")) {
|
|
626
|
+
return { errorType: "Rate limit error", severity: "high" };
|
|
627
|
+
}
|
|
628
|
+
if (msg.includes("file upload") || msg.includes("upload failed") || msg.includes("cloudinary") || msg.includes("s3 upload") || msg.includes("multipart upload")) {
|
|
629
|
+
return { errorType: "File upload failed", severity: "high" };
|
|
630
|
+
}
|
|
631
|
+
if (msg.includes("file size exceeded") || msg.includes("payload too large") || msg.includes("size validation")) {
|
|
632
|
+
return { errorType: "File size exceeded", severity: "medium" };
|
|
633
|
+
}
|
|
634
|
+
if (msg.includes("invalid file type") || msg.includes("mime type mismatch") || msg.includes("file format")) {
|
|
635
|
+
return { errorType: "Invalid file type", severity: "medium" };
|
|
636
|
+
}
|
|
637
|
+
if (msg.includes("storage quota exceeded") || msg.includes("bucket quota") || msg.includes("exhausted quota")) {
|
|
638
|
+
return { errorType: "Storage quota exceeded", severity: "high" };
|
|
639
|
+
}
|
|
640
|
+
if (msg.includes("cdn ") || msg.includes("upload to cdn") || msg.includes("cdn distribution")) {
|
|
641
|
+
return { errorType: "CDN upload failed", severity: "high" };
|
|
642
|
+
}
|
|
643
|
+
if (msg.includes("email sending failed") || msg.includes("sendgrid") || msg.includes("nodemailer") || msg.includes("resend")) {
|
|
644
|
+
return { errorType: "Email sending failed", severity: "high" };
|
|
645
|
+
}
|
|
646
|
+
if (msg.includes("smtp connection") || msg.includes("smtp error") || msg.includes("mail connection")) {
|
|
647
|
+
return { errorType: "SMTP connection error", severity: "high" };
|
|
648
|
+
}
|
|
649
|
+
if (msg.includes("template rendering") || msg.includes("mjml") || msg.includes("pug render")) {
|
|
650
|
+
return { errorType: "Template rendering error", severity: "medium" };
|
|
651
|
+
}
|
|
652
|
+
if (msg.includes("onesignal") || msg.includes("push notification") || msg.includes("fcm payload")) {
|
|
653
|
+
return { errorType: "OneSignal API error", severity: "high" };
|
|
654
|
+
}
|
|
655
|
+
if (msg.includes("cors") || msg.includes("cross-origin") || msg.includes("preflight") || msg.includes("access-control-allow")) {
|
|
656
|
+
return { errorType: "CORS error", severity: "high" };
|
|
657
|
+
}
|
|
658
|
+
if (msg.includes("fetch failed") || msg.includes("failed to fetch")) {
|
|
659
|
+
return { errorType: "Fetch failed error", severity: "high" };
|
|
660
|
+
}
|
|
661
|
+
if (msg.includes("timeout") || msg.includes("aborted") || msg.includes("timed out") || msg.includes("etimedout")) {
|
|
662
|
+
return { errorType: "Request timeout error", severity: "medium" };
|
|
663
|
+
}
|
|
664
|
+
if (msg.includes("websocket connection") || msg.includes("ws connection failed") || msg.includes("ws://") || msg.includes("wss://")) {
|
|
665
|
+
return { errorType: "WebSocket connection error", severity: "high" };
|
|
666
|
+
}
|
|
667
|
+
if (msg.includes("websocket closed") || msg.includes("websocket disconnected") || msg.includes("ws.close")) {
|
|
668
|
+
return { errorType: "WebSocket disconnect error", severity: "medium" };
|
|
669
|
+
}
|
|
670
|
+
if (context === "unhandledrejection") {
|
|
671
|
+
return { errorType: "Unhandled promise rejection", severity: "medium" };
|
|
672
|
+
}
|
|
673
|
+
if (msg.includes("async") && msg.includes("await")) {
|
|
674
|
+
return { errorType: "Async await failure", severity: "high" };
|
|
675
|
+
}
|
|
676
|
+
if (msg.includes("promise chain") || msg.includes("promise.all") || msg.includes("promise.race")) {
|
|
677
|
+
return { errorType: "Promise chain error", severity: "high" };
|
|
678
|
+
}
|
|
679
|
+
if (msg.includes("promise timed out") || msg.includes("promise timeout")) {
|
|
680
|
+
return { errorType: "Promise timeout error", severity: "medium" };
|
|
681
|
+
}
|
|
682
|
+
if (context === "uncaughtexception") {
|
|
683
|
+
return { errorType: "Uncaught exception", severity: "high" };
|
|
684
|
+
}
|
|
685
|
+
return { errorType: "Uncaught exception", severity: "medium" };
|
|
686
|
+
}
|
|
351
687
|
};
|
|
688
|
+
var Reportli = new ReportliTracker();
|
|
352
689
|
var src_default = Reportli;
|
|
353
690
|
// Annotate the CommonJS export names for ESM import in node:
|
|
354
691
|
0 && (module.exports = {
|