@voltro/plugin-sentry 0.85.0 → 0.87.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.
@@ -0,0 +1,47 @@
1
+ //#region src/breadcrumbs.ts
2
+ var e = {
3
+ trace: "debug",
4
+ debug: "debug",
5
+ info: "info",
6
+ warn: "warning",
7
+ error: "error",
8
+ fatal: "fatal"
9
+ }, t = (t) => ({
10
+ timestamp: t.ts.getTime() / 1e3,
11
+ level: e[t.level] ?? "info",
12
+ ...t.scope ? { category: t.scope } : {},
13
+ message: t.message,
14
+ ...Object.keys(t.fields).length > 0 ? { data: { ...t.fields } } : {}
15
+ }), n = (e = {}, n = () => Date.now()) => {
16
+ let r = e.maxPerTrace ?? 50, i = e.maxTraces ?? 1e3, a = e.ttlMs ?? 3e5, o = /* @__PURE__ */ new Map(), s = () => {
17
+ let e = n() - a;
18
+ for (let [t, n] of o) if (n.at < e) o.delete(t);
19
+ else break;
20
+ };
21
+ return {
22
+ add(e, a) {
23
+ s();
24
+ let c = o.get(e), l = c ?? {
25
+ at: n(),
26
+ crumbs: []
27
+ };
28
+ for (c && o.delete(e), l.at = n(), l.crumbs.push(t(a)), l.crumbs.length > r && l.crumbs.shift(), o.set(e, l); o.size > i;) {
29
+ let e = o.keys().next().value;
30
+ if (e === void 0) break;
31
+ o.delete(e);
32
+ }
33
+ },
34
+ take(e) {
35
+ let t = o.get(e);
36
+ return o.delete(e), t ? t.crumbs : [];
37
+ },
38
+ drop(e) {
39
+ o.delete(e);
40
+ },
41
+ size() {
42
+ return o.size;
43
+ }
44
+ };
45
+ };
46
+ //#endregion
47
+ export { n as makeBreadcrumbRing, t as toBreadcrumb };
@@ -40,4 +40,4 @@ var n = (t) => e.squash(t), r = (e, n, r = []) => {
40
40
  });
41
41
  };
42
42
  //#endregion
43
- export { o as i, c as n, n as r, r as t };
43
+ export { i as INFRASTRUCTURE_FAILURE_TAGS, r as captureServerError, c as captureToSentry, n as causeToError, a as isInfrastructureFailure, o as resolveCaptureFailures, s as shouldCapture };
package/dist/dsn.js ADDED
@@ -0,0 +1,17 @@
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
+ };
16
+ //#endregion
17
+ export { e as parseDsn };
package/dist/index.js CHANGED
@@ -1,54 +1,13 @@
1
- import { n as e, r as t, t as n } from "./server-DQn_uTTk.js";
2
- import { i as r, n as i, r as a, t as o } from "./capture-DcovIn-Z.js";
3
- import { Effect as s } from "effect";
4
- import { pluginEnv as c } from "@voltro/env";
5
- import { addSink as l } from "@voltro/logger";
6
- import { definePlugin as u, subscribeServerErrors as d } from "@voltro/protocol";
7
- //#region src/breadcrumbs.ts
8
- var f = {
9
- trace: "debug",
10
- debug: "debug",
11
- info: "info",
12
- warn: "warning",
13
- error: "error",
14
- fatal: "fatal"
15
- }, p = (e) => ({
16
- timestamp: e.ts.getTime() / 1e3,
17
- level: f[e.level] ?? "info",
18
- ...e.scope ? { category: e.scope } : {},
19
- message: e.message,
20
- ...Object.keys(e.fields).length > 0 ? { data: { ...e.fields } } : {}
21
- }), m = (e = {}, t = () => Date.now()) => {
22
- let n = e.maxPerTrace ?? 50, r = e.maxTraces ?? 1e3, i = e.ttlMs ?? 3e5, a = /* @__PURE__ */ new Map(), o = () => {
23
- let e = t() - i;
24
- for (let [t, n] of a) if (n.at < e) a.delete(t);
25
- else break;
26
- };
27
- return {
28
- add(e, i) {
29
- o();
30
- let s = a.get(e), c = s ?? {
31
- at: t(),
32
- crumbs: []
33
- };
34
- for (s && a.delete(e), c.at = t(), c.crumbs.push(p(i)), c.crumbs.length > n && c.crumbs.shift(), a.set(e, c); a.size > r;) {
35
- let e = a.keys().next().value;
36
- if (e === void 0) break;
37
- a.delete(e);
38
- }
39
- },
40
- take(e) {
41
- let t = a.get(e);
42
- return a.delete(e), t ? t.crumbs : [];
43
- },
44
- drop(e) {
45
- a.delete(e);
46
- },
47
- size() {
48
- return a.size;
49
- }
50
- };
51
- }, h = c([
1
+ import { parseDsn as e } from "./dsn.js";
2
+ import { makeBreadcrumbRing as t, toBreadcrumb as n } from "./breadcrumbs.js";
3
+ import { captureServerError as r, captureToSentry as i, causeToError as a, resolveCaptureFailures as o } from "./capture.js";
4
+ import { initSentryServer as s, sentryActiveFields as c } from "./server.js";
5
+ import { Effect as l } from "effect";
6
+ import { pluginEnv as u } from "@voltro/env";
7
+ import { addSink as d } from "@voltro/logger";
8
+ import { definePlugin as f, subscribeServerErrors as p } from "@voltro/protocol";
9
+ //#region src/index.ts
10
+ var m = u([
52
11
  {
53
12
  name: "SENTRY_DSN",
54
13
  required: !1,
@@ -67,19 +26,19 @@ var f = {
67
26
  secret: !1,
68
27
  description: "Release identifier for Sentry release health + source maps."
69
28
  }
70
- ]), g = (a = {}) => {
71
- let c = h.read("SENTRY_DSN", a.dsn), f = t(c), p = a.name ? `@voltro/plugin-sentry#${a.name}` : "@voltro/plugin-sentry";
72
- if (!f) return u({
73
- name: p,
29
+ ]), h = (n = {}) => {
30
+ let a = m.read("SENTRY_DSN", n.dsn), u = e(a), h = n.name ? `@voltro/plugin-sentry#${n.name}` : "@voltro/plugin-sentry";
31
+ if (!u) return f({
32
+ name: h,
74
33
  description: "Sentry error tracking (inactive — no valid SENTRY_DSN).",
75
- onActivate: (e) => s.sync(() => e.logger.warn("sentry inactive — no valid DSN (set `dsn` or SENTRY_DSN)")),
76
- onDeactivate: () => s.void
34
+ onActivate: (e) => l.sync(() => e.logger.warn("sentry inactive — no valid DSN (set `dsn` or SENTRY_DSN)")),
35
+ onDeactivate: () => l.void
77
36
  });
78
- let g = h.read("SENTRY_ENVIRONMENT", a.environment), _ = h.read("SENTRY_RELEASE", a.release), v = a.tracesSampleRate ?? 1, y = a.traces ?? !0, b = a.captureFailures ?? !1, x = r(b), S = m({ maxPerTrace: a.maxBreadcrumbs ?? 50 }), C, w = (e, t) => {
37
+ let g = m.read("SENTRY_ENVIRONMENT", n.environment), _ = m.read("SENTRY_RELEASE", n.release), v = n.tracesSampleRate ?? 1, y = n.traces ?? !0, b = n.captureFailures ?? !1, x = o(b), S = t({ maxPerTrace: n.maxBreadcrumbs ?? 50 }), C, w = (e, t) => {
79
38
  if (C) try {
80
39
  i(C, e, t, S.take(t.traceId), x);
81
40
  } catch {}
82
- }, T = (e, t) => e.pipe(s.tapCause((e) => s.sync(() => w(e, {
41
+ }, T = (e, t) => e.pipe(l.tapCause((e) => l.sync(() => w(e, {
83
42
  tag: t.tag,
84
43
  kind: t.kind,
85
44
  subject: t.subject,
@@ -90,32 +49,32 @@ var f = {
90
49
  "rpc:intercept:query",
91
50
  "rpc:intercept:action",
92
51
  "rpc:intercept:workflow",
93
- `network:outbound:${f.host}`
52
+ `network:outbound:${u.host}`
94
53
  ], D, O;
95
- return u({
96
- name: p,
54
+ return f({
55
+ name: h,
97
56
  description: "Deep Sentry integration — trace-correlated errors, breadcrumbs, and controlled performance traces.",
98
57
  permissions: E,
99
- declaredEnv: h.declared,
58
+ declaredEnv: m.declared,
100
59
  interceptMutation: T,
101
60
  interceptQuery: T,
102
61
  interceptAction: T,
103
62
  interceptWorkflow: T,
104
- contributeObservability: async (t) => {
105
- let r = {
106
- dsn: c,
63
+ contributeObservability: async (e) => {
64
+ let t = {
65
+ dsn: a,
107
66
  environment: g,
108
67
  release: _,
109
68
  tracesSampleRate: v,
110
69
  traces: y,
111
- profiling: a.profiling,
112
- profilesSampleRate: a.profilesSampleRate,
113
- init: a.init
114
- }, i = await n(r, t.logger);
115
- if (i === void 0) return;
116
- let o = i.sdk;
117
- if (i.client, C = o, t.logger.info("sentry active", {
118
- ...e(i, r),
70
+ profiling: n.profiling,
71
+ profilesSampleRate: n.profilesSampleRate,
72
+ init: n.init
73
+ }, r = await s(t, e.logger);
74
+ if (r === void 0) return;
75
+ let i = r.sdk;
76
+ if (r.client, C = i, e.logger.info("sentry active", {
77
+ ...c(r, t),
119
78
  captureFailures: typeof b == "function" ? "predicate" : b
120
79
  }), y) try {
121
80
  let { SentrySpanProcessor: e } = await import("@sentry/opentelemetry");
@@ -127,21 +86,21 @@ var f = {
127
86
  }
128
87
  };
129
88
  } catch {
130
- t.logger.warn("sentry traces are on but @sentry/opentelemetry is not installed — no span export. Set `traces: false` to silence this, or install it (it is an optional dependency of @voltro/plugin-sentry).");
89
+ e.logger.warn("sentry traces are on but @sentry/opentelemetry is not installed — no span export. Set `traces: false` to silence this, or install it (it is an optional dependency of @voltro/plugin-sentry).");
131
90
  return;
132
91
  }
133
92
  },
134
- onActivate: () => s.sync(() => {
135
- D = l((e) => {
93
+ onActivate: () => l.sync(() => {
94
+ D = d((e) => {
136
95
  let t = e.fields.traceId;
137
96
  typeof t == "string" && t.length > 0 && S.add(t, e);
138
- }), O = d((e) => {
97
+ }), O = p((e) => {
139
98
  if (C) try {
140
- o(C, e, e.traceId ? S.take(e.traceId) : []);
99
+ r(C, e, e.traceId ? S.take(e.traceId) : []);
141
100
  } catch {}
142
101
  });
143
102
  }),
144
- onDeactivate: () => s.promise(async () => {
103
+ onDeactivate: () => l.promise(async () => {
145
104
  D?.(), D = void 0, O?.(), O = void 0;
146
105
  try {
147
106
  await (await import("@sentry/node")).close(2e3);
@@ -150,4 +109,4 @@ var f = {
150
109
  });
151
110
  };
152
111
  //#endregion
153
- export { i as captureToSentry, a as causeToError, m as makeBreadcrumbRing, t as parseDsn, g as sentryPlugin, p as toBreadcrumb };
112
+ export { i as captureToSentry, a as causeToError, t as makeBreadcrumbRing, e as parseDsn, h as sentryPlugin, n as toBreadcrumb };
package/dist/server.js CHANGED
@@ -1,2 +1,45 @@
1
- import { n as e, t } from "./server-DQn_uTTk.js";
2
- export { t as initSentryServer, e as sentryActiveFields };
1
+ import { parseDsn as e } from "./dsn.js";
2
+ //#region src/server.ts
3
+ var t = async (t, n) => {
4
+ if (!e(t.dsn)) return;
5
+ let r;
6
+ try {
7
+ r = await import("@sentry/node");
8
+ } catch {
9
+ n.warn("sentry requested but @sentry/node is not installed — inactive");
10
+ return;
11
+ }
12
+ let i = [];
13
+ if (t.profiling) try {
14
+ let { nodeProfilingIntegration: e } = await import("@sentry/profiling-node");
15
+ i.push(e());
16
+ } catch {
17
+ n.warn("sentry profiling requested but @sentry/profiling-node is not installed");
18
+ }
19
+ let { integrations: a, ...o } = t.init ?? {};
20
+ Array.isArray(a) && i.push(...a);
21
+ let s = t.tracesSampleRate ?? 1, c = t.traces ?? !0, l = r.init({
22
+ ...o,
23
+ dsn: t.dsn,
24
+ skipOpenTelemetrySetup: !0,
25
+ tracesSampleRate: s,
26
+ ...t.environment ? { environment: t.environment } : {},
27
+ ...t.release ? { release: t.release } : {},
28
+ ...t.profiling ? { profilesSampleRate: t.profilesSampleRate ?? 1 } : {},
29
+ ...i.length > 0 ? { integrations: i } : {}
30
+ });
31
+ return {
32
+ sdk: r,
33
+ client: l,
34
+ tracesEnabled: c,
35
+ tracesSampleRate: s
36
+ };
37
+ }, n = (e, t) => ({
38
+ environment: t.environment,
39
+ release: t.release,
40
+ traces: e.tracesEnabled,
41
+ profiling: !!t.profiling,
42
+ ...e.tracesEnabled ? { tracesSampleRate: e.tracesSampleRate } : {}
43
+ });
44
+ //#endregion
45
+ export { t as initSentryServer, n as sentryActiveFields };
package/dist/web.js CHANGED
@@ -1,56 +1,34 @@
1
- import { i as e } from "./capture-DcovIn-Z.js";
2
- import { reportableError as t } from "@voltro/protocol";
3
- import { reportClientError as n, subscribeClientErrors as r, subscribeClientTraces as i } from "@voltro/client";
4
- import { publicEnvSnapshot as a } from "@voltro/env/public";
5
- //#region src/webTrace.ts
6
- var o = (e, n) => {
7
- e.withScope((r) => {
8
- r.setTag("voltro.errorSource", n.source), n.pathname && r.setTag("route.pathname", n.pathname), n.componentStack && r.setContext("react", { componentStack: n.componentStack }), n.context && r.setContext("voltro", n.context), e.captureException(t(n.error));
9
- });
10
- }, s = (e, t) => {
11
- e.startInactiveSpan({
12
- name: `${t.source}.${t.tag}`,
13
- op: `rpc.client.${t.source}`,
14
- onlyIfParent: !0,
15
- attributes: {
16
- "rpc.tag": t.tag,
17
- "voltro.source": t.source
18
- },
19
- links: [{
20
- context: {
21
- traceId: t.traceId,
22
- spanId: t.spanId,
23
- traceFlags: 1
24
- },
25
- attributes: { "voltro.link.type": "rpc.server-trace" }
26
- }]
27
- }).end();
28
- }, c = (e) => e.source.startsWith("rpc.") && typeof e.error?._tag == "string", l = (e) => {
29
- let t = a()[e];
1
+ import { resolveCaptureFailures as e } from "./capture.js";
2
+ import { captureClientError as t, recordClientTraceSpan as n } from "./webTrace.js";
3
+ import { reportClientError as r, subscribeClientErrors as i, subscribeClientTraces as a } from "@voltro/client";
4
+ import { publicEnvSnapshot as o } from "@voltro/env/public";
5
+ //#region src/web.ts
6
+ var s = (e) => e.source.startsWith("rpc.") && typeof e.error?._tag == "string", c = (e) => {
7
+ let t = o()[e];
30
8
  return typeof t == "string" && t !== "" ? t : void 0;
31
- }, u, d, f = async (t = {}) => {
9
+ }, l, u, d = async (r = {}) => {
32
10
  if (typeof window > "u") return;
33
- let n = t.dsn ?? l("VOLTRO_PUBLIC_SENTRY_DSN");
34
- if (!n) return;
35
- let a = t.environment ?? l("VOLTRO_PUBLIC_SENTRY_ENVIRONMENT"), f = t.release ?? l("VOLTRO_PUBLIC_SENTRY_RELEASE"), m = t.tracesSampleRate ?? 1, h = t.browserTracing !== !1, g = t.rpcSpans ?? h, _ = await import("@sentry/react");
11
+ let o = r.dsn ?? c("VOLTRO_PUBLIC_SENTRY_DSN");
12
+ if (!o) return;
13
+ let d = r.environment ?? c("VOLTRO_PUBLIC_SENTRY_ENVIRONMENT"), p = r.release ?? c("VOLTRO_PUBLIC_SENTRY_RELEASE"), m = r.tracesSampleRate ?? 1, h = r.browserTracing !== !1, g = r.rpcSpans ?? h, _ = await import("@sentry/react");
36
14
  _.init({
37
- dsn: n,
15
+ dsn: o,
38
16
  tracesSampleRate: m,
39
- ...a ? { environment: a } : {},
40
- ...f ? { release: f } : {},
17
+ ...d ? { environment: d } : {},
18
+ ...p ? { release: p } : {},
41
19
  integrations: h ? [_.browserTracingIntegration()] : []
42
20
  });
43
21
  let v = _;
44
- u?.(), u = void 0, g && (u = i((e) => {
22
+ l?.(), l = void 0, g && (l = a((e) => {
45
23
  try {
46
- s(v, e);
24
+ n(v, e);
47
25
  } catch {}
48
- })), d?.();
49
- let y = e(t.captureFailures ?? !1);
50
- d = r((e) => {
26
+ })), u?.();
27
+ let y = e(r.captureFailures ?? !1);
28
+ u = i((e) => {
51
29
  try {
52
- if (c(e) && !p(e.error, y)) return;
53
- o(v, e);
30
+ if (s(e) && !f(e.error, y)) return;
31
+ t(v, e);
54
32
  } catch {}
55
33
  }), console.info("[@voltro/plugin-sentry] browser active", {
56
34
  tracesSampleRate: m,
@@ -58,15 +36,15 @@ var o = (e, n) => {
58
36
  rpcSpans: g,
59
37
  rpcSpanMode: g ? "page-child-with-server-link" : "off"
60
38
  });
61
- }, p = (e, t) => {
39
+ }, f = (e, t) => {
62
40
  if (typeof t != "function") return t;
63
41
  try {
64
42
  return t(e);
65
43
  } catch {
66
44
  return !0;
67
45
  }
68
- }, m = () => {
69
- u?.(), u = void 0, d?.(), d = void 0;
46
+ }, p = () => {
47
+ l?.(), l = void 0, u?.(), u = void 0;
70
48
  };
71
49
  //#endregion
72
- export { o as captureClientError, m as closeSentryBrowser, f as initSentryBrowser, c as isDeclaredRpcFailure, s as recordClientTraceSpan, n as reportClientError };
50
+ export { t as captureClientError, p as closeSentryBrowser, d as initSentryBrowser, s as isDeclaredRpcFailure, n as recordClientTraceSpan, r as reportClientError };
@@ -0,0 +1,27 @@
1
+ import { reportableError as e } from "@voltro/protocol";
2
+ //#region src/webTrace.ts
3
+ var t = (t, n) => {
4
+ t.withScope((r) => {
5
+ r.setTag("voltro.errorSource", n.source), n.pathname && r.setTag("route.pathname", n.pathname), n.componentStack && r.setContext("react", { componentStack: n.componentStack }), n.context && r.setContext("voltro", n.context), t.captureException(e(n.error));
6
+ });
7
+ }, n = (e, t) => {
8
+ e.startInactiveSpan({
9
+ name: `${t.source}.${t.tag}`,
10
+ op: `rpc.client.${t.source}`,
11
+ onlyIfParent: !0,
12
+ attributes: {
13
+ "rpc.tag": t.tag,
14
+ "voltro.source": t.source
15
+ },
16
+ links: [{
17
+ context: {
18
+ traceId: t.traceId,
19
+ spanId: t.spanId,
20
+ traceFlags: 1
21
+ },
22
+ attributes: { "voltro.link.type": "rpc.server-trace" }
23
+ }]
24
+ }).end();
25
+ };
26
+ //#endregion
27
+ export { t as captureClientError, n as recordClientTraceSpan };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/plugin-sentry",
3
- "version": "0.85.0",
3
+ "version": "0.87.0",
4
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",
@@ -43,10 +43,10 @@
43
43
  "node": ">=24.0.0"
44
44
  },
45
45
  "dependencies": {
46
- "@voltro/client": "0.85.0",
47
- "@voltro/env": "0.85.0",
48
- "@voltro/logger": "0.85.0",
49
- "@voltro/protocol": "0.85.0"
46
+ "@voltro/client": "0.87.0",
47
+ "@voltro/env": "0.87.0",
48
+ "@voltro/logger": "0.87.0",
49
+ "@voltro/protocol": "0.87.0"
50
50
  },
51
51
  "optionalDependencies": {
52
52
  "@sentry/node": "^10.75.0",
@@ -1,57 +0,0 @@
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 };