@error-explorer/browser 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 +251 -0
- package/dist/error-explorer.cjs.js +2818 -0
- package/dist/error-explorer.cjs.js.map +1 -0
- package/dist/error-explorer.esm.js +2813 -0
- package/dist/error-explorer.esm.js.map +1 -0
- package/dist/error-explorer.min.js +2 -0
- package/dist/error-explorer.min.js.map +1 -0
- package/dist/index.d.ts +288 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
# @error-explorer/browser
|
|
2
|
+
|
|
3
|
+
Official Error Explorer SDK for Browser. Automatically captures errors, unhandled promise rejections, and provides detailed context through breadcrumbs.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🔄 **Automatic error capture** - `window.onerror`, unhandled promise rejections
|
|
8
|
+
- 🍞 **Breadcrumbs** - Track clicks, navigation, network requests, console logs
|
|
9
|
+
- 🧑 **User context** - Associate errors with user information
|
|
10
|
+
- 📦 **Offline support** - Queue events when offline, send when back online
|
|
11
|
+
- 🔒 **Data scrubbing** - Automatically filter sensitive data (passwords, tokens, etc.)
|
|
12
|
+
- ⚡ **Non-blocking** - Uses `sendBeacon` and `fetch` with keepalive
|
|
13
|
+
- 🎯 **Small footprint** - < 10KB gzipped
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# npm
|
|
19
|
+
npm install @error-explorer/browser
|
|
20
|
+
|
|
21
|
+
# yarn
|
|
22
|
+
yarn add @error-explorer/browser
|
|
23
|
+
|
|
24
|
+
# pnpm
|
|
25
|
+
pnpm add @error-explorer/browser
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
import ErrorExplorer from '@error-explorer/browser';
|
|
32
|
+
|
|
33
|
+
// Initialize (1 line!)
|
|
34
|
+
ErrorExplorer.init({
|
|
35
|
+
token: 'ee_your_project_token',
|
|
36
|
+
environment: 'production',
|
|
37
|
+
release: '1.0.0',
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// That's it! Errors are now captured automatically.
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## CDN Usage
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<script src="https://cdn.error-explorer.com/sdk.min.js"></script>
|
|
47
|
+
<script>
|
|
48
|
+
ErrorExplorer.init({
|
|
49
|
+
token: 'ee_your_project_token',
|
|
50
|
+
environment: 'production',
|
|
51
|
+
});
|
|
52
|
+
</script>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Configuration
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
ErrorExplorer.init({
|
|
59
|
+
// Required
|
|
60
|
+
token: 'ee_your_project_token',
|
|
61
|
+
|
|
62
|
+
// Recommended
|
|
63
|
+
environment: 'production', // or 'staging', 'development'
|
|
64
|
+
release: '1.2.3', // Your app version
|
|
65
|
+
|
|
66
|
+
// Auto capture (all true by default)
|
|
67
|
+
autoCapture: {
|
|
68
|
+
errors: true, // window.onerror
|
|
69
|
+
unhandledRejections: true, // Promise rejections
|
|
70
|
+
console: true, // console.error
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
// Breadcrumbs (all true by default except inputs)
|
|
74
|
+
breadcrumbs: {
|
|
75
|
+
enabled: true,
|
|
76
|
+
maxBreadcrumbs: 20,
|
|
77
|
+
clicks: true, // Click events
|
|
78
|
+
navigation: true, // Route changes
|
|
79
|
+
fetch: true, // Fetch requests
|
|
80
|
+
xhr: true, // XMLHttpRequest
|
|
81
|
+
console: true, // Console logs
|
|
82
|
+
inputs: false, // Input focus (privacy)
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
// Filtering
|
|
86
|
+
ignoreErrors: [/ResizeObserver/],
|
|
87
|
+
denyUrls: [/chrome-extension/],
|
|
88
|
+
allowUrls: [], // If set, only these URLs
|
|
89
|
+
|
|
90
|
+
// Hooks
|
|
91
|
+
beforeSend: (event) => {
|
|
92
|
+
// Modify or filter events
|
|
93
|
+
if (event.message.includes('ignore')) {
|
|
94
|
+
return null; // Drop event
|
|
95
|
+
}
|
|
96
|
+
return event;
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
// Transport
|
|
100
|
+
maxRetries: 3,
|
|
101
|
+
timeout: 5000,
|
|
102
|
+
offline: true, // Queue when offline
|
|
103
|
+
|
|
104
|
+
// Debug
|
|
105
|
+
debug: false,
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Manual Capture
|
|
110
|
+
|
|
111
|
+
```javascript
|
|
112
|
+
// Capture an exception
|
|
113
|
+
try {
|
|
114
|
+
riskyOperation();
|
|
115
|
+
} catch (error) {
|
|
116
|
+
ErrorExplorer.captureException(error, {
|
|
117
|
+
tags: { feature: 'checkout' },
|
|
118
|
+
extra: { orderId: '12345' },
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Capture a message
|
|
123
|
+
ErrorExplorer.captureMessage('User completed onboarding', 'info');
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## User Context
|
|
127
|
+
|
|
128
|
+
```javascript
|
|
129
|
+
// Set user (after login)
|
|
130
|
+
ErrorExplorer.setUser({
|
|
131
|
+
id: 'user_123',
|
|
132
|
+
email: 'john@example.com',
|
|
133
|
+
name: 'John Doe',
|
|
134
|
+
plan: 'pro', // Custom fields allowed
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Clear user (after logout)
|
|
138
|
+
ErrorExplorer.clearUser();
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Tags & Extra Data
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
// Set tags (for filtering in dashboard)
|
|
145
|
+
ErrorExplorer.setTags({
|
|
146
|
+
feature: 'checkout',
|
|
147
|
+
ab_test: 'variant_b',
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Set a single tag
|
|
151
|
+
ErrorExplorer.setTag('version', '2.0');
|
|
152
|
+
|
|
153
|
+
// Set extra data (appears in error details)
|
|
154
|
+
ErrorExplorer.setExtra({
|
|
155
|
+
cartTotal: 149.99,
|
|
156
|
+
itemCount: 3,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Set a named context
|
|
160
|
+
ErrorExplorer.setContext('cart', {
|
|
161
|
+
items: ['SKU-1', 'SKU-2'],
|
|
162
|
+
total: 149.99,
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Manual Breadcrumbs
|
|
167
|
+
|
|
168
|
+
```javascript
|
|
169
|
+
// Add a custom breadcrumb
|
|
170
|
+
ErrorExplorer.addBreadcrumb({
|
|
171
|
+
type: 'user-action',
|
|
172
|
+
category: 'ui',
|
|
173
|
+
message: 'User clicked "Add to Cart"',
|
|
174
|
+
level: 'info',
|
|
175
|
+
data: {
|
|
176
|
+
productId: 'SKU-123',
|
|
177
|
+
price: 29.99,
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Automatic Breadcrumbs
|
|
183
|
+
|
|
184
|
+
The SDK automatically captures:
|
|
185
|
+
|
|
186
|
+
| Type | Data |
|
|
187
|
+
|------|------|
|
|
188
|
+
| `click` | Element tag, id, classes, text |
|
|
189
|
+
| `navigation` | From URL, To URL, navigation type |
|
|
190
|
+
| `fetch` | Method, URL, status, duration |
|
|
191
|
+
| `xhr` | Method, URL, status, duration |
|
|
192
|
+
| `console` | Level, message |
|
|
193
|
+
| `input` | Element type, name (never the value!) |
|
|
194
|
+
|
|
195
|
+
## Flushing & Cleanup
|
|
196
|
+
|
|
197
|
+
```javascript
|
|
198
|
+
// Flush pending events (before page unload)
|
|
199
|
+
await ErrorExplorer.flush(5000); // 5s timeout
|
|
200
|
+
|
|
201
|
+
// Close SDK and cleanup
|
|
202
|
+
await ErrorExplorer.close();
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## TypeScript Support
|
|
206
|
+
|
|
207
|
+
Full TypeScript support with exported types:
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
import ErrorExplorer, {
|
|
211
|
+
InitOptions,
|
|
212
|
+
UserContext,
|
|
213
|
+
Breadcrumb,
|
|
214
|
+
CaptureContext,
|
|
215
|
+
SeverityLevel,
|
|
216
|
+
} from '@error-explorer/browser';
|
|
217
|
+
|
|
218
|
+
const user: UserContext = {
|
|
219
|
+
id: '123',
|
|
220
|
+
email: 'user@example.com',
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
ErrorExplorer.setUser(user);
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Framework Integrations
|
|
227
|
+
|
|
228
|
+
For framework-specific features, use our dedicated packages:
|
|
229
|
+
|
|
230
|
+
- **React**: `@error-explorer/react` - ErrorBoundary, hooks
|
|
231
|
+
- **Vue**: `@error-explorer/vue` - Plugin, composables
|
|
232
|
+
- **Angular**: `@error-explorer/angular` - Module, ErrorHandler
|
|
233
|
+
- **Next.js**: `@error-explorer/nextjs` - App Router support
|
|
234
|
+
|
|
235
|
+
## Privacy & Security
|
|
236
|
+
|
|
237
|
+
- **No PII by default**: Input values are never captured
|
|
238
|
+
- **Data scrubbing**: Passwords, tokens, API keys are automatically filtered
|
|
239
|
+
- **Configurable**: Add custom scrub fields via configuration
|
|
240
|
+
- **GDPR friendly**: User consent can be managed via `beforeSend`
|
|
241
|
+
|
|
242
|
+
## Browser Support
|
|
243
|
+
|
|
244
|
+
- Chrome 60+
|
|
245
|
+
- Firefox 55+
|
|
246
|
+
- Safari 11+
|
|
247
|
+
- Edge 79+
|
|
248
|
+
|
|
249
|
+
## License
|
|
250
|
+
|
|
251
|
+
MIT
|