@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/README.md
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# @error-explorer/vue
|
|
2
|
+
|
|
3
|
+
Error Explorer SDK for Vue.js 3 - Automatic error tracking with Vue integration.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Automatic Error Capture**: Hooks into Vue's `errorHandler` and `warnHandler`
|
|
8
|
+
- **Vue Router Integration**: Automatic navigation breadcrumbs
|
|
9
|
+
- **ErrorBoundary Component**: Catch and handle errors in component trees
|
|
10
|
+
- **Composables**: Vue 3 Composition API hooks for easy integration
|
|
11
|
+
- **TypeScript Support**: Full type definitions included
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @error-explorer/vue @error-explorer/browser
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
### Plugin Setup
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// main.ts
|
|
25
|
+
import { createApp } from 'vue';
|
|
26
|
+
import { createErrorExplorerPlugin } from '@error-explorer/vue';
|
|
27
|
+
import App from './App.vue';
|
|
28
|
+
|
|
29
|
+
const app = createApp(App);
|
|
30
|
+
|
|
31
|
+
app.use(createErrorExplorerPlugin({
|
|
32
|
+
token: 'ee_your_token_here',
|
|
33
|
+
environment: 'production',
|
|
34
|
+
release: '1.0.0',
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
app.mount('#app');
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### With Vue Router
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
// main.ts
|
|
44
|
+
import { createApp } from 'vue';
|
|
45
|
+
import { createRouter, createWebHistory } from 'vue-router';
|
|
46
|
+
import { createErrorExplorerPlugin, setupRouterIntegration } from '@error-explorer/vue';
|
|
47
|
+
import App from './App.vue';
|
|
48
|
+
|
|
49
|
+
const router = createRouter({
|
|
50
|
+
history: createWebHistory(),
|
|
51
|
+
routes: [/* ... */],
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const app = createApp(App);
|
|
55
|
+
|
|
56
|
+
// Initialize Error Explorer
|
|
57
|
+
app.use(createErrorExplorerPlugin({
|
|
58
|
+
token: 'ee_your_token_here',
|
|
59
|
+
environment: 'production',
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
// Setup router integration
|
|
63
|
+
app.use(router);
|
|
64
|
+
setupRouterIntegration(router);
|
|
65
|
+
|
|
66
|
+
app.mount('#app');
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## ErrorBoundary Component
|
|
70
|
+
|
|
71
|
+
Catch errors in a component subtree:
|
|
72
|
+
|
|
73
|
+
```vue
|
|
74
|
+
<script setup lang="ts">
|
|
75
|
+
import { ErrorBoundary } from '@error-explorer/vue';
|
|
76
|
+
|
|
77
|
+
const handleError = (error: Error, info: string) => {
|
|
78
|
+
console.error('Caught error:', error, info);
|
|
79
|
+
};
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<template>
|
|
83
|
+
<ErrorBoundary @error="handleError">
|
|
84
|
+
<template #default>
|
|
85
|
+
<RiskyComponent />
|
|
86
|
+
</template>
|
|
87
|
+
<template #fallback="{ error, reset }">
|
|
88
|
+
<div class="error-fallback">
|
|
89
|
+
<p>Something went wrong: {{ error.message }}</p>
|
|
90
|
+
<button @click="reset">Try Again</button>
|
|
91
|
+
</div>
|
|
92
|
+
</template>
|
|
93
|
+
</ErrorBoundary>
|
|
94
|
+
</template>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Higher-Order Component
|
|
98
|
+
|
|
99
|
+
Wrap a component with error boundary:
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { withErrorBoundary } from '@error-explorer/vue';
|
|
103
|
+
import RiskyComponent from './RiskyComponent.vue';
|
|
104
|
+
|
|
105
|
+
export default withErrorBoundary(RiskyComponent, {
|
|
106
|
+
onError: (error, info) => console.error(error),
|
|
107
|
+
tags: { feature: 'risky' },
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Composables
|
|
112
|
+
|
|
113
|
+
### useErrorExplorer
|
|
114
|
+
|
|
115
|
+
Access Error Explorer methods in Composition API:
|
|
116
|
+
|
|
117
|
+
```vue
|
|
118
|
+
<script setup lang="ts">
|
|
119
|
+
import { useErrorExplorer } from '@error-explorer/vue';
|
|
120
|
+
|
|
121
|
+
const { captureException, addBreadcrumb, setUser } = useErrorExplorer();
|
|
122
|
+
|
|
123
|
+
// Set user context
|
|
124
|
+
setUser({
|
|
125
|
+
id: 'user_123',
|
|
126
|
+
email: 'user@example.com',
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Add breadcrumb
|
|
130
|
+
addBreadcrumb({
|
|
131
|
+
type: 'user',
|
|
132
|
+
category: 'action',
|
|
133
|
+
message: 'User clicked submit',
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// Capture exception
|
|
137
|
+
const handleSubmit = async () => {
|
|
138
|
+
try {
|
|
139
|
+
await api.submit(data);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
captureException(error as Error, {
|
|
142
|
+
tags: { action: 'submit' },
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
</script>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### useErrorHandler
|
|
150
|
+
|
|
151
|
+
Simplify error handling in async operations:
|
|
152
|
+
|
|
153
|
+
```vue
|
|
154
|
+
<script setup lang="ts">
|
|
155
|
+
import { useErrorHandler } from '@error-explorer/vue';
|
|
156
|
+
|
|
157
|
+
const { wrapAsync, handleError } = useErrorHandler();
|
|
158
|
+
|
|
159
|
+
// Wrap async functions to auto-capture errors
|
|
160
|
+
const safeSubmit = wrapAsync(async () => {
|
|
161
|
+
await api.submit(formData);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Or handle manually
|
|
165
|
+
const manualSubmit = async () => {
|
|
166
|
+
try {
|
|
167
|
+
await api.submit(formData);
|
|
168
|
+
} catch (error) {
|
|
169
|
+
handleError(error, { tags: { form: 'contact' } });
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
</script>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### useActionTracker
|
|
176
|
+
|
|
177
|
+
Track user actions as breadcrumbs:
|
|
178
|
+
|
|
179
|
+
```vue
|
|
180
|
+
<script setup lang="ts">
|
|
181
|
+
import { useActionTracker } from '@error-explorer/vue';
|
|
182
|
+
|
|
183
|
+
const { trackAction, trackInteraction } = useActionTracker();
|
|
184
|
+
|
|
185
|
+
const handleClick = () => {
|
|
186
|
+
trackInteraction('submit-button', 'click', { formId: 'contact' });
|
|
187
|
+
// ... actual handler
|
|
188
|
+
};
|
|
189
|
+
</script>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### useComponentBreadcrumbs
|
|
193
|
+
|
|
194
|
+
Track component lifecycle:
|
|
195
|
+
|
|
196
|
+
```vue
|
|
197
|
+
<script setup lang="ts">
|
|
198
|
+
import { useComponentBreadcrumbs } from '@error-explorer/vue';
|
|
199
|
+
|
|
200
|
+
// Adds mount/unmount breadcrumbs automatically
|
|
201
|
+
useComponentBreadcrumbs();
|
|
202
|
+
</script>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Configuration Options
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
interface VueErrorExplorerOptions {
|
|
209
|
+
// Required: Your Error Explorer token
|
|
210
|
+
token: string;
|
|
211
|
+
|
|
212
|
+
// Environment (production, staging, development)
|
|
213
|
+
environment?: string;
|
|
214
|
+
|
|
215
|
+
// App release version
|
|
216
|
+
release?: string;
|
|
217
|
+
|
|
218
|
+
// Enable Vue error handler (default: true)
|
|
219
|
+
vueErrorHandler?: boolean;
|
|
220
|
+
|
|
221
|
+
// Enable Vue warning handler (default: true in dev)
|
|
222
|
+
vueWarnHandler?: boolean;
|
|
223
|
+
|
|
224
|
+
// Capture component name (default: true)
|
|
225
|
+
captureComponentName?: boolean;
|
|
226
|
+
|
|
227
|
+
// Capture component props (default: false)
|
|
228
|
+
captureComponentProps?: boolean;
|
|
229
|
+
|
|
230
|
+
// Props serialization depth (default: 2)
|
|
231
|
+
propsDepth?: number;
|
|
232
|
+
|
|
233
|
+
// Hook before capturing Vue errors
|
|
234
|
+
beforeVueCapture?: (
|
|
235
|
+
error: Error,
|
|
236
|
+
instance: ComponentPublicInstance | null,
|
|
237
|
+
info: string
|
|
238
|
+
) => boolean;
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Router Integration Options
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
import { setupRouterIntegration } from '@error-explorer/vue/router';
|
|
246
|
+
|
|
247
|
+
setupRouterIntegration(router, {
|
|
248
|
+
// Track navigation (default: true)
|
|
249
|
+
trackNavigation: true,
|
|
250
|
+
|
|
251
|
+
// Track route params (default: false)
|
|
252
|
+
trackParams: false,
|
|
253
|
+
|
|
254
|
+
// Track query params (default: false)
|
|
255
|
+
trackQuery: false,
|
|
256
|
+
|
|
257
|
+
// Custom route name extractor
|
|
258
|
+
getRouteName: (route) => route.meta.title || route.name || route.path,
|
|
259
|
+
|
|
260
|
+
// Filter navigation breadcrumbs
|
|
261
|
+
beforeNavigationBreadcrumb: (from, to) => {
|
|
262
|
+
// Return false to skip this breadcrumb
|
|
263
|
+
return !to.path.startsWith('/admin');
|
|
264
|
+
},
|
|
265
|
+
});
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Options API Support
|
|
269
|
+
|
|
270
|
+
For Options API components, use `this.$errorExplorer`:
|
|
271
|
+
|
|
272
|
+
```vue
|
|
273
|
+
<script>
|
|
274
|
+
export default {
|
|
275
|
+
methods: {
|
|
276
|
+
handleAction() {
|
|
277
|
+
this.$errorExplorer.addBreadcrumb({
|
|
278
|
+
type: 'user',
|
|
279
|
+
message: 'Action performed',
|
|
280
|
+
});
|
|
281
|
+
},
|
|
282
|
+
handleError(error) {
|
|
283
|
+
this.$errorExplorer.captureException(error);
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
};
|
|
287
|
+
</script>
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## Best Practices
|
|
291
|
+
|
|
292
|
+
1. **Initialize early**: Set up the plugin before mounting your app
|
|
293
|
+
2. **Set user context**: Call `setUser()` after authentication
|
|
294
|
+
3. **Use ErrorBoundary**: Wrap critical sections with ErrorBoundary
|
|
295
|
+
4. **Add meaningful breadcrumbs**: Track user actions for debugging context
|
|
296
|
+
5. **Don't capture props by default**: May contain sensitive data
|
|
297
|
+
|
|
298
|
+
## TypeScript
|
|
299
|
+
|
|
300
|
+
Full TypeScript support is included. Import types as needed:
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
import type {
|
|
304
|
+
VueErrorExplorerOptions,
|
|
305
|
+
VueComponentContext,
|
|
306
|
+
ErrorBoundaryProps,
|
|
307
|
+
} from '@error-explorer/vue';
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## License
|
|
311
|
+
|
|
312
|
+
MIT
|