@voltro/plugin-sentry 0.59.0 → 0.61.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/CHANGELOG.md CHANGED
@@ -39,6 +39,89 @@ _Changes staged for the next release accumulate here (rolled up from
39
39
 
40
40
  ---
41
41
 
42
+ ## [0.61.0] — 2026-08-31
43
+
44
+ ### ⚠ BREAKING
45
+
46
+ - **@voltro/client, @voltro/web, @voltro/cli** — `RpcError.kind` now distinguishes transport, handler, client, and unknown failures; manually emitted events must add the field, while `useConnectionStatus` now degrades only for transport failures and clears on the next rpc success.
47
+
48
+ **`voltro update` carries you across this** — codemod `0.61.0/01_rpc_errors_have_kinds`. If you pin versions by hand and never run it, print the notes without changing anything: `voltro update --codemods-only --from <your current version> --dry-run` (this one ships in 0.61.0).
49
+ - **@voltro/plugin-sentry, @voltro/cli** — Browser RPC spans now join the active page/navigation transaction and link to the Effect/server trace instead of creating one root transaction per call; `tracesSampleRate`, `browserTracing`, and the new `rpcSpans` switch control the resulting browser trace volume.
50
+
51
+ **`voltro update` carries you across this** — codemod `0.61.0/02_sentry_rpc_spans_join_page`. If you pin versions by hand and never run it, print the notes without changing anything: `voltro update --codemods-only --from <your current version> --dry-run` (this one ships in 0.61.0).
52
+
53
+ ### Fixed
54
+
55
+ - **@voltro/cli** — **Six SSR failure sites report to Sentry, not three.**
56
+
57
+ 0.60.0 gave the web server its own Sentry and wired the three loud sites: the SSR shell throw, the SPA layout shell throw, and the general render error (which covers a loader throw). The docs said "shell throw, loader throw, PPR/SWR refresh" — and an enumeration in a claim is read as exhaustive.
58
+
59
+ The other three were `warn`-level and reported to nobody: a failed PPR hole pass, a failed background SWR refresh, and a `not-found.tsx` that throws while rendering. They are quieter because the request still serves something — stale HTML, an unfilled hole, a plain 404 — which says something about the REQUEST and nothing about who else could find out. The answer to that is nobody: none of them reaches a browser boundary, so the pod's stdout was the only record.
60
+
61
+ They carry their own `voltro.stage` (`not-found-render`, `ppr-holes`, `swr-refresh`), so a quota-conscious project can drop them by stage without losing the three that fail the request.
62
+
63
+ `webSentry.test.ts` now fails if a render-path `log.error`/`log.warn` gains no reporter beside it — the property, rather than the six call sites.
64
+
65
+ ---
66
+
67
+ ## [0.60.0] — 2026-08-31
68
+
69
+ ### ⚠ BREAKING
70
+
71
+ - **@voltro/plugin-sentry** — **A declared failure no longer reaches Sentry by default, and the source-map upload now injects debug ids.** Two separate defects, both found by the same deployment on its first day of real server-side events.
72
+
73
+ **1. The contract was being reported as an incident.** The rpc interceptor skipped only clean interrupts; everything else went to `captureException`. So a failure declared in a procedure's `error:` union — the thing the client gets typed and branches on — arrived as `level: error`, `handled: yes`. The first server-side issue a deployment ever received was a person clicking a team they are not a member of.
74
+
75
+ Effect separates a failure from a defect, this framework leans on that split deliberately (a store refusal was made typed so an app could branch on it; an unlookupable conflict key was deliberately left a defect, because it is a broken call rather than a condition in the data), and a descriptor carries it in `error:`. Reporting both as an incident discarded that one layer up.
76
+
77
+ `shouldCapture` now skips a cause that is failures-ONLY. A defect is reported as before, including a defect that travelled beside a failure — the rule is failures-only rather than "any failure present" precisely so one cannot hide the other. `captureFailures: true` restores the old behaviour; a predicate keeps the ones that are signal.
78
+
79
+ **The browser half moved with it**, or the option would have been half-wired: a rejected call is an rpc error on the client too, published to the client error bus and captured by the browser bridge. `initSentryBrowser` takes the same option and applies it to `rpc.*` events carrying a `_tag`. Route render failures and `reportClientError` calls are never filtered — nobody declared those.
80
+
81
+ **2. `sentry-cli sourcemaps upload` does NOT write debug ids.** `inject` is a separate subcommand; `upload` only uses ids that are already present, and falls back to matching on the artifact NAME when they are not. That fallback cannot work for a server bundle: the artifact is named from `--url-prefix` (`~/chunk- ABC.js`) while the frame carries the absolute path the node process loaded, and nothing rewrites either side.
82
+
83
+ Measured downstream: 4300 artifacts uploaded, release finalised, every frame still minified. Nothing was red — the exact shape this code's own header warns about, an upload that matched nothing looking like one that worked. The comment above the uploader asserted the injection happened, which made it a description standing where a check belonged.
84
+
85
+ `inject` now runs first, over the same directories, and `sourcemapDebugIds.test.ts` drives the real binary to assert an id lands in both the JS and the map. `--url-prefix` stays as the fallback for the browser bundle, whose frames really are URLs.
86
+
87
+ The boot line names the new setting (`sentry active … captureFailures=false`), because a default the framework picks for you is one nobody finds again.
88
+
89
+ **`voltro update` carries you across this** — codemod `0.60.0/01_declared_failures_are_not_incidents`. If you pin versions by hand and never run it, print the notes without changing anything: `voltro update --codemods-only --from <your current version> --dry-run` (this one ships in 0.60.0).
90
+
91
+ ### Added
92
+
93
+ - **@voltro/cli, @voltro/plugin-sentry** — **The web server process now initialises Sentry and reports its own errors.**
94
+
95
+ A framework app runs two server processes. `voltro serve` is the api, where `sentryPlugin()` initialises the SDK through the plugin lifecycle. `voltro start` is the web server — SSR, loaders, ISR, the revalidation legs — and it has no plugin lifecycle, so it had none.
96
+
97
+ That was not a cosmetic difference in boot output. A web pod legitimately logs less than an api pod, because it has no store, no rpc, no scheduler, no workflows and no plugins. What it also had was **no error reporting**: an SSR shell throw is caught, logged and answered with a 500, so no browser ever renders it and the client-side ErrorBoundary bridge cannot see it either. Both ends of the integration worked and the middle was dark — while the docs' "React render error ✅ auto" row, true of the client path, read as covering all of them.
98
+
99
+ Set `SENTRY_DSN` on the web deployment and the boot says `sentry active` with the same message and the same field names as the api half, from the same function — `initSentryServer` in `@voltro/plugin-sentry/server`, which the api plugin now calls too. One init, because a copy of `skipOpenTelemetrySetup`, the traces default, the overrides-first spread and the degrade-on-missing-SDK path would have drifted the moment either half gained a case.
100
+
101
+ Three deliberate asymmetries, each because the two processes are not the same thing:
102
+
103
+ - **`traces: false` on the web side.** The api contributes a span processor to the framework's tracer; the web server has no tracer at all, so tracing on would put `traces: true` in a boot line while nothing produces a span. - **No DSN is SILENT here.** On the api side `sentryPlugin()` is a declaration and an inert one contradicts it. There is no declaration here. - **`@voltro/plugin-sentry` must be installed in the WEB app.** With a DSN set and the package missing, the boot names the command rather than failing — monitoring must never be what stops a deploy.
104
+
105
+ Measured against a real production `voltro start`, both branches. Note that production `voltro start` loads the app's precompiled start bundle, so a web deployment picks this up when that bundle is rebuilt — the framework version alone is not enough.
106
+
107
+ ### Fixed
108
+
109
+ - **@voltro/workflow, @voltro/runtime, @voltro/database, @voltro/cli, @voltro/plugin-sentry** — **Six raw writes removed from production log streams — and the guard that was supposed to catch them rewritten, because it was green for two independent reasons.**
110
+
111
+ A pod tail showed `[voltro:workflow] shard-lock coordination: row-based (dialect=mariadb, mode=row)` sitting between JSON records. `@voltro/logger` is what makes a line JSON in a pod and pretty on a TTY; a `process.stderr.write` bypasses that decision at exactly the place nobody looks, because a dev terminal renders both the same.
112
+
113
+ Fixed at the source: the workflow cluster layer (2), `rpcServer`'s computed-cache warning, the subscription outbox's and the RYW store's `warn`/`onError` defaults — those two are not fallbacks, the callers pass nothing, so the default IS the production path — and the migration file discovery's skip notice, which lands in the migrate job's stream.
114
+
115
+ **The guard is the part worth reading.** `prodLogDiscipline.test.ts` existed for this exact class and reported clean, for two reasons that had to be fixed separately:
116
+
117
+ - Its file set was a hand-written list of five. A guard that opts files IN says nothing about any file added after it was written. - Its matcher was LINE-LOCAL, so `process.stderr.write(` on one line and the `` `[tag] `` on the next never matched — 4 of the 9 call sites in the repo are written that way, including one in a file that WAS on the list. The guard had been pointed straight at an offender and called it clean.
118
+
119
+ It is opt-OUT now: every server-side package's source is scanned, exceptions carry a reason, and a second test fails if an exception's call site disappears — an allowlist entry for code that is gone reads as a rule with a hole in it.
120
+
121
+ Verified against a real `voltro serve` under `NODE_ENV=production`: 35 records, zero framework lines that are not JSON.
122
+
123
+ ---
124
+
42
125
  ## [0.59.0] — 2026-08-30
43
126
 
44
127
  ### ⚠ BREAKING
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # @voltro/plugin-sentry
4
4
 
5
- **Deep Sentry integration — error tracking correlated to the distributed trace, breadcrumbs from the framework log sink, and (opt-in) performance traces routed from the framework's OTel tracer via @sentry/node in OTel-consumer mode. Errors carry the active trace_id + span_id + the request's recent log lines.**
5
+ **Deep Sentry integration — trace-correlated error tracking, breadcrumbs from the framework log sink, page-owned browser performance spans, and server traces routed from the framework's OTel tracer via @sentry/node in OTel-consumer mode.**
6
6
 
7
7
  [📖 Documentation](https://docs.voltro.dev/docs/plugins/sentry) · [voltro.dev](https://voltro.dev) · [Voltro Cloud](https://voltro.cloud)
8
8
 
package/dist/index.d.ts CHANGED
@@ -35,7 +35,7 @@ declare interface CaptureContext {
35
35
  readonly spanId?: string;
36
36
  }
37
37
 
38
- export declare const captureToSentry: (sentry: SentryLike, cause: Cause.Cause<unknown>, ctx: CaptureContext, breadcrumbs: ReadonlyArray<Breadcrumb>) => void;
38
+ export declare const captureToSentry: (sentry: SentryLike, cause: Cause.Cause<unknown>, ctx: CaptureContext, breadcrumbs: ReadonlyArray<Breadcrumb>, captureFailures?: boolean | ((error: unknown) => boolean)) => void;
39
39
 
40
40
  /** Unwrap an Effect `Cause` to the underlying error value (Error | tagged
41
41
  * error | defect). `Cause.squash` returns the most informative throwable. */
@@ -92,19 +92,37 @@ export declare interface SentryPluginOptions {
92
92
  /**
93
93
  * Route the framework's OTel spans to Sentry as transactions. Default **true**.
94
94
  *
95
- * It was `false`, and that made the pair's default the worst of the three
96
- * available. The BROWSER half defaults `tracesSampleRate: 1.0` with
97
- * `browserTracing` on, so page loads, navigations and every rpc call already
98
- * become spans without anybody asking. With the server side off, each of those
99
- * spans is emitted and paid for, carries a `traceId` the api also logged, and
100
- * belongs to a trace with no server half — a browser hop hanging off nothing.
101
- * Both-off would at least be coherent; both-on is what the two halves were
102
- * built for.
103
- *
104
- * `false` turns them off and still leaves errors + breadcrumbs, which is the
105
- * whole of the plugin for an app with no trace budget.
95
+ * The browser half records page/navigation transactions and page-owned rpc
96
+ * child spans; those children link to the Effect/server trace. `false` turns
97
+ * server transactions off while leaving errors + breadcrumbs intact.
106
98
  */
107
99
  readonly traces?: boolean;
100
+ /**
101
+ * Whether a DECLARED failure reaches Sentry. **Default `false`.**
102
+ *
103
+ * A procedure's `error:` union is a contract: somebody wrote the outcome
104
+ * down, the client gets it typed and branches on it, and it describes a state
105
+ * of the world. `AccessDeniedError` on a team you are not in is the system
106
+ * working. A DEFECT is the opposite — nobody foresaw it — and that is what
107
+ * Sentry is built for. Defects are always reported; this option is only about
108
+ * the other half.
109
+ *
110
+ * The default was `true` by omission rather than by decision, and it filled a
111
+ * deployment's issue list with `level: error` entries for every invalid form
112
+ * value, every click on a resource without access and every call on a deleted
113
+ * row. An issue list of expected things is one nobody reads.
114
+ *
115
+ * Set `true` to keep the old behaviour — worth it if Sentry is where you see
116
+ * errors at all. Or pass a predicate when only some of them are signal:
117
+ *
118
+ * ```ts
119
+ * sentryPlugin({ captureFailures: (e) => (e as { _tag?: string })._tag === 'PaymentDeclined' })
120
+ * ```
121
+ *
122
+ * A cause carrying a defect is reported whatever it travelled with, so this
123
+ * cannot hide one by accident.
124
+ */
125
+ readonly captureFailures?: boolean | ((error: unknown) => boolean);
108
126
  /** Continuous CPU profiling via @sentry/profiling-node. Default false. */
109
127
  readonly profiling?: boolean;
110
128
  /** Profile sample rate (0..1) when `profiling`. Default 1.0. */
package/dist/index.js CHANGED
@@ -1,35 +1,23 @@
1
- import { Cause as e, Effect as t } from "effect";
2
- import { pluginEnv as n } from "@voltro/env";
3
- import { addSink as r } from "@voltro/logger";
4
- import { definePlugin as i, subscribeServerErrors as a } from "@voltro/protocol";
5
- //#region src/dsn.ts
6
- var o = (e) => {
7
- if (!e) return null;
8
- try {
9
- let t = new URL(e), n = t.username, r = t.pathname.split("/").filter(Boolean), i = r[r.length - 1];
10
- return !n || !i ? null : {
11
- protocol: t.protocol.replace(/:$/, ""),
12
- publicKey: n,
13
- host: t.host,
14
- projectId: i
15
- };
16
- } catch {
17
- return null;
18
- }
19
- }, s = {
1
+ import { n as e, r as t, t as n } from "./server-DQn_uTTk.js";
2
+ import { Cause as r, Effect as i } from "effect";
3
+ import { pluginEnv as a } from "@voltro/env";
4
+ import { addSink as o } from "@voltro/logger";
5
+ import { definePlugin as s, subscribeServerErrors as c } from "@voltro/protocol";
6
+ //#region src/breadcrumbs.ts
7
+ var l = {
20
8
  trace: "debug",
21
9
  debug: "debug",
22
10
  info: "info",
23
11
  warn: "warning",
24
12
  error: "error",
25
13
  fatal: "fatal"
26
- }, c = (e) => ({
14
+ }, u = (e) => ({
27
15
  timestamp: e.ts.getTime() / 1e3,
28
- level: s[e.level] ?? "info",
16
+ level: l[e.level] ?? "info",
29
17
  ...e.scope ? { category: e.scope } : {},
30
18
  message: e.message,
31
19
  ...Object.keys(e.fields).length > 0 ? { data: { ...e.fields } } : {}
32
- }), l = (e = {}, t = () => Date.now()) => {
20
+ }), d = (e = {}, t = () => Date.now()) => {
33
21
  let n = e.maxPerTrace ?? 50, r = e.maxTraces ?? 1e3, i = e.ttlMs ?? 3e5, a = /* @__PURE__ */ new Map(), o = () => {
34
22
  let e = t() - i;
35
23
  for (let [t, n] of a) if (n.at < e) a.delete(t);
@@ -38,11 +26,11 @@ var o = (e) => {
38
26
  return {
39
27
  add(e, i) {
40
28
  o();
41
- let s = a.get(e), l = s ?? {
29
+ let s = a.get(e), c = s ?? {
42
30
  at: t(),
43
31
  crumbs: []
44
32
  };
45
- for (s && a.delete(e), l.at = t(), l.crumbs.push(c(i)), l.crumbs.length > n && l.crumbs.shift(), a.set(e, l); a.size > r;) {
33
+ for (s && a.delete(e), c.at = t(), c.crumbs.push(u(i)), c.crumbs.length > n && c.crumbs.shift(), a.set(e, c); a.size > r;) {
46
34
  let e = a.keys().next().value;
47
35
  if (e === void 0) break;
48
36
  a.delete(e);
@@ -59,24 +47,35 @@ var o = (e) => {
59
47
  return a.size;
60
48
  }
61
49
  };
62
- }, u = (t) => e.squash(t), d = (e, t, n = []) => {
50
+ }, f = (e) => r.squash(e), p = (e, t, n = []) => {
63
51
  e.withScope((r) => {
64
52
  r.setTag("voltro.errorSource", t.source), t.name !== void 0 && r.setTag("voltro.name", t.name), t.traceId !== void 0 && r.setContext("trace", { trace_id: t.traceId }), t.fields !== void 0 && r.setContext("voltro", t.fields);
65
53
  for (let e of n) r.addBreadcrumb(e);
66
54
  e.captureException(t.error);
67
55
  });
68
- }, f = (t, n, r, i) => {
69
- if (e.isInterruptedOnly(n)) return;
70
- let a = u(n);
71
- t.withScope((e) => {
72
- e.setContext("trace", {
73
- trace_id: r.traceId,
74
- ...r.spanId === void 0 ? {} : { span_id: r.spanId }
75
- }), e.setTag("rpc.tag", r.tag), e.setTag("rpc.kind", r.kind), e.setTag("subject.type", r.subject.type), r.subject.tenantId !== void 0 && r.subject.tenantId !== null && e.setTag("tenant.id", r.subject.tenantId);
76
- for (let t of i) e.addBreadcrumb(t);
77
- t.captureException(a);
56
+ }, m = (e, t) => {
57
+ if (r.isInterruptedOnly(e)) return !1;
58
+ if (t === !0) return !0;
59
+ let n = [...r.failures(e)];
60
+ return [...r.defects(e)].length > 0 ? !0 : n.length === 0 || t === !1 ? !1 : n.some((e) => {
61
+ try {
62
+ return t(e);
63
+ } catch {
64
+ return !0;
65
+ }
66
+ });
67
+ }, h = (e, t, n, r, i = !1) => {
68
+ if (!m(t, i)) return;
69
+ let a = f(t);
70
+ e.withScope((t) => {
71
+ t.setContext("trace", {
72
+ trace_id: n.traceId,
73
+ ...n.spanId === void 0 ? {} : { span_id: n.spanId }
74
+ }), t.setTag("rpc.tag", n.tag), t.setTag("rpc.kind", n.kind), t.setTag("subject.type", n.subject.type), n.subject.tenantId !== void 0 && n.subject.tenantId !== null && t.setTag("tenant.id", n.subject.tenantId);
75
+ for (let e of r) t.addBreadcrumb(e);
76
+ e.captureException(a);
78
77
  });
79
- }, p = n([
78
+ }, g = a([
80
79
  {
81
80
  name: "SENTRY_DSN",
82
81
  required: !1,
@@ -95,76 +94,61 @@ var o = (e) => {
95
94
  secret: !1,
96
95
  description: "Release identifier for Sentry release health + source maps."
97
96
  }
98
- ]), m = (e = {}) => {
99
- let n = p.read("SENTRY_DSN", e.dsn), s = o(n), c = e.name ? `@voltro/plugin-sentry#${e.name}` : "@voltro/plugin-sentry";
100
- if (!s) return i({
101
- name: c,
97
+ ]), _ = (r = {}) => {
98
+ let a = g.read("SENTRY_DSN", r.dsn), l = t(a), u = r.name ? `@voltro/plugin-sentry#${r.name}` : "@voltro/plugin-sentry";
99
+ if (!l) return s({
100
+ name: u,
102
101
  description: "Sentry error tracking (inactive — no valid SENTRY_DSN).",
103
- onActivate: (e) => t.sync(() => e.logger.warn("sentry inactive — no valid DSN (set `dsn` or SENTRY_DSN)")),
104
- onDeactivate: () => t.void
102
+ onActivate: (e) => i.sync(() => e.logger.warn("sentry inactive — no valid DSN (set `dsn` or SENTRY_DSN)")),
103
+ onDeactivate: () => i.void
105
104
  });
106
- let u = p.read("SENTRY_ENVIRONMENT", e.environment), m = p.read("SENTRY_RELEASE", e.release), h = e.tracesSampleRate ?? 1, g = e.traces ?? !0, _ = l({ maxPerTrace: e.maxBreadcrumbs ?? 50 }), v, y = (e, t) => {
107
- if (v) try {
108
- f(v, e, t, _.take(t.traceId));
105
+ let f = g.read("SENTRY_ENVIRONMENT", r.environment), m = g.read("SENTRY_RELEASE", r.release), _ = r.tracesSampleRate ?? 1, v = r.traces ?? !0, y = r.captureFailures ?? !1, b = d({ maxPerTrace: r.maxBreadcrumbs ?? 50 }), x, S = (e, t) => {
106
+ if (x) try {
107
+ h(x, e, t, b.take(t.traceId), y);
109
108
  } catch {}
110
- }, b = (e, n) => e.pipe(t.tapErrorCause((e) => t.sync(() => y(e, {
111
- tag: n.tag,
112
- kind: n.kind,
113
- subject: n.subject,
114
- traceId: n.traceId,
115
- ...n.spanId === void 0 ? {} : { spanId: n.spanId }
116
- })))), x = [
109
+ }, C = (e, t) => e.pipe(i.tapErrorCause((e) => i.sync(() => S(e, {
110
+ tag: t.tag,
111
+ kind: t.kind,
112
+ subject: t.subject,
113
+ traceId: t.traceId,
114
+ ...t.spanId === void 0 ? {} : { spanId: t.spanId }
115
+ })))), w = [
117
116
  "rpc:intercept:mutation",
118
117
  "rpc:intercept:query",
119
118
  "rpc:intercept:action",
120
- `network:outbound:${s.host}`
121
- ], S, C;
122
- return i({
123
- name: c,
124
- description: "Deep Sentry integration — trace-correlated errors + breadcrumbs + (opt-in) performance traces.",
125
- permissions: x,
126
- declaredEnv: p.declared,
127
- interceptMutation: b,
128
- interceptQuery: b,
129
- interceptAction: b,
119
+ `network:outbound:${l.host}`
120
+ ], T, E;
121
+ return s({
122
+ name: u,
123
+ description: "Deep Sentry integration — trace-correlated errors, breadcrumbs, and controlled performance traces.",
124
+ permissions: w,
125
+ declaredEnv: g.declared,
126
+ interceptMutation: C,
127
+ interceptQuery: C,
128
+ interceptAction: C,
130
129
  contributeObservability: async (t) => {
131
- let r;
132
- try {
133
- r = await import("@sentry/node");
134
- } catch {
135
- t.logger.warn("sentry requested but @sentry/node is not installed — inactive");
136
- return;
137
- }
138
- let i = [];
139
- if (e.profiling) try {
140
- let { nodeProfilingIntegration: e } = await import("@sentry/profiling-node");
141
- i.push(e());
142
- } catch {
143
- t.logger.warn("sentry profiling requested but @sentry/profiling-node is not installed");
144
- }
145
- let { integrations: a, ...o } = e.init ?? {};
146
- if (a && i.push(...a), r.init({
147
- ...o,
148
- dsn: n,
149
- skipOpenTelemetrySetup: !0,
150
- tracesSampleRate: h,
151
- ...u ? { environment: u } : {},
152
- ...m ? { release: m } : {},
153
- ...e.profiling ? { profilesSampleRate: e.profilesSampleRate ?? 1 } : {},
154
- ...i.length > 0 ? { integrations: i } : {}
155
- }), v = r, t.logger.info("sentry active", {
156
- environment: u,
130
+ let i = {
131
+ dsn: a,
132
+ environment: f,
157
133
  release: m,
158
- traces: g,
159
- profiling: !!e.profiling,
160
- ...g ? { tracesSampleRate: h } : {}
161
- }), g) try {
134
+ tracesSampleRate: _,
135
+ traces: v,
136
+ profiling: r.profiling,
137
+ profilesSampleRate: r.profilesSampleRate,
138
+ init: r.init
139
+ }, o = await n(i, t.logger);
140
+ if (o === void 0) return;
141
+ let s = o.sdk;
142
+ if (o.client, x = s, t.logger.info("sentry active", {
143
+ ...e(o, i),
144
+ captureFailures: typeof y == "function" ? "predicate" : y
145
+ }), v) try {
162
146
  let { SentrySpanProcessor: e } = await import("@sentry/opentelemetry");
163
147
  return {
164
148
  spanProcessors: [new e()],
165
149
  resourceAttributes: {
166
150
  ...m ? { "service.version": m } : {},
167
- ...u ? { "deployment.environment": u } : {}
151
+ ...f ? { "deployment.environment": f } : {}
168
152
  }
169
153
  };
170
154
  } catch {
@@ -172,18 +156,18 @@ var o = (e) => {
172
156
  return;
173
157
  }
174
158
  },
175
- onActivate: () => t.sync(() => {
176
- S = r((e) => {
159
+ onActivate: () => i.sync(() => {
160
+ T = o((e) => {
177
161
  let t = e.fields.traceId;
178
- typeof t == "string" && t.length > 0 && _.add(t, e);
179
- }), C = a((e) => {
180
- if (v) try {
181
- d(v, e, e.traceId ? _.take(e.traceId) : []);
162
+ typeof t == "string" && t.length > 0 && b.add(t, e);
163
+ }), E = c((e) => {
164
+ if (x) try {
165
+ p(x, e, e.traceId ? b.take(e.traceId) : []);
182
166
  } catch {}
183
167
  });
184
168
  }),
185
- onDeactivate: () => t.promise(async () => {
186
- S?.(), S = void 0, C?.(), C = void 0;
169
+ onDeactivate: () => i.promise(async () => {
170
+ T?.(), T = void 0, E?.(), E = void 0;
187
171
  try {
188
172
  await (await import("@sentry/node")).close(2e3);
189
173
  } catch {}
@@ -191,4 +175,4 @@ var o = (e) => {
191
175
  });
192
176
  };
193
177
  //#endregion
194
- export { f as captureToSentry, u as causeToError, l as makeBreadcrumbRing, o as parseDsn, m as sentryPlugin, c as toBreadcrumb };
178
+ export { h as captureToSentry, f as causeToError, d as makeBreadcrumbRing, t as parseDsn, _ as sentryPlugin, u as toBreadcrumb };
@@ -0,0 +1,57 @@
1
+ //#region src/dsn.ts
2
+ var e = (e) => {
3
+ if (!e) return null;
4
+ try {
5
+ let t = new URL(e), n = t.username, r = t.pathname.split("/").filter(Boolean), i = r[r.length - 1];
6
+ return !n || !i ? null : {
7
+ protocol: t.protocol.replace(/:$/, ""),
8
+ publicKey: n,
9
+ host: t.host,
10
+ projectId: i
11
+ };
12
+ } catch {
13
+ return null;
14
+ }
15
+ }, t = async (t, n) => {
16
+ if (!e(t.dsn)) return;
17
+ let r;
18
+ try {
19
+ r = await import("@sentry/node");
20
+ } catch {
21
+ n.warn("sentry requested but @sentry/node is not installed — inactive");
22
+ return;
23
+ }
24
+ let i = [];
25
+ if (t.profiling) try {
26
+ let { nodeProfilingIntegration: e } = await import("@sentry/profiling-node");
27
+ i.push(e());
28
+ } catch {
29
+ n.warn("sentry profiling requested but @sentry/profiling-node is not installed");
30
+ }
31
+ let { integrations: a, ...o } = t.init ?? {};
32
+ Array.isArray(a) && i.push(...a);
33
+ let s = t.tracesSampleRate ?? 1, c = t.traces ?? !0, l = r.init({
34
+ ...o,
35
+ dsn: t.dsn,
36
+ skipOpenTelemetrySetup: !0,
37
+ tracesSampleRate: s,
38
+ ...t.environment ? { environment: t.environment } : {},
39
+ ...t.release ? { release: t.release } : {},
40
+ ...t.profiling ? { profilesSampleRate: t.profilesSampleRate ?? 1 } : {},
41
+ ...i.length > 0 ? { integrations: i } : {}
42
+ });
43
+ return {
44
+ sdk: r,
45
+ client: l,
46
+ tracesEnabled: c,
47
+ tracesSampleRate: s
48
+ };
49
+ }, n = (e, t) => ({
50
+ environment: t.environment,
51
+ release: t.release,
52
+ traces: e.tracesEnabled,
53
+ profiling: !!t.profiling,
54
+ ...e.tracesEnabled ? { tracesSampleRate: e.tracesSampleRate } : {}
55
+ });
56
+ //#endregion
57
+ export { n, e as r, t };
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Initialise `@sentry/node`, or explain why not.
3
+ *
4
+ * Returns `undefined` for the two non-error outcomes — no DSN, or the SDK is
5
+ * not installed — because neither is a reason to fail a boot. The api half made
6
+ * that call first (an optional dependency CAN fail to install, and a monitoring
7
+ * integration must never be the thing that stops a deploy), and the web half
8
+ * inherits it rather than deciding again.
9
+ */
10
+ export declare const initSentryServer: (options: SentryServerInitOptions, log: SentryServerLog) => Promise<SentryServer | undefined>;
11
+
12
+ /**
13
+ * The fields the `sentry active` line carries.
14
+ *
15
+ * Shared so the two processes cannot describe the same state differently — the
16
+ * whole point of the change is that a reader tailing an api pod and a web pod
17
+ * sees one vocabulary.
18
+ */
19
+ export declare const sentryActiveFields: (server: SentryServer, options: SentryServerInitOptions) => Record<string, unknown>;
20
+
21
+ export declare interface SentryServer {
22
+ /** The initialised `@sentry/node` namespace. */
23
+ readonly sdk: {
24
+ readonly captureException: (error: unknown, hint?: unknown) => string;
25
+ readonly flush?: (timeout?: number) => Promise<boolean>;
26
+ };
27
+ /** Whatever `Sentry.init` returned — the client, on SDK versions that return
28
+ * one. Passed through rather than re-fetched via `getClient()`, because the
29
+ * two are not the same call on every version and the caller asked for the
30
+ * init's answer. */
31
+ readonly client: unknown;
32
+ readonly tracesEnabled: boolean;
33
+ readonly tracesSampleRate: number;
34
+ }
35
+
36
+ /** What the caller must hand in — resolved from env by the caller, because the
37
+ * two processes read their environment through different gates. */
38
+ export declare interface SentryServerInitOptions {
39
+ readonly dsn: string | undefined;
40
+ readonly environment?: string | undefined;
41
+ readonly release?: string | undefined;
42
+ /** Default 1.0, matching the browser half. */
43
+ readonly tracesSampleRate?: number | undefined;
44
+ /** Default ON — see the plugin's `traces` option for why `false` made the
45
+ * browser half's spans point at nothing. */
46
+ readonly traces?: boolean | undefined;
47
+ readonly profiling?: boolean | undefined;
48
+ readonly profilesSampleRate?: number | undefined;
49
+ /** User escape hatch, spread FIRST so plugin-managed keys stay authoritative. */
50
+ readonly init?: Record<string, unknown> | undefined;
51
+ }
52
+
53
+ export declare interface SentryServerLog {
54
+ readonly info: (message: string, fields?: Record<string, unknown>) => void;
55
+ readonly warn: (message: string, fields?: Record<string, unknown>) => void;
56
+ }
57
+
58
+ export { }
package/dist/server.js ADDED
@@ -0,0 +1,2 @@
1
+ import { n as e, t } from "./server-DQn_uTTk.js";
2
+ export { t as initSentryServer, e as sentryActiveFields };
package/dist/web.d.ts CHANGED
@@ -20,21 +20,45 @@ export declare const closeSentryBrowser: () => void;
20
20
  * server (SSR) and without a DSN. */
21
21
  export declare const initSentryBrowser: (options?: SentryBrowserOptions) => Promise<void>;
22
22
 
23
- /** Emit a browser-side Sentry span into the SAME trace as the server
24
- * transaction the call will produce. */
23
+ /**
24
+ * Is this client-side event a DECLARED failure?
25
+ *
26
+ * Two conditions, and both are needed. The source must be an `rpc.*` one — a
27
+ * route render throw or a manual `reportClientError` is nobody's declared
28
+ * outcome. And the value must carry a `_tag`: the framework's typed errors are
29
+ * `Schema.TaggedError` subclasses, so a decoded one has one, while a transport
30
+ * failure, an aborted socket or a forwarded defect does not.
31
+ *
32
+ * The rule is deliberately narrow. Anything it cannot positively identify as
33
+ * declared is reported, because the cost of the two mistakes is not symmetric:
34
+ * a noisy issue is read and dismissed, a missing one is never read.
35
+ */
36
+ export declare const isDeclaredRpcFailure: (event: {
37
+ source: string;
38
+ error: unknown;
39
+ }) => boolean;
40
+
41
+ /** Add an rpc marker to the active page/navigation transaction and link it to
42
+ * the Effect trace continued by the server. With no active browser parent,
43
+ * `onlyIfParent` deliberately produces no recorded root transaction. */
25
44
  export declare const recordClientTraceSpan: (sentry: SentryBrowserLike, event: ClientTraceEvent) => void;
26
45
 
27
46
  export { reportClientError }
28
47
 
29
48
  export declare interface SentryBrowserLike {
30
- continueTrace<T>(context: {
31
- sentryTrace: string;
32
- baggage?: string;
33
- }, callback: () => T): T;
34
49
  startInactiveSpan(options: {
35
50
  name: string;
36
51
  op?: string;
52
+ onlyIfParent?: boolean;
37
53
  attributes?: Record<string, unknown>;
54
+ links?: ReadonlyArray<{
55
+ context: {
56
+ traceId: string;
57
+ spanId: string;
58
+ traceFlags: number;
59
+ };
60
+ attributes?: Record<string, string | number | boolean>;
61
+ }>;
38
62
  }): SentrySpanLike;
39
63
  withScope(callback: (scope: SentryBrowserScopeLike) => void): unknown;
40
64
  captureException(exception: unknown): unknown;
@@ -53,6 +77,25 @@ export declare interface SentryBrowserOptions {
53
77
  /** Instrument page loads + client navigations via `browserTracingIntegration`.
54
78
  * Default true. */
55
79
  readonly browserTracing?: boolean;
80
+ /** Record rpc markers under the active page/navigation transaction and link
81
+ * them to their server traces. Defaults to `browserTracing`; set `false` to
82
+ * disable only this bridge while keeping browser error reporting. Set
83
+ * `true` with `browserTracing:false` only when the app creates its own
84
+ * active Sentry transactions. */
85
+ readonly rpcSpans?: boolean;
86
+ /**
87
+ * Whether a DECLARED failure that came back from an rpc call reaches Sentry.
88
+ * **Default `false`**, matching `sentryPlugin({ captureFailures })`.
89
+ *
90
+ * Both halves need it or neither works. The api stops reporting
91
+ * `AccessDeniedError` and the browser keeps filing the same rejection,
92
+ * because a rejected call is an rpc error on this side too — the option would
93
+ * be half-wired, and the issue list would look unchanged.
94
+ *
95
+ * Route render failures and explicit `reportClientError` calls are NEVER
96
+ * filtered by this: nobody declared them, which is the whole distinction.
97
+ */
98
+ readonly captureFailures?: boolean | ((error: unknown) => boolean);
56
99
  }
57
100
 
58
101
  declare interface SentryBrowserScopeLike {
@@ -66,8 +109,4 @@ declare interface SentrySpanLike {
66
109
  end(): void;
67
110
  }
68
111
 
69
- /** Build the `sentry-trace` header for a client trace event (sampled=1 — the
70
- * framework records always-on; Sentry's client applies its own sample rate). */
71
- export declare const sentryTraceHeader: (event: ClientTraceEvent) => string;
72
-
73
112
  export { }
package/dist/web.js CHANGED
@@ -5,44 +5,66 @@ var i = (e, t) => {
5
5
  e.withScope((n) => {
6
6
  n.setTag("voltro.errorSource", t.source), t.pathname && n.setTag("route.pathname", t.pathname), t.componentStack && n.setContext("react", { componentStack: t.componentStack }), t.context && n.setContext("voltro", t.context), e.captureException(t.error);
7
7
  });
8
- }, a = (e) => `${e.traceId}-${e.spanId}-1`, o = (e, t) => {
9
- e.continueTrace({ sentryTrace: a(t) }, () => {
10
- e.startInactiveSpan({
11
- name: `${t.source}.${t.tag}`,
12
- op: `rpc.client.${t.source}`,
13
- attributes: {
14
- "rpc.tag": t.tag,
15
- "voltro.source": t.source
16
- }
17
- }).end();
18
- });
19
- }, s = (e) => {
8
+ }, a = (e, t) => {
9
+ e.startInactiveSpan({
10
+ name: `${t.source}.${t.tag}`,
11
+ op: `rpc.client.${t.source}`,
12
+ onlyIfParent: !0,
13
+ attributes: {
14
+ "rpc.tag": t.tag,
15
+ "voltro.source": t.source
16
+ },
17
+ links: [{
18
+ context: {
19
+ traceId: t.traceId,
20
+ spanId: t.spanId,
21
+ traceFlags: 1
22
+ },
23
+ attributes: { "voltro.link.type": "rpc.server-trace" }
24
+ }]
25
+ }).end();
26
+ }, o = (e) => e.source.startsWith("rpc.") && typeof e.error?._tag == "string", s = (e) => {
20
27
  let t = r()[e];
21
28
  return typeof t == "string" && t !== "" ? t : void 0;
22
29
  }, c, l, u = async (e = {}) => {
23
30
  if (typeof window > "u") return;
24
31
  let r = e.dsn ?? s("VOLTRO_PUBLIC_SENTRY_DSN");
25
32
  if (!r) return;
26
- let a = e.environment ?? s("VOLTRO_PUBLIC_SENTRY_ENVIRONMENT"), u = e.release ?? s("VOLTRO_PUBLIC_SENTRY_RELEASE"), d = await import("@sentry/react");
27
- d.init({
33
+ let u = e.environment ?? s("VOLTRO_PUBLIC_SENTRY_ENVIRONMENT"), f = e.release ?? s("VOLTRO_PUBLIC_SENTRY_RELEASE"), p = e.tracesSampleRate ?? 1, m = e.browserTracing !== !1, h = e.rpcSpans ?? m, g = await import("@sentry/react");
34
+ g.init({
28
35
  dsn: r,
29
- tracesSampleRate: e.tracesSampleRate ?? 1,
30
- ...a ? { environment: a } : {},
31
- ...u ? { release: u } : {},
32
- integrations: e.browserTracing === !1 ? [] : [d.browserTracingIntegration()]
36
+ tracesSampleRate: p,
37
+ ...u ? { environment: u } : {},
38
+ ...f ? { release: f } : {},
39
+ integrations: m ? [g.browserTracingIntegration()] : []
33
40
  });
34
- let f = d;
35
- c?.(), c = n((e) => {
41
+ let _ = g;
42
+ c?.(), c = void 0, h && (c = n((e) => {
36
43
  try {
37
- o(f, e);
44
+ a(_, e);
38
45
  } catch {}
39
- }), l?.(), l = t((e) => {
46
+ })), l?.();
47
+ let v = e.captureFailures ?? !1;
48
+ l = t((e) => {
40
49
  try {
41
- i(f, e);
50
+ if (o(e) && !d(e.error, v)) return;
51
+ i(_, e);
42
52
  } catch {}
53
+ }), console.info("[@voltro/plugin-sentry] browser active", {
54
+ tracesSampleRate: p,
55
+ browserTracing: m,
56
+ rpcSpans: h,
57
+ rpcSpanMode: h ? "page-child-with-server-link" : "off"
43
58
  });
44
- }, d = () => {
59
+ }, d = (e, t) => {
60
+ if (typeof t != "function") return t;
61
+ try {
62
+ return t(e);
63
+ } catch {
64
+ return !0;
65
+ }
66
+ }, f = () => {
45
67
  c?.(), c = void 0, l?.(), l = void 0;
46
68
  };
47
69
  //#endregion
48
- export { i as captureClientError, d as closeSentryBrowser, u as initSentryBrowser, o as recordClientTraceSpan, e as reportClientError, a as sentryTraceHeader };
70
+ export { i as captureClientError, f as closeSentryBrowser, u as initSentryBrowser, o as isDeclaredRpcFailure, a as recordClientTraceSpan, e as reportClientError };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@voltro/plugin-sentry",
3
- "version": "0.59.0",
4
- "description": "Deep Sentry integration — error tracking correlated to the distributed trace, breadcrumbs from the framework log sink, and (opt-in) performance traces routed from the framework's OTel tracer via @sentry/node in OTel-consumer mode. Errors carry the active trace_id + span_id + the request's recent log lines.",
3
+ "version": "0.61.0",
4
+ "description": "Deep Sentry integration — error tracking correlated to distributed traces, breadcrumbs from the framework log sink, controlled browser performance spans, and server traces routed from the framework's OTel tracer via @sentry/node in OTel-consumer mode.",
5
5
  "keywords": [
6
6
  "voltro",
7
7
  "typescript",
@@ -23,6 +23,11 @@
23
23
  "import": "./dist/index.js",
24
24
  "default": "./dist/index.js"
25
25
  },
26
+ "./server": {
27
+ "types": "./dist/server.d.ts",
28
+ "import": "./dist/server.js",
29
+ "default": "./dist/server.js"
30
+ },
26
31
  "./web": {
27
32
  "types": "./dist/web.d.ts",
28
33
  "import": "./dist/web.js",
@@ -38,10 +43,10 @@
38
43
  "node": ">=24.0.0"
39
44
  },
40
45
  "dependencies": {
41
- "@voltro/client": "0.59.0",
42
- "@voltro/env": "0.59.0",
43
- "@voltro/logger": "0.59.0",
44
- "@voltro/protocol": "0.59.0"
46
+ "@voltro/client": "0.61.0",
47
+ "@voltro/env": "0.61.0",
48
+ "@voltro/logger": "0.61.0",
49
+ "@voltro/protocol": "0.61.0"
45
50
  },
46
51
  "optionalDependencies": {
47
52
  "@sentry/node": "^10.70.0",