@vybesec/sdk 0.1.1 → 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 +85 -5
- package/package.json +12 -2
package/README.md
CHANGED
|
@@ -9,16 +9,96 @@ npm install @vybesec/sdk
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
|
-
import {
|
|
12
|
+
import { init, captureError, captureEvent } from "@vybesec/sdk";
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
init({
|
|
15
|
+
key: "pk_xxxxxxxxxxxxxxxx",
|
|
16
|
+
environment: "production",
|
|
17
|
+
platform: "other"
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
captureError(new Error("Something broke"));
|
|
21
|
+
|
|
22
|
+
captureEvent({
|
|
23
|
+
type: "custom",
|
|
24
|
+
message: "Checkout completed",
|
|
25
|
+
timestamp: Date.now(),
|
|
26
|
+
extra: { orderId: "order_123" }
|
|
17
27
|
});
|
|
18
28
|
```
|
|
19
29
|
|
|
20
30
|
## CDN (script tag)
|
|
21
31
|
|
|
22
32
|
```html
|
|
23
|
-
<script src="https://cdn.eazipost.com/v1/sdk.js"
|
|
33
|
+
<script src="https://cdn.eazipost.com/v1/sdk.js"></script>
|
|
34
|
+
<script>
|
|
35
|
+
VybeSec.init({
|
|
36
|
+
key: "pk_xxxxxxxxxxxxxxxx",
|
|
37
|
+
environment: "production"
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
VybeSec.captureError(new Error("Something broke"));
|
|
41
|
+
</script>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Configuration
|
|
45
|
+
|
|
46
|
+
| Option | Type | Description | Default |
|
|
47
|
+
| --- | --- | --- | --- |
|
|
48
|
+
| `key` | `string` | Project public key (DSN key). | **Required** |
|
|
49
|
+
| `environment` | `"production" | "staging" | "development"` | Environment tag. | `"production"` |
|
|
50
|
+
| `platform` | `"lovable" | "cursor" | "replit" | "v0" | "bolt" | "windsurf" | "other"` | AI/dev platform tag. | `"other"` |
|
|
51
|
+
| `release` | `string` | Release identifier. | `""` |
|
|
52
|
+
| `userId` | `string` | User identifier. | `undefined` |
|
|
53
|
+
| `sampleRate` | `number` | 0–1 sampling. | `1` |
|
|
54
|
+
| `maxBuffer` | `number` | Max buffered events. | `100` |
|
|
55
|
+
| `maxEventsPerMinute` | `number` | Client-side rate limit. | `120` |
|
|
56
|
+
| `ingestUrl` | `string` | Override ingest base URL. | VybeSec ingest |
|
|
57
|
+
|
|
58
|
+
## Events
|
|
59
|
+
|
|
60
|
+
### `captureError(error, context?)`
|
|
61
|
+
Sends a normalized error event. Automatically attaches URL, session, environment, and release tags.
|
|
62
|
+
|
|
63
|
+
### `captureEvent(event)`
|
|
64
|
+
Send a custom event. The SDK normalizes and scrubs sensitive values.
|
|
65
|
+
|
|
66
|
+
Supported event shape:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
type RawEvent = {
|
|
70
|
+
type: "error" | "warning" | "info" | "performance" | "custom";
|
|
71
|
+
message: string;
|
|
72
|
+
stackTrace?: string;
|
|
73
|
+
errorType?: string;
|
|
74
|
+
url?: string;
|
|
75
|
+
requestUrl?: string;
|
|
76
|
+
requestMethod?: string;
|
|
77
|
+
responseStatus?: number;
|
|
78
|
+
sessionId?: string;
|
|
79
|
+
userId?: string;
|
|
80
|
+
timestamp: number;
|
|
81
|
+
tags?: Record<string, string>;
|
|
82
|
+
extra?: Record<string, unknown>;
|
|
83
|
+
};
|
|
24
84
|
```
|
|
85
|
+
|
|
86
|
+
## Automatic instrumentation
|
|
87
|
+
|
|
88
|
+
The SDK captures:
|
|
89
|
+
- `window.error` and `unhandledrejection`
|
|
90
|
+
- Failed `fetch` and XHR responses
|
|
91
|
+
- SPA navigation changes
|
|
92
|
+
- Flushes queued events on tab close / hidden
|
|
93
|
+
|
|
94
|
+
## Backward compatibility policy
|
|
95
|
+
|
|
96
|
+
We treat patch and minor releases as backward compatible for the public API:
|
|
97
|
+
- `init`, `captureError`, `captureEvent`, and the global `VybeSec` object
|
|
98
|
+
|
|
99
|
+
Breaking changes will only ship with a major version bump and will be documented in the changelog.
|
|
100
|
+
|
|
101
|
+
## Security & PII
|
|
102
|
+
|
|
103
|
+
The SDK scrubs obvious secrets (API keys, passwords, bearer tokens) before sending events.
|
|
104
|
+
If you need deeper redaction, use a custom `captureEvent` wrapper to scrub payloads before calling the SDK.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vybesec/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -33,5 +33,15 @@
|
|
|
33
33
|
"esbuild": "^0.25.9",
|
|
34
34
|
"tsup": "^8.5.0",
|
|
35
35
|
"typescript": "^5.7.3"
|
|
36
|
-
}
|
|
36
|
+
},
|
|
37
|
+
"description": "VybeSec browser SDK for error and security monitoring.",
|
|
38
|
+
"keywords": [
|
|
39
|
+
"vybesec",
|
|
40
|
+
"error-monitoring",
|
|
41
|
+
"security",
|
|
42
|
+
"observability",
|
|
43
|
+
"sdk",
|
|
44
|
+
"javascript",
|
|
45
|
+
"browser"
|
|
46
|
+
]
|
|
37
47
|
}
|