@tracewayapp/frontend 0.2.0 → 0.3.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 +26 -59
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
# @tracewayapp/frontend
|
|
2
2
|
|
|
3
|
-
Traceway SDK for browser environments.
|
|
3
|
+
Traceway SDK for browser environments. Captures exceptions and messages with automatic batching and retry.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @tracewayapp/frontend
|
|
9
|
+
```
|
|
4
10
|
|
|
5
11
|
## Quick Start
|
|
6
12
|
|
|
7
|
-
```
|
|
8
|
-
import
|
|
13
|
+
```typescript
|
|
14
|
+
import { init, captureException, captureMessage, flush } from "@tracewayapp/frontend";
|
|
9
15
|
|
|
10
|
-
|
|
16
|
+
// Initialize once at app startup
|
|
17
|
+
init("your-token@https://traceway.example.com/api/report");
|
|
11
18
|
|
|
12
|
-
// Capture
|
|
13
|
-
|
|
19
|
+
// Capture errors
|
|
20
|
+
try {
|
|
21
|
+
riskyOperation();
|
|
22
|
+
} catch (error) {
|
|
23
|
+
captureException(error);
|
|
24
|
+
}
|
|
14
25
|
|
|
15
|
-
// Capture
|
|
16
|
-
|
|
26
|
+
// Capture custom messages
|
|
27
|
+
captureMessage("User completed checkout");
|
|
17
28
|
|
|
18
|
-
//
|
|
19
|
-
await
|
|
29
|
+
// Force-send all pending exceptions
|
|
30
|
+
await flush();
|
|
20
31
|
```
|
|
21
32
|
|
|
33
|
+
`init()` automatically installs `window.onerror` and `window.onunhandledrejection` handlers to capture uncaught errors.
|
|
34
|
+
|
|
22
35
|
## API
|
|
23
36
|
|
|
24
37
|
| Function | Description |
|
|
@@ -29,7 +42,7 @@ await traceway.flush();
|
|
|
29
42
|
| `captureMessage(msg)` | Capture an informational message |
|
|
30
43
|
| `flush()` | Force-send all pending exceptions immediately |
|
|
31
44
|
|
|
32
|
-
## Options
|
|
45
|
+
## Configuration Options
|
|
33
46
|
|
|
34
47
|
| Option | Type | Default | Description |
|
|
35
48
|
|--------|------|---------|-------------|
|
|
@@ -37,53 +50,7 @@ await traceway.flush();
|
|
|
37
50
|
| `debounceMs` | `number` | `1500` | Debounce interval before sending |
|
|
38
51
|
| `version` | `string` | `""` | Application version |
|
|
39
52
|
|
|
40
|
-
##
|
|
41
|
-
|
|
42
|
-
```
|
|
43
|
-
captureException()
|
|
44
|
-
|
|
|
45
|
-
v
|
|
46
|
-
pendingExceptions[] --> scheduleSync() (1.5s debounce)
|
|
47
|
-
|
|
|
48
|
-
v (debounce fires)
|
|
49
|
-
doSync()
|
|
50
|
-
|
|
|
51
|
-
+---------+---------+
|
|
52
|
-
| |
|
|
53
|
-
isSyncing? send batch
|
|
54
|
-
| |
|
|
55
|
-
return +-----+-----+
|
|
56
|
-
success failure
|
|
57
|
-
| |
|
|
58
|
-
done re-queue batch
|
|
59
|
-
|
|
|
60
|
-
if pending > 0
|
|
61
|
-
|
|
|
62
|
-
doSync() again
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
- Only one sync at a time (no concurrent fetches)
|
|
66
|
-
- New exceptions during an in-flight request are queued for the next batch
|
|
67
|
-
- On failure, the batch is re-queued at the front of the pending list
|
|
68
|
-
- On success after re-queue, any new pending items trigger an immediate sync
|
|
69
|
-
|
|
70
|
-
## Global Error Handlers
|
|
71
|
-
|
|
72
|
-
`init()` automatically installs `window.onerror` and `window.onunhandledrejection` handlers. Previous handlers are chained and called after Traceway captures the error.
|
|
73
|
-
|
|
74
|
-
## Browser Requirements
|
|
53
|
+
## Requirements
|
|
75
54
|
|
|
76
55
|
- `fetch` API
|
|
77
|
-
- `CompressionStream` API (gzip) —
|
|
78
|
-
|
|
79
|
-
## Stack Trace Format
|
|
80
|
-
|
|
81
|
-
Handles both V8 format (`at func (file:line:col)`) and Firefox format (`func@file:line:col`), producing Go-like output:
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
TypeError: Cannot read properties of null
|
|
85
|
-
handleClick()
|
|
86
|
-
app.js:42
|
|
87
|
-
render()
|
|
88
|
-
component.js:15
|
|
89
|
-
```
|
|
56
|
+
- `CompressionStream` API (gzip) — Chrome 80+, Firefox 113+, Safari 16.4+
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tracewayapp/frontend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Traceway SDK for browser environments",
|
|
5
|
-
"main": "./dist/index.
|
|
6
|
-
"module": "./dist/index.
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.
|
|
12
|
-
"require": "./dist/index.
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"dev": "tsup --watch"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@tracewayapp/core": "0.
|
|
26
|
+
"@tracewayapp/core": "0.3.0"
|
|
27
27
|
}
|
|
28
28
|
}
|