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