@@ -78,11 +78,27 @@ export class VueIntegration {
7878 /**
7979 * Extract additional useful information from the Vue app
8080 *
81- * @param vm - vue VM
81+ * @param vm - component instance
8282 * @param info - a Vue-specific error info, e.g. which lifecycle hook the error was found in.
8383 */
84+ private spoilAddons ( vm : { [ key : string ] : unknown } , info : string ) : VueIntegrationAddons {
85+ const isVue3 = vm . $ !== undefined ;
86+
87+ if ( isVue3 ) {
88+ return this . spoilAddonsFromVue3 ( vm , info ) ;
89+ } else {
90+ return this . spoilAddonsFromVue2 ( vm , info ) ;
91+ }
92+ }
93+
94+ /**
95+ * Extract additional useful information from the Vue 2 app
96+ *
97+ * @param vm - component instance
98+ * @param info - which lifecycle hook the error was found in.
99+ */
84100 // eslint-disable-next-line @typescript-eslint/no-explicit-any
85- private spoilAddons ( vm : { [ key : string ] : any } , info : string ) : VueIntegrationAddons {
101+ private spoilAddonsFromVue2 ( vm : { [ key : string ] : any } , info : string ) : VueIntegrationAddons {
86102 const addons : VueIntegrationAddons = {
87103 lifecycle : info ,
88104 component : null ,
@@ -130,6 +146,36 @@ export class VueIntegration {
130146 return addons ;
131147 }
132148
149+ /**
150+ * Extract additional useful information from the Vue 3 app
151+ *
152+ * @param vm - component instance
153+ * @param info - which lifecycle hook the error was found in.
154+ */
155+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
156+ private spoilAddonsFromVue3 ( vm : { [ key : string ] : any } , info : string ) : VueIntegrationAddons {
157+ const addons : VueIntegrationAddons = {
158+ lifecycle : info ,
159+ component : null ,
160+ } ;
161+
162+ /**
163+ * Extract the component name
164+ */
165+ if ( vm . $options !== undefined ) {
166+ addons [ 'component' ] = `<${ vm . $options . __name || vm . $options . name || vm . $options . _componentTag || 'Anonymous' } >` ;
167+ }
168+
169+ /**
170+ * Fill props
171+ */
172+ if ( Object . keys ( vm . $props ) . length ) {
173+ addons [ 'props' ] = vm . $props ;
174+ }
175+
176+ return addons ;
177+ }
178+
133179 /**
134180 * Write error to the console
135181 *
0 commit comments