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