@absolutejs/beacon 0.0.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 +94 -0
- package/README.md +98 -0
- package/dist/index.d.ts +137 -0
- package/dist/index.js +297 -0
- package/dist/index.js.map +10 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
**Licensor:** Alex Kahn
|
|
4
|
+
|
|
5
|
+
**Licensed Work:** @absolutejs/beacon (https://github.com/absolutejs/beacon)
|
|
6
|
+
|
|
7
|
+
**Change Date:** June 24, 2030
|
|
8
|
+
|
|
9
|
+
**Change License:** Apache License, Version 2.0
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Terms
|
|
14
|
+
|
|
15
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
16
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
17
|
+
Licensor may make an Additional Use Grant, permitting limited production use.
|
|
18
|
+
|
|
19
|
+
### Additional Use Grant
|
|
20
|
+
|
|
21
|
+
You may use the Licensed Work in production, provided your use does not include
|
|
22
|
+
any of the following:
|
|
23
|
+
|
|
24
|
+
1. **Offering a Competing Service.** You may not offer the Licensed Work, or
|
|
25
|
+
any derivative or substantial portion of it, to third parties as a hosted or
|
|
26
|
+
managed error-tracking, exception-monitoring, crash-reporting, session-replay,
|
|
27
|
+
or real-user-monitoring (RUM) service that competes with hosted observability
|
|
28
|
+
offerings (including, but not limited to, Sentry, Datadog, LogRocket, Bugsnag,
|
|
29
|
+
Rollbar, Honeybadger, Airbrake, Raygun, TrackJS, AppSignal, New Relic Browser,
|
|
30
|
+
FullStory, Highlight, or any similar hosted offering whose primary value to its
|
|
31
|
+
users is capturing client-side errors, breadcrumbs, or sessions from end-user
|
|
32
|
+
browsers). This includes any product whose primary value to its users is the
|
|
33
|
+
functionality the Licensed Work provides.
|
|
34
|
+
|
|
35
|
+
2. **Resale or Redistribution as a Standalone Product.** You may not sell,
|
|
36
|
+
license, or distribute the Licensed Work, or any derivative or fork of it,
|
|
37
|
+
as a standalone commercial product.
|
|
38
|
+
|
|
39
|
+
3. **Removal of Attribution.** Any derivative work, fork, or redistribution of
|
|
40
|
+
the Licensed Work must prominently credit AbsoluteJS and include a link to
|
|
41
|
+
the original project repository (https://github.com/absolutejs/beacon).
|
|
42
|
+
|
|
43
|
+
For clarity, the following uses are expressly permitted:
|
|
44
|
+
|
|
45
|
+
- Using the Licensed Work to capture errors from your own applications,
|
|
46
|
+
websites, internal tools, or SaaS products (whether commercial or non-
|
|
47
|
+
commercial), so long as the Licensed Work itself is not the primary product
|
|
48
|
+
you are selling.
|
|
49
|
+
- Using the Licensed Work as a dependency in commercial software you build and
|
|
50
|
+
sell, as long as the software is not itself a competing hosted observability
|
|
51
|
+
service of the kind described in clause 1.
|
|
52
|
+
- Providing consulting, development, or professional services to clients using
|
|
53
|
+
the Licensed Work.
|
|
54
|
+
- Forking and modifying the Licensed Work for your own internal use, provided
|
|
55
|
+
attribution is maintained.
|
|
56
|
+
|
|
57
|
+
### Change Date and Change License
|
|
58
|
+
|
|
59
|
+
On the Change Date specified above, or on such other date as the Licensor may
|
|
60
|
+
specify by written notice, the Licensed Work will be made available under the
|
|
61
|
+
Change License (Apache License, Version 2.0). Until the Change Date, the terms
|
|
62
|
+
of this Business Source License 1.1 apply.
|
|
63
|
+
|
|
64
|
+
### Trademark
|
|
65
|
+
|
|
66
|
+
This license does not grant you any rights to use the "AbsoluteJS" or
|
|
67
|
+
"@absolutejs" name, logo, or any related trademarks. Forks and derivative works
|
|
68
|
+
must not be named or branded in a manner that suggests endorsement by or
|
|
69
|
+
affiliation with AbsoluteJS or the Licensor.
|
|
70
|
+
|
|
71
|
+
### Notices
|
|
72
|
+
|
|
73
|
+
You must not remove or obscure any licensing, copyright, or other notices
|
|
74
|
+
included in the Licensed Work.
|
|
75
|
+
|
|
76
|
+
### No Warranty
|
|
77
|
+
|
|
78
|
+
THE LICENSED WORK IS PROVIDED "AS IS". THE LICENSOR HEREBY DISCLAIMS ALL
|
|
79
|
+
WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
|
|
80
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO
|
|
81
|
+
EVENT SHALL THE LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY,
|
|
82
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR
|
|
83
|
+
IN CONNECTION WITH THE LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE
|
|
84
|
+
LICENSED WORK.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Contact
|
|
89
|
+
|
|
90
|
+
For commercial licensing inquiries or additional permissions, contact:
|
|
91
|
+
|
|
92
|
+
- **Alex Kahn**
|
|
93
|
+
- alexkahndev@gmail.com
|
|
94
|
+
- alexkahndev.github.io
|
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# @absolutejs/beacon
|
|
2
|
+
|
|
3
|
+
> Tiny, zero-dependency browser SDK for the AbsoluteJS observability stack.
|
|
4
|
+
> **~2 KB gzipped.**
|
|
5
|
+
|
|
6
|
+
Captures uncaught errors + unhandled rejections, records breadcrumbs
|
|
7
|
+
(console / click / fetch / navigation), batches, and POSTs an envelope to
|
|
8
|
+
[`@absolutejs/errors/ingest`](https://www.npmjs.com/package/@absolutejs/errors)
|
|
9
|
+
via `navigator.sendBeacon` / `fetch` keepalive.
|
|
10
|
+
|
|
11
|
+
## Why it's not Effect-native (on purpose)
|
|
12
|
+
|
|
13
|
+
A browser SDK loads on **every page for every user**, so bytes are the dominant
|
|
14
|
+
cost. Measured: an Effect-native client is **~108 KB gz**; this is **~2 KB gz**.
|
|
15
|
+
The client has no trust boundary — it's a dumb producer of telemetry — so the
|
|
16
|
+
Effect/Schema rigor lives **server-side** in `@absolutejs/errors/ingest`, which
|
|
17
|
+
validates the untrusted POST body.
|
|
18
|
+
|
|
19
|
+
You lose nothing on type safety: the envelope is **contract-locked** to the
|
|
20
|
+
ingest endpoint's accepted shape by a compile-time assertion (the type spans the
|
|
21
|
+
wire; the runtime machinery does not). Change the shape on either side and the
|
|
22
|
+
build breaks.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
bun add @absolutejs/beacon
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Zero runtime dependencies.
|
|
31
|
+
|
|
32
|
+
## Quick start
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { initBeacon, captureException } from "@absolutejs/beacon";
|
|
36
|
+
|
|
37
|
+
initBeacon({
|
|
38
|
+
project: "web",
|
|
39
|
+
endpoint: "https://api.example.com/ingest",
|
|
40
|
+
release: import.meta.env.VITE_RELEASE,
|
|
41
|
+
environment: "production",
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Uncaught errors + unhandled rejections are captured automatically.
|
|
45
|
+
// Manual capture anywhere:
|
|
46
|
+
try {
|
|
47
|
+
await checkout();
|
|
48
|
+
} catch (e) {
|
|
49
|
+
captureException(e, { tags: { component: "billing" } });
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Or hold an instance instead of the global:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { createBeacon } from "@absolutejs/beacon";
|
|
57
|
+
const beacon = createBeacon({ project: "web" });
|
|
58
|
+
beacon.setUser({ id: currentUserId });
|
|
59
|
+
beacon.captureMessage("checkout started", "info");
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## What it does
|
|
63
|
+
|
|
64
|
+
- **Auto-capture** — `window.onerror` + `unhandledrejection` (toggle via `instrument`).
|
|
65
|
+
- **Breadcrumbs** — `console.error`/`warn`, clicks, `fetch` (skipping its own
|
|
66
|
+
ingest endpoint), and SPA navigations, in a ring buffer attached to each event.
|
|
67
|
+
- **Batching** — buffers up to `maxBatch` (default 30) / `flushIntervalMs`
|
|
68
|
+
(default 5s); flushes reliably on `pagehide` / tab-hidden via `sendBeacon`.
|
|
69
|
+
- **Context** — `setTags`, `setUser`, per-call `tags`/`extra`, a per-session id.
|
|
70
|
+
- **Sampling + redaction** — `sampleRate` and a `beforeSend(event)` hook
|
|
71
|
+
(return `null` to drop).
|
|
72
|
+
- **Replay seam** — `getReplayId()` stamps each event with the active
|
|
73
|
+
session-replay id (wired by `@absolutejs/replay`).
|
|
74
|
+
|
|
75
|
+
## API
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
createBeacon(options) => Beacon
|
|
79
|
+
initBeacon(options) => Beacon // also sets the global singleton
|
|
80
|
+
getBeacon() => Beacon | undefined
|
|
81
|
+
|
|
82
|
+
// Beacon:
|
|
83
|
+
captureException(error, { level?, tags?, extra? })
|
|
84
|
+
captureMessage(message, level?)
|
|
85
|
+
addBreadcrumb({ message, type?, data? })
|
|
86
|
+
setTags(tags) · setUser(user | null)
|
|
87
|
+
flush() => Promise<void> // buffered events out now
|
|
88
|
+
close() => Promise<void> // remove listeners + final flush
|
|
89
|
+
|
|
90
|
+
// Global helpers (no-op until initBeacon): captureException, captureMessage, addBreadcrumb
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
SSR-safe: imported in a non-DOM environment, `createBeacon` returns a no-op.
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
BSL-1.1 with a named carveout against hosted error-tracking / session-replay
|
|
98
|
+
SaaS (Sentry, Datadog, LogRocket). See `LICENSE`.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @absolutejs/beacon — tiny, zero-dependency browser SDK for the AbsoluteJS
|
|
3
|
+
* observability stack.
|
|
4
|
+
*
|
|
5
|
+
* It is deliberately NOT Effect-native: a browser SDK loads on every page for
|
|
6
|
+
* every user, so bytes are the dominant cost (measured: an Effect client is
|
|
7
|
+
* ~108 KB gz; this is ~2-5 KB gz). The client has no trust boundary — it's a
|
|
8
|
+
* dumb producer of telemetry — so the Effect/Schema rigor lives server-side in
|
|
9
|
+
* `@absolutejs/errors/ingest`, which validates the untrusted POST body.
|
|
10
|
+
*
|
|
11
|
+
* Type safety is preserved end-to-end WITHOUT shipping Effect: the envelope
|
|
12
|
+
* type below is contract-locked to the ingest endpoint's accepted shape by a
|
|
13
|
+
* compile-time assertion in tests (`tests/contract.test.ts`). The type spans
|
|
14
|
+
* the wire; the runtime machinery does not.
|
|
15
|
+
*
|
|
16
|
+
* captureException / global handlers
|
|
17
|
+
* → enrich (breadcrumbs, tags, context, replayId)
|
|
18
|
+
* → batch
|
|
19
|
+
* → flush: POST envelope to /ingest via sendBeacon / fetch keepalive
|
|
20
|
+
*/
|
|
21
|
+
export type BeaconLevel = "fatal" | "error" | "warning" | "info";
|
|
22
|
+
export type Breadcrumb = {
|
|
23
|
+
/** `Date.now()` when recorded. */
|
|
24
|
+
at: number;
|
|
25
|
+
type: "console" | "click" | "navigation" | "fetch" | "custom";
|
|
26
|
+
message: string;
|
|
27
|
+
data?: Record<string, unknown>;
|
|
28
|
+
};
|
|
29
|
+
/** One captured occurrence — structurally the ingest endpoint's `BeaconEvent`. */
|
|
30
|
+
export type BeaconEvent = {
|
|
31
|
+
name: string;
|
|
32
|
+
message: string;
|
|
33
|
+
level?: BeaconLevel;
|
|
34
|
+
stack?: string;
|
|
35
|
+
at?: number;
|
|
36
|
+
traceId?: string;
|
|
37
|
+
spanId?: string;
|
|
38
|
+
replayId?: string;
|
|
39
|
+
tags?: Record<string, string>;
|
|
40
|
+
extra?: Record<string, unknown>;
|
|
41
|
+
};
|
|
42
|
+
/** The POST body — structurally the ingest endpoint's `BeaconEnvelope`. */
|
|
43
|
+
export type BeaconEnvelope = {
|
|
44
|
+
v: 1;
|
|
45
|
+
project: string;
|
|
46
|
+
release?: string;
|
|
47
|
+
environment?: string;
|
|
48
|
+
events: BeaconEvent[];
|
|
49
|
+
};
|
|
50
|
+
export type CaptureContext = {
|
|
51
|
+
level?: BeaconLevel;
|
|
52
|
+
tags?: Record<string, string>;
|
|
53
|
+
extra?: Record<string, unknown>;
|
|
54
|
+
};
|
|
55
|
+
/** Pluggable wire transport — injectable for tests / custom auth / proxies. */
|
|
56
|
+
export type BeaconTransport = (request: {
|
|
57
|
+
url: string;
|
|
58
|
+
body: string;
|
|
59
|
+
key?: string;
|
|
60
|
+
/** True on unload-time flushes — prefer `navigator.sendBeacon`. */
|
|
61
|
+
useBeacon: boolean;
|
|
62
|
+
}) => void | Promise<void>;
|
|
63
|
+
export type BeaconInstrumentation = {
|
|
64
|
+
/** `window.onerror` / `error` events. Default true. */
|
|
65
|
+
globalErrors?: boolean;
|
|
66
|
+
/** `unhandledrejection` events. Default true. */
|
|
67
|
+
unhandledRejections?: boolean;
|
|
68
|
+
/** Breadcrumb `console.error` / `console.warn`. Default true. */
|
|
69
|
+
console?: boolean;
|
|
70
|
+
/** Breadcrumb document clicks. Default true. */
|
|
71
|
+
clicks?: boolean;
|
|
72
|
+
/** Breadcrumb `fetch` calls. Default true. */
|
|
73
|
+
fetch?: boolean;
|
|
74
|
+
/** Breadcrumb SPA navigations (`pushState`/`replaceState`/`popstate`). Default true. */
|
|
75
|
+
history?: boolean;
|
|
76
|
+
};
|
|
77
|
+
export type BeaconOptions = {
|
|
78
|
+
/** Project id (required) — scopes issues server-side. */
|
|
79
|
+
project: string;
|
|
80
|
+
/** Ingest endpoint URL. Default `/ingest`. */
|
|
81
|
+
endpoint?: string;
|
|
82
|
+
release?: string;
|
|
83
|
+
environment?: string;
|
|
84
|
+
/** Auth key, sent as `x-beacon-key` (forces `fetch` over `sendBeacon`). */
|
|
85
|
+
key?: string;
|
|
86
|
+
/** Auto-flush once this many events are buffered. Default 30. */
|
|
87
|
+
maxBatch?: number;
|
|
88
|
+
/** Auto-flush interval (ms). Default 5000. */
|
|
89
|
+
flushIntervalMs?: number;
|
|
90
|
+
/** Breadcrumbs retained (ring buffer). Default 30. */
|
|
91
|
+
maxBreadcrumbs?: number;
|
|
92
|
+
/** Sample rate 0..1 — fraction of events kept. Default 1. */
|
|
93
|
+
sampleRate?: number;
|
|
94
|
+
/** Mutate or drop (return null) each event before it's buffered. */
|
|
95
|
+
beforeSend?: (event: BeaconEvent) => BeaconEvent | null;
|
|
96
|
+
/** Supply the active session-replay id (wired by @absolutejs/replay). */
|
|
97
|
+
getReplayId?: () => string | undefined;
|
|
98
|
+
/** Auto-instrumentation toggles (all default true). */
|
|
99
|
+
instrument?: BeaconInstrumentation;
|
|
100
|
+
/** Override the wire transport (default: sendBeacon / fetch keepalive). */
|
|
101
|
+
transport?: BeaconTransport;
|
|
102
|
+
};
|
|
103
|
+
export type Beacon = {
|
|
104
|
+
captureException: (error: unknown, context?: CaptureContext) => void;
|
|
105
|
+
captureMessage: (message: string, level?: BeaconLevel) => void;
|
|
106
|
+
addBreadcrumb: (crumb: {
|
|
107
|
+
message: string;
|
|
108
|
+
type?: Breadcrumb["type"];
|
|
109
|
+
data?: Record<string, unknown>;
|
|
110
|
+
}) => void;
|
|
111
|
+
/** Merge persistent tags applied to every subsequent event. */
|
|
112
|
+
setTags: (tags: Record<string, string>) => void;
|
|
113
|
+
/** Set (or clear, with null) the user attached to events. */
|
|
114
|
+
setUser: (user: {
|
|
115
|
+
id?: string;
|
|
116
|
+
email?: string;
|
|
117
|
+
} | null) => void;
|
|
118
|
+
/** Flush buffered events now. */
|
|
119
|
+
flush: () => Promise<void>;
|
|
120
|
+
/** Remove all listeners + do a final flush. */
|
|
121
|
+
close: () => Promise<void>;
|
|
122
|
+
};
|
|
123
|
+
export declare const createBeacon: (options: BeaconOptions) => Beacon;
|
|
124
|
+
/** Initialize the global beacon. Returns the instance. */
|
|
125
|
+
export declare const initBeacon: (options: BeaconOptions) => Beacon;
|
|
126
|
+
/** The global beacon, if `initBeacon` has been called. */
|
|
127
|
+
export declare const getBeacon: () => Beacon | undefined;
|
|
128
|
+
/** Capture against the global beacon (no-op if uninitialized). */
|
|
129
|
+
export declare const captureException: (error: unknown, context?: CaptureContext) => void;
|
|
130
|
+
/** Capture a message against the global beacon (no-op if uninitialized). */
|
|
131
|
+
export declare const captureMessage: (message: string, level?: BeaconLevel) => void;
|
|
132
|
+
/** Add a breadcrumb to the global beacon (no-op if uninitialized). */
|
|
133
|
+
export declare const addBreadcrumb: (crumb: {
|
|
134
|
+
message: string;
|
|
135
|
+
type?: Breadcrumb["type"];
|
|
136
|
+
data?: Record<string, unknown>;
|
|
137
|
+
}) => void;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var inBrowser = () => typeof window !== "undefined";
|
|
3
|
+
var newId = () => {
|
|
4
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
5
|
+
return crypto.randomUUID();
|
|
6
|
+
}
|
|
7
|
+
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
8
|
+
};
|
|
9
|
+
var toError = (value) => {
|
|
10
|
+
if (value instanceof Error)
|
|
11
|
+
return value;
|
|
12
|
+
if (typeof value === "string")
|
|
13
|
+
return new Error(value);
|
|
14
|
+
if (typeof value === "object" && value !== null) {
|
|
15
|
+
const object = value;
|
|
16
|
+
const message = typeof object.message === "string" ? object.message : safeStringify(value);
|
|
17
|
+
const error = new Error(message);
|
|
18
|
+
if (typeof object.name === "string")
|
|
19
|
+
error.name = object.name;
|
|
20
|
+
return error;
|
|
21
|
+
}
|
|
22
|
+
return new Error(String(value));
|
|
23
|
+
};
|
|
24
|
+
var safeStringify = (value) => {
|
|
25
|
+
try {
|
|
26
|
+
return JSON.stringify(value) ?? String(value);
|
|
27
|
+
} catch {
|
|
28
|
+
return String(value);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var describeElement = (element) => {
|
|
32
|
+
const tag = element.tagName.toLowerCase();
|
|
33
|
+
const id = element.id ? `#${element.id}` : "";
|
|
34
|
+
const cls = typeof element.className === "string" && element.className.trim() !== "" ? `.${element.className.trim().split(/\s+/).slice(0, 2).join(".")}` : "";
|
|
35
|
+
return `${tag}${id}${cls}`;
|
|
36
|
+
};
|
|
37
|
+
var noopBeacon = {
|
|
38
|
+
addBreadcrumb: () => {},
|
|
39
|
+
captureException: () => {},
|
|
40
|
+
captureMessage: () => {},
|
|
41
|
+
close: async () => {},
|
|
42
|
+
flush: async () => {},
|
|
43
|
+
setTags: () => {},
|
|
44
|
+
setUser: () => {}
|
|
45
|
+
};
|
|
46
|
+
var defaultTransport = ({ url, body, key, useBeacon }) => {
|
|
47
|
+
if (typeof navigator === "undefined")
|
|
48
|
+
return;
|
|
49
|
+
if (useBeacon && key === undefined && typeof navigator.sendBeacon === "function") {
|
|
50
|
+
navigator.sendBeacon(url, new Blob([body], { type: "application/json" }));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (typeof fetch === "function") {
|
|
54
|
+
fetch(url, {
|
|
55
|
+
body,
|
|
56
|
+
headers: {
|
|
57
|
+
"content-type": "application/json",
|
|
58
|
+
...key !== undefined ? { "x-beacon-key": key } : {}
|
|
59
|
+
},
|
|
60
|
+
keepalive: true,
|
|
61
|
+
method: "POST"
|
|
62
|
+
}).catch(() => {});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var createBeacon = (options) => {
|
|
66
|
+
if (!inBrowser())
|
|
67
|
+
return noopBeacon;
|
|
68
|
+
const endpoint = options.endpoint ?? "/ingest";
|
|
69
|
+
const maxBatch = options.maxBatch ?? 30;
|
|
70
|
+
const flushIntervalMs = options.flushIntervalMs ?? 5000;
|
|
71
|
+
const maxBreadcrumbs = options.maxBreadcrumbs ?? 30;
|
|
72
|
+
const sampleRate = options.sampleRate ?? 1;
|
|
73
|
+
const transport = options.transport ?? defaultTransport;
|
|
74
|
+
const instrument = options.instrument ?? {};
|
|
75
|
+
const sessionId = newId();
|
|
76
|
+
const buffer = [];
|
|
77
|
+
const breadcrumbs = [];
|
|
78
|
+
const cleanups = [];
|
|
79
|
+
let tags = {};
|
|
80
|
+
let user;
|
|
81
|
+
const flush = async (useBeacon = false) => {
|
|
82
|
+
if (buffer.length === 0)
|
|
83
|
+
return;
|
|
84
|
+
const events = buffer.splice(0, buffer.length);
|
|
85
|
+
const envelope = {
|
|
86
|
+
events,
|
|
87
|
+
project: options.project,
|
|
88
|
+
v: 1,
|
|
89
|
+
...options.release !== undefined ? { release: options.release } : {},
|
|
90
|
+
...options.environment !== undefined ? { environment: options.environment } : {}
|
|
91
|
+
};
|
|
92
|
+
await transport({
|
|
93
|
+
body: JSON.stringify(envelope),
|
|
94
|
+
url: endpoint,
|
|
95
|
+
useBeacon,
|
|
96
|
+
...options.key !== undefined ? { key: options.key } : {}
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
const addBreadcrumb = (crumb) => {
|
|
100
|
+
breadcrumbs.push({
|
|
101
|
+
at: Date.now(),
|
|
102
|
+
message: crumb.message.slice(0, 200),
|
|
103
|
+
type: crumb.type ?? "custom",
|
|
104
|
+
...crumb.data !== undefined ? { data: crumb.data } : {}
|
|
105
|
+
});
|
|
106
|
+
while (breadcrumbs.length > maxBreadcrumbs)
|
|
107
|
+
breadcrumbs.shift();
|
|
108
|
+
};
|
|
109
|
+
const enrich = (event) => {
|
|
110
|
+
if (sampleRate < 1 && Math.random() > sampleRate)
|
|
111
|
+
return null;
|
|
112
|
+
const enriched = { ...event, at: event.at ?? Date.now() };
|
|
113
|
+
const replayId = options.getReplayId?.();
|
|
114
|
+
if (replayId !== undefined)
|
|
115
|
+
enriched.replayId = replayId;
|
|
116
|
+
const mergedTags = { ...tags, ...event.tags };
|
|
117
|
+
if (Object.keys(mergedTags).length > 0)
|
|
118
|
+
enriched.tags = mergedTags;
|
|
119
|
+
const extra = { sessionId, ...event.extra };
|
|
120
|
+
if (breadcrumbs.length > 0)
|
|
121
|
+
extra.breadcrumbs = [...breadcrumbs];
|
|
122
|
+
if (user !== undefined)
|
|
123
|
+
extra.user = user;
|
|
124
|
+
enriched.extra = extra;
|
|
125
|
+
return options.beforeSend !== undefined ? options.beforeSend(enriched) : enriched;
|
|
126
|
+
};
|
|
127
|
+
const push = (event) => {
|
|
128
|
+
const enriched = enrich(event);
|
|
129
|
+
if (enriched === null)
|
|
130
|
+
return;
|
|
131
|
+
buffer.push(enriched);
|
|
132
|
+
if (buffer.length >= maxBatch)
|
|
133
|
+
flush();
|
|
134
|
+
};
|
|
135
|
+
const captureException = (error, context = {}) => {
|
|
136
|
+
const resolved = toError(error);
|
|
137
|
+
const event = {
|
|
138
|
+
level: context.level ?? "error",
|
|
139
|
+
message: resolved.message,
|
|
140
|
+
name: resolved.name
|
|
141
|
+
};
|
|
142
|
+
if (resolved.stack !== undefined)
|
|
143
|
+
event.stack = resolved.stack;
|
|
144
|
+
if (context.tags !== undefined)
|
|
145
|
+
event.tags = context.tags;
|
|
146
|
+
if (context.extra !== undefined)
|
|
147
|
+
event.extra = context.extra;
|
|
148
|
+
push(event);
|
|
149
|
+
};
|
|
150
|
+
const captureMessage = (message, level = "info") => {
|
|
151
|
+
push({ level, message, name: "Message" });
|
|
152
|
+
};
|
|
153
|
+
if (instrument.globalErrors !== false) {
|
|
154
|
+
const onError = (event) => {
|
|
155
|
+
const error = event.error instanceof Error ? event.error : new Error(event.message || "Uncaught error");
|
|
156
|
+
captureException(error, { level: "error" });
|
|
157
|
+
};
|
|
158
|
+
window.addEventListener("error", onError, true);
|
|
159
|
+
cleanups.push(() => window.removeEventListener("error", onError, true));
|
|
160
|
+
}
|
|
161
|
+
if (instrument.unhandledRejections !== false) {
|
|
162
|
+
const onRejection = (event) => {
|
|
163
|
+
const reason = event.reason;
|
|
164
|
+
if (reason instanceof Error) {
|
|
165
|
+
captureException(reason, { level: "error" });
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const error = new Error(typeof reason === "string" ? reason : safeStringify(reason));
|
|
169
|
+
error.name = "UnhandledRejection";
|
|
170
|
+
captureException(error, { level: "error" });
|
|
171
|
+
};
|
|
172
|
+
window.addEventListener("unhandledrejection", onRejection);
|
|
173
|
+
cleanups.push(() => window.removeEventListener("unhandledrejection", onRejection));
|
|
174
|
+
}
|
|
175
|
+
if (instrument.console !== false && typeof console !== "undefined") {
|
|
176
|
+
for (const method of ["error", "warn"]) {
|
|
177
|
+
const original = console[method];
|
|
178
|
+
console[method] = (...args) => {
|
|
179
|
+
addBreadcrumb({
|
|
180
|
+
message: `console.${method}: ${args.map(String).join(" ")}`,
|
|
181
|
+
type: "console"
|
|
182
|
+
});
|
|
183
|
+
original.apply(console, args);
|
|
184
|
+
};
|
|
185
|
+
cleanups.push(() => {
|
|
186
|
+
console[method] = original;
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (instrument.clicks !== false && typeof document !== "undefined") {
|
|
191
|
+
const onClick = (event) => {
|
|
192
|
+
const target = event.target;
|
|
193
|
+
if (target instanceof Element) {
|
|
194
|
+
addBreadcrumb({ message: describeElement(target), type: "click" });
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
document.addEventListener("click", onClick, true);
|
|
198
|
+
cleanups.push(() => document.removeEventListener("click", onClick, true));
|
|
199
|
+
}
|
|
200
|
+
if (instrument.fetch !== false && typeof window.fetch === "function") {
|
|
201
|
+
const originalFetch = window.fetch;
|
|
202
|
+
const wrapped = async (...args) => {
|
|
203
|
+
const [input, init] = args;
|
|
204
|
+
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
205
|
+
const method = init?.method ?? "GET";
|
|
206
|
+
if (url.includes(endpoint))
|
|
207
|
+
return originalFetch(...args);
|
|
208
|
+
try {
|
|
209
|
+
const response = await originalFetch(...args);
|
|
210
|
+
addBreadcrumb({
|
|
211
|
+
data: { status: response.status },
|
|
212
|
+
message: `${method} ${url} → ${response.status}`,
|
|
213
|
+
type: "fetch"
|
|
214
|
+
});
|
|
215
|
+
return response;
|
|
216
|
+
} catch (error) {
|
|
217
|
+
addBreadcrumb({ message: `${method} ${url} → failed`, type: "fetch" });
|
|
218
|
+
throw error;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
window.fetch = wrapped;
|
|
222
|
+
cleanups.push(() => {
|
|
223
|
+
window.fetch = originalFetch;
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
if (instrument.history !== false && typeof history !== "undefined") {
|
|
227
|
+
const record = () => addBreadcrumb({
|
|
228
|
+
message: `navigate ${location.pathname}${location.search}`,
|
|
229
|
+
type: "navigation"
|
|
230
|
+
});
|
|
231
|
+
const patch = (key) => {
|
|
232
|
+
const original = history[key].bind(history);
|
|
233
|
+
history[key] = (...args) => {
|
|
234
|
+
const result = original(...args);
|
|
235
|
+
record();
|
|
236
|
+
return result;
|
|
237
|
+
};
|
|
238
|
+
return () => {
|
|
239
|
+
history[key] = original;
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
cleanups.push(patch("pushState"), patch("replaceState"));
|
|
243
|
+
window.addEventListener("popstate", record);
|
|
244
|
+
cleanups.push(() => window.removeEventListener("popstate", record));
|
|
245
|
+
}
|
|
246
|
+
const timer = setInterval(() => {
|
|
247
|
+
flush();
|
|
248
|
+
}, flushIntervalMs);
|
|
249
|
+
timer.unref?.();
|
|
250
|
+
cleanups.push(() => clearInterval(timer));
|
|
251
|
+
const onHide = () => {
|
|
252
|
+
flush(true);
|
|
253
|
+
};
|
|
254
|
+
window.addEventListener("pagehide", onHide);
|
|
255
|
+
document.addEventListener("visibilitychange", () => {
|
|
256
|
+
if (document.visibilityState === "hidden")
|
|
257
|
+
onHide();
|
|
258
|
+
});
|
|
259
|
+
cleanups.push(() => window.removeEventListener("pagehide", onHide));
|
|
260
|
+
return {
|
|
261
|
+
addBreadcrumb,
|
|
262
|
+
captureException,
|
|
263
|
+
captureMessage,
|
|
264
|
+
close: async () => {
|
|
265
|
+
for (const cleanup of cleanups.splice(0, cleanups.length))
|
|
266
|
+
cleanup();
|
|
267
|
+
await flush(true);
|
|
268
|
+
},
|
|
269
|
+
flush: () => flush(false),
|
|
270
|
+
setTags: (next) => {
|
|
271
|
+
tags = { ...tags, ...next };
|
|
272
|
+
},
|
|
273
|
+
setUser: (next) => {
|
|
274
|
+
user = next ?? undefined;
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
var current;
|
|
279
|
+
var initBeacon = (options) => {
|
|
280
|
+
current = createBeacon(options);
|
|
281
|
+
return current;
|
|
282
|
+
};
|
|
283
|
+
var getBeacon = () => current;
|
|
284
|
+
var captureException = (error, context) => current?.captureException(error, context);
|
|
285
|
+
var captureMessage = (message, level) => current?.captureMessage(message, level);
|
|
286
|
+
var addBreadcrumb = (crumb) => current?.addBreadcrumb(crumb);
|
|
287
|
+
export {
|
|
288
|
+
initBeacon,
|
|
289
|
+
getBeacon,
|
|
290
|
+
createBeacon,
|
|
291
|
+
captureMessage,
|
|
292
|
+
captureException,
|
|
293
|
+
addBreadcrumb
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
//# debugId=B13E8A92E369FE8164756E2164756E21
|
|
297
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * @absolutejs/beacon — tiny, zero-dependency browser SDK for the AbsoluteJS\n * observability stack.\n *\n * It is deliberately NOT Effect-native: a browser SDK loads on every page for\n * every user, so bytes are the dominant cost (measured: an Effect client is\n * ~108 KB gz; this is ~2-5 KB gz). The client has no trust boundary — it's a\n * dumb producer of telemetry — so the Effect/Schema rigor lives server-side in\n * `@absolutejs/errors/ingest`, which validates the untrusted POST body.\n *\n * Type safety is preserved end-to-end WITHOUT shipping Effect: the envelope\n * type below is contract-locked to the ingest endpoint's accepted shape by a\n * compile-time assertion in tests (`tests/contract.test.ts`). The type spans\n * the wire; the runtime machinery does not.\n *\n * captureException / global handlers\n * → enrich (breadcrumbs, tags, context, replayId)\n * → batch\n * → flush: POST envelope to /ingest via sendBeacon / fetch keepalive\n */\n\nexport type BeaconLevel = \"fatal\" | \"error\" | \"warning\" | \"info\";\n\nexport type Breadcrumb = {\n /** `Date.now()` when recorded. */\n at: number;\n type: \"console\" | \"click\" | \"navigation\" | \"fetch\" | \"custom\";\n message: string;\n data?: Record<string, unknown>;\n};\n\n/** One captured occurrence — structurally the ingest endpoint's `BeaconEvent`. */\nexport type BeaconEvent = {\n name: string;\n message: string;\n level?: BeaconLevel;\n stack?: string;\n at?: number;\n traceId?: string;\n spanId?: string;\n replayId?: string;\n tags?: Record<string, string>;\n extra?: Record<string, unknown>;\n};\n\n/** The POST body — structurally the ingest endpoint's `BeaconEnvelope`. */\nexport type BeaconEnvelope = {\n v: 1;\n project: string;\n release?: string;\n environment?: string;\n events: BeaconEvent[];\n};\n\nexport type CaptureContext = {\n level?: BeaconLevel;\n tags?: Record<string, string>;\n extra?: Record<string, unknown>;\n};\n\n/** Pluggable wire transport — injectable for tests / custom auth / proxies. */\nexport type BeaconTransport = (request: {\n url: string;\n body: string;\n key?: string;\n /** True on unload-time flushes — prefer `navigator.sendBeacon`. */\n useBeacon: boolean;\n}) => void | Promise<void>;\n\nexport type BeaconInstrumentation = {\n /** `window.onerror` / `error` events. Default true. */\n globalErrors?: boolean;\n /** `unhandledrejection` events. Default true. */\n unhandledRejections?: boolean;\n /** Breadcrumb `console.error` / `console.warn`. Default true. */\n console?: boolean;\n /** Breadcrumb document clicks. Default true. */\n clicks?: boolean;\n /** Breadcrumb `fetch` calls. Default true. */\n fetch?: boolean;\n /** Breadcrumb SPA navigations (`pushState`/`replaceState`/`popstate`). Default true. */\n history?: boolean;\n};\n\nexport type BeaconOptions = {\n /** Project id (required) — scopes issues server-side. */\n project: string;\n /** Ingest endpoint URL. Default `/ingest`. */\n endpoint?: string;\n release?: string;\n environment?: string;\n /** Auth key, sent as `x-beacon-key` (forces `fetch` over `sendBeacon`). */\n key?: string;\n /** Auto-flush once this many events are buffered. Default 30. */\n maxBatch?: number;\n /** Auto-flush interval (ms). Default 5000. */\n flushIntervalMs?: number;\n /** Breadcrumbs retained (ring buffer). Default 30. */\n maxBreadcrumbs?: number;\n /** Sample rate 0..1 — fraction of events kept. Default 1. */\n sampleRate?: number;\n /** Mutate or drop (return null) each event before it's buffered. */\n beforeSend?: (event: BeaconEvent) => BeaconEvent | null;\n /** Supply the active session-replay id (wired by @absolutejs/replay). */\n getReplayId?: () => string | undefined;\n /** Auto-instrumentation toggles (all default true). */\n instrument?: BeaconInstrumentation;\n /** Override the wire transport (default: sendBeacon / fetch keepalive). */\n transport?: BeaconTransport;\n};\n\nexport type Beacon = {\n captureException: (error: unknown, context?: CaptureContext) => void;\n captureMessage: (message: string, level?: BeaconLevel) => void;\n addBreadcrumb: (crumb: {\n message: string;\n type?: Breadcrumb[\"type\"];\n data?: Record<string, unknown>;\n }) => void;\n /** Merge persistent tags applied to every subsequent event. */\n setTags: (tags: Record<string, string>) => void;\n /** Set (or clear, with null) the user attached to events. */\n setUser: (user: { id?: string; email?: string } | null) => void;\n /** Flush buffered events now. */\n flush: () => Promise<void>;\n /** Remove all listeners + do a final flush. */\n close: () => Promise<void>;\n};\n\n// =============================================================================\n// Helpers\n// =============================================================================\n\nconst inBrowser = (): boolean => typeof window !== \"undefined\";\n\nconst newId = (): string => {\n if (\n typeof crypto !== \"undefined\" &&\n typeof crypto.randomUUID === \"function\"\n ) {\n return crypto.randomUUID();\n }\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n};\n\nconst toError = (value: unknown): Error => {\n if (value instanceof Error) return value;\n if (typeof value === \"string\") return new Error(value);\n if (typeof value === \"object\" && value !== null) {\n const object = value as { message?: unknown; name?: unknown };\n const message =\n typeof object.message === \"string\"\n ? object.message\n : safeStringify(value);\n const error = new Error(message);\n if (typeof object.name === \"string\") error.name = object.name;\n return error;\n }\n return new Error(String(value));\n};\n\nconst safeStringify = (value: unknown): string => {\n try {\n return JSON.stringify(value) ?? String(value);\n } catch {\n return String(value);\n }\n};\n\nconst describeElement = (element: Element): string => {\n const tag = element.tagName.toLowerCase();\n const id = element.id ? `#${element.id}` : \"\";\n const cls =\n typeof element.className === \"string\" && element.className.trim() !== \"\"\n ? `.${element.className.trim().split(/\\s+/).slice(0, 2).join(\".\")}`\n : \"\";\n return `${tag}${id}${cls}`;\n};\n\nconst noopBeacon: Beacon = {\n addBreadcrumb: () => {},\n captureException: () => {},\n captureMessage: () => {},\n close: async () => {},\n flush: async () => {},\n setTags: () => {},\n setUser: () => {},\n};\n\n// =============================================================================\n// Default transport — sendBeacon on unload, fetch keepalive otherwise\n// =============================================================================\n\nconst defaultTransport: BeaconTransport = ({ url, body, key, useBeacon }) => {\n if (typeof navigator === \"undefined\") return;\n // sendBeacon can't set headers, so it's only usable when there's no key.\n if (\n useBeacon &&\n key === undefined &&\n typeof navigator.sendBeacon === \"function\"\n ) {\n navigator.sendBeacon(url, new Blob([body], { type: \"application/json\" }));\n return;\n }\n if (typeof fetch === \"function\") {\n void fetch(url, {\n body,\n headers: {\n \"content-type\": \"application/json\",\n ...(key !== undefined ? { \"x-beacon-key\": key } : {}),\n },\n keepalive: true,\n method: \"POST\",\n }).catch(() => {\n // Telemetry is best-effort; a failed POST must never surface to the app.\n });\n }\n};\n\n// =============================================================================\n// createBeacon\n// =============================================================================\n\nexport const createBeacon = (options: BeaconOptions): Beacon => {\n if (!inBrowser()) return noopBeacon; // SSR / non-DOM import is a no-op\n\n const endpoint = options.endpoint ?? \"/ingest\";\n const maxBatch = options.maxBatch ?? 30;\n const flushIntervalMs = options.flushIntervalMs ?? 5000;\n const maxBreadcrumbs = options.maxBreadcrumbs ?? 30;\n const sampleRate = options.sampleRate ?? 1;\n const transport = options.transport ?? defaultTransport;\n const instrument = options.instrument ?? {};\n const sessionId = newId();\n\n const buffer: BeaconEvent[] = [];\n const breadcrumbs: Breadcrumb[] = [];\n const cleanups: Array<() => void> = [];\n let tags: Record<string, string> = {};\n let user: { id?: string; email?: string } | undefined;\n\n const flush = async (useBeacon = false): Promise<void> => {\n if (buffer.length === 0) return;\n const events = buffer.splice(0, buffer.length);\n const envelope: BeaconEnvelope = {\n events,\n project: options.project,\n v: 1,\n ...(options.release !== undefined ? { release: options.release } : {}),\n ...(options.environment !== undefined\n ? { environment: options.environment }\n : {}),\n };\n await transport({\n body: JSON.stringify(envelope),\n url: endpoint,\n useBeacon,\n ...(options.key !== undefined ? { key: options.key } : {}),\n });\n };\n\n const addBreadcrumb: Beacon[\"addBreadcrumb\"] = (crumb) => {\n breadcrumbs.push({\n at: Date.now(),\n message: crumb.message.slice(0, 200),\n type: crumb.type ?? \"custom\",\n ...(crumb.data !== undefined ? { data: crumb.data } : {}),\n });\n while (breadcrumbs.length > maxBreadcrumbs) breadcrumbs.shift();\n };\n\n const enrich = (event: BeaconEvent): BeaconEvent | null => {\n if (sampleRate < 1 && Math.random() > sampleRate) return null;\n const enriched: BeaconEvent = { ...event, at: event.at ?? Date.now() };\n const replayId = options.getReplayId?.();\n if (replayId !== undefined) enriched.replayId = replayId;\n const mergedTags = { ...tags, ...event.tags };\n if (Object.keys(mergedTags).length > 0) enriched.tags = mergedTags;\n const extra: Record<string, unknown> = { sessionId, ...event.extra };\n if (breadcrumbs.length > 0) extra.breadcrumbs = [...breadcrumbs];\n if (user !== undefined) extra.user = user;\n enriched.extra = extra;\n return options.beforeSend !== undefined\n ? options.beforeSend(enriched)\n : enriched;\n };\n\n const push = (event: BeaconEvent): void => {\n const enriched = enrich(event);\n if (enriched === null) return;\n buffer.push(enriched);\n if (buffer.length >= maxBatch) void flush();\n };\n\n const captureException: Beacon[\"captureException\"] = (\n error,\n context = {},\n ) => {\n const resolved = toError(error);\n const event: BeaconEvent = {\n level: context.level ?? \"error\",\n message: resolved.message,\n name: resolved.name,\n };\n if (resolved.stack !== undefined) event.stack = resolved.stack;\n if (context.tags !== undefined) event.tags = context.tags;\n if (context.extra !== undefined) event.extra = context.extra;\n push(event);\n };\n\n const captureMessage: Beacon[\"captureMessage\"] = (\n message,\n level = \"info\",\n ) => {\n push({ level, message, name: \"Message\" });\n };\n\n // --- auto-instrumentation -------------------------------------------------\n\n if (instrument.globalErrors !== false) {\n const onError = (event: ErrorEvent): void => {\n const error =\n event.error instanceof Error\n ? event.error\n : new Error(event.message || \"Uncaught error\");\n captureException(error, { level: \"error\" });\n };\n window.addEventListener(\"error\", onError, true);\n cleanups.push(() => window.removeEventListener(\"error\", onError, true));\n }\n\n if (instrument.unhandledRejections !== false) {\n const onRejection = (event: PromiseRejectionEvent): void => {\n const reason = event.reason;\n if (reason instanceof Error) {\n captureException(reason, { level: \"error\" });\n return;\n }\n const error = new Error(\n typeof reason === \"string\" ? reason : safeStringify(reason),\n );\n error.name = \"UnhandledRejection\";\n captureException(error, { level: \"error\" });\n };\n window.addEventListener(\"unhandledrejection\", onRejection);\n cleanups.push(() =>\n window.removeEventListener(\"unhandledrejection\", onRejection),\n );\n }\n\n if (instrument.console !== false && typeof console !== \"undefined\") {\n for (const method of [\"error\", \"warn\"] as const) {\n const original = console[method];\n console[method] = (...args: unknown[]): void => {\n addBreadcrumb({\n message: `console.${method}: ${args.map(String).join(\" \")}`,\n type: \"console\",\n });\n original.apply(console, args);\n };\n cleanups.push(() => {\n console[method] = original;\n });\n }\n }\n\n if (instrument.clicks !== false && typeof document !== \"undefined\") {\n const onClick = (event: Event): void => {\n const target = event.target;\n if (target instanceof Element) {\n addBreadcrumb({ message: describeElement(target), type: \"click\" });\n }\n };\n document.addEventListener(\"click\", onClick, true);\n cleanups.push(() => document.removeEventListener(\"click\", onClick, true));\n }\n\n if (instrument.fetch !== false && typeof window.fetch === \"function\") {\n const originalFetch = window.fetch;\n const wrapped = async (\n ...args: Parameters<typeof fetch>\n ): Promise<Response> => {\n const [input, init] = args;\n const url =\n typeof input === \"string\"\n ? input\n : input instanceof URL\n ? input.href\n : input.url;\n const method = init?.method ?? \"GET\";\n // Never breadcrumb our own ingest POSTs — avoids a feedback loop.\n if (url.includes(endpoint)) return originalFetch(...args);\n try {\n const response = await originalFetch(...args);\n addBreadcrumb({\n data: { status: response.status },\n message: `${method} ${url} → ${response.status}`,\n type: \"fetch\",\n });\n return response;\n } catch (error) {\n addBreadcrumb({ message: `${method} ${url} → failed`, type: \"fetch\" });\n throw error;\n }\n };\n window.fetch = wrapped as typeof window.fetch;\n cleanups.push(() => {\n window.fetch = originalFetch;\n });\n }\n\n if (instrument.history !== false && typeof history !== \"undefined\") {\n const record = (): void =>\n addBreadcrumb({\n message: `navigate ${location.pathname}${location.search}`,\n type: \"navigation\",\n });\n const patch = (key: \"pushState\" | \"replaceState\"): (() => void) => {\n const original = history[key].bind(history);\n history[key] = (...args: Parameters<History[\"pushState\"]>) => {\n const result = original(...args);\n record();\n return result;\n };\n return () => {\n history[key] = original;\n };\n };\n cleanups.push(patch(\"pushState\"), patch(\"replaceState\"));\n window.addEventListener(\"popstate\", record);\n cleanups.push(() => window.removeEventListener(\"popstate\", record));\n }\n\n // Flush on a timer + when the page is hidden / unloaded (the reliable moment).\n const timer = setInterval(() => {\n void flush();\n }, flushIntervalMs);\n (timer as { unref?: () => void }).unref?.();\n cleanups.push(() => clearInterval(timer));\n\n const onHide = (): void => {\n void flush(true);\n };\n window.addEventListener(\"pagehide\", onHide);\n document.addEventListener(\"visibilitychange\", () => {\n if (document.visibilityState === \"hidden\") onHide();\n });\n cleanups.push(() => window.removeEventListener(\"pagehide\", onHide));\n\n return {\n addBreadcrumb,\n captureException,\n captureMessage,\n close: async () => {\n for (const cleanup of cleanups.splice(0, cleanups.length)) cleanup();\n await flush(true);\n },\n flush: () => flush(false),\n setTags: (next) => {\n tags = { ...tags, ...next };\n },\n setUser: (next) => {\n user = next ?? undefined;\n },\n };\n};\n\n// =============================================================================\n// Singleton convenience (Sentry-style global API)\n// =============================================================================\n\nlet current: Beacon | undefined;\n\n/** Initialize the global beacon. Returns the instance. */\nexport const initBeacon = (options: BeaconOptions): Beacon => {\n current = createBeacon(options);\n return current;\n};\n\n/** The global beacon, if `initBeacon` has been called. */\nexport const getBeacon = (): Beacon | undefined => current;\n\n/** Capture against the global beacon (no-op if uninitialized). */\nexport const captureException = (\n error: unknown,\n context?: CaptureContext,\n): void => current?.captureException(error, context);\n\n/** Capture a message against the global beacon (no-op if uninitialized). */\nexport const captureMessage = (message: string, level?: BeaconLevel): void =>\n current?.captureMessage(message, level);\n\n/** Add a breadcrumb to the global beacon (no-op if uninitialized). */\nexport const addBreadcrumb = (crumb: {\n message: string;\n type?: Breadcrumb[\"type\"];\n data?: Record<string, unknown>;\n}): void => current?.addBreadcrumb(crumb);\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AAqIA,IAAM,YAAY,MAAe,OAAO,WAAW;AAEnD,IAAM,QAAQ,MAAc;AAAA,EAC1B,IACE,OAAO,WAAW,eAClB,OAAO,OAAO,eAAe,YAC7B;AAAA,IACA,OAAO,OAAO,WAAW;AAAA,EAC3B;AAAA,EACA,OAAO,GAAG,KAAK,IAAI,EAAE,SAAS,EAAE,KAAK,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE;AAAA;AAG7E,IAAM,UAAU,CAAC,UAA0B;AAAA,EACzC,IAAI,iBAAiB;AAAA,IAAO,OAAO;AAAA,EACnC,IAAI,OAAO,UAAU;AAAA,IAAU,OAAO,IAAI,MAAM,KAAK;AAAA,EACrD,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAAA,IAC/C,MAAM,SAAS;AAAA,IACf,MAAM,UACJ,OAAO,OAAO,YAAY,WACtB,OAAO,UACP,cAAc,KAAK;AAAA,IACzB,MAAM,QAAQ,IAAI,MAAM,OAAO;AAAA,IAC/B,IAAI,OAAO,OAAO,SAAS;AAAA,MAAU,MAAM,OAAO,OAAO;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jB,OAAO,iBAAiB,YAAY,MAAM;AAAA,EAC1C,SAAS,iBAAiB,oBAAoB,MAAM;AAAA,IAClD,IAAI,SAAS,oBAAoB;AAAA,MAAU,OAAO;AAAA,GACnD;AAAA,EACD,SAAS,KAAK,MAAM,OAAO,oBAAoB,YAAY,MAAM,CAAC;AAAA,EAElE,OAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,YAAY;AAAA,MACjB,WAAW,WAAW,SAAS,OAAO,GAAG,SAAS,MAAM;AAAA,QAAG,QAAQ;AAAA,MACnE,MAAM,MAAM,IAAI;AAAA;AAAA,IAElB,OAAO,MAAM,MAAM,KAAK;AAAA,IACxB,SAAS,CAAC,SAAS;AAAA,MACjB,OAAO,KAAK,SAAS,KAAK;AAAA;AAAA,IAE5B,SAAS,CAAC,SAAS;AAAA,MACjB,OAAO,QAAQ;AAAA;AAAA,EAEnB;AAAA;AAOF,IAAI;AAGG,IAAM,aAAa,CAAC,YAAmC;AAAA,EAC5D,UAAU,aAAa,OAAO;AAAA,EAC9B,OAAO;AAAA;AAIF,IAAM,YAAY,MAA0B;AAG5C,IAAM,mBAAmB,CAC9B,OACA,YACS,SAAS,iBAAiB,OAAO,OAAO;AAG5C,IAAM,iBAAiB,CAAC,SAAiB,UAC9C,SAAS,eAAe,SAAS,KAAK;AAGjC,IAAM,gBAAgB,CAAC,UAIlB,SAAS,cAAc,KAAK;",
|
|
8
|
+
"debugId": "B13E8A92E369FE8164756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@absolutejs/beacon",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Tiny, zero-dependency browser SDK for the AbsoluteJS observability stack. Captures uncaught errors + unhandled rejections, breadcrumbs (console/click/fetch/history), batches, and POSTs an envelope to @absolutejs/errors/ingest via sendBeacon/keepalive. ~2-5KB gz, no Effect in the browser; end-to-end type-safe via the shared erased envelope contract.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/absolutejs/beacon.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/absolutejs/beacon",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/absolutejs/beacon/issues"
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"license": "BSL-1.1",
|
|
18
|
+
"author": "Alex Kahn",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "rm -rf dist && bun build src/index.ts --outdir dist --sourcemap --target=browser && tsc --project tsconfig.build.json",
|
|
35
|
+
"test": "bun test",
|
|
36
|
+
"typecheck": "tsc --noEmit",
|
|
37
|
+
"format": "prettier --write \"./**/*.{ts,json,md}\"",
|
|
38
|
+
"check:package": "bun run typecheck && bun run build && bun run test",
|
|
39
|
+
"release": "bun run format && bun run check:package && bun publish"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"absolutejs",
|
|
43
|
+
"beacon",
|
|
44
|
+
"errors",
|
|
45
|
+
"browser",
|
|
46
|
+
"sentry",
|
|
47
|
+
"error-tracking",
|
|
48
|
+
"breadcrumbs",
|
|
49
|
+
"observability",
|
|
50
|
+
"rum"
|
|
51
|
+
],
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@absolutejs/errors": "^0.3.0",
|
|
54
|
+
"@happy-dom/global-registrator": "^20.10.6",
|
|
55
|
+
"@types/bun": "^1.3.14",
|
|
56
|
+
"prettier": "^3.8.3",
|
|
57
|
+
"typescript": "^5.9.0"
|
|
58
|
+
}
|
|
59
|
+
}
|