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