@syntropysoft/syntropyfront 0.1.0-alpha.1 โ 0.2.0
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 +313 -233
- package/dist/index.cjs +308 -3234
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +309 -3231
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +14 -12
package/README.md
CHANGED
|
@@ -1,322 +1,402 @@
|
|
|
1
|
-
|
|
2
|
-
<img src="./assets/syntropysoft-logo.png" alt="SyntropyLog Logo" width="170"/>
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
<h1 align="center">SyntropyFront</h1>
|
|
6
|
-
|
|
7
|
-
<p align="center">
|
|
8
|
-
<strong>From Chaos to Clarity</strong>
|
|
9
|
-
<br />
|
|
10
|
-
The Observability Framework for High-Performance Teams
|
|
11
|
-
</p>
|
|
12
|
-
<p align="center">
|
|
13
|
-
Advanced frontend tracing and error monitoring with reactive object tracking, worker architecture, and circular reference handling
|
|
14
|
-
<br />
|
|
15
|
-
</p>
|
|
16
|
-
|
|
17
|
-
## ๐ Features
|
|
18
|
-
|
|
19
|
-
- **๐ Reactive Object Tracking** - Real-time object state tracking using JavaScript Proxies
|
|
20
|
-
- **โก Worker Architecture** - Non-blocking data collection and processing
|
|
21
|
-
- **๐ก๏ธ Circular Reference Handling** - Robust serialization for complex objects
|
|
22
|
-
- **๐ฏ Configuration Presets** - Pre-configured setups for different use cases
|
|
23
|
-
- **๐ฆ Lazy Loading** - Dynamic module loading for optimal bundle size
|
|
24
|
-
- **๐ Framework Agnostic** - Works with any JavaScript framework
|
|
25
|
-
- **๐ Breadcrumb System** - Comprehensive user action tracking
|
|
26
|
-
- **๐ Automatic Retry** - Exponential backoff with persistent buffer
|
|
27
|
-
- **๐ Privacy First** - Granular context collection with opt-in sensitive data
|
|
1
|
+
# SyntropyFront
|
|
28
2
|
|
|
29
|
-
|
|
3
|
+
๐ **Observability library with automatic capture - Just 1 line of code!**
|
|
30
4
|
|
|
31
|
-
|
|
32
|
-
npm install syntropyfront
|
|
33
|
-
```
|
|
5
|
+
SyntropyFront automatically captures user interactions, errors, HTTP calls, and console logs, providing comprehensive observability for your web applications with minimal setup.
|
|
34
6
|
|
|
35
|
-
##
|
|
7
|
+
## โจ Features
|
|
36
8
|
|
|
37
|
-
|
|
38
|
-
|
|
9
|
+
- ๐ฏ **Automatic click capture** - Tracks all user interactions
|
|
10
|
+
- ๐จ **Error detection** - Catches uncaught exceptions and promise rejections
|
|
11
|
+
- ๐ **HTTP monitoring** - Intercepts fetch calls automatically
|
|
12
|
+
- ๐ **Console logging** - Records console.log, console.error, console.warn
|
|
13
|
+
- ๐พ **Smart storage** - Keeps the last N events (configurable)
|
|
14
|
+
- ๐ค **Flexible posting** - Posts errors to your endpoint or logs to console
|
|
15
|
+
- โก **Zero configuration** - Works out of the box with just an import
|
|
39
16
|
|
|
40
|
-
|
|
41
|
-
await SyntropyFront.init({
|
|
42
|
-
preset: 'balanced',
|
|
43
|
-
agent: {
|
|
44
|
-
endpoint: 'https://your-api.com/errors'
|
|
45
|
-
}
|
|
46
|
-
});
|
|
17
|
+
## ๐ Quick Start
|
|
47
18
|
|
|
48
|
-
|
|
49
|
-
const userProfile = SyntropyFront.addProxyObject('userProfile', {
|
|
50
|
-
name: 'John Doe',
|
|
51
|
-
preferences: { theme: 'dark' }
|
|
52
|
-
});
|
|
19
|
+
### Basic Usage (1 line of code!)
|
|
53
20
|
|
|
54
|
-
|
|
55
|
-
|
|
21
|
+
```javascript
|
|
22
|
+
import syntropyFront from 'syntropyfront';
|
|
23
|
+
// That's it! Auto-initializes and captures everything automatically
|
|
56
24
|
```
|
|
57
25
|
|
|
58
|
-
|
|
26
|
+
### With Custom Configuration
|
|
59
27
|
|
|
60
|
-
### Safe Preset
|
|
61
28
|
```javascript
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
29
|
+
import syntropyFront from 'syntropyfront';
|
|
30
|
+
|
|
31
|
+
// Option 1: Console only (default)
|
|
32
|
+
syntropyFront.configure({
|
|
33
|
+
maxEvents: 50
|
|
65
34
|
});
|
|
66
|
-
```
|
|
67
|
-
- **Use case**: Production environments with privacy concerns
|
|
68
|
-
- **Features**: Errors only, minimal context, no tracking
|
|
69
|
-
- **Bundle size**: ~25KB
|
|
70
35
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
36
|
+
// Option 2: With endpoint (automatic fetch)
|
|
37
|
+
syntropyFront.configure({
|
|
38
|
+
maxEvents: 50,
|
|
39
|
+
fetch: {
|
|
40
|
+
url: 'https://your-api.com/errors',
|
|
41
|
+
options: {
|
|
42
|
+
headers: {
|
|
43
|
+
'Authorization': 'Bearer your-token',
|
|
44
|
+
'Content-Type': 'application/json'
|
|
45
|
+
},
|
|
46
|
+
mode: 'cors'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
76
49
|
});
|
|
77
|
-
```
|
|
78
|
-
- **Use case**: General production use
|
|
79
|
-
- **Features**: Periodic sending, curated context, moderate tracking
|
|
80
|
-
- **Bundle size**: ~60KB
|
|
81
50
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
51
|
+
// Option 3: With custom error handler (maximum flexibility)
|
|
52
|
+
syntropyFront.configure({
|
|
53
|
+
maxEvents: 50,
|
|
54
|
+
onError: (errorPayload) => {
|
|
55
|
+
// You can do anything with the error:
|
|
56
|
+
// - Send to your API
|
|
57
|
+
// - Save to localStorage
|
|
58
|
+
// - Send to a repository
|
|
59
|
+
// - Upload to cloud
|
|
60
|
+
// - Whatever you want!
|
|
61
|
+
console.log('Error captured:', errorPayload);
|
|
62
|
+
|
|
63
|
+
// Example: send to multiple places
|
|
64
|
+
fetch('https://api1.com/errors', {
|
|
65
|
+
method: 'POST',
|
|
66
|
+
body: JSON.stringify(errorPayload)
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Also save locally
|
|
70
|
+
localStorage.setItem('lastError', JSON.stringify(errorPayload));
|
|
71
|
+
}
|
|
87
72
|
});
|
|
88
73
|
```
|
|
89
|
-
- **Use case**: Development and debugging
|
|
90
|
-
- **Features**: Frequent sending, full context, complete tracking
|
|
91
|
-
- **Bundle size**: ~60KB
|
|
92
74
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
75
|
+
## ๐ฆ Installation
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npm install syntropyfront
|
|
79
|
+
## ๐ฏ How It Works
|
|
80
|
+
|
|
81
|
+
SyntropyFront automatically:
|
|
82
|
+
|
|
83
|
+
1. **Captures clicks** - Records element info, coordinates, and timestamps
|
|
84
|
+
2. **Detects errors** - Intercepts `window.onerror` and `window.onunhandledrejection`
|
|
85
|
+
3. **Monitors HTTP** - Wraps `window.fetch` to track requests and responses
|
|
86
|
+
4. **Logs console** - Intercepts console methods to capture debug info
|
|
87
|
+
5. **Maintains context** - Keeps the last N events as breadcrumbs
|
|
88
|
+
6. **Posts errors** - Sends error data with full context to your endpoint
|
|
89
|
+
|
|
90
|
+
## ๐ What Gets Captured
|
|
91
|
+
|
|
92
|
+
### Error Payload Structure
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"type": "uncaught_exception",
|
|
97
|
+
"error": {
|
|
98
|
+
"message": "Error message",
|
|
99
|
+
"source": "file.js",
|
|
100
|
+
"lineno": 42,
|
|
101
|
+
"colno": 15,
|
|
102
|
+
"stack": "Error stack trace..."
|
|
103
|
+
},
|
|
104
|
+
"breadcrumbs": [
|
|
105
|
+
{
|
|
106
|
+
"category": "user",
|
|
107
|
+
"message": "click",
|
|
108
|
+
"data": {
|
|
109
|
+
"element": "BUTTON",
|
|
110
|
+
"id": "submit-btn",
|
|
111
|
+
"className": "btn-primary",
|
|
112
|
+
"x": 100,
|
|
113
|
+
"y": 200
|
|
114
|
+
},
|
|
115
|
+
"timestamp": "2024-01-01T12:00:00.000Z"
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
"timestamp": "2024-01-01T12:00:00.000Z"
|
|
119
|
+
}
|
|
99
120
|
```
|
|
100
|
-
- **Use case**: High-performance applications
|
|
101
|
-
- **Features**: Critical errors only, minimal overhead
|
|
102
|
-
- **Bundle size**: ~25KB
|
|
103
121
|
|
|
104
|
-
|
|
122
|
+
### Breadcrumb Categories
|
|
123
|
+
|
|
124
|
+
- **`user`** - Click events, form submissions, etc.
|
|
125
|
+
- **`http`** - Fetch requests, responses, and errors
|
|
126
|
+
- **`console`** - Console.log, console.error, console.warn
|
|
127
|
+
- **`error`** - Manual error reports
|
|
128
|
+
|
|
129
|
+
## โ๏ธ Configuration Options
|
|
130
|
+
|
|
131
|
+
SyntropyFront uses a priority system for error handling:
|
|
105
132
|
|
|
106
|
-
|
|
133
|
+
1. **Custom Error Handler** (`onError`) - Maximum flexibility
|
|
134
|
+
2. **Endpoint** (`fetch`) - Automatic posting
|
|
135
|
+
3. **Console** - Default fallback
|
|
136
|
+
|
|
137
|
+
### Basic Configuration (Console Only)
|
|
107
138
|
|
|
108
139
|
```javascript
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
name: 'John Doe',
|
|
112
|
-
preferences: { theme: 'dark' }
|
|
140
|
+
syntropyFront.configure({
|
|
141
|
+
maxEvents: 50 // Number of events to keep in memory
|
|
113
142
|
});
|
|
143
|
+
```
|
|
114
144
|
|
|
115
|
-
|
|
116
|
-
userProfile.name = 'Jane Doe';
|
|
117
|
-
userProfile.preferences.theme = 'light';
|
|
145
|
+
### With Endpoint (Automatic Fetch)
|
|
118
146
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
147
|
+
```javascript
|
|
148
|
+
syntropyFront.configure({
|
|
149
|
+
maxEvents: 50,
|
|
150
|
+
fetch: {
|
|
151
|
+
url: 'https://your-api.com/errors',
|
|
152
|
+
options: {
|
|
153
|
+
headers: {
|
|
154
|
+
'Authorization': 'Bearer your-token',
|
|
155
|
+
'X-API-Key': 'your-api-key',
|
|
156
|
+
'Content-Type': 'application/json'
|
|
157
|
+
},
|
|
158
|
+
mode: 'cors',
|
|
159
|
+
credentials: 'include'
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
});
|
|
122
163
|
```
|
|
123
164
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
Offload data processing to Web Workers for non-blocking operation:
|
|
165
|
+
### With Custom Error Handler (Maximum Flexibility)
|
|
127
166
|
|
|
128
167
|
```javascript
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
168
|
+
syntropyFront.configure({
|
|
169
|
+
maxEvents: 50,
|
|
170
|
+
onError: (errorPayload) => {
|
|
171
|
+
// You have complete control over what to do with the error
|
|
172
|
+
|
|
173
|
+
// Send to your API
|
|
174
|
+
fetch('https://your-api.com/errors', {
|
|
175
|
+
method: 'POST',
|
|
176
|
+
body: JSON.stringify(errorPayload)
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// Save to localStorage
|
|
180
|
+
localStorage.setItem('lastError', JSON.stringify(errorPayload));
|
|
181
|
+
|
|
182
|
+
// Send to multiple services
|
|
183
|
+
Promise.all([
|
|
184
|
+
fetch('https://service1.com/errors', { method: 'POST', body: JSON.stringify(errorPayload) }),
|
|
185
|
+
fetch('https://service2.com/errors', { method: 'POST', body: JSON.stringify(errorPayload) })
|
|
186
|
+
]);
|
|
187
|
+
|
|
188
|
+
// Upload to cloud storage
|
|
189
|
+
// Send to repository
|
|
190
|
+
// Log to file
|
|
191
|
+
// Whatever you want!
|
|
192
|
+
}
|
|
133
193
|
});
|
|
134
|
-
|
|
135
|
-
// Check worker status
|
|
136
|
-
const isAvailable = SyntropyFront.isWorkerAvailable();
|
|
137
|
-
const status = SyntropyFront.getWorkerStatus();
|
|
138
194
|
```
|
|
139
195
|
|
|
140
|
-
##
|
|
196
|
+
## ๐ง API Reference
|
|
141
197
|
|
|
142
|
-
|
|
198
|
+
### Core Methods
|
|
143
199
|
|
|
144
200
|
```javascript
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
|
|
201
|
+
// Add custom breadcrumb
|
|
202
|
+
syntropyFront.addBreadcrumb('user', 'Custom action', { data: 'value' });
|
|
203
|
+
|
|
204
|
+
// Send manual error
|
|
205
|
+
syntropyFront.sendError(new Error('Custom error'));
|
|
206
|
+
|
|
207
|
+
// Get current breadcrumbs
|
|
208
|
+
const breadcrumbs = syntropyFront.getBreadcrumbs();
|
|
148
209
|
|
|
149
|
-
//
|
|
150
|
-
|
|
210
|
+
// Clear breadcrumbs
|
|
211
|
+
syntropyFront.clearBreadcrumbs();
|
|
212
|
+
|
|
213
|
+
// Get statistics
|
|
214
|
+
const stats = syntropyFront.getStats();
|
|
215
|
+
// Returns: { breadcrumbs: 5, errors: 2, isActive: true, maxEvents: 50, endpoint: 'console' }
|
|
151
216
|
```
|
|
152
217
|
|
|
153
|
-
##
|
|
218
|
+
## ๐ฏ Extending SyntropyFront
|
|
219
|
+
|
|
220
|
+
SyntropyFront captures the essentials by default, but you can extend it to capture any DOM events you want:
|
|
154
221
|
|
|
155
|
-
|
|
222
|
+
### Adding Custom Event Capture
|
|
156
223
|
|
|
157
224
|
```javascript
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
225
|
+
import syntropyFront from 'syntropyfront';
|
|
226
|
+
|
|
227
|
+
// Add scroll tracking
|
|
228
|
+
window.addEventListener('scroll', () => {
|
|
229
|
+
syntropyFront.addBreadcrumb('user', 'scroll', {
|
|
230
|
+
scrollY: window.scrollY,
|
|
231
|
+
scrollX: window.scrollX
|
|
232
|
+
});
|
|
162
233
|
});
|
|
163
234
|
|
|
164
|
-
//
|
|
165
|
-
|
|
166
|
-
|
|
235
|
+
// Add form submissions
|
|
236
|
+
document.addEventListener('submit', (event) => {
|
|
237
|
+
syntropyFront.addBreadcrumb('user', 'form_submit', {
|
|
238
|
+
formId: event.target.id,
|
|
239
|
+
formAction: event.target.action
|
|
240
|
+
});
|
|
241
|
+
});
|
|
167
242
|
|
|
168
|
-
|
|
243
|
+
// Add window resize
|
|
244
|
+
window.addEventListener('resize', () => {
|
|
245
|
+
syntropyFront.addBreadcrumb('system', 'window_resize', {
|
|
246
|
+
width: window.innerWidth,
|
|
247
|
+
height: window.innerHeight
|
|
248
|
+
});
|
|
249
|
+
});
|
|
169
250
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
agent: { endpoint: 'https://api.com/errors' }
|
|
251
|
+
// Add custom business events
|
|
252
|
+
function trackPurchase(productId, amount) {
|
|
253
|
+
syntropyFront.addBreadcrumb('business', 'purchase', {
|
|
254
|
+
productId,
|
|
255
|
+
amount,
|
|
256
|
+
timestamp: new Date().toISOString()
|
|
177
257
|
});
|
|
178
|
-
}
|
|
258
|
+
}
|
|
179
259
|
```
|
|
180
260
|
|
|
181
|
-
###
|
|
182
|
-
```javascript
|
|
183
|
-
// In your main.js
|
|
184
|
-
import { createApp } from 'vue';
|
|
185
|
-
import App from './App.vue';
|
|
261
|
+
### Common Events You Can Track
|
|
186
262
|
|
|
187
|
-
|
|
263
|
+
- **User interactions**: `click`, `scroll`, `keydown`, `focus`, `blur`
|
|
264
|
+
- **Form events**: `submit`, `input`, `change`, `reset`
|
|
265
|
+
- **System events**: `resize`, `online`, `offline`, `visibilitychange`
|
|
266
|
+
- **Custom events**: Any business logic or user actions
|
|
267
|
+
- **Performance**: `load`, `DOMContentLoaded`, timing events
|
|
188
268
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
agent: { endpoint: 'https://api.com/errors' }
|
|
193
|
-
});
|
|
269
|
+
## ๐ CORS Configuration
|
|
270
|
+
|
|
271
|
+
To use with your API, ensure your server allows CORS:
|
|
194
272
|
|
|
195
|
-
|
|
273
|
+
```javascript
|
|
274
|
+
// Express.js example
|
|
275
|
+
app.use(cors({
|
|
276
|
+
origin: 'http://localhost:3000',
|
|
277
|
+
credentials: true
|
|
278
|
+
}));
|
|
279
|
+
|
|
280
|
+
// Or in headers
|
|
281
|
+
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000');
|
|
282
|
+
res.setHeader('Access-Control-Allow-Methods', 'POST');
|
|
283
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
|
196
284
|
```
|
|
197
285
|
|
|
198
|
-
|
|
199
|
-
```typescript
|
|
200
|
-
// In your main.ts
|
|
201
|
-
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
202
|
-
import { AppModule } from './app/app.module';
|
|
286
|
+
## ๐ฑ Framework Support
|
|
203
287
|
|
|
204
|
-
|
|
205
|
-
SyntropyFront.init({
|
|
206
|
-
preset: 'balanced',
|
|
207
|
-
agent: { endpoint: 'https://api.com/errors' }
|
|
208
|
-
});
|
|
288
|
+
SyntropyFront works with any JavaScript framework:
|
|
209
289
|
|
|
210
|
-
|
|
211
|
-
|
|
290
|
+
- โ
**React** - Works out of the box
|
|
291
|
+
- โ
**Vue** - Works out of the box
|
|
292
|
+
- โ
**Angular** - Works out of the box
|
|
293
|
+
- โ
**Svelte** - Works out of the box
|
|
294
|
+
- โ
**Vanilla JS** - Works out of the box
|
|
212
295
|
|
|
213
|
-
##
|
|
296
|
+
## ๐ฏ Examples
|
|
214
297
|
|
|
215
|
-
###
|
|
216
|
-
|
|
217
|
-
#### `SyntropyFront.init(config)`
|
|
218
|
-
Initialize SyntropyFront with configuration.
|
|
298
|
+
### React Example
|
|
219
299
|
|
|
220
|
-
|
|
221
|
-
|
|
300
|
+
```jsx
|
|
301
|
+
import React from 'react';
|
|
302
|
+
import syntropyFront from 'syntropyfront';
|
|
222
303
|
|
|
223
|
-
|
|
224
|
-
|
|
304
|
+
function App() {
|
|
305
|
+
// SyntropyFront auto-initializes on import
|
|
306
|
+
return (
|
|
307
|
+
<div>
|
|
308
|
+
<button onClick={() => console.log('Button clicked')}>
|
|
309
|
+
Click me!
|
|
310
|
+
</button>
|
|
311
|
+
</div>
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
```
|
|
225
315
|
|
|
226
|
-
|
|
227
|
-
Add a breadcrumb entry.
|
|
316
|
+
### Vue Example
|
|
228
317
|
|
|
229
|
-
|
|
230
|
-
|
|
318
|
+
```vue
|
|
319
|
+
<template>
|
|
320
|
+
<button @click="handleClick">Click me!</button>
|
|
321
|
+
</template>
|
|
231
322
|
|
|
232
|
-
|
|
323
|
+
<script>
|
|
324
|
+
import syntropyFront from 'syntropyfront';
|
|
233
325
|
|
|
234
|
-
|
|
235
|
-
{
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
batchTimeout: 10000,
|
|
240
|
-
batchSize: 20,
|
|
241
|
-
maxRetries: 3,
|
|
242
|
-
usePersistentBuffer: true
|
|
243
|
-
},
|
|
244
|
-
proxyTracking: {
|
|
245
|
-
enabled: true,
|
|
246
|
-
maxStates: 10,
|
|
247
|
-
trackNested: true,
|
|
248
|
-
trackArrays: true
|
|
249
|
-
},
|
|
250
|
-
useWorker: true,
|
|
251
|
-
maxBreadcrumbs: 50,
|
|
252
|
-
context: {
|
|
253
|
-
device: true,
|
|
254
|
-
window: true,
|
|
255
|
-
session: true,
|
|
256
|
-
ui: true,
|
|
257
|
-
network: true
|
|
326
|
+
export default {
|
|
327
|
+
methods: {
|
|
328
|
+
handleClick() {
|
|
329
|
+
console.log('Button clicked');
|
|
330
|
+
}
|
|
258
331
|
}
|
|
259
332
|
}
|
|
333
|
+
</script>
|
|
260
334
|
```
|
|
261
335
|
|
|
262
|
-
|
|
336
|
+
### Manual Error Reporting
|
|
263
337
|
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
npm test
|
|
338
|
+
```javascript
|
|
339
|
+
import syntropyFront from 'syntropyfront';
|
|
267
340
|
|
|
268
|
-
|
|
269
|
-
|
|
341
|
+
try {
|
|
342
|
+
// Your code here
|
|
343
|
+
} catch (error) {
|
|
344
|
+
// SyntropyFront will automatically capture this
|
|
345
|
+
throw error;
|
|
346
|
+
}
|
|
270
347
|
|
|
271
|
-
|
|
272
|
-
|
|
348
|
+
// Or manually report
|
|
349
|
+
syntropyFront.sendError(new Error('Something went wrong'));
|
|
273
350
|
```
|
|
274
351
|
|
|
275
|
-
|
|
352
|
+
### Extending with Custom Events
|
|
276
353
|
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
npm install
|
|
280
|
-
|
|
281
|
-
# Build the package
|
|
282
|
-
npm run build
|
|
354
|
+
```javascript
|
|
355
|
+
import syntropyFront from 'syntropyfront';
|
|
283
356
|
|
|
284
|
-
|
|
285
|
-
|
|
357
|
+
// Add your custom event listeners
|
|
358
|
+
window.addEventListener('scroll', () => {
|
|
359
|
+
syntropyFront.addBreadcrumb('user', 'scroll', {
|
|
360
|
+
scrollY: window.scrollY,
|
|
361
|
+
scrollX: window.scrollX
|
|
362
|
+
});
|
|
363
|
+
});
|
|
286
364
|
|
|
287
|
-
|
|
288
|
-
|
|
365
|
+
// Track business events
|
|
366
|
+
function userCompletedCheckout(orderId, total) {
|
|
367
|
+
syntropyFront.addBreadcrumb('business', 'checkout_completed', {
|
|
368
|
+
orderId,
|
|
369
|
+
total,
|
|
370
|
+
timestamp: new Date().toISOString()
|
|
371
|
+
});
|
|
372
|
+
}
|
|
289
373
|
|
|
290
|
-
|
|
291
|
-
|
|
374
|
+
// Track performance
|
|
375
|
+
window.addEventListener('load', () => {
|
|
376
|
+
syntropyFront.addBreadcrumb('performance', 'page_loaded', {
|
|
377
|
+
loadTime: performance.now()
|
|
378
|
+
});
|
|
379
|
+
});
|
|
292
380
|
```
|
|
293
381
|
|
|
294
|
-
##
|
|
295
|
-
|
|
296
|
-
The build process generates multiple formats:
|
|
382
|
+
## ๐ Debugging
|
|
297
383
|
|
|
298
|
-
|
|
299
|
-
- **CommonJS** (`dist/index.cjs`) - Node.js compatibility
|
|
300
|
-
- **IIFE** (`dist/index.min.js`) - Browser-ready minified bundle
|
|
384
|
+
SyntropyFront logs helpful information to the console:
|
|
301
385
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
4. Add tests
|
|
308
|
-
5. Submit a pull request
|
|
386
|
+
```
|
|
387
|
+
๐ SyntropyFront: Initialized with automatic capture
|
|
388
|
+
โ
SyntropyFront: Configured - maxEvents: 50, endpoint: https://your-api.com/errors
|
|
389
|
+
โ Error: { type: "uncaught_exception", error: {...}, breadcrumbs: [...] }
|
|
390
|
+
```
|
|
309
391
|
|
|
310
392
|
## ๐ License
|
|
311
393
|
|
|
312
|
-
Apache 2.0
|
|
394
|
+
Apache 2.0
|
|
313
395
|
|
|
314
|
-
##
|
|
396
|
+
## ๐ค Contributing
|
|
315
397
|
|
|
316
|
-
|
|
317
|
-
- ๐ [Issues](https://github.com/Syntropysoft/syntropyfront/issues)
|
|
318
|
-
- ๐ฌ [Discussions](https://github.com/Syntropysoft/syntropyfront/discussions)
|
|
398
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
319
399
|
|
|
320
400
|
---
|
|
321
401
|
|
|
322
|
-
Made with โค๏ธ
|
|
402
|
+
**Made with โค๏ธ for better web observability**
|