@belvador/browser 0.1.0 → 0.2.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
@@ -45,6 +45,14 @@ each attempt times out after 10 s, failed sends retry at most 5 times, `429` rat
45
45
  respected, and a revoked key (`401`/`403`) stops sending for the life of the page or isolate.
46
46
  Every public function catches its own errors.
47
47
 
48
+ ## Check the connection
49
+
50
+ "No errors" is not proof that errors arrive. Call `verifyIntegration()` from `@belvador/browser` once after `init`:
51
+ it sends one marked test error (never an issue), reads it back and resolves to
52
+ `{ outcome: "verified" | "problem" | "unconfirmed", checks, docsUrl, … }`. It never throws.
53
+ Requests the visitor cancelled (`AbortError`) are not reported unless you set `captureAborted: true`.
54
+ See https://belvador.dev/docs/sdk/verify
55
+
48
56
  ## Status
49
57
 
50
58
  `0.x` — used by Belvador's own apps first. The API may still change before `1.0`.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,12 @@
1
+ import type { VerificationResult, VerifyOptions } from "@belvador/core";
1
2
  import { type BrowserOptions } from "./internal.js";
2
3
  export type { BrowserOptions } from "./internal.js";
3
- export { SDK_VERSION, addBreadcrumb, captureException, captureMessage, close, flush, lastEventId, setContext, setTag, setTags, setUser, withScope, type BelvadorBreadcrumb, type BelvadorEvent, type BelvadorEventHint, type Scope, type SeverityLevel, } from "@belvador/core";
4
+ export { SDK_VERSION, addBreadcrumb, captureException, captureMessage, close, flush, getDiagnostics, lastEventId, setContext, setTag, setTags, setUser, withScope, type BelvadorBreadcrumb, type BelvadorEvent, type BelvadorEventHint, type Diagnostic, type DiagnosticCode, type DiagnosticsSnapshot, type Scope, type SeverityLevel, type VerificationResult, type VerifyOptions, } from "@belvador/core";
4
5
  /** Starts error tracking; returns whether it is running. Never throws. */
5
6
  export declare function init(options: BrowserOptions): boolean;
7
+ /**
8
+ * Proves this page reports to Belvador: a captured and an uncaught verification error
9
+ * (the console shows one "expected" error), read back from Belvador. Run it once after
10
+ * setup or deploy; never automatic. Always resolves; prints one summary line.
11
+ */
12
+ export declare function verifyIntegration(options?: VerifyOptions): Promise<VerificationResult>;
package/dist/index.js CHANGED
@@ -2,9 +2,17 @@
2
2
  // Built on the open-source Sentry JavaScript SDK (MIT), with Belvador's
3
3
  // privacy and sending rules. Importing this module does nothing until init().
4
4
  import { init as engineInit } from "@sentry/browser";
5
- import { initWith } from "./internal.js";
6
- export { SDK_VERSION, addBreadcrumb, captureException, captureMessage, close, flush, lastEventId, setContext, setTag, setTags, setUser, withScope, } from "@belvador/core";
5
+ import { initWith, verifyBrowser } from "./internal.js";
6
+ export { SDK_VERSION, addBreadcrumb, captureException, captureMessage, close, flush, getDiagnostics, lastEventId, setContext, setTag, setTags, setUser, withScope, } from "@belvador/core";
7
7
  /** Starts error tracking; returns whether it is running. Never throws. */
8
8
  export function init(options) {
9
9
  return initWith(engineInit, options, "browser");
10
10
  }
11
+ /**
12
+ * Proves this page reports to Belvador: a captured and an uncaught verification error
13
+ * (the console shows one "expected" error), read back from Belvador. Run it once after
14
+ * setup or deploy; never automatic. Always resolves; prints one summary line.
15
+ */
16
+ export function verifyIntegration(options) {
17
+ return verifyBrowser(options);
18
+ }
@@ -1,5 +1,5 @@
1
1
  import type { BrowserOptions as EngineBrowserOptions } from "@sentry/browser";
2
- import { type BelvadorOptions, type RuntimeName } from "@belvador/core";
2
+ import { type BelvadorOptions, type RuntimeName, type VerificationResult, type VerifyOptions } from "@belvador/core";
3
3
  export type BrowserOptions = BelvadorOptions & {
4
4
  /** Breadcrumb sources, all off by default (each one patches a browser API). */
5
5
  instrument?: {
@@ -23,3 +23,8 @@ export declare function browserEngineOptions(options: BrowserOptions, runtime: E
23
23
  * replaced silently. Returns whether Belvador is running. Never throws.
24
24
  */
25
25
  export declare function initWith(engineInit: (options: EngineBrowserOptions) => unknown, options: BrowserOptions, runtime: Extract<RuntimeName, "browser" | "react" | "tanstack-start">): boolean;
26
+ /**
27
+ * Browser verification (integration-health spec 02 §3): the global error handler is
28
+ * installed, a captured verification arrives, and an uncaught one does too.
29
+ */
30
+ export declare function verifyBrowser(options?: VerifyOptions): Promise<VerificationResult>;
package/dist/internal.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Shared by @belvador/browser, /react and /tanstack-start: browser engine
2
2
  // options and the idempotent init. Not a public API.
3
3
  import { breadcrumbsIntegration, browserApiErrorsIntegration, dedupeIntegration, eventFiltersIntegration, functionToStringIntegration, getClient, globalHandlersIntegration, httpContextIntegration, linkedErrorsIntegration, } from "@sentry/browser";
4
- import { BELVADOR_MARKER, buildEngineOptions, isActive, warnOnce, } from "@belvador/core";
4
+ import { BELVADOR_MARKER, buildEngineOptions, isActive, reportDiagnostic, runVerification, warnOnce, } from "@belvador/core";
5
5
  const EXTENSION_URLS = [
6
6
  /^chrome-extension:\/\//i,
7
7
  /^moz-extension:\/\//i,
@@ -52,6 +52,7 @@ export function initWith(engineInit, options, runtime) {
52
52
  const prev = existing.getOptions();
53
53
  if (prev[BELVADOR_MARKER] === true && prev["dsn"] === options?.dsn)
54
54
  return true;
55
+ reportDiagnostic("BLV_INIT_CONFLICT");
55
56
  warnOnce("init skipped: another error-tracking client is already running in this page. Remove the old init so errors are not captured twice.");
56
57
  return false;
57
58
  }
@@ -65,3 +66,20 @@ export function initWith(engineInit, options, runtime) {
65
66
  return false;
66
67
  }
67
68
  }
69
+ /**
70
+ * Browser verification (integration-health spec 02 §3): the global error handler is
71
+ * installed, a captured verification arrives, and an uncaught one does too.
72
+ */
73
+ export function verifyBrowser(options) {
74
+ return runVerification({
75
+ surface: "browser",
76
+ hook: () => {
77
+ try {
78
+ return { ok: Boolean(getClient()?.getIntegrationByName("GlobalHandlers")) };
79
+ }
80
+ catch {
81
+ return { ok: false };
82
+ }
83
+ },
84
+ }, options);
85
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@belvador/browser",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Belvador error tracking for the browser: one init, errors only, private by default.",
5
5
  "license": "MIT",
6
6
  "author": "Belvador (https://belvador.dev)",
@@ -37,7 +37,7 @@
37
37
  "node": ">=18"
38
38
  },
39
39
  "dependencies": {
40
- "@belvador/core": "0.1.0",
40
+ "@belvador/core": "0.2.0",
41
41
  "@sentry/browser": "10.76.2"
42
42
  },
43
43
  "publishConfig": {