reportli 1.0.1 → 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 +9 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +117 -328
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +117 -336
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
- package/src/index.ts +156 -363
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Watches your SaaS, catches every error, files the GitHub issue — automatically.
|
|
5
|
-
*/
|
|
6
|
-
declare const Reportli: {
|
|
7
|
-
init({ apiKey }: {
|
|
8
|
-
apiKey: string;
|
|
9
|
-
}): void;
|
|
10
|
-
capture(error: any): void;
|
|
11
|
-
errorHandler(): (err: any, _req: any, _res: any, next: any) => void;
|
|
1
|
+
type Config = {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
environment?: string;
|
|
12
4
|
};
|
|
13
|
-
export
|
|
14
|
-
|
|
5
|
+
export declare const Reportli: {
|
|
6
|
+
init(cfg: Config): void;
|
|
7
|
+
capture(error: unknown): void;
|
|
8
|
+
captureMessage(message: string): void;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
15
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,KAAK,MAAM,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAiDF,eAAO,MAAM,QAAQ;cACT,MAAM;mBAmGD,OAAO;4BAeE,MAAM;CAO/B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -20,353 +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
26
|
var ENDPOINT = "https://fahikyfmgdyzejdfftox.supabase.co/functions/v1/rapid-processor";
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} catch {
|
|
40
|
-
return "server";
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function getBrowser() {
|
|
44
|
-
if (isBrowser)
|
|
45
|
-
return navigator.userAgent;
|
|
46
|
-
return `Node.js ${typeof process !== "undefined" ? process.version : "unknown"}`;
|
|
47
|
-
}
|
|
48
|
-
function parseStack(stack) {
|
|
49
|
-
if (!stack)
|
|
50
|
-
return { file: "unknown", line: 0, column: 0 };
|
|
51
|
-
const match = stack.match(/at .+ \((.+):(\d+):(\d+)\)/) || stack.match(/at (.+):(\d+):(\d+)/);
|
|
52
|
-
return {
|
|
53
|
-
file: match?.[1]?.split("/")?.pop() || "unknown",
|
|
54
|
-
line: parseInt(match?.[2] || "0"),
|
|
55
|
-
column: parseInt(match?.[3] || "0")
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function getErrorCode(error) {
|
|
59
|
-
return error?.code || error?.status?.toString() || error?.statusCode?.toString() || error?.name || "ERR_UNKNOWN";
|
|
60
|
-
}
|
|
61
|
-
function classifyError(error, context) {
|
|
62
|
-
const msg = String(error?.message || error || "").toLowerCase();
|
|
63
|
-
const name = String(error?.name || "").toLowerCase();
|
|
64
|
-
if (name.includes("quotaexceeded") || msg.includes("quota exceeded") || msg.includes("localstorage") || msg.includes("indexeddb"))
|
|
65
|
-
return { errorType: "localStorage quota exceeded", severity: "medium" };
|
|
66
|
-
if (msg.includes("hydration") || msg.includes("does not match server"))
|
|
67
|
-
return { errorType: "React hydration error", severity: "high" };
|
|
68
|
-
if (msg.includes("invalid hook call") || msg.includes("rules of hooks"))
|
|
69
|
-
return { errorType: "Invalid hook call error", severity: "critical" };
|
|
70
|
-
if (msg.includes("failed prop type") || msg.includes("invalid prop"))
|
|
71
|
-
return { errorType: "Props type error", severity: "low" };
|
|
72
|
-
if (msg.includes("render") || msg.includes("react error boundary"))
|
|
73
|
-
return { errorType: "Component render error", severity: "critical" };
|
|
74
|
-
if (msg.includes("route not found") || msg.includes("404 route"))
|
|
75
|
-
return { errorType: "Route not found error", severity: "medium" };
|
|
76
|
-
if (msg.includes("failed to fetch dynamically imported") || msg.includes("dynamic import"))
|
|
77
|
-
return { errorType: "Dynamic import error", severity: "high" };
|
|
78
|
-
if (msg.includes("suspense"))
|
|
79
|
-
return { errorType: "Suspense boundary error", severity: "medium" };
|
|
80
|
-
if (name === "typeerror" || msg.startsWith("typeerror"))
|
|
81
|
-
return { errorType: "TypeError", severity: "high" };
|
|
82
|
-
if (name === "referenceerror")
|
|
83
|
-
return { errorType: "ReferenceError", severity: "critical" };
|
|
84
|
-
if (name === "rangeerror" || msg.includes("maximum call stack"))
|
|
85
|
-
return { errorType: "Stack overflow error", severity: "critical" };
|
|
86
|
-
if (name === "syntaxerror")
|
|
87
|
-
return { errorType: "SyntaxError", severity: "high" };
|
|
88
|
-
if (msg.includes("stripe") && (msg.includes("init") || msg.includes("key")))
|
|
89
|
-
return { errorType: "Stripe initialization error", severity: "critical" };
|
|
90
|
-
if (msg.includes("payment") || msg.includes("card declined"))
|
|
91
|
-
return { errorType: "Payment processing error", severity: "critical" };
|
|
92
|
-
if (msg.includes("checkout session"))
|
|
93
|
-
return { errorType: "Checkout session error", severity: "high" };
|
|
94
|
-
if (msg.includes("refund failed"))
|
|
95
|
-
return { errorType: "Refund failed error", severity: "high" };
|
|
96
|
-
if (msg.includes("supabase") || msg.includes("postgresterror"))
|
|
97
|
-
return { errorType: "Supabase query error", severity: "critical" };
|
|
98
|
-
if (msg.includes("unique constraint") || msg.includes("duplicate key"))
|
|
99
|
-
return { errorType: "Unique constraint error", severity: "high" };
|
|
100
|
-
if (msg.includes("foreign key"))
|
|
101
|
-
return { errorType: "Foreign key error", severity: "high" };
|
|
102
|
-
if (msg.includes("transaction failed") || msg.includes("rollback"))
|
|
103
|
-
return { errorType: "Transaction failed error", severity: "critical" };
|
|
104
|
-
if (msg.includes("connection lost") || msg.includes("econnrefused"))
|
|
105
|
-
return { errorType: "Connection lost error", severity: "critical" };
|
|
106
|
-
if (msg.includes("query timeout"))
|
|
107
|
-
return { errorType: "Query timeout error", severity: "high" };
|
|
108
|
-
if (msg.includes("jwt expired") || msg.includes("token expired"))
|
|
109
|
-
return { errorType: "JWT expired error", severity: "high" };
|
|
110
|
-
if (msg.includes("jwt") && msg.includes("invalid"))
|
|
111
|
-
return { errorType: "JWT verification error", severity: "high" };
|
|
112
|
-
if (msg.includes("firebase admin"))
|
|
113
|
-
return { errorType: "Firebase admin error", severity: "critical" };
|
|
114
|
-
if (msg.includes("unauthorized") || msg.includes("permission denied"))
|
|
115
|
-
return { errorType: "Unauthorized access error", severity: "high" };
|
|
116
|
-
if (msg.includes("login failed") || msg.includes("invalid credentials"))
|
|
117
|
-
return { errorType: "Login failed error", severity: "medium" };
|
|
118
|
-
if (msg.includes("session ended") || msg.includes("session expired"))
|
|
119
|
-
return { errorType: "Session ended error", severity: "medium" };
|
|
120
|
-
if (msg.includes("oauth"))
|
|
121
|
-
return { errorType: "OAuth callback error", severity: "high" };
|
|
122
|
-
if (msg.includes("cron job") || msg.includes("cron failed"))
|
|
123
|
-
return { errorType: "Cron job failed", severity: "high" };
|
|
124
|
-
if (msg.includes("queue processing") || msg.includes("bullmq"))
|
|
125
|
-
return { errorType: "Queue processing error", severity: "high" };
|
|
126
|
-
if (msg.includes("webhook"))
|
|
127
|
-
return { errorType: "Webhook delivery failed", severity: "high" };
|
|
128
|
-
if (msg.includes("retry limit"))
|
|
129
|
-
return { errorType: "Retry limit exceeded", severity: "high" };
|
|
130
|
-
if (msg.includes("out of memory") || msg.includes("heap limit"))
|
|
131
|
-
return { errorType: "Out of memory error", severity: "critical" };
|
|
132
|
-
if (msg.includes("cannot find module"))
|
|
133
|
-
return { errorType: "Module not found error", severity: "critical" };
|
|
134
|
-
if (msg.includes("email") || msg.includes("smtp") || msg.includes("sendgrid") || msg.includes("nodemailer"))
|
|
135
|
-
return { errorType: "Email sending failed", severity: "high" };
|
|
136
|
-
if (msg.includes("onesignal") || msg.includes("push notification"))
|
|
137
|
-
return { errorType: "OneSignal API error", severity: "high" };
|
|
138
|
-
if (msg.includes("file upload") || msg.includes("upload failed"))
|
|
139
|
-
return { errorType: "File upload failed", severity: "high" };
|
|
140
|
-
if (msg.includes("file size exceeded") || msg.includes("payload too large"))
|
|
141
|
-
return { errorType: "File size exceeded", severity: "medium" };
|
|
142
|
-
if (msg.includes("invalid file type") || msg.includes("mime type"))
|
|
143
|
-
return { errorType: "Invalid file type", severity: "medium" };
|
|
144
|
-
if (msg.includes("cors") || msg.includes("cross-origin"))
|
|
145
|
-
return { errorType: "CORS error", severity: "high" };
|
|
146
|
-
if (msg.includes("fetch failed") || msg.includes("failed to fetch"))
|
|
147
|
-
return { errorType: "Fetch failed error", severity: "high" };
|
|
148
|
-
if (msg.includes("timeout") || msg.includes("timed out") || msg.includes("etimedout"))
|
|
149
|
-
return { errorType: "Request timeout error", severity: "medium" };
|
|
150
|
-
if (msg.includes("websocket"))
|
|
151
|
-
return { errorType: "WebSocket connection error", severity: "high" };
|
|
152
|
-
if (context === "unhandledrejection")
|
|
153
|
-
return { errorType: "Unhandled promise rejection", severity: "medium" };
|
|
154
|
-
if (context === "uncaughtexception")
|
|
155
|
-
return { errorType: "Uncaught exception", severity: "high" };
|
|
156
|
-
if (context === "express")
|
|
157
|
-
return { errorType: "Route handler error", severity: "high" };
|
|
158
|
-
return { errorType: "Uncaught exception", severity: "medium" };
|
|
159
|
-
}
|
|
160
|
-
function normalizeError(err) {
|
|
161
|
-
if (err instanceof Error)
|
|
162
|
-
return { name: err.name, message: err.message, stack: err.stack };
|
|
163
|
-
if (typeof err === "string")
|
|
164
|
-
return { name: "Error", message: err, stack: new Error(err).stack };
|
|
165
|
-
if (err && typeof err === "object")
|
|
166
|
-
return {
|
|
167
|
-
name: err.name || err.code || "Error",
|
|
168
|
-
message: err.message || err.reason || JSON.stringify(err),
|
|
169
|
-
stack: err.stack || new Error(err.message).stack
|
|
170
|
-
};
|
|
171
|
-
return { name: "Error", message: "Unknown error", stack: new Error().stack };
|
|
172
|
-
}
|
|
173
|
-
async function send(payload) {
|
|
174
|
-
try {
|
|
175
|
-
if (payload.message?.includes("rapid-processor"))
|
|
176
|
-
return;
|
|
177
|
-
await fetch(ENDPOINT, {
|
|
178
|
-
method: "POST",
|
|
179
|
-
headers: {
|
|
180
|
-
"Content-Type": "application/json",
|
|
181
|
-
"x-api-key": _apiKey
|
|
182
|
-
},
|
|
183
|
-
body: JSON.stringify(payload)
|
|
184
|
-
});
|
|
185
|
-
} catch {
|
|
186
|
-
}
|
|
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
|
+
});
|
|
187
38
|
}
|
|
188
|
-
function
|
|
189
|
-
|
|
190
|
-
const { file, line, column } = parseStack(normalized.stack);
|
|
191
|
-
const { errorType, severity } = classifyError(normalized, context);
|
|
192
|
-
return {
|
|
39
|
+
function sendError(data) {
|
|
40
|
+
post({
|
|
193
41
|
type: "ERROR",
|
|
194
|
-
apiKey:
|
|
195
|
-
message:
|
|
196
|
-
code:
|
|
197
|
-
stack:
|
|
198
|
-
file,
|
|
199
|
-
line,
|
|
200
|
-
column,
|
|
201
|
-
url:
|
|
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,
|
|
202
50
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
203
|
-
environment:
|
|
204
|
-
browser:
|
|
205
|
-
error_category:
|
|
206
|
-
severity,
|
|
51
|
+
environment: config.environment ?? "production",
|
|
52
|
+
browser: typeof navigator !== "undefined" ? navigator.userAgent : "node",
|
|
53
|
+
error_category: data.code ?? "Error",
|
|
54
|
+
severity: data.severity ?? "high",
|
|
207
55
|
status: "open"
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
function activateBrowserListeners() {
|
|
211
|
-
window.addEventListener("error", (event) => {
|
|
212
|
-
if (event.filename?.includes("rapid-processor"))
|
|
213
|
-
return;
|
|
214
|
-
const target = event.target;
|
|
215
|
-
if (target && target.tagName) {
|
|
216
|
-
const tag = target.tagName;
|
|
217
|
-
const src = target.src || target.href || "";
|
|
218
|
-
if (["IMG", "SCRIPT", "LINK", "VIDEO", "AUDIO", "SOURCE"].includes(tag)) {
|
|
219
|
-
send(buildErrorPayload({
|
|
220
|
-
name: "ResourceError",
|
|
221
|
-
message: `${tag} failed to load: ${src}`,
|
|
222
|
-
stack: `at ${window.location.href}`
|
|
223
|
-
}));
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
const err = event.error || {
|
|
228
|
-
name: "Error",
|
|
229
|
-
message: event.message,
|
|
230
|
-
stack: `${event.message} at ${event.filename}:${event.lineno}:${event.colno}`
|
|
231
|
-
};
|
|
232
|
-
send(buildErrorPayload(err));
|
|
233
|
-
}, true);
|
|
234
|
-
window.addEventListener("unhandledrejection", (event) => {
|
|
235
|
-
send(buildErrorPayload(event.reason || { message: "Unhandled Promise Rejection" }, "unhandledrejection"));
|
|
236
|
-
});
|
|
237
|
-
const originalFetch = window.fetch;
|
|
238
|
-
window.fetch = async function(input, init) {
|
|
239
|
-
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
240
|
-
if (url.includes("rapid-processor") || url.includes("supabase.co/functions")) {
|
|
241
|
-
return originalFetch.apply(this, arguments);
|
|
242
|
-
}
|
|
243
|
-
try {
|
|
244
|
-
const response = await originalFetch.apply(this, arguments);
|
|
245
|
-
if (!response.ok) {
|
|
246
|
-
send(buildErrorPayload({
|
|
247
|
-
name: `API ${response.status} Error`,
|
|
248
|
-
message: `HTTP ${response.status}: ${init?.method || "GET"} ${url}`,
|
|
249
|
-
stack: `${init?.method || "GET"} ${url} \u2192 ${response.status} ${response.statusText}`,
|
|
250
|
-
status: response.status
|
|
251
|
-
}));
|
|
252
|
-
}
|
|
253
|
-
return response;
|
|
254
|
-
} catch (err) {
|
|
255
|
-
send(buildErrorPayload({
|
|
256
|
-
name: "FetchError",
|
|
257
|
-
message: `Fetch failed: ${init?.method || "GET"} ${url} \u2014 ${err.message}`,
|
|
258
|
-
stack: err.stack
|
|
259
|
-
}));
|
|
260
|
-
throw err;
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
const originalOpen = XMLHttpRequest.prototype.open;
|
|
264
|
-
const originalSend = XMLHttpRequest.prototype.send;
|
|
265
|
-
XMLHttpRequest.prototype.open = function(method, url) {
|
|
266
|
-
this._r_method = method;
|
|
267
|
-
this._r_url = url;
|
|
268
|
-
return originalOpen.apply(this, arguments);
|
|
269
|
-
};
|
|
270
|
-
XMLHttpRequest.prototype.send = function() {
|
|
271
|
-
this.addEventListener("loadend", () => {
|
|
272
|
-
const url = this._r_url || "";
|
|
273
|
-
const method = this._r_method || "GET";
|
|
274
|
-
if (url.includes("rapid-processor"))
|
|
275
|
-
return;
|
|
276
|
-
if (this.status >= 400 || this.status === 0) {
|
|
277
|
-
send(buildErrorPayload({
|
|
278
|
-
name: `XHR ${this.status} Error`,
|
|
279
|
-
message: `XHR ${this.status}: ${method} ${url}`,
|
|
280
|
-
stack: `${method} ${url} \u2192 ${this.status} ${this.statusText}`,
|
|
281
|
-
status: this.status
|
|
282
|
-
}));
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
return originalSend.apply(this, arguments);
|
|
286
|
-
};
|
|
287
|
-
window.addEventListener("beforeunload", () => {
|
|
288
|
-
try {
|
|
289
|
-
navigator.sendBeacon(ENDPOINT, JSON.stringify({
|
|
290
|
-
type: "SDK_DISCONNECTED",
|
|
291
|
-
apiKey: _apiKey,
|
|
292
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
293
|
-
environment: "browser",
|
|
294
|
-
url: getUrl()
|
|
295
|
-
}));
|
|
296
|
-
} catch {
|
|
297
|
-
}
|
|
298
56
|
});
|
|
299
57
|
}
|
|
300
|
-
function activateServerListeners() {
|
|
301
|
-
process.on("uncaughtException", (error) => {
|
|
302
|
-
send(buildErrorPayload(error, "uncaughtexception"));
|
|
303
|
-
});
|
|
304
|
-
process.on("unhandledRejection", (reason) => {
|
|
305
|
-
send(buildErrorPayload(
|
|
306
|
-
reason instanceof Error ? reason : { name: "UnhandledRejection", message: String(reason), stack: "" },
|
|
307
|
-
"unhandledrejection"
|
|
308
|
-
));
|
|
309
|
-
});
|
|
310
|
-
const shutdown = async () => {
|
|
311
|
-
await send({
|
|
312
|
-
type: "SDK_DISCONNECTED",
|
|
313
|
-
apiKey: _apiKey,
|
|
314
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
315
|
-
environment: "server",
|
|
316
|
-
url: getUrl()
|
|
317
|
-
});
|
|
318
|
-
process.exit(0);
|
|
319
|
-
};
|
|
320
|
-
process.on("SIGTERM", shutdown);
|
|
321
|
-
process.on("SIGINT", shutdown);
|
|
322
|
-
}
|
|
323
58
|
var Reportli = {
|
|
324
|
-
init(
|
|
325
|
-
if (
|
|
59
|
+
init(cfg) {
|
|
60
|
+
if (initialized)
|
|
326
61
|
return;
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
62
|
+
config = cfg;
|
|
63
|
+
initialized = true;
|
|
64
|
+
console.log(
|
|
65
|
+
"\u2705 Reportli initialized successfully. Error monitoring is active."
|
|
66
|
+
);
|
|
67
|
+
window.addEventListener("error", (event) => {
|
|
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"
|
|
339
81
|
});
|
|
340
82
|
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
browser: getBrowser()
|
|
83
|
+
}, true);
|
|
84
|
+
window.addEventListener("unhandledrejection", (event) => {
|
|
85
|
+
const err = event.reason;
|
|
86
|
+
sendError({
|
|
87
|
+
message: err?.message ?? String(err),
|
|
88
|
+
code: err?.name ?? "UnhandledPromiseRejection",
|
|
89
|
+
stack: err?.stack
|
|
349
90
|
});
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
91
|
+
});
|
|
92
|
+
const originalFetch = window.fetch;
|
|
93
|
+
window.fetch = async (...args) => {
|
|
94
|
+
try {
|
|
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
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return response;
|
|
104
|
+
} catch (e) {
|
|
105
|
+
sendError({
|
|
106
|
+
message: e?.message ?? "Fetch failed",
|
|
107
|
+
code: "FetchError",
|
|
108
|
+
stack: e?.stack
|
|
109
|
+
});
|
|
110
|
+
throw e;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
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);
|
|
118
|
+
};
|
|
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
|
+
});
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
this.addEventListener("error", function() {
|
|
129
|
+
sendError({
|
|
130
|
+
message: "XHR connection failed",
|
|
131
|
+
code: "XHRConnectionError"
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
return send.apply(this, args);
|
|
135
|
+
};
|
|
356
136
|
},
|
|
357
137
|
capture(error) {
|
|
358
|
-
if (
|
|
359
|
-
|
|
360
|
-
|
|
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
|
+
});
|
|
149
|
+
}
|
|
361
150
|
},
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
151
|
+
captureMessage(message) {
|
|
152
|
+
sendError({
|
|
153
|
+
message,
|
|
154
|
+
code: "Message",
|
|
155
|
+
severity: "low"
|
|
156
|
+
});
|
|
367
157
|
}
|
|
368
158
|
};
|
|
369
|
-
var src_default = Reportli;
|
|
370
159
|
// Annotate the CommonJS export names for ESM import in node:
|
|
371
160
|
0 && (module.exports = {
|
|
372
161
|
Reportli
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Reportli SDK v1.0.1\n * Your AI agent that never sleeps.\n * Watches your SaaS, catches every error, files the GitHub issue \u2014 automatically.\n */\n\nconst ENDPOINT = \"https://fahikyfmgdyzejdfftox.supabase.co/functions/v1/rapid-processor\";\n\nconst isBrowser = typeof window !== \"undefined\";\nconst isNode = typeof process !== \"undefined\" && !!(process.versions?.node);\n\nlet _apiKey = \"\";\n\n// \u2500\u2500\u2500 Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction getEnvironment(): string {\n return isBrowser ? \"browser\" : \"server\";\n}\n\nfunction getUrl(): string {\n if (isBrowser) return window.location.href;\n try { return require(\"os\").hostname(); } catch { return \"server\"; }\n}\n\nfunction getBrowser(): string {\n if (isBrowser) return navigator.userAgent;\n return `Node.js ${typeof process !== \"undefined\" ? process.version : \"unknown\"}`;\n}\n\nfunction parseStack(stack: string | undefined): { file: string; line: number; column: number } {\n if (!stack) return { file: \"unknown\", line: 0, column: 0 };\n const match =\n stack.match(/at .+ \\((.+):(\\d+):(\\d+)\\)/) ||\n stack.match(/at (.+):(\\d+):(\\d+)/);\n return {\n file: match?.[1]?.split(\"/\")?.pop() || \"unknown\",\n line: parseInt(match?.[2] || \"0\"),\n column: parseInt(match?.[3] || \"0\"),\n };\n}\n\nfunction getErrorCode(error: any): string {\n return error?.code || error?.status?.toString() || error?.statusCode?.toString() || error?.name || \"ERR_UNKNOWN\";\n}\n\nfunction classifyError(error: any, context?: string): { errorType: string; severity: \"low\" | \"medium\" | \"high\" | \"critical\" } {\n const msg = String(error?.message || error || \"\").toLowerCase();\n const name = String(error?.name || \"\").toLowerCase();\n\n if (name.includes(\"quotaexceeded\") || msg.includes(\"quota exceeded\") || msg.includes(\"localstorage\") || msg.includes(\"indexeddb\"))\n return { errorType: \"localStorage quota exceeded\", severity: \"medium\" };\n if (msg.includes(\"hydration\") || msg.includes(\"does not match server\"))\n return { errorType: \"React hydration error\", severity: \"high\" };\n if (msg.includes(\"invalid hook call\") || msg.includes(\"rules of hooks\"))\n return { errorType: \"Invalid hook call error\", severity: \"critical\" };\n if (msg.includes(\"failed prop type\") || msg.includes(\"invalid prop\"))\n return { errorType: \"Props type error\", severity: \"low\" };\n if (msg.includes(\"render\") || msg.includes(\"react error boundary\"))\n return { errorType: \"Component render error\", severity: \"critical\" };\n if (msg.includes(\"route not found\") || msg.includes(\"404 route\"))\n return { errorType: \"Route not found error\", severity: \"medium\" };\n if (msg.includes(\"failed to fetch dynamically imported\") || msg.includes(\"dynamic import\"))\n return { errorType: \"Dynamic import error\", severity: \"high\" };\n if (msg.includes(\"suspense\"))\n return { errorType: \"Suspense boundary error\", severity: \"medium\" };\n if (name === \"typeerror\" || msg.startsWith(\"typeerror\"))\n return { errorType: \"TypeError\", severity: \"high\" };\n if (name === \"referenceerror\")\n return { errorType: \"ReferenceError\", severity: \"critical\" };\n if (name === \"rangeerror\" || msg.includes(\"maximum call stack\"))\n return { errorType: \"Stack overflow error\", severity: \"critical\" };\n if (name === \"syntaxerror\")\n return { errorType: \"SyntaxError\", severity: \"high\" };\n if (msg.includes(\"stripe\") && (msg.includes(\"init\") || msg.includes(\"key\")))\n return { errorType: \"Stripe initialization error\", severity: \"critical\" };\n if (msg.includes(\"payment\") || msg.includes(\"card declined\"))\n return { errorType: \"Payment processing error\", severity: \"critical\" };\n if (msg.includes(\"checkout session\"))\n return { errorType: \"Checkout session error\", severity: \"high\" };\n if (msg.includes(\"refund failed\"))\n return { errorType: \"Refund failed error\", severity: \"high\" };\n if (msg.includes(\"supabase\") || msg.includes(\"postgresterror\"))\n return { errorType: \"Supabase query error\", severity: \"critical\" };\n if (msg.includes(\"unique constraint\") || msg.includes(\"duplicate key\"))\n return { errorType: \"Unique constraint error\", severity: \"high\" };\n if (msg.includes(\"foreign key\"))\n return { errorType: \"Foreign key error\", severity: \"high\" };\n if (msg.includes(\"transaction failed\") || msg.includes(\"rollback\"))\n return { errorType: \"Transaction failed error\", severity: \"critical\" };\n if (msg.includes(\"connection lost\") || msg.includes(\"econnrefused\"))\n return { errorType: \"Connection lost error\", severity: \"critical\" };\n if (msg.includes(\"query timeout\"))\n return { errorType: \"Query timeout error\", severity: \"high\" };\n if (msg.includes(\"jwt expired\") || msg.includes(\"token expired\"))\n return { errorType: \"JWT expired error\", severity: \"high\" };\n if (msg.includes(\"jwt\") && msg.includes(\"invalid\"))\n return { errorType: \"JWT verification error\", severity: \"high\" };\n if (msg.includes(\"firebase admin\"))\n return { errorType: \"Firebase admin error\", severity: \"critical\" };\n if (msg.includes(\"unauthorized\") || msg.includes(\"permission denied\"))\n return { errorType: \"Unauthorized access error\", severity: \"high\" };\n if (msg.includes(\"login failed\") || msg.includes(\"invalid credentials\"))\n return { errorType: \"Login failed error\", severity: \"medium\" };\n if (msg.includes(\"session ended\") || msg.includes(\"session expired\"))\n return { errorType: \"Session ended error\", severity: \"medium\" };\n if (msg.includes(\"oauth\"))\n return { errorType: \"OAuth callback error\", severity: \"high\" };\n if (msg.includes(\"cron job\") || msg.includes(\"cron failed\"))\n return { errorType: \"Cron job failed\", severity: \"high\" };\n if (msg.includes(\"queue processing\") || msg.includes(\"bullmq\"))\n return { errorType: \"Queue processing error\", severity: \"high\" };\n if (msg.includes(\"webhook\"))\n return { errorType: \"Webhook delivery failed\", severity: \"high\" };\n if (msg.includes(\"retry limit\"))\n return { errorType: \"Retry limit exceeded\", severity: \"high\" };\n if (msg.includes(\"out of memory\") || msg.includes(\"heap limit\"))\n return { errorType: \"Out of memory error\", severity: \"critical\" };\n if (msg.includes(\"cannot find module\"))\n return { errorType: \"Module not found error\", severity: \"critical\" };\n if (msg.includes(\"email\") || msg.includes(\"smtp\") || msg.includes(\"sendgrid\") || msg.includes(\"nodemailer\"))\n return { errorType: \"Email sending failed\", severity: \"high\" };\n if (msg.includes(\"onesignal\") || msg.includes(\"push notification\"))\n return { errorType: \"OneSignal API error\", severity: \"high\" };\n if (msg.includes(\"file upload\") || msg.includes(\"upload failed\"))\n return { errorType: \"File upload failed\", severity: \"high\" };\n if (msg.includes(\"file size exceeded\") || msg.includes(\"payload too large\"))\n return { errorType: \"File size exceeded\", severity: \"medium\" };\n if (msg.includes(\"invalid file type\") || msg.includes(\"mime type\"))\n return { errorType: \"Invalid file type\", severity: \"medium\" };\n if (msg.includes(\"cors\") || msg.includes(\"cross-origin\"))\n return { errorType: \"CORS error\", severity: \"high\" };\n if (msg.includes(\"fetch failed\") || msg.includes(\"failed to fetch\"))\n return { errorType: \"Fetch failed error\", severity: \"high\" };\n if (msg.includes(\"timeout\") || msg.includes(\"timed out\") || msg.includes(\"etimedout\"))\n return { errorType: \"Request timeout error\", severity: \"medium\" };\n if (msg.includes(\"websocket\"))\n return { errorType: \"WebSocket connection error\", severity: \"high\" };\n if (context === \"unhandledrejection\")\n return { errorType: \"Unhandled promise rejection\", severity: \"medium\" };\n if (context === \"uncaughtexception\")\n return { errorType: \"Uncaught exception\", severity: \"high\" };\n if (context === \"express\")\n return { errorType: \"Route handler error\", severity: \"high\" };\n return { errorType: \"Uncaught exception\", severity: \"medium\" };\n}\n\nfunction normalizeError(err: any): { name: string; message: string; stack?: string } {\n if (err instanceof Error) return { name: err.name, message: err.message, stack: err.stack };\n if (typeof err === \"string\") return { name: \"Error\", message: err, stack: new Error(err).stack };\n if (err && typeof err === \"object\") return {\n name: err.name || err.code || \"Error\",\n message: err.message || err.reason || JSON.stringify(err),\n stack: err.stack || new Error(err.message).stack,\n };\n return { name: \"Error\", message: \"Unknown error\", stack: new Error().stack };\n}\n\n// \u2500\u2500\u2500 Send \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nasync function send(payload: object): Promise<void> {\n try {\n if ((payload as any).message?.includes(\"rapid-processor\")) return;\n await fetch(ENDPOINT, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": _apiKey,\n },\n body: JSON.stringify(payload),\n });\n } catch {\n // Fail silently \u2014 never break user app\n }\n}\n\n// \u2500\u2500\u2500 Build error payload \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction buildErrorPayload(error: any, context?: string): object {\n const normalized = normalizeError(error);\n const { file, line, column } = parseStack(normalized.stack);\n const { errorType, severity } = classifyError(normalized, context);\n\n return {\n type: \"ERROR\",\n apiKey: _apiKey,\n message: normalized.message,\n code: getErrorCode(error),\n stack: normalized.stack || \"\",\n file,\n line,\n column,\n url: getUrl(),\n timestamp: new Date().toISOString(),\n environment: getEnvironment(),\n browser: getBrowser(),\n error_category: errorType,\n severity,\n status: \"open\",\n };\n}\n\n// \u2500\u2500\u2500 Browser listeners \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction activateBrowserListeners(): void {\n // JS runtime errors + resource load errors\n window.addEventListener(\"error\", (event) => {\n if ((event as any).filename?.includes(\"rapid-processor\")) return;\n\n const target = event.target as HTMLElement;\n if (target && target.tagName) {\n const tag = target.tagName;\n const src = (target as any).src || (target as any).href || \"\";\n if ([\"IMG\", \"SCRIPT\", \"LINK\", \"VIDEO\", \"AUDIO\", \"SOURCE\"].includes(tag)) {\n send(buildErrorPayload({\n name: \"ResourceError\",\n message: `${tag} failed to load: ${src}`,\n stack: `at ${window.location.href}`,\n }));\n return;\n }\n }\n\n const err = (event as ErrorEvent).error || {\n name: \"Error\",\n message: (event as ErrorEvent).message,\n stack: `${(event as ErrorEvent).message} at ${(event as ErrorEvent).filename}:${(event as ErrorEvent).lineno}:${(event as ErrorEvent).colno}`,\n };\n send(buildErrorPayload(err));\n }, true);\n\n // Unhandled promise rejections\n window.addEventListener(\"unhandledrejection\", (event) => {\n send(buildErrorPayload(event.reason || { message: \"Unhandled Promise Rejection\" }, \"unhandledrejection\"));\n });\n\n // Intercept fetch\n const originalFetch = window.fetch;\n window.fetch = async function (input: RequestInfo | URL, init?: RequestInit): Promise<Response> {\n const url = typeof input === \"string\" ? input : (input instanceof URL ? input.toString() : (input as Request).url);\n if (url.includes(\"rapid-processor\") || url.includes(\"supabase.co/functions\")) {\n return originalFetch.apply(this, arguments as any);\n }\n try {\n const response = await originalFetch.apply(this, arguments as any);\n if (!response.ok) {\n send(buildErrorPayload({\n name: `API ${response.status} Error`,\n message: `HTTP ${response.status}: ${init?.method || \"GET\"} ${url}`,\n stack: `${init?.method || \"GET\"} ${url} \u2192 ${response.status} ${response.statusText}`,\n status: response.status,\n }));\n }\n return response;\n } catch (err: any) {\n send(buildErrorPayload({\n name: \"FetchError\",\n message: `Fetch failed: ${init?.method || \"GET\"} ${url} \u2014 ${err.message}`,\n stack: err.stack,\n }));\n throw err;\n }\n };\n\n // Intercept XHR\n const originalOpen = XMLHttpRequest.prototype.open;\n const originalSend = XMLHttpRequest.prototype.send;\n\n XMLHttpRequest.prototype.open = function (method: string, url: string) {\n (this as any)._r_method = method;\n (this as any)._r_url = url;\n return originalOpen.apply(this, arguments as any);\n } as any;\n\n XMLHttpRequest.prototype.send = function () {\n this.addEventListener(\"loadend\", () => {\n const url: string = (this as any)._r_url || \"\";\n const method: string = (this as any)._r_method || \"GET\";\n if (url.includes(\"rapid-processor\")) return;\n if (this.status >= 400 || this.status === 0) {\n send(buildErrorPayload({\n name: `XHR ${this.status} Error`,\n message: `XHR ${this.status}: ${method} ${url}`,\n stack: `${method} ${url} \u2192 ${this.status} ${this.statusText}`,\n status: this.status,\n }));\n }\n });\n return originalSend.apply(this, arguments as any);\n } as any;\n\n // Disconnect when page closes\n window.addEventListener(\"beforeunload\", () => {\n try {\n navigator.sendBeacon(ENDPOINT, JSON.stringify({\n type: \"SDK_DISCONNECTED\",\n apiKey: _apiKey,\n timestamp: new Date().toISOString(),\n environment: \"browser\",\n url: getUrl(),\n }));\n } catch { /* silent */ }\n });\n}\n\n// \u2500\u2500\u2500 Server listeners \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction activateServerListeners(): void {\n process.on(\"uncaughtException\", (error: Error) => {\n send(buildErrorPayload(error, \"uncaughtexception\"));\n });\n\n process.on(\"unhandledRejection\", (reason: any) => {\n send(buildErrorPayload(\n reason instanceof Error ? reason : { name: \"UnhandledRejection\", message: String(reason), stack: \"\" },\n \"unhandledrejection\"\n ));\n });\n\n const shutdown = async () => {\n await send({\n type: \"SDK_DISCONNECTED\",\n apiKey: _apiKey,\n timestamp: new Date().toISOString(),\n environment: \"server\",\n url: getUrl(),\n });\n process.exit(0);\n };\n\n process.on(\"SIGTERM\", shutdown);\n process.on(\"SIGINT\", shutdown);\n}\n\n// \u2500\u2500\u2500 Public API \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst Reportli = {\n init({ apiKey }: { apiKey: string }): void {\n if (!apiKey || _apiKey) return;\n _apiKey = apiKey;\n\n // Send SDK_INITIALIZED once only\n if (isBrowser && typeof localStorage !== \"undefined\") {\n const key = `reportli_init_${apiKey}`;\n if (!localStorage.getItem(key)) {\n localStorage.setItem(key, \"true\");\n send({\n type: \"SDK_INITIALIZED\",\n apiKey: _apiKey,\n timestamp: new Date().toISOString(),\n environment: getEnvironment(),\n url: getUrl(),\n browser: getBrowser(),\n });\n }\n } else {\n send({\n type: \"SDK_INITIALIZED\",\n apiKey: _apiKey,\n timestamp: new Date().toISOString(),\n environment: getEnvironment(),\n url: getUrl(),\n browser: getBrowser(),\n });\n }\n\n if (isBrowser) {\n activateBrowserListeners();\n } else if (isNode) {\n activateServerListeners();\n }\n },\n\n capture(error: any): void {\n if (!_apiKey) return;\n send(buildErrorPayload(error, \"manual\"));\n },\n\n errorHandler() {\n return function (err: any, _req: any, _res: any, next: any) {\n send(buildErrorPayload(err, \"express\"));\n next(err);\n };\n },\n};\n\nexport default Reportli;\nexport { Reportli };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["// reportli.ts\n\nconst ENDPOINT =\n \"https://fahikyfmgdyzejdfftox.supabase.co/functions/v1/rapid-processor\";\n\ntype Config = {\n apiKey: string;\n environment?: string;\n};\n\nlet initialized = false;\nlet config: Config;\n\nfunction post(payload: Record<string, unknown>) {\n fetch(ENDPOINT, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n }).catch(() => {\n // Never throw from the SDK.\n });\n}\n\nfunction sendError(data: {\n message: string;\n code?: string;\n stack?: string;\n file?: string;\n line?: number;\n column?: number;\n severity?: string;\n}) {\n post({\n type: \"ERROR\",\n apiKey: config.apiKey,\n message: data.message,\n code: data.code ?? \"Error\",\n stack: data.stack ?? null,\n file: data.file ?? null,\n line: data.line ?? null,\n column: data.column ?? null,\n url:\n typeof window !== \"undefined\" ? window.location.href : null,\n timestamp: new Date().toISOString(),\n environment: config.environment ?? \"production\",\n browser:\n typeof navigator !== \"undefined\"\n ? navigator.userAgent\n : \"node\",\n error_category: data.code ?? \"Error\",\n severity: data.severity ?? \"high\",\n status: \"open\",\n });\n}\n\nexport const Reportli = {\n init(cfg: Config) {\n if (initialized) return;\n\n config = cfg;\n initialized = true;\n\n console.log(\n \"\u2705 Reportli initialized successfully. Error monitoring is active.\"\n );\n\n // JS errors\n window.addEventListener(\"error\", (event: any) => {\n if (event.error instanceof Error) {\n sendError({\n message: event.error.message,\n code: event.error.name,\n stack: event.error.stack,\n file: event.filename,\n line: event.lineno,\n column: event.colno,\n });\n } else if (event.target) {\n // Resource load failure\n sendError({\n message: \"Resource failed to load\",\n code: \"ResourceLoadError\",\n });\n }\n }, true);\n\n // Promise rejections\n window.addEventListener(\"unhandledrejection\", (event: any) => {\n const err = event.reason;\n sendError({\n message: err?.message ?? String(err),\n code: err?.name ?? \"UnhandledPromiseRejection\",\n stack: err?.stack,\n });\n });\n\n // fetch interception\n const originalFetch = window.fetch;\n window.fetch = async (...args) => {\n try {\n const response = await originalFetch(...args);\n\n if (!response.ok) {\n sendError({\n message: `Fetch HTTP ${response.status}`,\n code: `HTTP_${response.status}`,\n severity: \"medium\",\n });\n }\n\n return response;\n } catch (e: any) {\n sendError({\n message: e?.message ?? \"Fetch failed\",\n code: \"FetchError\",\n stack: e?.stack,\n });\n throw e;\n }\n };\n\n // XMLHttpRequest interception\n const open = XMLHttpRequest.prototype.open;\n const send = XMLHttpRequest.prototype.send;\n\n XMLHttpRequest.prototype.open = function (\n method,\n url,\n ...rest\n ) {\n (this as any).__reportli_url = url;\n return open.call(this, method, url, ...rest);\n };\n\n XMLHttpRequest.prototype.send = function (...args) {\n this.addEventListener(\"load\", function () {\n if (this.status >= 400) {\n sendError({\n message: `XHR HTTP ${this.status}`,\n code: `XHR_${this.status}`,\n });\n }\n });\n\n this.addEventListener(\"error\", function () {\n sendError({\n message: \"XHR connection failed\",\n code: \"XHRConnectionError\",\n });\n });\n\n return send.apply(this, args as any);\n };\n },\n\n capture(error: unknown) {\n if (error instanceof Error) {\n sendError({\n message: error.message,\n code: error.name,\n stack: error.stack,\n });\n } else {\n sendError({\n message: String(error),\n code: \"ManualCapture\",\n });\n }\n },\n\n captureMessage(message: string) {\n sendError({\n message,\n code: \"Message\",\n severity: \"low\",\n });\n },\n};"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|