@absolutejs/beacon 0.7.0-beta.23 → 0.7.0-beta.24

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/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ This file is generated by `absolute-changelog` from the entries in
6
6
  `changelog/`. Edit an entry, not this file — and add new ones under
7
7
  `changelog/unreleased/`.
8
8
 
9
+ ## 0.7.0-beta.24 — 2026-11-17
10
+
11
+ ### Fixed
12
+
13
+ - **Preserve safe browser rejection diagnostics instead of empty JSON, handle throwing getters and proxies, and avoid serializing arbitrary rejection payloads or fabricating stacks.** (`BEACON_SDK_VERSION`)
14
+
9
15
  ## 0.7.0-beta.23 — 2026-10-28
10
16
 
11
17
  ### Fixed
package/changelog.json CHANGED
@@ -2,6 +2,19 @@
2
2
  "contract": 1,
3
3
  "name": "@absolutejs/beacon",
4
4
  "releases": [
5
+ {
6
+ "changes": [
7
+ {
8
+ "kind": "fixed",
9
+ "summary": "Preserve safe browser rejection diagnostics instead of empty JSON, handle throwing getters and proxies, and avoid serializing arbitrary rejection payloads or fabricating stacks.",
10
+ "symbols": [
11
+ "BEACON_SDK_VERSION"
12
+ ]
13
+ }
14
+ ],
15
+ "date": "2026-11-17",
16
+ "version": "0.7.0-beta.24"
17
+ },
5
18
  {
6
19
  "changes": [
7
20
  {
package/dist/index.d.ts CHANGED
@@ -1,23 +1,3 @@
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
1
  export { BEACON_ATTRIBUTE, BEACON_SIGNAL } from "./contracts";
22
2
  export type { BeaconSignal } from "./contracts";
23
3
  import type { BeaconSignal } from "./contracts";
@@ -25,7 +5,7 @@ export type BeaconLevel = "fatal" | "error" | "warning" | "info";
25
5
  /** Response header used to correlate a browser signal with its server request. */
26
6
  export declare const BEACON_TRACE_HEADER = "x-absolute-trace-id";
27
7
  /** Beacon package version retained with every captured event. */
28
- export declare const BEACON_SDK_VERSION = "0.7.0-beta.23";
8
+ export declare const BEACON_SDK_VERSION = "0.7.0-beta.24";
29
9
  /** Arbitrary event tags, with Beacon's reserved `signal` tag type-checked. */
30
10
  export type BeaconTags = Record<string, string> & {
31
11
  signal?: BeaconSignal;
package/dist/index.js CHANGED
@@ -1,3 +1,56 @@
1
+ // src/rejection.ts
2
+ var read = (value, key) => {
3
+ try {
4
+ return value !== null && (typeof value === "object" || typeof value === "function") ? Reflect.get(value, key) : undefined;
5
+ } catch {
6
+ return;
7
+ }
8
+ };
9
+ var isArray = (value) => {
10
+ try {
11
+ return Array.isArray(value);
12
+ } catch {
13
+ return false;
14
+ }
15
+ };
16
+ var text = (value) => typeof value === "string" && value.length > 0 ? value.slice(0, 2048) : undefined;
17
+ var describeRejection = (reason) => {
18
+ const extra = {
19
+ rejectionType: reason === null ? "null" : isArray(reason) ? "array" : typeof reason
20
+ };
21
+ const name = text(read(reason, "name"));
22
+ const message = text(read(reason, "message"));
23
+ const originalStack = read(reason, "stack");
24
+ const stack = typeof originalStack === "string" ? originalStack : undefined;
25
+ const className = text(read(read(reason, "constructor"), "name"));
26
+ if (className)
27
+ extra.rejectionClass = className;
28
+ for (const key of ["code", "type", "status", "statusText", "url"]) {
29
+ const value = read(reason, key);
30
+ if (typeof value === "number" && Number.isFinite(value))
31
+ extra[key] = value;
32
+ else if (text(value))
33
+ extra[key] = text(value);
34
+ }
35
+ const target = read(reason, "target");
36
+ const tag = text(read(target, "tagName"));
37
+ if (tag)
38
+ extra.resourceTag = tag;
39
+ if (tag && ["SCRIPT", "LINK", "IMG", "SOURCE", "VIDEO", "AUDIO"].includes(tag.toUpperCase())) {
40
+ const url = text(read(target, "currentSrc")) ?? text(read(target, "src")) ?? text(read(target, "href"));
41
+ if (url)
42
+ extra.resourceUrl = url;
43
+ }
44
+ const description = message ?? (typeof reason === "string" ? reason : reason === null || typeof reason !== "object" && typeof reason !== "function" ? String(reason) : `Unhandled promise rejection (${name ?? className ?? "object"}${extra.type ? `: ${extra.type}` : ""}${extra.status !== undefined ? `; status ${extra.status}` : ""})`);
45
+ const error = new Error(description);
46
+ error.name = name ?? "UnhandledRejection";
47
+ error.stack = stack;
48
+ const cause = read(reason, "cause");
49
+ if (stack !== undefined && cause !== undefined)
50
+ error.cause = cause;
51
+ return { error, extra };
52
+ };
53
+
1
54
  // src/contracts.ts
2
55
  var BEACON_SIGNAL = {
3
56
  AUTH_FAILURE_STORM: "auth_failure_storm",
@@ -192,7 +245,7 @@ var consumeEarlyLayoutShiftBuffer = () => {
192
245
 
193
246
  // src/index.ts
194
247
  var BEACON_TRACE_HEADER = "x-absolute-trace-id";
195
- var BEACON_SDK_VERSION = "0.7.0-beta.23";
248
+ var BEACON_SDK_VERSION = "0.7.0-beta.24";
196
249
  var inBrowser = () => typeof window !== "undefined";
197
250
  var newId = () => {
198
251
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
@@ -2026,22 +2079,17 @@ var createBeacon = (options) => {
2026
2079
  if (instrument.unhandledRejections !== false) {
2027
2080
  const onRejection = (event) => {
2028
2081
  const reason = event.reason;
2029
- if (reason instanceof Error) {
2082
+ let nativeError = false;
2083
+ try {
2084
+ nativeError = reason instanceof Error;
2085
+ } catch {}
2086
+ if (nativeError) {
2030
2087
  captureException(reason, { level: "error" });
2031
2088
  reportCapturedErrorClick(reason);
2032
2089
  return;
2033
2090
  }
2034
- if (typeof reason === "object" && reason !== null && typeof reason.stack === "string") {
2035
- captureException(reason, { level: "error" });
2036
- return;
2037
- }
2038
- const message = typeof reason === "string" ? reason : safeStringify(reason);
2039
- captureException(errorWithoutStack("UnhandledRejection", message), {
2040
- extra: {
2041
- rejectionType: reason === null ? "null" : Array.isArray(reason) ? "array" : typeof reason
2042
- },
2043
- level: "error"
2044
- });
2091
+ const { error, extra } = describeRejection(reason);
2092
+ captureException(error, { extra, level: "error" });
2045
2093
  reportErrorClick?.("UnhandledRejection");
2046
2094
  };
2047
2095
  window.addEventListener("unhandledrejection", onRejection);
@@ -5072,5 +5120,5 @@ export {
5072
5120
  redactBeaconEvent
5073
5121
  };
5074
5122
 
5075
- //# debugId=B14B49B1244463DE64756E2164756E21
5123
+ //# debugId=0615D4EF9F91436164756E2164756E21
5076
5124
  //# sourceMappingURL=index.js.map