@watchforge/browser 0.1.0 → 0.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 +32 -112
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -1,142 +1,62 @@
|
|
|
1
|
-
# WatchForge JavaScript SDK
|
|
1
|
+
# WatchForge JavaScript SDK (`@watchforge/browser`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Browser and Node SDK for WatchForge. **One call to `register()`** turns on automatic error reporting—no manual `try/catch` required for typical crashes.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## What this package does *not* require
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- **No Material UI (MUI)** and no other UI library. If `npm install` fails with errors about `@mui/material` or `@mui/lab`, that conflict comes from **your app’s existing dependencies**, not from WatchForge. Fix or align MUI versions in your project, or install with:
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npm install @watchforge/browser --legacy-peer-deps
|
|
11
|
+
```
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
import { register, captureException, captureMessage } from './path/to/sdk/index.js';
|
|
13
|
-
```
|
|
13
|
+
- **React is optional.** It is only needed if you use the React `ErrorBoundary` export from `@watchforge/browser/react`. Plain JavaScript, Vue, Angular, etc. can use the main entry without installing React.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
## Installation
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
npm install @watchforge/browser
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
## Quick
|
|
22
|
-
|
|
23
|
-
```javascript
|
|
24
|
-
import { register, captureException, captureMessage, flush } from '@watchforge/browser';
|
|
25
|
-
|
|
26
|
-
// Initialize the SDK
|
|
27
|
-
register({
|
|
28
|
-
endpoint: "https://PUBLIC_KEY@localhost:8001/PROJECT_ID",
|
|
29
|
-
app_env: "development",
|
|
30
|
-
debug: true // Set to false in production
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// Capture an exception
|
|
34
|
-
try {
|
|
35
|
-
// your code
|
|
36
|
-
} catch (error) {
|
|
37
|
-
captureException(error);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Capture a message
|
|
41
|
-
captureMessage("Something happened", "info");
|
|
42
|
-
|
|
43
|
-
// Manually flush events (optional - auto-flushes after 5s or 10 events)
|
|
44
|
-
flush();
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## API Reference
|
|
21
|
+
## Quick start (all most apps need)
|
|
48
22
|
|
|
49
|
-
|
|
23
|
+
Call **`register()` once** as early as possible (e.g. app entry / main bundle), with your **DSN** from the WatchForge project settings.
|
|
50
24
|
|
|
51
|
-
Initialize the WatchForge SDK.
|
|
52
|
-
|
|
53
|
-
**Parameters:**
|
|
54
|
-
- `endpoint` (string, required): Your WatchForge endpoint URL
|
|
55
|
-
- `app_env` (string, optional): Application environment (default: "production")
|
|
56
|
-
- `debug` (boolean, optional): Enable debug logging (default: false)
|
|
57
|
-
|
|
58
|
-
**Example:**
|
|
59
25
|
```javascript
|
|
26
|
+
import { register } from '@watchforge/browser';
|
|
27
|
+
|
|
60
28
|
register({
|
|
61
|
-
|
|
62
|
-
app_env:
|
|
63
|
-
debug: false
|
|
29
|
+
dsn: 'https://PUBLIC_KEY@your-host/PROJECT_ID',
|
|
30
|
+
app_env: 'production', // e.g. development | staging | production
|
|
31
|
+
debug: false, // true while integrating locally
|
|
64
32
|
});
|
|
65
33
|
```
|
|
66
34
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
Capture an exception/error.
|
|
70
|
-
|
|
71
|
-
**Parameters:**
|
|
72
|
-
- `error` (Error): The error object to capture
|
|
73
|
-
|
|
74
|
-
**Example:**
|
|
75
|
-
```javascript
|
|
76
|
-
try {
|
|
77
|
-
riskyOperation();
|
|
78
|
-
} catch (error) {
|
|
79
|
-
captureException(error);
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### `captureMessage(message, level)`
|
|
84
|
-
|
|
85
|
-
Capture a custom message.
|
|
86
|
-
|
|
87
|
-
**Parameters:**
|
|
88
|
-
- `message` (string): The message to capture
|
|
89
|
-
- `level` (string, optional): Message level - "info", "warning", or "error" (default: "info")
|
|
90
|
-
|
|
91
|
-
**Example:**
|
|
92
|
-
```javascript
|
|
93
|
-
captureMessage("User logged in", "info");
|
|
94
|
-
captureMessage("Rate limit approaching", "warning");
|
|
95
|
-
captureMessage("Critical system failure", "error");
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### `flush()`
|
|
99
|
-
|
|
100
|
-
Manually flush all buffered events to the backend immediately.
|
|
35
|
+
That’s enough for **automatic** reporting in the browser and Node:
|
|
101
36
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
```
|
|
37
|
+
| Where | What gets reported automatically |
|
|
38
|
+
|--------|----------------------------------|
|
|
39
|
+
| **Browser** | Uncaught errors (`window.onerror`), unhandled promise rejections, plus breadcrumbs (console, clicks, navigation) to give context around failures |
|
|
40
|
+
| **Node** | `uncaughtException` and `unhandledRejection` |
|
|
107
41
|
|
|
108
|
-
|
|
42
|
+
You do **not** need to call `captureException` in normal flows—those global handlers already send errors to WatchForge.
|
|
109
43
|
|
|
110
|
-
|
|
111
|
-
- **Unhandled errors** via `window.onerror`
|
|
112
|
-
- **Unhandled promise rejections** via `window.onunhandledrejection`
|
|
44
|
+
## How events reach WatchForge
|
|
113
45
|
|
|
114
|
-
|
|
46
|
+
After `register()`, the SDK buffers events and sends them to your ingestion endpoint derived from the DSN. Failures are grouped and shown in the WatchForge UI like other SDKs.
|
|
115
47
|
|
|
116
|
-
##
|
|
48
|
+
## Optional: copy files instead of npm
|
|
117
49
|
|
|
118
|
-
|
|
119
|
-
- When 10 events accumulate, OR
|
|
120
|
-
- After 5 seconds of inactivity
|
|
50
|
+
You can copy the `src/` folder into your repo and import from your path (same `register` API).
|
|
121
51
|
|
|
122
|
-
|
|
52
|
+
## Advanced (optional APIs)
|
|
123
53
|
|
|
124
|
-
|
|
54
|
+
For manual reporting (handled errors, custom messages, immediate flush), see **`CONFIGURATION_GUIDE.md`** in this repository. The main package also exports `captureException`, `captureMessage`, and `flush` if you need them—**they are not required** for automatic error capture.
|
|
125
55
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
```javascript
|
|
129
|
-
// Old (deprecated)
|
|
130
|
-
init({ dsn: "...", environment: "production" });
|
|
131
|
-
|
|
132
|
-
// New (recommended)
|
|
133
|
-
register({ endpoint: "...", app_env: "production" });
|
|
134
|
-
```
|
|
56
|
+
### Deprecated
|
|
135
57
|
|
|
136
|
-
|
|
58
|
+
`init()` is deprecated; use `register()` with a `dsn` field.
|
|
137
59
|
|
|
138
|
-
|
|
139
|
-
- Firefox (latest)
|
|
140
|
-
- Safari (latest)
|
|
60
|
+
## Browser support
|
|
141
61
|
|
|
142
|
-
|
|
62
|
+
Modern browsers with ES modules. For **React** error boundaries, import from `@watchforge/browser/react`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@watchforge/browser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"description": "WatchForge JavaScript SDK for Node.js, Express.js, and React",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,6 +32,11 @@
|
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": ">=16.8.0"
|
|
34
34
|
},
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"react": {
|
|
37
|
+
"optional": true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
35
40
|
"browser": {
|
|
36
41
|
"http": false,
|
|
37
42
|
"https": false,
|