nuxt-error-tracker 0.1.9 → 0.1.10
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/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -57,8 +57,9 @@ interface Breadcrumb {
|
|
|
57
57
|
timestamp?: string
|
|
58
58
|
data?: Record<string, unknown>
|
|
59
59
|
}
|
|
60
|
+
type ErrorLevel = 'fatal' | 'error' | 'warning' | 'info' | 'debug'
|
|
60
61
|
interface ErrorTrackerHelpers {
|
|
61
|
-
$trackError: (err: unknown) => void
|
|
62
|
+
$trackError: (err: unknown, level?: ErrorLevel) => void
|
|
62
63
|
$addBreadcrumb: (crumb: Breadcrumb) => void
|
|
63
64
|
}
|
|
64
65
|
declare module '#app' {
|
|
@@ -6,6 +6,7 @@ export interface Crumb {
|
|
|
6
6
|
timestamp?: string;
|
|
7
7
|
data?: Record<string, unknown>;
|
|
8
8
|
}
|
|
9
|
+
export type ErrorLevel = 'fatal' | 'error' | 'warning' | 'info' | 'debug';
|
|
9
10
|
export interface FlushError {
|
|
10
11
|
message: string;
|
|
11
12
|
stack: string;
|
|
@@ -13,6 +14,7 @@ export interface FlushError {
|
|
|
13
14
|
url: string;
|
|
14
15
|
route: string;
|
|
15
16
|
occurredAt: string;
|
|
17
|
+
level?: ErrorLevel;
|
|
16
18
|
breadcrumbs?: Crumb[];
|
|
17
19
|
}
|
|
18
20
|
export interface FlushBody {
|
|
@@ -79,7 +79,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
79
79
|
flush();
|
|
80
80
|
}, FLUSH_DELAY);
|
|
81
81
|
}
|
|
82
|
-
function capture(err, source) {
|
|
82
|
+
function capture(err, source, level = "error") {
|
|
83
83
|
try {
|
|
84
84
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
85
85
|
if (error.message === "Script error.") return;
|
|
@@ -91,6 +91,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
91
91
|
message: error.message.slice(0, 1e3),
|
|
92
92
|
stack: (error.stack ?? "").slice(0, 8e3),
|
|
93
93
|
source,
|
|
94
|
+
level,
|
|
94
95
|
url: window.location.href.slice(0, 2e3),
|
|
95
96
|
route: route.fullPath.slice(0, 500),
|
|
96
97
|
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -197,7 +198,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
197
198
|
});
|
|
198
199
|
return {
|
|
199
200
|
provide: {
|
|
200
|
-
trackError: (err) => capture(err, "window"),
|
|
201
|
+
trackError: (err, level = "error") => capture(err, "window", level),
|
|
201
202
|
addBreadcrumb: (c) => addCrumb(c)
|
|
202
203
|
}
|
|
203
204
|
};
|