@flareapp/vue 1.0.1 → 2.0.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/index.d.mts CHANGED
@@ -1,28 +1,176 @@
1
- import { flare } from '@flareapp/js';
1
+ import * as vue from "vue";
2
+ import { ComponentPublicInstance, Plugin, PropType } from "vue";
2
3
 
3
- function flareVue(app) {
4
- const initialErrorHandler = app.config.errorHandler;
5
-
6
- app.config.errorHandler = (error, vm, info) => {
7
- const componentName =
8
- vm && vm.$options && vm.$options.name
9
- ? vm.$options.name
10
- : 'AnonymousComponent';
11
-
12
- const context = {
13
- vue: { info, componentName },
14
- };
15
-
16
- flare.report(error, context, { vue: { vm, info } });
17
-
18
- if (typeof initialErrorHandler === 'function') {
19
- initialErrorHandler(error, vm, info);
20
-
21
- return;
22
- }
23
-
24
- throw error;
25
- };
26
- }
27
-
28
- export { flareVue };
4
+ //#region src/types.d.ts
5
+ type ErrorOrigin = 'setup' | 'render' | 'lifecycle' | 'event' | 'watcher' | 'unknown';
6
+ type ComponentHierarchyFrame = {
7
+ component: string;
8
+ file: string | null;
9
+ props?: Record<string, unknown>;
10
+ };
11
+ type RouteParamValue = string | string[];
12
+ type RouteQueryValue = string | null;
13
+ type RouteContext = {
14
+ name: string | null;
15
+ path: string;
16
+ fullPath: string;
17
+ params: Record<string, RouteParamValue>;
18
+ query: Record<string, RouteQueryValue | RouteQueryValue[]>;
19
+ hash: string;
20
+ matched: string[];
21
+ };
22
+ type FlareVueContext = {
23
+ vue: {
24
+ info: string;
25
+ errorOrigin: ErrorOrigin;
26
+ componentName: string;
27
+ componentProps?: Record<string, unknown>;
28
+ componentHierarchy: string[];
29
+ componentHierarchyFrames: ComponentHierarchyFrame[];
30
+ route?: RouteContext;
31
+ };
32
+ };
33
+ type FlareVueWarningContext = {
34
+ vue: {
35
+ type: 'warning';
36
+ info: string;
37
+ componentName: string;
38
+ componentTrace: string;
39
+ route?: RouteContext;
40
+ };
41
+ };
42
+ type FlareErrorBoundaryHookParams = {
43
+ error: Error;
44
+ instance: ComponentPublicInstance | null;
45
+ info: string;
46
+ };
47
+ type FlareVueOptions = {
48
+ captureWarnings?: boolean;
49
+ attachProps?: boolean;
50
+ propsMaxDepth?: number;
51
+ propsDenylist?: RegExp;
52
+ replaceDefaultDenylist?: boolean;
53
+ beforeEvaluate?: (params: FlareErrorBoundaryHookParams) => void;
54
+ beforeSubmit?: (params: FlareErrorBoundaryHookParams & {
55
+ context: FlareVueContext;
56
+ }) => FlareVueContext;
57
+ afterSubmit?: (params: FlareErrorBoundaryHookParams & {
58
+ context: FlareVueContext;
59
+ }) => void;
60
+ };
61
+ type FlareErrorBoundaryFallbackProps = {
62
+ error: Error;
63
+ componentProps?: Record<string, unknown>;
64
+ componentHierarchy: string[];
65
+ componentHierarchyFrames: ComponentHierarchyFrame[];
66
+ resetErrorBoundary: () => void;
67
+ };
68
+ //#endregion
69
+ //#region src/FlareErrorBoundary.d.ts
70
+ declare const FlareErrorBoundary: vue.DefineComponent<vue.ExtractPropTypes<{
71
+ beforeEvaluate: {
72
+ type: PropType<(params: FlareErrorBoundaryHookParams) => void>;
73
+ default: undefined;
74
+ };
75
+ beforeSubmit: {
76
+ type: PropType<(params: FlareErrorBoundaryHookParams & {
77
+ context: FlareVueContext;
78
+ }) => FlareVueContext>;
79
+ default: undefined;
80
+ };
81
+ afterSubmit: {
82
+ type: PropType<(params: FlareErrorBoundaryHookParams & {
83
+ context: FlareVueContext;
84
+ }) => void>;
85
+ default: undefined;
86
+ };
87
+ onReset: {
88
+ type: PropType<(error: Error | null) => void>;
89
+ default: undefined;
90
+ };
91
+ resetKeys: {
92
+ type: PropType<unknown[]>;
93
+ default: undefined;
94
+ };
95
+ attachProps: {
96
+ type: BooleanConstructor;
97
+ default: boolean;
98
+ };
99
+ propsMaxDepth: {
100
+ type: NumberConstructor;
101
+ default: number;
102
+ };
103
+ propsDenylist: {
104
+ type: PropType<RegExp>;
105
+ default: undefined;
106
+ };
107
+ replaceDefaultDenylist: {
108
+ type: BooleanConstructor;
109
+ default: boolean;
110
+ };
111
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
112
+ [key: string]: any;
113
+ }>[] | null | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
114
+ beforeEvaluate: {
115
+ type: PropType<(params: FlareErrorBoundaryHookParams) => void>;
116
+ default: undefined;
117
+ };
118
+ beforeSubmit: {
119
+ type: PropType<(params: FlareErrorBoundaryHookParams & {
120
+ context: FlareVueContext;
121
+ }) => FlareVueContext>;
122
+ default: undefined;
123
+ };
124
+ afterSubmit: {
125
+ type: PropType<(params: FlareErrorBoundaryHookParams & {
126
+ context: FlareVueContext;
127
+ }) => void>;
128
+ default: undefined;
129
+ };
130
+ onReset: {
131
+ type: PropType<(error: Error | null) => void>;
132
+ default: undefined;
133
+ };
134
+ resetKeys: {
135
+ type: PropType<unknown[]>;
136
+ default: undefined;
137
+ };
138
+ attachProps: {
139
+ type: BooleanConstructor;
140
+ default: boolean;
141
+ };
142
+ propsMaxDepth: {
143
+ type: NumberConstructor;
144
+ default: number;
145
+ };
146
+ propsDenylist: {
147
+ type: PropType<RegExp>;
148
+ default: undefined;
149
+ };
150
+ replaceDefaultDenylist: {
151
+ type: BooleanConstructor;
152
+ default: boolean;
153
+ };
154
+ }>> & Readonly<{}>, {
155
+ beforeEvaluate: (params: FlareErrorBoundaryHookParams) => void;
156
+ beforeSubmit: (params: FlareErrorBoundaryHookParams & {
157
+ context: FlareVueContext;
158
+ }) => FlareVueContext;
159
+ afterSubmit: (params: FlareErrorBoundaryHookParams & {
160
+ context: FlareVueContext;
161
+ }) => void;
162
+ onReset: (error: Error | null) => void;
163
+ resetKeys: unknown[];
164
+ attachProps: boolean;
165
+ propsMaxDepth: number;
166
+ propsDenylist: RegExp;
167
+ replaceDefaultDenylist: boolean;
168
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
169
+ //#endregion
170
+ //#region src/flareVue.d.ts
171
+ declare const flareVue: Plugin<[FlareVueOptions?]>;
172
+ //#endregion
173
+ //#region src/constants.d.ts
174
+ declare const DEFAULT_PROPS_DENYLIST: RegExp;
175
+ //#endregion
176
+ export { type ComponentHierarchyFrame, DEFAULT_PROPS_DENYLIST, type ErrorOrigin, FlareErrorBoundary, type FlareErrorBoundaryFallbackProps, type FlareErrorBoundaryHookParams, type FlareVueContext, type FlareVueOptions, type FlareVueWarningContext, type RouteContext, type RouteParamValue, type RouteQueryValue, flareVue };
package/dist/index.mjs CHANGED
@@ -1,20 +1,442 @@
1
- // src/index.js
2
- import { flare } from "@flareapp/js";
3
- function flareVue(app) {
4
- const initialErrorHandler = app.config.errorHandler;
5
- app.config.errorHandler = (error, vm, info) => {
6
- const componentName = vm && vm.$options && vm.$options.name ? vm.$options.name : "AnonymousComponent";
7
- const context = {
8
- vue: { info, componentName }
9
- };
10
- flare.report(error, context, { vue: { vm, info } });
11
- if (typeof initialErrorHandler === "function") {
12
- initialErrorHandler(error, vm, info);
13
- return;
14
- }
15
- throw error;
16
- };
17
- }
18
- export {
19
- flareVue
1
+ import { flare, redactFullPath, resolveDenylist } from "@flareapp/js";
2
+ import { defineComponent, getCurrentInstance, onErrorCaptured, ref, watch } from "vue";
3
+
4
+ //#region src/constants.ts
5
+ const PACKAGE_VERSION = typeof process !== "undefined" && typeof process.env?.PACKAGE_VERSION !== "undefined" ? process.env.PACKAGE_VERSION : "?";
6
+ const MAX_HIERARCHY_DEPTH = 50;
7
+ const DEFAULT_PROPS_DENYLIST = /password|passwd|pwd|token|secret|authorization|\bauth\b|bearer|oauth|credentials?|cookie|api[-_]?key|private[-_]?key|session|csrf|xsrf|\bpin\b|\bssn\b|card[-_]?number|\bcvv\b/i;
8
+ function resolveDenylist$1(custom, replaceDefault = false) {
9
+ return resolveDenylist(custom, replaceDefault, DEFAULT_PROPS_DENYLIST);
10
+ }
11
+ const MAX_PROP_STRING_LENGTH = 1e3;
12
+ const MAX_PROP_ARRAY_LENGTH = 100;
13
+ const MAX_PROP_OBJECT_KEYS = 100;
14
+ const INFO_TO_ORIGIN = {
15
+ "setup function": "setup",
16
+ "render function": "render",
17
+ "component update": "render",
18
+ "watcher getter": "watcher",
19
+ "watcher callback": "watcher",
20
+ "watcher cleanup function": "watcher",
21
+ "native event handler": "event",
22
+ "component event handler": "event",
23
+ "beforeCreate hook": "lifecycle",
24
+ "created hook": "lifecycle",
25
+ "beforeMount hook": "lifecycle",
26
+ "mounted hook": "lifecycle",
27
+ "beforeUpdate hook": "lifecycle",
28
+ "updated hook": "lifecycle",
29
+ "beforeUnmount hook": "lifecycle",
30
+ "unmounted hook": "lifecycle",
31
+ "activated hook": "lifecycle",
32
+ "deactivated hook": "lifecycle",
33
+ "errorCaptured hook": "lifecycle",
34
+ "renderTracked hook": "lifecycle",
35
+ "renderTriggered hook": "lifecycle",
36
+ "serverPrefetch hook": "lifecycle",
37
+ "vnode hook": "lifecycle",
38
+ "directive hook": "lifecycle",
39
+ "transition hook": "lifecycle",
40
+ "ref function": "setup",
41
+ "async component loader": "setup",
42
+ "scheduler flush": "render",
43
+ "app errorHandler": "lifecycle",
44
+ "app warnHandler": "lifecycle",
45
+ "app unmount cleanup function": "lifecycle",
46
+ "0": "setup",
47
+ "1": "render",
48
+ "2": "watcher",
49
+ "3": "watcher",
50
+ "4": "watcher",
51
+ "5": "event",
52
+ "6": "event",
53
+ "7": "lifecycle",
54
+ "8": "lifecycle",
55
+ "9": "lifecycle",
56
+ "10": "lifecycle",
57
+ "11": "lifecycle",
58
+ "12": "setup",
59
+ "13": "setup",
60
+ "14": "render",
61
+ "15": "render",
62
+ "16": "lifecycle",
63
+ "sp": "lifecycle",
64
+ "bc": "lifecycle",
65
+ "c": "lifecycle",
66
+ "bm": "lifecycle",
67
+ "m": "lifecycle",
68
+ "bu": "lifecycle",
69
+ "u": "lifecycle",
70
+ "bum": "lifecycle",
71
+ "um": "lifecycle",
72
+ "a": "lifecycle",
73
+ "da": "lifecycle",
74
+ "ec": "lifecycle",
75
+ "rtc": "lifecycle",
76
+ "rtg": "lifecycle"
77
+ };
78
+
79
+ //#endregion
80
+ //#region src/getComponentName.ts
81
+ function getComponentName(instance) {
82
+ if (!instance) return "AnonymousComponent";
83
+ const options = instance.$options;
84
+ return options.__name || options.name || "AnonymousComponent";
85
+ }
86
+
87
+ //#endregion
88
+ //#region src/buildComponentHierarchy.ts
89
+ function buildComponentHierarchy(instance) {
90
+ const hierarchy = [];
91
+ let current = instance;
92
+ while (current && hierarchy.length < MAX_HIERARCHY_DEPTH) {
93
+ hierarchy.push(getComponentName(current));
94
+ current = current.$parent;
95
+ }
96
+ return hierarchy;
97
+ }
98
+
99
+ //#endregion
100
+ //#region src/serializeProps.ts
101
+ function serializeProps(value, maxDepth, denylist = DEFAULT_PROPS_DENYLIST) {
102
+ return serialize(value, 0, maxDepth, /* @__PURE__ */ new WeakSet(), denylist);
103
+ }
104
+ function serialize(value, depth, maxDepth, seen, denylist) {
105
+ if (value === null) return null;
106
+ const type = typeof value;
107
+ if (type === "function") return "[Function]";
108
+ if (type === "symbol") return "[Symbol]";
109
+ if (type === "bigint") return value.toString();
110
+ if (type === "string") return truncateString(value);
111
+ if (type !== "object") return value;
112
+ if (seen.has(value)) return "[Circular]";
113
+ if (Array.isArray(value)) {
114
+ if (depth > maxDepth) return "[Array]";
115
+ seen.add(value);
116
+ const out = (value.length > MAX_PROP_ARRAY_LENGTH ? value.slice(0, MAX_PROP_ARRAY_LENGTH) : value).map((item) => serialize(item, depth + 1, maxDepth, seen, denylist));
117
+ if (value.length > MAX_PROP_ARRAY_LENGTH) out.push(`[… ${value.length - MAX_PROP_ARRAY_LENGTH} more items]`);
118
+ seen.delete(value);
119
+ return out;
120
+ }
121
+ if (!isPlainObject(value)) return "[Object]";
122
+ if (depth > maxDepth) return "[Object]";
123
+ seen.add(value);
124
+ const out = {};
125
+ const keys = Object.keys(value);
126
+ const limitedKeys = keys.length > MAX_PROP_OBJECT_KEYS ? keys.slice(0, MAX_PROP_OBJECT_KEYS) : keys;
127
+ for (const key of limitedKeys) {
128
+ if (denylist.test(key)) {
129
+ out[key] = "[redacted]";
130
+ continue;
131
+ }
132
+ out[key] = serialize(value[key], depth + 1, maxDepth, seen, denylist);
133
+ }
134
+ if (keys.length > MAX_PROP_OBJECT_KEYS) out["…"] = `[${keys.length - MAX_PROP_OBJECT_KEYS} more keys]`;
135
+ seen.delete(value);
136
+ return out;
137
+ }
138
+ function truncateString(value) {
139
+ if (value.length <= MAX_PROP_STRING_LENGTH) return value;
140
+ return `${value.slice(0, MAX_PROP_STRING_LENGTH)}…[truncated ${value.length - MAX_PROP_STRING_LENGTH} chars]`;
141
+ }
142
+ function isPlainObject(value) {
143
+ if (value === null || typeof value !== "object") return false;
144
+ const prototype = Object.getPrototypeOf(value);
145
+ return prototype === null || prototype === Object.prototype;
146
+ }
147
+
148
+ //#endregion
149
+ //#region src/buildComponentHierarchyFrames.ts
150
+ function buildComponentHierarchyFrames(instance, options) {
151
+ const frames = [];
152
+ let current = instance;
153
+ while (current && frames.length < MAX_HIERARCHY_DEPTH) {
154
+ const frameOptions = current.$options;
155
+ const frame = {
156
+ component: getComponentName(current),
157
+ file: frameOptions.__file ?? null
158
+ };
159
+ if (options.attachProps && current.$props) frame.props = serializeProps(current.$props, options.propsMaxDepth, options.propsDenylist);
160
+ frames.push(frame);
161
+ current = current.$parent;
162
+ }
163
+ return frames;
164
+ }
165
+
166
+ //#endregion
167
+ //#region src/convertToError.ts
168
+ function convertToError(error) {
169
+ if (error instanceof Error) return error;
170
+ if (typeof error === "string") return new Error(error);
171
+ return new Error(String(error));
172
+ }
173
+
174
+ //#endregion
175
+ //#region src/getErrorOrigin.ts
176
+ function getErrorOrigin(info) {
177
+ return INFO_TO_ORIGIN[info] ?? "unknown";
178
+ }
179
+
180
+ //#endregion
181
+ //#region src/getRouteContext.ts
182
+ const ROUTE_PARAMS_DEPTH = 2;
183
+ function getRouteContext(router, options = {}) {
184
+ if (!router || typeof router !== "object" || !("currentRoute" in router)) return null;
185
+ const currentRouteRef = router.currentRoute;
186
+ if (!currentRouteRef || typeof currentRouteRef !== "object" || !("value" in currentRouteRef)) return null;
187
+ const route = currentRouteRef.value;
188
+ if (!route || typeof route !== "object") return null;
189
+ const r = route;
190
+ const name = r.name;
191
+ const denylist = options.denylist ?? DEFAULT_PROPS_DENYLIST;
192
+ const params = r.params && typeof r.params === "object" ? r.params : {};
193
+ const query = r.query && typeof r.query === "object" ? r.query : {};
194
+ return {
195
+ name: typeof name === "string" ? name : typeof name === "symbol" ? name.toString() : null,
196
+ path: typeof r.path === "string" ? r.path : "",
197
+ fullPath: typeof r.fullPath === "string" ? redactFullPath(r.fullPath, denylist) : "",
198
+ params: serializeProps(params, ROUTE_PARAMS_DEPTH, denylist),
199
+ query: serializeProps(query, ROUTE_PARAMS_DEPTH, denylist),
200
+ hash: typeof r.hash === "string" ? r.hash : "",
201
+ matched: Array.isArray(r.matched) ? r.matched.map((record) => {
202
+ if (!record || typeof record !== "object") return "unknown";
203
+ const n = record.name;
204
+ return typeof n === "string" ? n : typeof n === "symbol" ? n.toString() : "unknown";
205
+ }) : []
206
+ };
207
+ }
208
+
209
+ //#endregion
210
+ //#region src/flareVue.ts
211
+ function vueContextToAttributes(context) {
212
+ const vue = {
213
+ info: context.vue.info,
214
+ errorOrigin: context.vue.errorOrigin,
215
+ componentName: context.vue.componentName,
216
+ componentHierarchy: context.vue.componentHierarchy,
217
+ componentHierarchyFrames: context.vue.componentHierarchyFrames
218
+ };
219
+ if (context.vue.componentProps) vue.componentProps = context.vue.componentProps;
220
+ if (context.vue.route) vue.route = context.vue.route;
221
+ return { "context.custom": {
222
+ framework: "vue",
223
+ vue
224
+ } };
225
+ }
226
+ function vueWarningContextToAttributes(context) {
227
+ const vue = {
228
+ type: context.vue.type,
229
+ info: context.vue.info,
230
+ componentName: context.vue.componentName,
231
+ componentTrace: context.vue.componentTrace
232
+ };
233
+ if (context.vue.route) vue.route = context.vue.route;
234
+ return { "context.custom": {
235
+ framework: "vue",
236
+ vue
237
+ } };
238
+ }
239
+ const installedApps = /* @__PURE__ */ new WeakSet();
240
+ const flareVue = (app, options) => {
241
+ if (installedApps.has(app)) return;
242
+ installedApps.add(app);
243
+ flare.setSdkInfo({
244
+ name: "@flareapp/vue",
245
+ version: PACKAGE_VERSION
246
+ });
247
+ flare.setFramework({
248
+ name: "Vue",
249
+ version: app.version
250
+ });
251
+ const attachProps = options?.attachProps ?? false;
252
+ const propsMaxDepth = options?.propsMaxDepth ?? 2;
253
+ const propsDenylist = resolveDenylist$1(options?.propsDenylist, options?.replaceDefaultDenylist);
254
+ const initialErrorHandler = app.config.errorHandler;
255
+ app.config.errorHandler = (error, instance, info) => {
256
+ const errorToReport = convertToError(error);
257
+ options?.beforeEvaluate?.({
258
+ error: errorToReport,
259
+ instance,
260
+ info
261
+ });
262
+ const errorOrigin = getErrorOrigin(info);
263
+ const componentName = getComponentName(instance);
264
+ const componentProps = attachProps && instance?.$props ? serializeProps(instance.$props, propsMaxDepth, propsDenylist) : void 0;
265
+ const componentHierarchy = buildComponentHierarchy(instance);
266
+ const componentHierarchyFrames = buildComponentHierarchyFrames(instance, {
267
+ attachProps,
268
+ propsMaxDepth,
269
+ propsDenylist
270
+ });
271
+ const route = getRouteContext(app.config.globalProperties.$router, { denylist: propsDenylist });
272
+ const context = { vue: {
273
+ info,
274
+ errorOrigin,
275
+ componentName,
276
+ ...componentProps && { componentProps },
277
+ componentHierarchy,
278
+ componentHierarchyFrames,
279
+ ...route && { route }
280
+ } };
281
+ const finalContext = options?.beforeSubmit?.({
282
+ error: errorToReport,
283
+ instance,
284
+ info,
285
+ context
286
+ }) ?? context;
287
+ Promise.resolve(flare.report(errorToReport, vueContextToAttributes(finalContext))).catch(() => {});
288
+ options?.afterSubmit?.({
289
+ error: errorToReport,
290
+ instance,
291
+ info,
292
+ context: finalContext
293
+ });
294
+ if (typeof initialErrorHandler === "function") {
295
+ initialErrorHandler(error, instance, info);
296
+ return;
297
+ }
298
+ console.error(error);
299
+ };
300
+ if (options?.captureWarnings) {
301
+ const initialWarnHandler = app.config.warnHandler;
302
+ app.config.warnHandler = (msg, instance, trace) => {
303
+ const componentName = getComponentName(instance);
304
+ const route = getRouteContext(app.config.globalProperties.$router, { denylist: propsDenylist });
305
+ const context = { vue: {
306
+ type: "warning",
307
+ info: msg,
308
+ componentName,
309
+ componentTrace: trace,
310
+ ...route && { route }
311
+ } };
312
+ Promise.resolve(flare.reportMessage(msg, "warning", vueWarningContextToAttributes(context))).catch(() => {});
313
+ if (typeof initialWarnHandler === "function") initialWarnHandler(msg, instance, trace);
314
+ };
315
+ }
20
316
  };
317
+
318
+ //#endregion
319
+ //#region src/FlareErrorBoundary.ts
320
+ const FlareErrorBoundary = defineComponent({
321
+ name: "FlareErrorBoundary",
322
+ props: {
323
+ beforeEvaluate: {
324
+ type: Function,
325
+ default: void 0
326
+ },
327
+ beforeSubmit: {
328
+ type: Function,
329
+ default: void 0
330
+ },
331
+ afterSubmit: {
332
+ type: Function,
333
+ default: void 0
334
+ },
335
+ onReset: {
336
+ type: Function,
337
+ default: void 0
338
+ },
339
+ resetKeys: {
340
+ type: Array,
341
+ default: void 0
342
+ },
343
+ attachProps: {
344
+ type: Boolean,
345
+ default: false
346
+ },
347
+ propsMaxDepth: {
348
+ type: Number,
349
+ default: 2
350
+ },
351
+ propsDenylist: {
352
+ type: RegExp,
353
+ default: void 0
354
+ },
355
+ replaceDefaultDenylist: {
356
+ type: Boolean,
357
+ default: false
358
+ }
359
+ },
360
+ setup(props, { slots }) {
361
+ const currentInstance = getCurrentInstance();
362
+ const error = ref(null);
363
+ const componentProps = ref(void 0);
364
+ const componentHierarchy = ref([]);
365
+ const componentHierarchyFrames = ref([]);
366
+ const resetErrorBoundary = () => {
367
+ props.onReset?.(error.value);
368
+ error.value = null;
369
+ componentProps.value = void 0;
370
+ componentHierarchy.value = [];
371
+ componentHierarchyFrames.value = [];
372
+ };
373
+ watch(() => props.resetKeys, (nextKeys, prevKeys) => {
374
+ if (error.value === null || !nextKeys || !prevKeys) return;
375
+ const lengthChanged = prevKeys.length !== nextKeys.length;
376
+ const valuesChanged = nextKeys.some((key, i) => !Object.is(key, prevKeys[i]));
377
+ if (lengthChanged || valuesChanged) resetErrorBoundary();
378
+ });
379
+ onErrorCaptured((currentError, instance, info) => {
380
+ const errorToReport = convertToError(currentError);
381
+ props.beforeEvaluate?.({
382
+ error: errorToReport,
383
+ instance,
384
+ info
385
+ });
386
+ const resolvedDenylist = resolveDenylist$1(props.propsDenylist, props.replaceDefaultDenylist);
387
+ const hierarchy = buildComponentHierarchy(instance);
388
+ const hierarchyFrames = buildComponentHierarchyFrames(instance, {
389
+ attachProps: props.attachProps,
390
+ propsMaxDepth: props.propsMaxDepth,
391
+ propsDenylist: resolvedDenylist
392
+ });
393
+ const componentName = getComponentName(instance);
394
+ error.value = errorToReport;
395
+ const instanceProps = props.attachProps && instance?.$props ? serializeProps(instance.$props, props.propsMaxDepth, resolvedDenylist) : void 0;
396
+ const errorOrigin = getErrorOrigin(info);
397
+ const route = getRouteContext(currentInstance?.appContext.config.globalProperties.$router, { denylist: resolvedDenylist });
398
+ const context = { vue: {
399
+ info,
400
+ errorOrigin,
401
+ ...route && { route },
402
+ componentName,
403
+ ...instanceProps && { componentProps: instanceProps },
404
+ componentHierarchy: hierarchy,
405
+ componentHierarchyFrames: hierarchyFrames
406
+ } };
407
+ const finalContext = props.beforeSubmit?.({
408
+ error: errorToReport,
409
+ instance,
410
+ info,
411
+ context
412
+ }) ?? context;
413
+ componentProps.value = finalContext.vue.componentProps;
414
+ componentHierarchy.value = finalContext.vue.componentHierarchy;
415
+ componentHierarchyFrames.value = finalContext.vue.componentHierarchyFrames;
416
+ Promise.resolve(flare.report(errorToReport, vueContextToAttributes(finalContext))).catch(() => {});
417
+ props.afterSubmit?.({
418
+ error: errorToReport,
419
+ instance,
420
+ info,
421
+ context: finalContext
422
+ });
423
+ return false;
424
+ });
425
+ return () => {
426
+ if (error.value !== null) {
427
+ if (slots.fallback) return slots.fallback({
428
+ error: error.value,
429
+ ...componentProps.value && { componentProps: componentProps.value },
430
+ componentHierarchy: componentHierarchy.value,
431
+ componentHierarchyFrames: componentHierarchyFrames.value,
432
+ resetErrorBoundary
433
+ });
434
+ return null;
435
+ }
436
+ return slots.default?.();
437
+ };
438
+ }
439
+ });
440
+
441
+ //#endregion
442
+ export { DEFAULT_PROPS_DENYLIST, FlareErrorBoundary, flareVue };