@absolutejs/beacon 0.4.19 → 0.6.0

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 CHANGED
@@ -70,7 +70,9 @@ beacon.captureMessage("checkout started", "info");
70
70
  - **Stable semantic grouping** — pass `groupingKey` for synthetic or provider
71
71
  failures whose stack or wording can move between releases. The matching
72
72
  `@absolutejs/errors` ingest service validates and hashes it server-side;
73
- clients never choose raw fingerprints.
73
+ clients never choose raw fingerprints. Beacon's built-in signals always add
74
+ a stable grouping key derived from the normalized route and semantic target,
75
+ excluding durations, counts, release ids, entity UUIDs, and collector stacks.
74
76
  - **Cause chains** — preserves nested `Error.cause` stacks and diagnostic fields
75
77
  in `extra.errorCauses`, including database driver error codes and details.
76
78
  - **Sampling + redaction** — `sampleRate`, a `beforeSend(event)` hook
@@ -81,7 +83,9 @@ beacon.captureMessage("checkout started", "info");
81
83
  it.
82
84
  - **Noise filtering** — known browser-host/scanner failures such as CefSharp's
83
85
  `Object Not Found Matching Id` rejection and confirmed Meta in-app-browser
84
- native-bridge injection failures are dropped by default
86
+ native-bridge injection failures are dropped by default. Known crawler and
87
+ security-scanner user agents are dropped before they can create synthetic UI,
88
+ service-worker, or transport issues
85
89
  (`filterKnownNoise: false` opts out).
86
90
  - **Resource policy** — `instrument.resourceErrors` accepts a predicate so
87
91
  expected failures such as optional cross-origin images can become grouped
@@ -111,8 +115,9 @@ beacon.captureMessage("checkout started", "info");
111
115
  child painting past a non-scrolling parent (the flex-squeeze cutoff), and
112
116
  content cut by `overflow: hidden` without an ellipsis treatment. Issues
113
117
  group per element, kind, and viewport bucket (`xs/sm/md/lg/xl`), with the
114
- spill size in tags. Subtrees of scroll containers and absolutely positioned
115
- escapees (badges, popovers, drawers) are skipped by design; mark deliberate
118
+ spill size in tags. Hidden/off-canvas subtrees, icon-font glyph paint bounds,
119
+ scroll containers, and absolutely positioned escapees (badges, popovers,
120
+ drawers) are skipped by design; mark deliberate
116
121
  bleeds with `data-beacon-overflow="allow"`.
117
122
  - **Ambient watchdogs** — silent failures users abandon instead of reporting
118
123
  become warning issues: scroll jail (a leaked modal scroll lock), stuck
@@ -128,6 +133,9 @@ beacon.captureMessage("checkout started", "info");
128
133
  frustration (identical resubmits / repeated native-validation failures).
129
134
  Each is individually toggleable on `signals`, deduped, capped, and exempts
130
135
  `data-beacon-scan="allow"` subtrees where a DOM scan is involved.
136
+ Reload loops require repeated loads of the same normalized route; ordinary
137
+ navigation across several pages does not qualify. Occlusion scans exclude
138
+ hidden, inert, transparent, and pointer-disabled control subtrees.
131
139
  - **Theme and loading contracts** — mark an application boundary with
132
140
  `data-beacon-theme="adaptive"` to report large opaque surfaces whose
133
141
  luminance polarity contradicts the active light/dark mode. Intentional
@@ -156,6 +164,20 @@ beacon.captureMessage("checkout started", "info");
156
164
  dedicated/shared worker construction, runtime, and message-decoding failures
157
165
  become replay-linked warnings. Normal socket closes, page teardown, hidden-tab
158
166
  SSE errors, and successfully replaced service workers are exempt.
167
+ - **Attributed reliability signals** — Event Timing identifies genuinely slow
168
+ interactions (without treating an ordinary click timer as latency), Layout
169
+ Instability names shifted elements, and long animation frames include their
170
+ worst script when the browser exposes it. Successful HTTP responses can be
171
+ classified through the host-owned `instrument.classifyResponse` callback for
172
+ GraphQL-style errors without Beacon retaining response bodies.
173
+ - **Lifecycle and platform gaps** — marked empty application roots, marked dirty
174
+ forms abandoned during navigation, marked media errors/stalls, Web Storage and
175
+ IndexedDB failures, discarded documents, bfcache rejection reasons, slow
176
+ static resources, policy reports, connection changes, and opt-in User Timing
177
+ measures are observable. `observeCapability(name, promise)` captures handled
178
+ browser-API rejection while preserving normal promise behavior. Crash reports
179
+ require the server-side Reporting API receiver in `@absolutejs/errors` because
180
+ the page cannot execute after its browser process crashes.
159
181
 
160
182
  ## API
161
183
 
@@ -169,6 +191,7 @@ captureException(error, { groupingKey?, level?, traceId?, spanId?, tags?, extra?
169
191
  captureMessage(message, level?, { groupingKey?, traceId?, spanId?, tags?, extra? })
170
192
  addBreadcrumb({ message, type?, data? })
171
193
  setTags(tags) · setUser(user | null)
194
+ observeCapability(name, promise) => Promise
172
195
  flush() => Promise<void> // buffered events out now
173
196
  close() => Promise<void> // remove listeners + final flush
174
197
 
@@ -178,7 +201,8 @@ BEACON_SIGNAL.SLOW_RESPONSE
178
201
  BEACON_SIGNAL.HTTP_5XX
179
202
  BEACON_TRACE_HEADER // "x-absolute-trace-id"
180
203
 
181
- // Global helpers (no-op until initBeacon): captureException, captureMessage, addBreadcrumb
204
+ // Global helpers (no-op until initBeacon): captureException, captureMessage,
205
+ // addBreadcrumb, observeCapability
182
206
  ```
183
207
 
184
208
  SSR-safe: imported in a non-DOM environment, `createBeacon` returns a no-op.
package/dist/index.d.ts CHANGED
@@ -23,28 +23,42 @@ export type BeaconLevel = "fatal" | "error" | "warning" | "info";
23
23
  export declare const BEACON_SIGNAL: {
24
24
  readonly AUTH_FAILURE_STORM: "auth_failure_storm";
25
25
  readonly BROWSER_INTERVENTION: "browser_intervention";
26
+ readonly BROWSER_POLICY_VIOLATION: "browser_policy_violation";
27
+ readonly BFCACHE_BLOCKED: "bfcache_blocked";
28
+ readonly CAPABILITY_FAILURE: "capability_failure";
29
+ readonly BLANK_APP_ROOT: "blank_app_root";
26
30
  readonly CONSOLE_ERROR: "console_error";
27
31
  readonly CSP_VIOLATION: "csp_violation";
28
32
  readonly CLIPBOARD_FAILURE: "clipboard_failure";
29
33
  readonly DEAD_CLICK: "dead_click";
34
+ readonly DISRUPTIVE_LAYOUT_SHIFT: "disruptive_layout_shift";
35
+ readonly DOCUMENT_DISCARDED: "document_discarded";
36
+ readonly ERROR_CLICK: "error_click";
30
37
  readonly FETCH_FAILED: "fetch_failed";
31
38
  readonly FOCUS_LOST: "focus_lost";
32
39
  readonly FONT_FAILURE: "font_failure";
33
40
  readonly FORM_FRUSTRATION: "form_frustration";
41
+ readonly FORM_ABANDONMENT: "form_abandonment";
34
42
  readonly FOCUSED_CONTROL_OFFSCREEN: "focused_control_offscreen";
35
43
  readonly HTTP_5XX: "http_5xx";
36
44
  readonly INVISIBLE_TEXT: "invisible_text";
37
45
  readonly EMBEDDED_CONTENT_STALLED: "embedded_content_stalled";
38
46
  readonly LAYOUT_OVERFLOW: "layout_overflow";
39
47
  readonly MAIN_THREAD_STALL: "main_thread_stall";
48
+ readonly MEDIA_PLAYBACK_FAILED: "media_playback_failed";
49
+ readonly MEDIA_PLAYBACK_STALLED: "media_playback_stalled";
40
50
  readonly MODAL_FOCUS_ESCAPE: "modal_focus_escape";
41
51
  readonly OCCLUDED_CONTROL: "occluded_control";
42
52
  readonly RAGE_CLICK: "rage_click";
43
53
  readonly RATE_LIMITED: "rate_limited";
54
+ readonly NAVIGATION_STALLED: "navigation_stalled";
44
55
  readonly RELOAD_LOOP: "reload_loop";
45
56
  readonly REQUEST_STORM: "request_storm";
57
+ readonly SEMANTIC_RESPONSE_FAILURE: "semantic_response_failure";
46
58
  readonly SCROLL_JAIL: "scroll_jail";
47
59
  readonly SLOW_RESPONSE: "slow_response";
60
+ readonly SLOW_RESOURCE: "slow_resource";
61
+ readonly SLOW_INTERACTION: "slow_interaction";
48
62
  readonly SOCKET_ABNORMAL_CLOSE: "socket_abnormal_close";
49
63
  readonly SOCKET_FLAPPING: "socket_flapping";
50
64
  readonly SSE_FLAPPING: "sse_flapping";
@@ -52,6 +66,8 @@ export declare const BEACON_SIGNAL: {
52
66
  readonly STALLED_STREAM: "stalled_stream";
53
67
  readonly STUCK_LOADING: "stuck_loading";
54
68
  readonly THEME_MISMATCH: "theme_mismatch";
69
+ readonly THRASHED_CURSOR: "thrashed_cursor";
70
+ readonly STORAGE_FAILURE: "storage_failure";
55
71
  readonly WEBGL_CONTEXT_LOST: "webgl_context_lost";
56
72
  readonly SERVICE_WORKER_FAILURE: "service_worker_failure";
57
73
  readonly WORKER_FAILURE: "worker_failure";
@@ -59,12 +75,18 @@ export declare const BEACON_SIGNAL: {
59
75
  export type BeaconSignal = (typeof BEACON_SIGNAL)[keyof typeof BEACON_SIGNAL];
60
76
  /** Stable DOM attributes understood by Beacon's instrumentation. */
61
77
  export declare const BEACON_ATTRIBUTE: {
78
+ /** Names an application root whose settled empty state is a failure. */
79
+ readonly APP_ROOT: "data-beacon-app-root";
62
80
  readonly DEAD_CLICK: "data-beacon-dead-click";
63
81
  readonly NAME: "data-beacon-name";
64
82
  /** Names an iframe whose initial load should be watched for a stall. */
65
83
  readonly EMBED: "data-beacon-embed";
66
84
  /** Marks loading UI that should participate in the stuck-loading watchdog. */
67
85
  readonly LOADING: "data-beacon-loading";
86
+ /** Names a form whose dirty navigation should be reported as abandonment. */
87
+ readonly FORM: "data-beacon-form";
88
+ /** Names media whose user-visible playback should be watched. */
89
+ readonly MEDIA: "data-beacon-media";
68
90
  /** `="allow"` exempts an element AND its subtree from layout-overflow
69
91
  * detection — for deliberate bleeds (decorative shapes, marquees). */
70
92
  readonly OVERFLOW: "data-beacon-overflow";
@@ -151,6 +173,26 @@ export type BeaconInstrumentation = {
151
173
  xhr?: boolean;
152
174
  /** Breadcrumb SPA navigations (`pushState`/`replaceState`/`popstate`). Default true. */
153
175
  history?: boolean;
176
+ /** Record Network Information API changes as breadcrumbs. Default true. */
177
+ networkChanges?: boolean;
178
+ /** Record application-authored Performance API measures as breadcrumbs.
179
+ * Default false because measure names are host-owned. */
180
+ userTiming?: boolean;
181
+ /** Privacy-owned application classifier for successful HTTP responses that
182
+ * encode a semantic failure (for example GraphQL errors in an HTTP 200).
183
+ * Beacon never reads or stores the response body itself. */
184
+ classifyResponse?: (response: Response, request: {
185
+ method: string;
186
+ url: string;
187
+ }) => void | false | {
188
+ groupingKey: string;
189
+ message: string;
190
+ tags?: Record<string, string>;
191
+ } | Promise<void | false | {
192
+ groupingKey: string;
193
+ message: string;
194
+ tags?: Record<string, string>;
195
+ }>;
154
196
  };
155
197
  export type BeaconResourceFailure = {
156
198
  crossOrigin: boolean;
@@ -167,6 +209,12 @@ export type BeaconResourceFailure = {
167
209
  * `console.error`. Each detector is feature-gated and independently tunable.
168
210
  */
169
211
  export type BeaconSignals = {
212
+ /** Back/forward navigations the browser could not restore from bfcache. */
213
+ bfcacheBlocks?: boolean;
214
+ /** Marked application roots that settle without meaningful visible content. */
215
+ blankAppRoots?: boolean;
216
+ /** Delay before an application root is evaluated. Default 3000ms. */
217
+ blankAppRootSettleMs?: number;
170
218
  /** Repeated 401/403 responses from one endpoint inside a short window.
171
219
  * Default true. */
172
220
  authFailureStorms?: boolean;
@@ -176,6 +224,9 @@ export type BeaconSignals = {
176
224
  authFailureStormWindowMs?: number;
177
225
  /** Browser intervention reports surfaced by ReportingObserver. Default true. */
178
226
  browserInterventions?: boolean;
227
+ /** Deprecation, permissions-policy, integrity, and cross-origin policy
228
+ * reports exposed by ReportingObserver. Default true. */
229
+ browserPolicyViolations?: boolean;
179
230
  /** Enforced Content Security Policy violations. Default true. */
180
231
  cspViolations?: boolean;
181
232
  /** Rejected clipboard writes, including failures handled by application
@@ -185,6 +236,10 @@ export type BeaconSignals = {
185
236
  rageClicks?: boolean;
186
237
  /** An interactive control clicked with no DOM/nav/scroll/focus/request response. Default true. */
187
238
  deadClicks?: boolean;
239
+ /** A user interaction followed shortly by an error. Default true. */
240
+ errorClicks?: boolean;
241
+ /** Correlation window between interaction and error. Default 2000ms. */
242
+ errorClickWindowMs?: number;
188
243
  /** Responses with status >= 500. Default true. */
189
244
  serverErrors?: boolean;
190
245
  /** Responses slower than `slowResponseMs`. Default true. */
@@ -202,6 +257,8 @@ export type BeaconSignals = {
202
257
  /** The same form submitted or failing native validation repeatedly within a
203
258
  * minute — the quiet sibling of a rage click. Default true. */
204
259
  formFrustration?: boolean;
260
+ /** Dirty marked forms left without a successful submission. Default true. */
261
+ formAbandonment?: boolean;
205
262
  /** A focused editable control left outside the mobile visual viewport after
206
263
  * the on-screen keyboard settles. Default true. */
207
264
  focusedControlsOffscreen?: boolean;
@@ -224,6 +281,12 @@ export type BeaconSignals = {
224
281
  * popovers, drawers) are skipped by design. Default true.
225
282
  */
226
283
  layoutOverflows?: boolean;
284
+ /** Large unexpected Layout Instability API entries with culprit elements. */
285
+ disruptiveLayoutShifts?: boolean;
286
+ /** Individual unexpected shift score that becomes an issue. Default 0.1. */
287
+ disruptiveLayoutShiftMin?: number;
288
+ /** A page reloaded after the browser discarded its previous document. */
289
+ documentDiscards?: boolean;
227
290
  /** Maximum layout-overflow issues reported per page load. Default 5. */
228
291
  layoutOverflowMaxReports?: number;
229
292
  /** Quiet period after load/resize/navigation before the settled visual
@@ -231,6 +294,14 @@ export type BeaconSignals = {
231
294
  layoutOverflowSettleMs?: number;
232
295
  /** Repeated long animation frames/tasks on a visible page. Default true. */
233
296
  mainThreadStalls?: boolean;
297
+ /** Responding interactions that exceed the latency threshold. Default true. */
298
+ slowInteractions?: boolean;
299
+ /** Interaction duration that becomes a warning. Default 1000ms. */
300
+ slowInteractionMs?: number;
301
+ /** Opt-in marked media playback failures and sustained stalls. Default true. */
302
+ mediaFailures?: boolean;
303
+ /** Time continuously waiting/stalled before reporting. Default 10000ms. */
304
+ mediaStallMs?: number;
234
305
  /** Long-frame duration that counts as a main-thread stall. Default 200ms. */
235
306
  mainThreadStallMs?: number;
236
307
  /** Stalls inside the window that trip a report. Default 3. */
@@ -251,6 +322,8 @@ export type BeaconSignals = {
251
322
  /** Several full page loads within a minute — a crash or reload loop.
252
323
  * Default true. */
253
324
  reloadLoops?: boolean;
325
+ /** SPA navigations accepted by a router but never settled. Default true. */
326
+ stalledNavigations?: boolean;
254
327
  /** The same endpoint hit `requestStormCount` times inside
255
328
  * `requestStormWindowMs` — refetch loops and retry storms. Needs the
256
329
  * fetch/XHR instrumentation. Default true. */
@@ -315,6 +388,16 @@ export type BeaconSignals = {
315
388
  navigationResponseMs?: number;
316
389
  /** Slow-response threshold (ms). Default 8000. */
317
390
  slowResponseMs?: number;
391
+ /** Slow successful static resources from Resource Timing. Default true. */
392
+ slowResources?: boolean;
393
+ /** Static resource duration that becomes a warning. Default 5000ms. */
394
+ slowResourceMs?: number;
395
+ /** Browser storage writes and IndexedDB operations that fail. Default true. */
396
+ storageFailures?: boolean;
397
+ /** Erratic desktop pointer movement indicating confusion/waiting. Default true. */
398
+ thrashedCursors?: boolean;
399
+ /** Cursor direction reversals inside the detection window. Default 8. */
400
+ thrashedCursorReversals?: number;
318
401
  };
319
402
  export type BeaconNetworkFailure = {
320
403
  at: number;
@@ -328,6 +411,12 @@ export type BeaconNetworkFailure = {
328
411
  };
329
412
  method: string;
330
413
  online: boolean | null;
414
+ connection?: {
415
+ downlink?: number;
416
+ effectiveType?: string;
417
+ rtt?: number;
418
+ saveData?: boolean;
419
+ };
331
420
  transport: "fetch" | "xhr";
332
421
  visibilityState: string;
333
422
  };
@@ -405,6 +494,8 @@ export type WebVital = {
405
494
  sdkVersion?: string;
406
495
  /** Optional W3C trace correlation. */
407
496
  traceId?: string;
497
+ /** Privacy-bounded field attribution supplied by web-vitals/attribution. */
498
+ attribution?: Record<string, unknown>;
408
499
  };
409
500
  /** Override Web Vital delivery without changing collection semantics. */
410
501
  export type BeaconVitalsTransport = (vital: WebVital) => void | Promise<void>;
@@ -414,6 +505,7 @@ type WebVitalMetric = {
414
505
  rating: string;
415
506
  id: string;
416
507
  navigationType: string;
508
+ attribution?: Record<string, unknown>;
417
509
  };
418
510
  type WebVitalReporter = (callback: (metric: WebVitalMetric) => void) => void;
419
511
  /** The subset of the `web-vitals` package surface beacon uses. */
@@ -461,6 +553,9 @@ export type Beacon = {
461
553
  id?: string;
462
554
  email?: string;
463
555
  } | null) => void;
556
+ /** Observe an application-owned browser capability promise without globally
557
+ * monkey-patching sensitive platform APIs. */
558
+ observeCapability: <T>(name: string, operation: Promise<T>) => Promise<T>;
464
559
  /** Flush buffered events now. */
465
560
  flush: () => Promise<void>;
466
561
  /** Remove all listeners + do a final flush. */
@@ -485,4 +580,6 @@ export declare const addBreadcrumb: (crumb: {
485
580
  type?: Breadcrumb["type"];
486
581
  data?: Record<string, unknown>;
487
582
  }) => void;
583
+ /** Observe an application-owned browser capability against the global beacon. */
584
+ export declare const observeCapability: <T>(name: string, operation: Promise<T>) => Promise<T>;
488
585
  export {};