@bugmail-js/core 0.1.0 → 0.1.3
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 +86 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,3 +1,89 @@
|
|
|
1
|
+
# @bugmail-js/core — Core utilities for BugMail SDKs
|
|
2
|
+
|
|
3
|
+
This package contains framework-agnostic building blocks used by the BugMail JavaScript SDKs (browser, Node, and server integrations).
|
|
4
|
+
|
|
5
|
+
Use this package if you are building a custom integration or need low-level control. It exports small, well-scoped classes for capturing errors, tracking breadcrumbs, and sending reports.
|
|
6
|
+
|
|
7
|
+
Highlights
|
|
8
|
+
- `BugMailCoreClient` — lightweight client that prepares and sends error payloads to the BugMail backend.
|
|
9
|
+
- `BreadcrumbTracker` — record user events leading up to an error.
|
|
10
|
+
- `CoreNetworkManager`, `CoreErrorProcessor` — helpers for networking and normalization.
|
|
11
|
+
|
|
12
|
+
Installation
|
|
13
|
+
|
|
14
|
+
Typically you do not need to install this directly; other SDK packages depend on it. If you need it directly:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @bugmail-js/core
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Quick example (capture an exception)
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
import { BugMailCoreClient } from '@bugmail-js/core';
|
|
24
|
+
|
|
25
|
+
const client = new BugMailCoreClient({
|
|
26
|
+
baseUrl: 'http://localhost:8000',
|
|
27
|
+
apiPath: '/api/sdk/v1/errors',
|
|
28
|
+
onError: (info) => console.warn('Reporting failed', info),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
await client.captureException(new Error('Test error'), {
|
|
32
|
+
headers: { 'X-Bugmail-Api-Key': 'YOUR_PROJECT_API_KEY' },
|
|
33
|
+
payload: {
|
|
34
|
+
error: { name: 'Error', message: 'Test error', stack: '...' },
|
|
35
|
+
context: { url: '/test', environment: 'development' }
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
API reference (important parts)
|
|
41
|
+
|
|
42
|
+
- `new BugMailCoreClient(config)`
|
|
43
|
+
- `config.baseUrl` — backend base URL (default: env `BUGMAIL_API_BASE_URL` or `http://localhost:8000`)
|
|
44
|
+
- `config.apiPath` — ingestion path (default: `/api/sdk/v1/errors`)
|
|
45
|
+
- `config.onError` — optional callback invoked when report fails
|
|
46
|
+
|
|
47
|
+
- `captureException(error, context)`
|
|
48
|
+
- `error` — Error object or any serializable value
|
|
49
|
+
- `context` — optional object: `{ headers, payload, user, breadcrumbs }`
|
|
50
|
+
- Include `headers: { 'X-Bugmail-Api-Key': '<YOUR_PROJECT_API_KEY>' }`
|
|
51
|
+
|
|
52
|
+
- `BreadcrumbTracker`
|
|
53
|
+
- `new BreadcrumbTracker({ maxBreadcrumbs })`
|
|
54
|
+
- `record(breadcrumb)` — add a breadcrumb object
|
|
55
|
+
- `recordCustom(message, category, data, level)`
|
|
56
|
+
- `recordRequest(requestData)` — convenience for HTTP breadcrumbs
|
|
57
|
+
- `getBreadcrumbs()`, `clear()`
|
|
58
|
+
|
|
59
|
+
Advanced
|
|
60
|
+
|
|
61
|
+
- `CoreNetworkManager` and `CoreErrorProcessor` are exported for advanced integration points (custom retries, queueing, or server-side normalization).
|
|
62
|
+
|
|
63
|
+
Integration notes
|
|
64
|
+
|
|
65
|
+
- The core package is intentionally minimal and has no browser-only dependencies. Browser and Node SDKs re-export and extend it with environment-specific behavior (automatic capture, global handlers, middleware, etc.).
|
|
66
|
+
|
|
67
|
+
Backend integration & headers
|
|
68
|
+
|
|
69
|
+
- Ingestion endpoint: `POST {baseUrl}/api/sdk/v1/errors`
|
|
70
|
+
- Auth header: `x-bugmail-api-key: <YOUR_PROJECT_API_KEY>` (case-insensitive)
|
|
71
|
+
- Typical payload shape:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
{
|
|
75
|
+
"error": { "name": "TypeError", "message": "...", "stack": "..." },
|
|
76
|
+
"context": { "breadcrumbs": [...], "request": { ... } },
|
|
77
|
+
"timestamp": "2025-09-06T15:40:00.000Z",
|
|
78
|
+
"environment": "production"
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The backend validates the API key, groups the error, stores breadcrumbs, enforces rate/plan limits, may run AI analysis, and returns `201` with `{ status: "success", error_id: "..." }`.
|
|
83
|
+
|
|
84
|
+
Contributing
|
|
85
|
+
|
|
86
|
+
Please follow the repository contributing guidelines. Tests and simple usage examples are appreciated.
|
|
1
87
|
# Shared core logic for BugMail SDKs
|
|
2
88
|
|
|
3
89
|
This package will contain shared logic for Node.js and Django SDKs.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bugmail-js/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"exports": {
|
|
@@ -35,4 +35,4 @@
|
|
|
35
35
|
"url": "https://github.com/MarcorpAI/Bugmail-SDKs/issues"
|
|
36
36
|
},
|
|
37
37
|
"sideEffects": false
|
|
38
|
-
}
|
|
38
|
+
}
|