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