@booboo.dev/js 0.1.0 → 0.2.0
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/{chunk-O4OOPXTS.cjs → chunk-MX4LENZA.cjs} +73 -9
- package/dist/{chunk-5PWHK5SB.js → chunk-WK5B54X6.js} +71 -7
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1 -1
- package/dist/react.cjs +3 -3
- package/dist/react.js +1 -1
- package/dist/vue.cjs +2 -2
- package/dist/vue.js +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/stacktrace.ts
|
|
2
|
+
function cleanFilename(raw) {
|
|
3
|
+
try {
|
|
4
|
+
const url = new URL(raw);
|
|
5
|
+
return url.pathname.replace(/^\//, "");
|
|
6
|
+
} catch (e) {
|
|
7
|
+
return raw;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function isAppFrame(cleanedFilename) {
|
|
11
|
+
return !cleanedFilename.includes("node_modules/");
|
|
12
|
+
}
|
|
2
13
|
var CHROME_RE = /^\s*at\s+(?:(new\s+)?(.+?)\s+\((.+?):(\d+):(\d+)\)|(.+?):(\d+):(\d+))\s*$/;
|
|
3
14
|
var FIREFOX_RE = /^\s*(.+?)@(.+?):(\d+):(\d+)\s*$/;
|
|
4
15
|
function parseStack(error) {
|
|
@@ -39,6 +50,57 @@ function parseStack(error) {
|
|
|
39
50
|
return frames.reverse();
|
|
40
51
|
}
|
|
41
52
|
|
|
53
|
+
// src/source.ts
|
|
54
|
+
var CONTEXT_LINES = 5;
|
|
55
|
+
var FETCH_TIMEOUT = 2e3;
|
|
56
|
+
var sourceCache = /* @__PURE__ */ new Map();
|
|
57
|
+
async function fetchSource(url) {
|
|
58
|
+
if (sourceCache.has(url)) return sourceCache.get(url);
|
|
59
|
+
try {
|
|
60
|
+
const controller = new AbortController();
|
|
61
|
+
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT);
|
|
62
|
+
const res = await fetch(url, { signal: controller.signal });
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
if (!res.ok) return null;
|
|
65
|
+
const text = await res.text();
|
|
66
|
+
const lines = text.split("\n");
|
|
67
|
+
sourceCache.set(url, lines);
|
|
68
|
+
return lines;
|
|
69
|
+
} catch (e2) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async function enrichFrames(frames) {
|
|
74
|
+
const urls = /* @__PURE__ */ new Set();
|
|
75
|
+
for (const frame of frames) {
|
|
76
|
+
if (frame.filename && frame.lineno) {
|
|
77
|
+
try {
|
|
78
|
+
new URL(frame.filename);
|
|
79
|
+
urls.add(frame.filename);
|
|
80
|
+
} catch (e3) {
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
await Promise.all([...urls].map(fetchSource));
|
|
85
|
+
return frames.map((frame) => {
|
|
86
|
+
const cleaned = cleanFilename(frame.filename);
|
|
87
|
+
const enriched = {
|
|
88
|
+
...frame,
|
|
89
|
+
filename: cleaned,
|
|
90
|
+
in_app: isAppFrame(cleaned)
|
|
91
|
+
};
|
|
92
|
+
if (!frame.lineno) return enriched;
|
|
93
|
+
const lines = sourceCache.get(frame.filename);
|
|
94
|
+
if (!lines) return enriched;
|
|
95
|
+
const idx = frame.lineno - 1;
|
|
96
|
+
if (idx < 0 || idx >= lines.length) return enriched;
|
|
97
|
+
enriched.context_line = lines[idx];
|
|
98
|
+
enriched.pre_context = lines.slice(Math.max(0, idx - CONTEXT_LINES), idx);
|
|
99
|
+
enriched.post_context = lines.slice(idx + 1, idx + 1 + CONTEXT_LINES);
|
|
100
|
+
return enriched;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
42
104
|
// src/breadcrumbs.ts
|
|
43
105
|
var DEFAULT_MAX = 30;
|
|
44
106
|
var breadcrumbBuffer = [];
|
|
@@ -213,7 +275,7 @@ var Transport = class {
|
|
|
213
275
|
body: JSON.stringify(event),
|
|
214
276
|
keepalive: true
|
|
215
277
|
});
|
|
216
|
-
} catch (
|
|
278
|
+
} catch (e4) {
|
|
217
279
|
}
|
|
218
280
|
}
|
|
219
281
|
this.flushing = false;
|
|
@@ -231,7 +293,7 @@ var Transport = class {
|
|
|
231
293
|
body: JSON.stringify(event),
|
|
232
294
|
keepalive: true
|
|
233
295
|
});
|
|
234
|
-
} catch (
|
|
296
|
+
} catch (e5) {
|
|
235
297
|
}
|
|
236
298
|
}
|
|
237
299
|
}
|
|
@@ -276,13 +338,15 @@ var BoobooClient = class {
|
|
|
276
338
|
}
|
|
277
339
|
captureException(error, extra) {
|
|
278
340
|
const frames = parseStack(error);
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
341
|
+
enrichFrames(frames).then((enriched) => {
|
|
342
|
+
const event = this.buildEvent(
|
|
343
|
+
error.message,
|
|
344
|
+
error.constructor.name || "Error",
|
|
345
|
+
enriched,
|
|
346
|
+
extra
|
|
347
|
+
);
|
|
348
|
+
this.sendEvent(event);
|
|
349
|
+
});
|
|
286
350
|
}
|
|
287
351
|
captureMessage(message, level = "error") {
|
|
288
352
|
const event = this.buildEvent(message, "Error", [], void 0, level);
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
// src/stacktrace.ts
|
|
2
|
+
function cleanFilename(raw) {
|
|
3
|
+
try {
|
|
4
|
+
const url = new URL(raw);
|
|
5
|
+
return url.pathname.replace(/^\//, "");
|
|
6
|
+
} catch {
|
|
7
|
+
return raw;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function isAppFrame(cleanedFilename) {
|
|
11
|
+
return !cleanedFilename.includes("node_modules/");
|
|
12
|
+
}
|
|
2
13
|
var CHROME_RE = /^\s*at\s+(?:(new\s+)?(.+?)\s+\((.+?):(\d+):(\d+)\)|(.+?):(\d+):(\d+))\s*$/;
|
|
3
14
|
var FIREFOX_RE = /^\s*(.+?)@(.+?):(\d+):(\d+)\s*$/;
|
|
4
15
|
function parseStack(error) {
|
|
@@ -39,6 +50,57 @@ function parseStack(error) {
|
|
|
39
50
|
return frames.reverse();
|
|
40
51
|
}
|
|
41
52
|
|
|
53
|
+
// src/source.ts
|
|
54
|
+
var CONTEXT_LINES = 5;
|
|
55
|
+
var FETCH_TIMEOUT = 2e3;
|
|
56
|
+
var sourceCache = /* @__PURE__ */ new Map();
|
|
57
|
+
async function fetchSource(url) {
|
|
58
|
+
if (sourceCache.has(url)) return sourceCache.get(url);
|
|
59
|
+
try {
|
|
60
|
+
const controller = new AbortController();
|
|
61
|
+
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT);
|
|
62
|
+
const res = await fetch(url, { signal: controller.signal });
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
if (!res.ok) return null;
|
|
65
|
+
const text = await res.text();
|
|
66
|
+
const lines = text.split("\n");
|
|
67
|
+
sourceCache.set(url, lines);
|
|
68
|
+
return lines;
|
|
69
|
+
} catch {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async function enrichFrames(frames) {
|
|
74
|
+
const urls = /* @__PURE__ */ new Set();
|
|
75
|
+
for (const frame of frames) {
|
|
76
|
+
if (frame.filename && frame.lineno) {
|
|
77
|
+
try {
|
|
78
|
+
new URL(frame.filename);
|
|
79
|
+
urls.add(frame.filename);
|
|
80
|
+
} catch {
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
await Promise.all([...urls].map(fetchSource));
|
|
85
|
+
return frames.map((frame) => {
|
|
86
|
+
const cleaned = cleanFilename(frame.filename);
|
|
87
|
+
const enriched = {
|
|
88
|
+
...frame,
|
|
89
|
+
filename: cleaned,
|
|
90
|
+
in_app: isAppFrame(cleaned)
|
|
91
|
+
};
|
|
92
|
+
if (!frame.lineno) return enriched;
|
|
93
|
+
const lines = sourceCache.get(frame.filename);
|
|
94
|
+
if (!lines) return enriched;
|
|
95
|
+
const idx = frame.lineno - 1;
|
|
96
|
+
if (idx < 0 || idx >= lines.length) return enriched;
|
|
97
|
+
enriched.context_line = lines[idx];
|
|
98
|
+
enriched.pre_context = lines.slice(Math.max(0, idx - CONTEXT_LINES), idx);
|
|
99
|
+
enriched.post_context = lines.slice(idx + 1, idx + 1 + CONTEXT_LINES);
|
|
100
|
+
return enriched;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
42
104
|
// src/breadcrumbs.ts
|
|
43
105
|
var DEFAULT_MAX = 30;
|
|
44
106
|
var breadcrumbBuffer = [];
|
|
@@ -276,13 +338,15 @@ var BoobooClient = class {
|
|
|
276
338
|
}
|
|
277
339
|
captureException(error, extra) {
|
|
278
340
|
const frames = parseStack(error);
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
341
|
+
enrichFrames(frames).then((enriched) => {
|
|
342
|
+
const event = this.buildEvent(
|
|
343
|
+
error.message,
|
|
344
|
+
error.constructor.name || "Error",
|
|
345
|
+
enriched,
|
|
346
|
+
extra
|
|
347
|
+
);
|
|
348
|
+
this.sendEvent(event);
|
|
349
|
+
});
|
|
286
350
|
}
|
|
287
351
|
captureMessage(message, level = "error") {
|
|
288
352
|
const event = this.buildEvent(message, "Error", [], void 0, level);
|
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkMX4LENZAcjs = require('./chunk-MX4LENZA.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -13,4 +13,4 @@ var _chunkO4OOPXTScjs = require('./chunk-O4OOPXTS.cjs');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
exports.addBreadcrumb =
|
|
16
|
+
exports.addBreadcrumb = _chunkMX4LENZAcjs.addBreadcrumb; exports.captureException = _chunkMX4LENZAcjs.captureException; exports.captureMessage = _chunkMX4LENZAcjs.captureMessage; exports.getClient = _chunkMX4LENZAcjs.getClient; exports.init = _chunkMX4LENZAcjs.init; exports.parseStack = _chunkMX4LENZAcjs.parseStack;
|
package/dist/index.d.cts
CHANGED
|
@@ -3,6 +3,10 @@ interface StackFrame {
|
|
|
3
3
|
function: string;
|
|
4
4
|
lineno: number;
|
|
5
5
|
colno?: number;
|
|
6
|
+
context_line?: string;
|
|
7
|
+
pre_context?: string[];
|
|
8
|
+
post_context?: string[];
|
|
9
|
+
in_app?: boolean;
|
|
6
10
|
}
|
|
7
11
|
interface Breadcrumb {
|
|
8
12
|
type: "console" | "click" | "navigation" | "fetch" | "custom";
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ interface StackFrame {
|
|
|
3
3
|
function: string;
|
|
4
4
|
lineno: number;
|
|
5
5
|
colno?: number;
|
|
6
|
+
context_line?: string;
|
|
7
|
+
pre_context?: string[];
|
|
8
|
+
post_context?: string[];
|
|
9
|
+
in_app?: boolean;
|
|
6
10
|
}
|
|
7
11
|
interface Breadcrumb {
|
|
8
12
|
type: "console" | "click" | "navigation" | "fetch" | "custom";
|
package/dist/index.js
CHANGED
package/dist/react.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkMX4LENZAcjs = require('./chunk-MX4LENZA.cjs');
|
|
5
5
|
|
|
6
6
|
// src/react.ts
|
|
7
7
|
var _react = require('react');
|
|
@@ -17,13 +17,13 @@ var ErrorBoundary = class extends _react.Component {
|
|
|
17
17
|
return { error };
|
|
18
18
|
}
|
|
19
19
|
componentDidCatch(error, errorInfo) {
|
|
20
|
-
const client =
|
|
20
|
+
const client = _chunkMX4LENZAcjs.getClient.call(void 0, );
|
|
21
21
|
if (client) {
|
|
22
22
|
const extra = {};
|
|
23
23
|
if (errorInfo.componentStack) {
|
|
24
24
|
extra.componentStack = errorInfo.componentStack;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
_chunkMX4LENZAcjs.captureException.call(void 0, error, extra);
|
|
27
27
|
}
|
|
28
28
|
_optionalChain([this, 'access', _ => _.props, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(error, errorInfo)]);
|
|
29
29
|
}
|
package/dist/react.js
CHANGED
package/dist/vue.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkMX4LENZAcjs = require('./chunk-MX4LENZA.cjs');
|
|
4
4
|
|
|
5
5
|
// src/vue.ts
|
|
6
6
|
function BoobooVue(_options) {
|
|
@@ -18,7 +18,7 @@ function BoobooVue(_options) {
|
|
|
18
18
|
extra.propKeys = Object.keys(instance.$props);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
_chunkMX4LENZAcjs.captureException.call(void 0, error, extra);
|
|
22
22
|
if (typeof prevHandler === "function") {
|
|
23
23
|
prevHandler(err, instance, info);
|
|
24
24
|
}
|
package/dist/vue.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@booboo.dev/js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Official JavaScript SDK for booboo.dev error tracking",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"license": "MIT",
|
|
46
46
|
"repository": {
|
|
47
47
|
"type": "git",
|
|
48
|
-
"url": "https://github.com/
|
|
48
|
+
"url": "https://github.com/getbooboo/js"
|
|
49
49
|
},
|
|
50
50
|
"keywords": ["error-tracking", "booboo", "monitoring", "javascript", "react", "vue"]
|
|
51
51
|
}
|