@vigilon/browser 0.0.0-stage → 0.2.9-beta.pr-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/LICENSE +15 -0
- package/README.md +105 -2
- package/dist/index.cjs +736 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +105 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.mjs +703 -0
- package/dist/index.mjs.map +1 -0
- package/dist/vigilon.min.js +8 -0
- package/dist/vigilon.min.js.map +1 -0
- package/package.json +64 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vigilon
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,106 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@vigilon/browser`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Error monitoring for browser applications. Captures uncaught errors and unhandled promise rejections, and errors you report yourself, and sends them to [Vigilon](https://vigilon.io), where they appear on the Errors page as Error Groups with origin `browser`.
|
|
4
|
+
|
|
5
|
+
> **Early access.** Browser error monitoring is not yet generally available. The ingest endpoint accepts events only from projects enabled for early access and answers `403` for the rest, which the SDK does not retry.
|
|
6
|
+
|
|
7
|
+
Zero dependencies, about 5 KB gzipped, and no side effects on import.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @vigilon/browser
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Or load the script-tag build, which exposes `window.Vigilon`:
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<script src="https://unpkg.com/@vigilon/browser@0/dist/vigilon.min.js" crossorigin="anonymous"></script>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Pin an exact version (`@vigilon/browser@0.2.8`) in production so a release never changes your page without a deploy.
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
Create an API key in the [Vigilon dashboard](https://app.vigilon.io) under your project's **Settings** page, **API Keys** tab. Call `init` once, as early as possible in your app's entry point:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { init } from "@vigilon/browser";
|
|
29
|
+
|
|
30
|
+
init({
|
|
31
|
+
apiKey: "your-api-key",
|
|
32
|
+
serviceName: "dashboard",
|
|
33
|
+
environment: "production",
|
|
34
|
+
serviceVersion: "2026.10.26-1",
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The API key ships to every visitor's browser, so treat it as public: it can only send telemetry to its project.
|
|
39
|
+
|
|
40
|
+
`init` returns `false` and logs the reason when it cannot start. During server-side rendering there is no `window`, so `init` and every other function are safe no-ops; you can import the package from code that runs on both sides.
|
|
41
|
+
|
|
42
|
+
Set `serviceVersion` to your release (a build number or commit SHA). Without it, Vigilon cannot tell which release introduced an error, and the SDK warns once.
|
|
43
|
+
|
|
44
|
+
## Reporting errors yourself
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { captureException, setTag, setUser } from "@vigilon/browser";
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
await saveSettings();
|
|
51
|
+
} catch (error) {
|
|
52
|
+
captureException(error); // returns the event ID, or null when it was not sent
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
setUser({ id: "user_8f2c" }); // an opaque ID; never an email address
|
|
56
|
+
setTag("plan", "pro");
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`captureException` accepts any thrown value. Non-`Error` values are recorded with their string or JSON form as the message, and an error's `cause` chain is captured up to five levels.
|
|
60
|
+
|
|
61
|
+
## Configuration
|
|
62
|
+
|
|
63
|
+
| Option | Default | |
|
|
64
|
+
|---|---|---|
|
|
65
|
+
| `apiKey` | required | A project API key. |
|
|
66
|
+
| `serviceName` | required | The Service this app reports as: 1 to 100 letters, digits, and `. _ : / -`. |
|
|
67
|
+
| `environment` | required | The deployment environment, with the same character set. |
|
|
68
|
+
| `serviceVersion` | none | The release. |
|
|
69
|
+
| `endpoint` | `https://ingest.vigilon.io` | The ingest base URL. |
|
|
70
|
+
| `ignoreErrors` | see below | More errors to drop, as strings (substring match) or regular expressions, matched against the message and against `type: message`. |
|
|
71
|
+
| `denyUrls` | see below | More script URLs whose errors are dropped. |
|
|
72
|
+
| `beforeSend` | none | `(event) => event \| null`. Edit or drop each event before it is sent. |
|
|
73
|
+
| `sampleRate` | `1` | The fraction of errors to send. |
|
|
74
|
+
| `maxEventsPerPage` | `100` | At most this many events per page load. |
|
|
75
|
+
| `debug` | `false` | Log SDK diagnostics to the console. |
|
|
76
|
+
|
|
77
|
+
Some noise is dropped by default: `Script error.` (an opaque error from a cross-origin script), failed and aborted network requests (`Failed to fetch`, `NetworkError when attempting to fetch resource`, `Load failed`, `AbortError`), `ResizeObserver loop` warnings, and errors thrown by browser extensions. The same error repeating within a minute is sent once, so an error loop cannot flood your project.
|
|
78
|
+
|
|
79
|
+
`flush()` sends queued events now and `close()` flushes and stops capturing. Both resolve `true` when everything was sent.
|
|
80
|
+
|
|
81
|
+
## Privacy
|
|
82
|
+
|
|
83
|
+
The SDK removes the query string, the fragment, and any `user:password@` from the page URL and from every URL in a stack trace. It drops tags whose key looks like a credential (`password`, `token`, `secret`, `authorization`, `cookie`, and similar), and a `setUser` ID that looks like an email address. The session ID is a random value in `sessionStorage`, one per tab; the SDK sets no cookies. Vigilon applies the same rules again on its side.
|
|
84
|
+
|
|
85
|
+
**Error messages are sent as they are.** A message is free text, so it can contain whatever your code put in it, and Vigilon cannot scrub it reliably. If your messages can carry personal data, scrub them in `beforeSend`:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
init({
|
|
89
|
+
// ...
|
|
90
|
+
beforeSend(event) {
|
|
91
|
+
event.exception.message = event.exception.message.replace(/\S+@\S+/g, "[email]");
|
|
92
|
+
return event;
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Delivery
|
|
98
|
+
|
|
99
|
+
Events are batched and sent with `fetch`. When the page is hidden or unloaded, queued events are sent with `keepalive` so they outlive the page. The SDK retries a request only when the endpoint is rate limiting (`429`), temporarily unavailable (`503`), or unreachable, and honours `Retry-After` by pausing all sends. It gives up on an event after five attempts or 30 minutes after its first attempt.
|
|
100
|
+
|
|
101
|
+
Delivery is **at-least-once with duplicate suppression inside a one-hour window**, not exactly-once: a retry after an ambiguous network failure is recognised and counted once if it arrives within an hour.
|
|
102
|
+
|
|
103
|
+
## Support
|
|
104
|
+
|
|
105
|
+
- Bugs and feature requests: [GitHub Issues](https://github.com/vigilonio/js/issues)
|
|
106
|
+
- Security vulnerabilities: report them privately to [security@vigilon.io](mailto:security@vigilon.io)
|