@belvador/tanstack-start 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 +11 -2
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +10 -4
- package/dist/server.d.ts +10 -1
- package/dist/server.js +11 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -42,8 +42,17 @@ export const startInstance = createStart(() => ({
|
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
Server functions and server routes are reported with their server stack; redirects,
|
|
45
|
-
`notFound()
|
|
46
|
-
`
|
|
45
|
+
`notFound()`, errors with a status below 500 and requests the visitor cancelled (`AbortError`,
|
|
46
|
+
or a failure after the client disconnected — `captureAborted: true` reports them) are not.
|
|
47
|
+
Needs `nodejs_compat` and the `BELVADOR_DSN` secret on the server.
|
|
48
|
+
|
|
49
|
+
## Check the connection
|
|
50
|
+
|
|
51
|
+
"No errors" is not proof that errors arrive. Call `verifyIntegration()` once from the browser
|
|
52
|
+
(`@belvador/tanstack-start/client`) and once from a server route (`@belvador/tanstack-start/server`):
|
|
53
|
+
each sends one marked test error (never an issue), reads it back and resolves to
|
|
54
|
+
`{ outcome: "verified" | "problem" | "unconfirmed", checks, docsUrl, … }`. It never throws. See
|
|
55
|
+
https://belvador.dev/docs/sdk/verify
|
|
47
56
|
|
|
48
57
|
## What it sends
|
|
49
58
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactOptions } from "@belvador/react";
|
|
2
|
-
export { ErrorBoundary, SDK_VERSION, addBreadcrumb, captureException, captureMessage, close, flush, lastEventId, reactErrorHandler, setContext, setTag, setTags, setUser, withErrorBoundary, withScope, type ErrorBoundaryProps, type ReactOptions, } from "@belvador/react";
|
|
2
|
+
export { ErrorBoundary, SDK_VERSION, addBreadcrumb, captureException, captureMessage, close, flush, getDiagnostics, lastEventId, reactErrorHandler, setContext, setTag, setTags, setUser, withErrorBoundary, withScope, verifyIntegration, type Diagnostic, type DiagnosticCode, type DiagnosticsSnapshot, type ErrorBoundaryProps, type ReactOptions, type VerificationResult, type VerifyOptions, } from "@belvador/react";
|
|
3
3
|
export { belvadorOnCatch } from "./index.js";
|
|
4
4
|
/** Starts error tracking in the browser; returns whether it is running. Never throws. */
|
|
5
5
|
export declare function init(options: ReactOptions): boolean;
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { initReact } from "@belvador/react/internal";
|
|
2
|
-
export { ErrorBoundary, SDK_VERSION, addBreadcrumb, captureException, captureMessage, close, flush, lastEventId, reactErrorHandler, setContext, setTag, setTags, setUser, withErrorBoundary, withScope, } from "@belvador/react";
|
|
2
|
+
export { ErrorBoundary, SDK_VERSION, addBreadcrumb, captureException, captureMessage, close, flush, getDiagnostics, lastEventId, reactErrorHandler, setContext, setTag, setTags, setUser, withErrorBoundary, withScope, verifyIntegration, } from "@belvador/react";
|
|
3
3
|
export { belvadorOnCatch } from "./index.js";
|
|
4
4
|
/** Starts error tracking in the browser; returns whether it is running. Never throws. */
|
|
5
5
|
export function init(options) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { SDK_VERSION } from "@belvador/core";
|
|
2
2
|
/**
|
|
3
3
|
* Control flow, not failures: redirects, not-found, thrown Responses and
|
|
4
|
-
* anything carrying an HTTP status below 500
|
|
4
|
+
* anything carrying an HTTP status below 500 (499 "client closed" included) are
|
|
5
|
+
* never reported. Client cancellations (AbortError, or a failure after the visitor
|
|
6
|
+
* disconnected) are dropped by the SDK itself unless `captureAborted` is on.
|
|
5
7
|
*/
|
|
6
8
|
export declare function isExpectedError(error: unknown): boolean;
|
|
7
9
|
/**
|
package/dist/index.js
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
// bundles: it only calls the runtime-neutral capture API.
|
|
4
4
|
import { isNotFound, isRedirect } from "@tanstack/react-router";
|
|
5
5
|
import { createMiddleware } from "@tanstack/react-start";
|
|
6
|
-
import { captureException } from "@belvador/core";
|
|
6
|
+
import { captureException, markHooked, noteClientAbort } from "@belvador/core";
|
|
7
7
|
export { SDK_VERSION } from "@belvador/core";
|
|
8
8
|
/**
|
|
9
9
|
* Control flow, not failures: redirects, not-found, thrown Responses and
|
|
10
|
-
* anything carrying an HTTP status below 500
|
|
10
|
+
* anything carrying an HTTP status below 500 (499 "client closed" included) are
|
|
11
|
+
* never reported. Client cancellations (AbortError, or a failure after the visitor
|
|
12
|
+
* disconnected) are dropped by the SDK itself unless `captureAborted` is on.
|
|
11
13
|
*/
|
|
12
14
|
export function isExpectedError(error) {
|
|
13
15
|
try {
|
|
@@ -40,21 +42,25 @@ function report(error, kind) {
|
|
|
40
42
|
* `requestMiddleware` (closest to the handler) so it sees errors before an
|
|
41
43
|
* error-page middleware turns them into a response.
|
|
42
44
|
*/
|
|
43
|
-
export const belvadorRequestMiddleware = createMiddleware().server(async ({ next }) => {
|
|
45
|
+
export const belvadorRequestMiddleware = createMiddleware().server(async ({ next, request }) => {
|
|
46
|
+
markHooked("middleware");
|
|
44
47
|
try {
|
|
45
48
|
return await next();
|
|
46
49
|
}
|
|
47
50
|
catch (error) {
|
|
51
|
+
noteClientAbort(error, request?.signal);
|
|
48
52
|
report(error, "request");
|
|
49
53
|
throw error;
|
|
50
54
|
}
|
|
51
55
|
});
|
|
52
56
|
/** Server-function middleware: same contract, put it LAST in `functionMiddleware`. */
|
|
53
|
-
export const belvadorFunctionMiddleware = createMiddleware({ type: "function" }).server(async ({ next }) => {
|
|
57
|
+
export const belvadorFunctionMiddleware = createMiddleware({ type: "function" }).server(async ({ next, signal }) => {
|
|
58
|
+
markHooked("middleware");
|
|
54
59
|
try {
|
|
55
60
|
return await next();
|
|
56
61
|
}
|
|
57
62
|
catch (error) {
|
|
63
|
+
noteClientAbort(error, signal);
|
|
58
64
|
report(error, "server_function");
|
|
59
65
|
throw error;
|
|
60
66
|
}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
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";
|
|
4
|
+
export type { VerificationResult, VerifyOptions } from "@belvador/core";
|
|
3
5
|
/**
|
|
4
6
|
* `export default withBelvador((env) => ({ release: env.BELVADOR_RELEASE }), { fetch })`:
|
|
5
7
|
* one client per request, errors reported and re-thrown, the response untouched.
|
|
6
8
|
*/
|
|
7
9
|
export declare function withBelvador<Env, H>(optionsCallback: (env: Env) => WorkerOptions | undefined, handler: H): H;
|
|
10
|
+
/**
|
|
11
|
+
* Proves the server reports to Belvador. Call it inside a server function or server
|
|
12
|
+
* route (for example a temporary `/api/verify-belvador` route): it checks that the call
|
|
13
|
+
* runs inside belvadorRequestMiddleware/belvadorFunctionMiddleware, sends one
|
|
14
|
+
* verification error and reads it back. Never automatic; always resolves.
|
|
15
|
+
*/
|
|
16
|
+
export declare function verifyIntegration(options?: VerifyOptions): Promise<VerificationResult>;
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// @belvador/tanstack-start/server — Workers side. Wrap the default export of
|
|
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
6
|
/**
|
|
6
7
|
* `export default withBelvador((env) => ({ release: env.BELVADOR_RELEASE }), { fetch })`:
|
|
7
8
|
* one client per request, errors reported and re-thrown, the response untouched.
|
|
@@ -9,3 +10,12 @@ export { SDK_VERSION, addBreadcrumb, captureException, captureMessage, flush, se
|
|
|
9
10
|
export function withBelvador(optionsCallback, handler) {
|
|
10
11
|
return wrapHandler(optionsCallback, handler, "tanstack-start");
|
|
11
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Proves the server reports to Belvador. Call it inside a server function or server
|
|
15
|
+
* route (for example a temporary `/api/verify-belvador` route): it checks that the call
|
|
16
|
+
* runs inside belvadorRequestMiddleware/belvadorFunctionMiddleware, sends one
|
|
17
|
+
* verification error and reads it back. Never automatic; always resolves.
|
|
18
|
+
*/
|
|
19
|
+
export function verifyIntegration(options) {
|
|
20
|
+
return runVerification({ surface: "server", hook: () => ({ ok: currentHooks().has("middleware") }) }, options);
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@belvador/tanstack-start",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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.
|
|
46
|
-
"@belvador/core": "0.
|
|
47
|
-
"@belvador/react": "0.
|
|
45
|
+
"@belvador/cloudflare": "0.2.0",
|
|
46
|
+
"@belvador/core": "0.2.0",
|
|
47
|
+
"@belvador/react": "0.2.0"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public",
|