@error-explorer/vue 1.1.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 +312 -0
- package/dist/index.cjs +658 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +433 -0
- package/dist/index.d.ts +433 -0
- package/dist/index.js +639 -0
- package/dist/index.js.map +1 -0
- package/dist/router.cjs +143 -0
- package/dist/router.cjs.map +1 -0
- package/dist/router.d.cts +56 -0
- package/dist/router.d.ts +56 -0
- package/dist/router.js +140 -0
- package/dist/router.js.map +1 -0
- package/package.json +82 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { App, ComponentPublicInstance, Plugin, PropType, VNode } from 'vue';
|
|
3
|
+
import { InitOptions, ErrorExplorer, CaptureContext, Breadcrumb, UserContext } from '@error-explorer/browser';
|
|
4
|
+
export { Breadcrumb, CaptureContext, ErrorExplorer, InitOptions, UserContext } from '@error-explorer/browser';
|
|
5
|
+
export { RouterIntegrationOptions, createRouterIntegration, setupRouterIntegration } from './router.js';
|
|
6
|
+
import 'vue-router';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Types for @error-explorer/vue
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Vue-specific initialization options
|
|
14
|
+
*/
|
|
15
|
+
interface VueErrorExplorerOptions extends InitOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Vue application instance (optional - can be set via plugin install)
|
|
18
|
+
*/
|
|
19
|
+
app?: App;
|
|
20
|
+
/**
|
|
21
|
+
* Enable Vue error handler integration
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
vueErrorHandler?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Enable Vue warning handler integration
|
|
27
|
+
* @default true in development, false in production
|
|
28
|
+
*/
|
|
29
|
+
vueWarnHandler?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Enable Vue Router integration for navigation breadcrumbs
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
34
|
+
router?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Capture component name in error context
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
captureComponentName?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Capture component props in error context (be careful with sensitive data)
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
captureComponentProps?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Maximum depth for serializing component props
|
|
47
|
+
* @default 2
|
|
48
|
+
*/
|
|
49
|
+
propsDepth?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Hook called before capturing a Vue error
|
|
52
|
+
* Return false to skip capturing
|
|
53
|
+
*/
|
|
54
|
+
beforeVueCapture?: (error: Error, instance: ComponentPublicInstance | null, info: string) => boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Vue component context captured with errors
|
|
58
|
+
*/
|
|
59
|
+
interface VueComponentContext {
|
|
60
|
+
/**
|
|
61
|
+
* Component name
|
|
62
|
+
*/
|
|
63
|
+
name?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Component file path (if available)
|
|
66
|
+
*/
|
|
67
|
+
file?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Component props (if enabled)
|
|
70
|
+
*/
|
|
71
|
+
props?: Record<string, unknown>;
|
|
72
|
+
/**
|
|
73
|
+
* Vue error info string (e.g., "render function", "watcher callback")
|
|
74
|
+
*/
|
|
75
|
+
info?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Component trace (parent hierarchy)
|
|
78
|
+
*/
|
|
79
|
+
trace?: string[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Vue plugin install function type
|
|
83
|
+
*/
|
|
84
|
+
type VuePluginInstall = (app: App, options?: VueErrorExplorerOptions) => void;
|
|
85
|
+
/**
|
|
86
|
+
* ErrorBoundary component props
|
|
87
|
+
*/
|
|
88
|
+
interface ErrorBoundaryProps {
|
|
89
|
+
/**
|
|
90
|
+
* Callback when an error is caught
|
|
91
|
+
*/
|
|
92
|
+
onError?: (error: Error, info: string) => void;
|
|
93
|
+
/**
|
|
94
|
+
* Whether to capture the error to Error Explorer
|
|
95
|
+
* @default true
|
|
96
|
+
*/
|
|
97
|
+
capture?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Additional tags to add when capturing
|
|
100
|
+
*/
|
|
101
|
+
tags?: Record<string, string>;
|
|
102
|
+
/**
|
|
103
|
+
* Additional context to add when capturing
|
|
104
|
+
*/
|
|
105
|
+
context?: Record<string, unknown>;
|
|
106
|
+
/**
|
|
107
|
+
* Fallback content to render when an error occurs
|
|
108
|
+
* Can be a VNode or a render function receiving error and reset callback
|
|
109
|
+
*/
|
|
110
|
+
fallback?: unknown;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* ErrorBoundary exposed methods
|
|
114
|
+
*/
|
|
115
|
+
interface ErrorBoundaryExposed {
|
|
116
|
+
/**
|
|
117
|
+
* Reset the error state
|
|
118
|
+
*/
|
|
119
|
+
reset: () => void;
|
|
120
|
+
/**
|
|
121
|
+
* Current error (if any)
|
|
122
|
+
*/
|
|
123
|
+
error: Error | null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Vue Plugin for Error Explorer
|
|
128
|
+
*/
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Restore original handlers
|
|
132
|
+
*/
|
|
133
|
+
declare function restoreHandlers(app: App): void;
|
|
134
|
+
/**
|
|
135
|
+
* Create Vue plugin for Error Explorer
|
|
136
|
+
*/
|
|
137
|
+
declare function createErrorExplorerPlugin(options?: VueErrorExplorerOptions): Plugin;
|
|
138
|
+
declare module 'vue' {
|
|
139
|
+
interface ComponentCustomProperties {
|
|
140
|
+
$errorExplorer: typeof ErrorExplorer;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* ErrorBoundary component
|
|
146
|
+
*
|
|
147
|
+
* Usage:
|
|
148
|
+
* ```vue
|
|
149
|
+
* <ErrorBoundary @error="handleError" :fallback="ErrorFallback">
|
|
150
|
+
* <MyComponent />
|
|
151
|
+
* </ErrorBoundary>
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* Or with scoped slot for fallback:
|
|
155
|
+
* ```vue
|
|
156
|
+
* <ErrorBoundary>
|
|
157
|
+
* <template #default>
|
|
158
|
+
* <MyComponent />
|
|
159
|
+
* </template>
|
|
160
|
+
* <template #fallback="{ error, reset }">
|
|
161
|
+
* <div>
|
|
162
|
+
* <p>Error: {{ error.message }}</p>
|
|
163
|
+
* <button @click="reset">Retry</button>
|
|
164
|
+
* </div>
|
|
165
|
+
* </template>
|
|
166
|
+
* </ErrorBoundary>
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
declare const ErrorBoundary: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
170
|
+
/**
|
|
171
|
+
* Whether to capture the error to Error Explorer
|
|
172
|
+
*/
|
|
173
|
+
capture: {
|
|
174
|
+
type: BooleanConstructor;
|
|
175
|
+
default: boolean;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Additional tags to add when capturing
|
|
179
|
+
*/
|
|
180
|
+
tags: {
|
|
181
|
+
type: PropType<Record<string, string>>;
|
|
182
|
+
default: () => {};
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Additional context to add when capturing
|
|
186
|
+
*/
|
|
187
|
+
context: {
|
|
188
|
+
type: PropType<Record<string, unknown>>;
|
|
189
|
+
default: () => {};
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Fallback component to render when an error occurs
|
|
193
|
+
*/
|
|
194
|
+
fallback: {
|
|
195
|
+
type: PropType<VNode | (() => VNode) | null>;
|
|
196
|
+
default: null;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Whether to stop error propagation
|
|
200
|
+
*/
|
|
201
|
+
stopPropagation: {
|
|
202
|
+
type: BooleanConstructor;
|
|
203
|
+
default: boolean;
|
|
204
|
+
};
|
|
205
|
+
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
206
|
+
[key: string]: any;
|
|
207
|
+
}> | VNode<vue.RendererNode, vue.RendererElement, {
|
|
208
|
+
[key: string]: any;
|
|
209
|
+
}>[] | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
210
|
+
/**
|
|
211
|
+
* Emitted when an error is caught
|
|
212
|
+
*/
|
|
213
|
+
error: (error: Error, info: string) => true;
|
|
214
|
+
/**
|
|
215
|
+
* Emitted when the error state is reset
|
|
216
|
+
*/
|
|
217
|
+
reset: () => true;
|
|
218
|
+
}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
219
|
+
/**
|
|
220
|
+
* Whether to capture the error to Error Explorer
|
|
221
|
+
*/
|
|
222
|
+
capture: {
|
|
223
|
+
type: BooleanConstructor;
|
|
224
|
+
default: boolean;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Additional tags to add when capturing
|
|
228
|
+
*/
|
|
229
|
+
tags: {
|
|
230
|
+
type: PropType<Record<string, string>>;
|
|
231
|
+
default: () => {};
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Additional context to add when capturing
|
|
235
|
+
*/
|
|
236
|
+
context: {
|
|
237
|
+
type: PropType<Record<string, unknown>>;
|
|
238
|
+
default: () => {};
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Fallback component to render when an error occurs
|
|
242
|
+
*/
|
|
243
|
+
fallback: {
|
|
244
|
+
type: PropType<VNode | (() => VNode) | null>;
|
|
245
|
+
default: null;
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Whether to stop error propagation
|
|
249
|
+
*/
|
|
250
|
+
stopPropagation: {
|
|
251
|
+
type: BooleanConstructor;
|
|
252
|
+
default: boolean;
|
|
253
|
+
};
|
|
254
|
+
}>> & Readonly<{
|
|
255
|
+
onError?: ((error: Error, info: string) => any) | undefined;
|
|
256
|
+
onReset?: (() => any) | undefined;
|
|
257
|
+
}>, {
|
|
258
|
+
capture: boolean;
|
|
259
|
+
tags: Record<string, string>;
|
|
260
|
+
context: Record<string, unknown>;
|
|
261
|
+
fallback: VNode<vue.RendererNode, vue.RendererElement, {
|
|
262
|
+
[key: string]: any;
|
|
263
|
+
}> | (() => VNode) | null;
|
|
264
|
+
stopPropagation: boolean;
|
|
265
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
266
|
+
/**
|
|
267
|
+
* Higher-order component to wrap a component with ErrorBoundary
|
|
268
|
+
*/
|
|
269
|
+
declare function withErrorBoundary<T extends {
|
|
270
|
+
new (): any;
|
|
271
|
+
}>(Component: T, options?: {
|
|
272
|
+
capture?: boolean;
|
|
273
|
+
tags?: Record<string, string>;
|
|
274
|
+
context?: Record<string, unknown>;
|
|
275
|
+
fallback?: VNode | (() => VNode);
|
|
276
|
+
onError?: (error: Error, info: string) => void;
|
|
277
|
+
}): vue.DefineComponent<{}, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
278
|
+
[key: string]: any;
|
|
279
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
280
|
+
type ErrorBoundaryInstance = InstanceType<typeof ErrorBoundary>;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Vue 3 Composables for Error Explorer
|
|
284
|
+
*/
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Injection key for Error Explorer
|
|
288
|
+
*/
|
|
289
|
+
declare const ErrorExplorerKey: unique symbol;
|
|
290
|
+
/**
|
|
291
|
+
* Use Error Explorer instance
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```ts
|
|
295
|
+
* const { captureException, addBreadcrumb } = useErrorExplorer();
|
|
296
|
+
*
|
|
297
|
+
* try {
|
|
298
|
+
* await riskyOperation();
|
|
299
|
+
* } catch (error) {
|
|
300
|
+
* captureException(error);
|
|
301
|
+
* }
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
declare function useErrorExplorer(): {
|
|
305
|
+
/**
|
|
306
|
+
* Check if Error Explorer is initialized
|
|
307
|
+
*/
|
|
308
|
+
isInitialized: () => boolean;
|
|
309
|
+
/**
|
|
310
|
+
* Capture an exception
|
|
311
|
+
*/
|
|
312
|
+
captureException: (error: Error, context?: CaptureContext) => string;
|
|
313
|
+
/**
|
|
314
|
+
* Capture a message
|
|
315
|
+
*/
|
|
316
|
+
captureMessage: (message: string, level?: "debug" | "info" | "warning" | "error" | "critical") => string;
|
|
317
|
+
/**
|
|
318
|
+
* Add a breadcrumb
|
|
319
|
+
*/
|
|
320
|
+
addBreadcrumb: (breadcrumb: Breadcrumb) => void;
|
|
321
|
+
/**
|
|
322
|
+
* Set user context
|
|
323
|
+
*/
|
|
324
|
+
setUser: (user: UserContext) => void;
|
|
325
|
+
/**
|
|
326
|
+
* Clear user context
|
|
327
|
+
*/
|
|
328
|
+
clearUser: () => void;
|
|
329
|
+
/**
|
|
330
|
+
* Set a tag
|
|
331
|
+
*/
|
|
332
|
+
setTag: (key: string, value: string) => void;
|
|
333
|
+
/**
|
|
334
|
+
* Set multiple tags
|
|
335
|
+
*/
|
|
336
|
+
setTags: (tags: Record<string, string>) => void;
|
|
337
|
+
/**
|
|
338
|
+
* Set extra context
|
|
339
|
+
*/
|
|
340
|
+
setExtra: (extra: Record<string, unknown>) => void;
|
|
341
|
+
/**
|
|
342
|
+
* Set named context
|
|
343
|
+
*/
|
|
344
|
+
setContext: (name: string, context: Record<string, unknown>) => void;
|
|
345
|
+
/**
|
|
346
|
+
* Flush pending events
|
|
347
|
+
*/
|
|
348
|
+
flush: (timeout?: number) => Promise<boolean>;
|
|
349
|
+
/**
|
|
350
|
+
* Close the SDK
|
|
351
|
+
*/
|
|
352
|
+
close: (timeout?: number) => Promise<boolean>;
|
|
353
|
+
};
|
|
354
|
+
/**
|
|
355
|
+
* Track component lifecycle for debugging
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```ts
|
|
359
|
+
* // In setup()
|
|
360
|
+
* useComponentBreadcrumbs();
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
declare function useComponentBreadcrumbs(): void;
|
|
364
|
+
/**
|
|
365
|
+
* Create a breadcrumb tracker for user actions
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* ```ts
|
|
369
|
+
* const { trackAction } = useActionTracker();
|
|
370
|
+
*
|
|
371
|
+
* const handleClick = () => {
|
|
372
|
+
* trackAction('button_clicked', { buttonId: 'submit' });
|
|
373
|
+
* // ... actual handler
|
|
374
|
+
* };
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
declare function useActionTracker(): {
|
|
378
|
+
/**
|
|
379
|
+
* Track a user action
|
|
380
|
+
*/
|
|
381
|
+
trackAction: (action: string, data?: Record<string, unknown>) => void;
|
|
382
|
+
/**
|
|
383
|
+
* Track a UI interaction
|
|
384
|
+
*/
|
|
385
|
+
trackInteraction: (element: string, action: "click" | "input" | "focus" | "blur" | "submit", data?: Record<string, unknown>) => void;
|
|
386
|
+
};
|
|
387
|
+
/**
|
|
388
|
+
* Create an error handler for async operations
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* ```ts
|
|
392
|
+
* const { wrapAsync, handleError } = useErrorHandler();
|
|
393
|
+
*
|
|
394
|
+
* // Option 1: Wrap async function
|
|
395
|
+
* const safeSubmit = wrapAsync(async () => {
|
|
396
|
+
* await api.submit(data);
|
|
397
|
+
* });
|
|
398
|
+
*
|
|
399
|
+
* // Option 2: Manual handling
|
|
400
|
+
* try {
|
|
401
|
+
* await riskyOperation();
|
|
402
|
+
* } catch (error) {
|
|
403
|
+
* handleError(error, { tags: { operation: 'risky' } });
|
|
404
|
+
* }
|
|
405
|
+
* ```
|
|
406
|
+
*/
|
|
407
|
+
declare function useErrorHandler(defaultContext?: CaptureContext): {
|
|
408
|
+
handleError: (error: unknown, context?: CaptureContext) => Error;
|
|
409
|
+
wrapAsync: <T extends (...args: any[]) => Promise<any>>(fn: T, context?: CaptureContext) => ((...args: Parameters<T>) => Promise<Awaited<ReturnType<T>> | undefined>);
|
|
410
|
+
tryCatch: <T>(fn: () => T, context?: CaptureContext) => T | undefined;
|
|
411
|
+
};
|
|
412
|
+
/**
|
|
413
|
+
* Set user context from a reactive source
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* ```ts
|
|
417
|
+
* const user = ref({ id: '123', email: 'user@example.com' });
|
|
418
|
+
* useUserContext(user);
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
declare function useUserContext(user: {
|
|
422
|
+
value: UserContext | null;
|
|
423
|
+
} | UserContext | null): {
|
|
424
|
+
setUser: (newUser: UserContext) => void;
|
|
425
|
+
clearUser: () => void;
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* @error-explorer/vue
|
|
430
|
+
* Error Explorer SDK for Vue.js 3 - Automatic error tracking with Vue integration
|
|
431
|
+
*/
|
|
432
|
+
|
|
433
|
+
export { ErrorBoundary, type ErrorBoundaryExposed, type ErrorBoundaryInstance, type ErrorBoundaryProps, ErrorExplorerKey, type VueComponentContext, type VueErrorExplorerOptions, type VuePluginInstall, createErrorExplorerPlugin, createErrorExplorerPlugin as default, restoreHandlers, useActionTracker, useComponentBreadcrumbs, useErrorExplorer, useErrorHandler, useUserContext, withErrorBoundary };
|