@belvador/tanstack-start 0.2.0 → 0.4.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
@@ -46,6 +46,52 @@ Server functions and server routes are reported with their server stack; redirec
46
46
  or a failure after the client disconnected — `captureAborted: true` reports them) are not.
47
47
  Needs `nodejs_compat` and the `BELVADOR_DSN` secret on the server.
48
48
 
49
+ ## Monitor background work
50
+
51
+ Errors alone cannot tell you that a job never ran. Wrap scheduled and queued work in
52
+ `withMonitor` (Sentry-compatible check-ins): Belvador sees each run start and finish, and
53
+ opens an incident when a run fails, times out or never happens.
54
+
55
+ ```ts
56
+ // src/routes/api/jobs/nightly-invoices.ts — called by your scheduler
57
+ import { createFileRoute } from "@tanstack/react-router";
58
+ import { withMonitor } from "@belvador/tanstack-start/server";
59
+
60
+ export const Route = createFileRoute("/api/jobs/nightly-invoices")({
61
+ server: {
62
+ handlers: {
63
+ POST: async () => {
64
+ const sent = await withMonitor(
65
+ "nightly-invoices",
66
+ async (run) => {
67
+ const due = await loadDueInvoices();
68
+ if (due.length === 0) run.skip("nothing_due");
69
+ return sendInvoices(due);
70
+ },
71
+ { schedule: { type: "crontab", value: "0 2 * * *" }, timezone: "Europe/Berlin" },
72
+ );
73
+ return Response.json({ sent });
74
+ },
75
+ },
76
+ },
77
+ });
78
+ ```
79
+
80
+ Your function's result and errors come back unchanged (a synchronous function stays
81
+ synchronous); an error is also reported as a normal issue with the monitor's slug. For queue
82
+ consumers pass `runId` (your message id), `attempt` and `willRetry` so retries count as one
83
+ run. `captureCheckIn()` and `heartbeat()` cover manual start/finish and "still alive" checks.
84
+ Check-ins are sent only from server code. See https://belvador.dev/docs/monitors/setup
85
+
86
+ ## Link requests with one trace
87
+
88
+ Off by default. `tracePropagation: { targets: [/^\/api\//, "https://api.example.com"] }` (in
89
+ `init` and in the `withBelvador` options) adds `traceparent` and `sentry-trace` headers to
90
+ `fetch` calls to those URLs, so the browser error, the server error and the job's check-ins
91
+ behind one request share a trace id. An incoming
92
+ `traceparent` (or `sentry-trace`) is continued. No spans or transactions are sent; `baggage`
93
+ only with `baggage: true`. See https://belvador.dev/docs/sdk/tracing
94
+
49
95
  ## Check the connection
50
96
 
51
97
  "No errors" is not proof that errors arrive. Call `verifyIntegration()` once from the browser
@@ -56,8 +102,9 @@ https://belvador.dev/docs/sdk/verify
56
102
 
57
103
  ## What it sends
58
104
 
59
- Errors only (exceptions, messages, breadcrumbs you turn on, attachments if you enable them).
60
- No tracing, session replay, logs or profiling — those items are dropped inside your app.
105
+ Errors (exceptions, messages, breadcrumbs you turn on, attachments if you enable them) and
106
+ the job check-ins you send with `withMonitor`. No spans, session replay, logs or profiling —
107
+ those items are dropped inside your app.
61
108
 
62
109
  Before anything leaves your app the SDK removes `Authorization`, `Cookie` and `Set-Cookie`
63
110
  headers, request bodies and cookies, client IP headers, and masks credentials in URLs, query
package/dist/server.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type WorkerOptions } from "@belvador/cloudflare";
2
2
  import { type VerificationResult, type VerifyOptions } from "@belvador/core";
3
- export { SDK_VERSION, addBreadcrumb, captureException, captureMessage, flush, getDiagnostics, setContext, setTag, setTags, setUser, withScope, type BelvadorEnv, type Diagnostic, type DiagnosticCode, type DiagnosticsSnapshot, type WorkerOptions, } from "@belvador/cloudflare";
3
+ export { SDK_VERSION, addBreadcrumb, captureCheckIn, captureException, captureMessage, flush, heartbeat, withMonitor, getDiagnostics, setContext, setTag, setTags, setUser, withScope, type BelvadorEnv, type Diagnostic, type DiagnosticCode, type DiagnosticsSnapshot, type CheckInInput, type MonitorConfigInput, type MonitorSchedule, type RunHandle, type TracePropagationOptions, type WithMonitorOptions, type WorkerOptions, } from "@belvador/cloudflare";
4
4
  export type { VerificationResult, VerifyOptions } from "@belvador/core";
5
5
  /**
6
6
  * `export default withBelvador((env) => ({ release: env.BELVADOR_RELEASE }), { fetch })`:
package/dist/server.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // src/server.ts; add the middleware from "@belvador/tanstack-start" to src/start.ts.
3
3
  import { wrapHandler } from "@belvador/cloudflare";
4
4
  import { currentHooks, runVerification, } from "@belvador/core";
5
- export { SDK_VERSION, addBreadcrumb, captureException, captureMessage, flush, getDiagnostics, setContext, setTag, setTags, setUser, withScope, } from "@belvador/cloudflare";
5
+ export { SDK_VERSION, addBreadcrumb, captureCheckIn, captureException, captureMessage, flush, heartbeat, withMonitor, getDiagnostics, setContext, setTag, setTags, setUser, withScope, } from "@belvador/cloudflare";
6
6
  /**
7
7
  * `export default withBelvador((env) => ({ release: env.BELVADOR_RELEASE }), { fetch })`:
8
8
  * one client per request, errors reported and re-thrown, the response untouched.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@belvador/tanstack-start",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Belvador error tracking for TanStack Start on Cloudflare Workers: client, server entry and middleware.",
5
5
  "license": "MIT",
6
6
  "author": "Belvador (https://belvador.dev)",
@@ -42,9 +42,9 @@
42
42
  "node": ">=18"
43
43
  },
44
44
  "dependencies": {
45
- "@belvador/cloudflare": "0.2.0",
46
- "@belvador/core": "0.2.0",
47
- "@belvador/react": "0.2.0"
45
+ "@belvador/cloudflare": "0.4.0",
46
+ "@belvador/core": "0.4.0",
47
+ "@belvador/react": "0.4.0"
48
48
  },
49
49
  "publishConfig": {
50
50
  "access": "public",