@debugkit/dashboard 0.5.0 → 0.6.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/.env.example +3 -0
- package/dist/client/assets/_authed-BMdIkvB6.js +7 -0
- package/dist/client/assets/_authed-Rg-Gabby.js +1 -0
- package/dist/client/assets/{charts-C0zeGTzu.js → charts-QIIL2Fv7.js} +6 -6
- package/dist/client/assets/index-CMjwqklY.js +10 -0
- package/dist/client/assets/invite._token-CDogkC9p.js +1 -0
- package/dist/client/assets/issues._fingerprint-DLe_lV5d.js +1 -0
- package/dist/client/assets/login-BG9v4zhc.js +1 -0
- package/dist/client/assets/{preload-helper-CDziuvpw.js → preload-helper-Dscj_TcA.js} +1 -1
- package/dist/client/assets/settings-Ce1uqKl0.js +1 -0
- package/dist/client/assets/styles-DztngwT9.css +2 -0
- package/dist/client/assets/team-TUMAZ4jv.js +1 -0
- package/dist/client/assets/{ui-BiRMJGWB.js → ui-C0HGOza2.js} +1 -1
- package/dist/server/assets/{_authed-DODQ_Iys.js → _authed-DDQ5yYfy.js} +31 -18
- package/dist/server/assets/{_authed-CuDay0Tl.js → _authed-Dray_9Ct.js} +1 -1
- package/dist/server/assets/{_tanstack-start-manifest_v-BBxgjm04.js → _tanstack-start-manifest_v-BItoYCqL.js} +19 -7
- package/dist/server/assets/{demo-hrRBo9_U.js → demo-BsMMDk_F.js} +2 -2
- package/dist/server/assets/{dynamodb-DyPK9SVV.js → dynamodb-Zkk1-mgz.js} +93 -2
- package/dist/server/assets/{firestore-B2xzpzYA.js → firestore-C52q_vwM.js} +43 -2
- package/dist/server/assets/{fns-DPsnK0zS.js → fns-DwGaMi8S.js} +30 -2
- package/dist/server/assets/fns-mbUIXXep.js +529 -0
- package/dist/server/assets/invite._token-BWiwnST7.js +136 -0
- package/dist/server/assets/{issues._fingerprint-CZCZDm7t.js → issues._fingerprint-D9vjIk3M.js} +2 -2
- package/dist/server/assets/{login-D-UG6SFw.js → login-BXi46U4B.js} +2 -2
- package/dist/server/assets/{memory-Do0CDoAX.js → memory-BssaqdZm.js} +30 -0
- package/dist/server/assets/{queries-CxHrgTdM.js → queries-BJxX3Kjp.js} +744 -30
- package/dist/server/assets/{router-CIIGBCmL.js → router-m6Hpq6Ep.js} +58 -35
- package/dist/server/assets/{settings-BHfngShx.js → settings-ByFLIJce.js} +2 -2
- package/dist/server/assets/src-D83GYTrp.js +9 -0
- package/dist/server/assets/team-CifrrNkf.js +255 -0
- package/dist/server/server.js +42 -14
- package/handler.mjs +95 -0
- package/lambda.mjs +61 -0
- package/package.json +16 -7
- package/server.mjs +4 -39
- package/dist/client/assets/_authed-DTn7rMla.js +0 -1
- package/dist/client/assets/_authed-Dc7covsB.js +0 -7
- package/dist/client/assets/index-D12jr1bm.js +0 -10
- package/dist/client/assets/issues._fingerprint-C6ryZvIu.js +0 -1
- package/dist/client/assets/login-oLP1Yyz3.js +0 -1
- package/dist/client/assets/settings-9oQsCwdV.js +0 -1
- package/dist/client/assets/styles-DBg7wMRg.css +0 -2
- package/dist/server/assets/fns-hk_OJe6M.js +0 -250
- package/dist/server/assets/src-D9VHcuh4.js +0 -491
- package/dist/server/assets/src-JXktBs5H.js +0 -4
package/handler.mjs
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// The deBug dashboard as one request handler, for any Node host: the local server (server.mjs),
|
|
2
|
+
// a Firebase function (onRequest), or a Lambda behind a Function URL (see lambda.mjs).
|
|
3
|
+
// Serves built assets from dist/client and hands every other request to the TanStack Start app.
|
|
4
|
+
import { createReadStream, existsSync, statSync } from "node:fs";
|
|
5
|
+
import { extname, join, normalize, sep } from "node:path";
|
|
6
|
+
import { Readable } from "node:stream";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
|
|
9
|
+
const ROOT = fileURLToPath(new URL("./dist/client", import.meta.url));
|
|
10
|
+
const TYPES = {
|
|
11
|
+
".js": "text/javascript",
|
|
12
|
+
".css": "text/css",
|
|
13
|
+
".svg": "image/svg+xml",
|
|
14
|
+
".png": "image/png",
|
|
15
|
+
".ico": "image/x-icon",
|
|
16
|
+
".woff2": "font/woff2",
|
|
17
|
+
".json": "application/json",
|
|
18
|
+
".txt": "text/plain",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
let app;
|
|
22
|
+
/** The built TanStack Start app (loaded once, on the first request). */
|
|
23
|
+
const loadApp = () => (app ??= import("./dist/server/server.js").then((m) => m.default));
|
|
24
|
+
|
|
25
|
+
/** A static file under dist/client for this path, or undefined. Never escapes the folder. */
|
|
26
|
+
export function staticFile(pathname, root = ROOT) {
|
|
27
|
+
if (pathname === "/") return undefined;
|
|
28
|
+
let decoded;
|
|
29
|
+
try {
|
|
30
|
+
decoded = decodeURIComponent(pathname);
|
|
31
|
+
} catch {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
const file = normalize(join(root, decoded));
|
|
35
|
+
if (!file.startsWith(root + sep)) return undefined;
|
|
36
|
+
return existsSync(file) && statSync(file).isFile() ? file : undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The web Request for a Node request. Hosts that already read the body (Firebase, Express) leave it in rawBody. */
|
|
40
|
+
export function toRequest(req) {
|
|
41
|
+
const proto = String(req.headers["x-forwarded-proto"] ?? "").split(",")[0].trim() || (req.socket?.encrypted ? "https" : "http");
|
|
42
|
+
const host = req.headers["x-forwarded-host"] ?? req.headers.host ?? "localhost";
|
|
43
|
+
const url = new URL(req.originalUrl ?? req.url ?? "/", `${proto}://${host}`);
|
|
44
|
+
const headers = new Headers();
|
|
45
|
+
for (const [k, v] of Object.entries(req.headers)) {
|
|
46
|
+
if (v === undefined) continue;
|
|
47
|
+
for (const one of Array.isArray(v) ? v : [v]) headers.append(k, String(one));
|
|
48
|
+
}
|
|
49
|
+
const method = req.method ?? "GET";
|
|
50
|
+
let body;
|
|
51
|
+
if (method !== "GET" && method !== "HEAD") body = Buffer.isBuffer(req.rawBody) ? req.rawBody : Readable.toWeb(req);
|
|
52
|
+
return new Request(url, { method, headers, body, duplex: body && !Buffer.isBuffer(body) ? "half" : undefined });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Write a web Response to a Node response, keeping every Set-Cookie header. */
|
|
56
|
+
export async function sendResponse(res, response, method = "GET") {
|
|
57
|
+
const headers = {};
|
|
58
|
+
response.headers.forEach((v, k) => {
|
|
59
|
+
if (k !== "set-cookie") headers[k] = v;
|
|
60
|
+
});
|
|
61
|
+
const cookies = response.headers.getSetCookie?.() ?? [];
|
|
62
|
+
if (cookies.length) headers["set-cookie"] = cookies;
|
|
63
|
+
res.writeHead(response.status, headers);
|
|
64
|
+
if (response.body && method !== "HEAD") Readable.fromWeb(response.body).pipe(res);
|
|
65
|
+
else res.end();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The dashboard as `(req, res) => Promise<void>`. Settings come from process.env (see .env.example).
|
|
70
|
+
* Options: `root` (the built client assets), `app` (a fetch handler, for tests).
|
|
71
|
+
*/
|
|
72
|
+
export function createHandler(options = {}) {
|
|
73
|
+
const root = options.root ?? ROOT;
|
|
74
|
+
return async function debugkitDashboard(req, res) {
|
|
75
|
+
try {
|
|
76
|
+
const url = new URL(req.originalUrl ?? req.url ?? "/", "http://x");
|
|
77
|
+
const file = staticFile(url.pathname, root);
|
|
78
|
+
if (file && (req.method === "GET" || req.method === "HEAD")) {
|
|
79
|
+
res.writeHead(200, {
|
|
80
|
+
"content-type": TYPES[extname(file)] ?? "application/octet-stream",
|
|
81
|
+
"cache-control": url.pathname.startsWith("/assets/") ? "public, max-age=31536000, immutable" : "no-cache",
|
|
82
|
+
});
|
|
83
|
+
if (req.method === "HEAD") return void res.end();
|
|
84
|
+
return void createReadStream(file).pipe(res);
|
|
85
|
+
}
|
|
86
|
+
const fetchApp = options.app ?? (await loadApp());
|
|
87
|
+
const response = await fetchApp.fetch(toRequest(req));
|
|
88
|
+
await sendResponse(res, response, req.method);
|
|
89
|
+
} catch (err) {
|
|
90
|
+
console.error(err);
|
|
91
|
+
if (!res.headersSent) res.writeHead(500);
|
|
92
|
+
res.end("Internal error");
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
package/lambda.mjs
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// The deBug dashboard on AWS Lambda, behind a Function URL (payload format 2.0).
|
|
2
|
+
// Deployed by `npx debugkit deploy-dashboard`; settings come from the function's environment.
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { extname } from "node:path";
|
|
5
|
+
import { staticFile } from "./handler.mjs";
|
|
6
|
+
|
|
7
|
+
process.env.NODE_ENV ??= "production";
|
|
8
|
+
|
|
9
|
+
const TEXT = /^(text\/|application\/(json|javascript)|image\/svg)/;
|
|
10
|
+
const TYPES = { ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png", ".ico": "image/x-icon", ".woff2": "font/woff2", ".json": "application/json", ".txt": "text/plain" };
|
|
11
|
+
|
|
12
|
+
let app;
|
|
13
|
+
const loadApp = () => (app ??= import("./dist/server/server.js").then((m) => m.default));
|
|
14
|
+
|
|
15
|
+
/** A web Request for a Function URL event. */
|
|
16
|
+
export function eventToRequest(event) {
|
|
17
|
+
const h = event.headers ?? {};
|
|
18
|
+
const url = new URL(`https://${h["x-forwarded-host"] ?? h.host ?? event.requestContext?.domainName ?? "localhost"}${event.rawPath ?? "/"}${event.rawQueryString ? `?${event.rawQueryString}` : ""}`);
|
|
19
|
+
const headers = new Headers();
|
|
20
|
+
for (const [k, v] of Object.entries(h)) if (v !== undefined) headers.set(k, String(v));
|
|
21
|
+
// Function URLs move cookies out of the headers.
|
|
22
|
+
if (event.cookies?.length) headers.set("cookie", event.cookies.join("; "));
|
|
23
|
+
const method = event.requestContext?.http?.method ?? "GET";
|
|
24
|
+
const body = method === "GET" || method === "HEAD" || event.body == null ? undefined : Buffer.from(event.body, event.isBase64Encoded ? "base64" : "utf8");
|
|
25
|
+
return new Request(url, { method, headers, body });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** A Function URL result for a web Response. */
|
|
29
|
+
export async function responseToResult(response, method = "GET") {
|
|
30
|
+
const headers = {};
|
|
31
|
+
response.headers.forEach((v, k) => {
|
|
32
|
+
if (k !== "set-cookie") headers[k] = v;
|
|
33
|
+
});
|
|
34
|
+
const cookies = response.headers.getSetCookie?.() ?? [];
|
|
35
|
+
const buf = method === "HEAD" || !response.body ? Buffer.alloc(0) : Buffer.from(await response.arrayBuffer());
|
|
36
|
+
const text = TEXT.test(headers["content-type"] ?? "");
|
|
37
|
+
return { statusCode: response.status, headers, cookies, body: buf.toString(text ? "utf8" : "base64"), isBase64Encoded: !text };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function handler(event, _context, options = {}) {
|
|
41
|
+
try {
|
|
42
|
+
const method = event.requestContext?.http?.method ?? "GET";
|
|
43
|
+
const file = (method === "GET" || method === "HEAD") && staticFile(event.rawPath ?? "/", options.root);
|
|
44
|
+
if (file) {
|
|
45
|
+
const type = TYPES[extname(file)] ?? "application/octet-stream";
|
|
46
|
+
const buf = readFileSync(file);
|
|
47
|
+
const text = TEXT.test(type);
|
|
48
|
+
return {
|
|
49
|
+
statusCode: 200,
|
|
50
|
+
headers: { "content-type": type, "cache-control": (event.rawPath ?? "").startsWith("/assets/") ? "public, max-age=31536000, immutable" : "no-cache" },
|
|
51
|
+
body: method === "HEAD" ? "" : buf.toString(text ? "utf8" : "base64"),
|
|
52
|
+
isBase64Encoded: !text && method !== "HEAD",
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const fetchApp = options.app ?? (await loadApp());
|
|
56
|
+
return await responseToResult(await fetchApp.fetch(eventToRequest(event)), method);
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error(err);
|
|
59
|
+
return { statusCode: 500, body: "Internal error" };
|
|
60
|
+
}
|
|
61
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@debugkit/dashboard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "The self-hosted deBug dashboard. Run it with npx debugkit dashboard, or npx @debugkit/dashboard with your own settings.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -9,14 +9,13 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
11
|
"server.mjs",
|
|
12
|
+
"handler.mjs",
|
|
13
|
+
"lambda.mjs",
|
|
12
14
|
"scripts",
|
|
13
15
|
".env.example"
|
|
14
16
|
],
|
|
15
17
|
"dependencies": {
|
|
16
|
-
"@aws-sdk/client-dynamodb": "^3.700.0",
|
|
17
|
-
"@aws-sdk/lib-dynamodb": "^3.700.0",
|
|
18
18
|
"@tanstack/react-router": "^1.170.46",
|
|
19
|
-
"firebase-admin": "^13.0.1",
|
|
20
19
|
"react": "^19.3.1",
|
|
21
20
|
"react-dom": "^19.3.1",
|
|
22
21
|
"recharts": "^3.10.1"
|
|
@@ -29,9 +28,9 @@
|
|
|
29
28
|
"tailwindcss": "^4.3.5",
|
|
30
29
|
"vite": "^8.3.7",
|
|
31
30
|
"@tanstack/react-start": "^1.169.5",
|
|
32
|
-
"@debugkit/adapters": "0.
|
|
33
|
-
"@debugkit/ingest": "0.
|
|
34
|
-
"@debugkit/schema": "0.
|
|
31
|
+
"@debugkit/adapters": "0.6.0",
|
|
32
|
+
"@debugkit/ingest": "0.6.0",
|
|
33
|
+
"@debugkit/schema": "0.6.0"
|
|
35
34
|
},
|
|
36
35
|
"engines": {
|
|
37
36
|
"node": ">=20.12"
|
|
@@ -45,6 +44,16 @@
|
|
|
45
44
|
"publishConfig": {
|
|
46
45
|
"access": "public"
|
|
47
46
|
},
|
|
47
|
+
"exports": {
|
|
48
|
+
"./handler": "./handler.mjs",
|
|
49
|
+
"./lambda": "./lambda.mjs",
|
|
50
|
+
"./package.json": "./package.json"
|
|
51
|
+
},
|
|
52
|
+
"optionalDependencies": {
|
|
53
|
+
"@aws-sdk/client-dynamodb": "^3.700.0",
|
|
54
|
+
"@aws-sdk/lib-dynamodb": "^3.700.0",
|
|
55
|
+
"firebase-admin": "^13.0.1"
|
|
56
|
+
},
|
|
48
57
|
"scripts": {
|
|
49
58
|
"dev": "vite dev --port 4400",
|
|
50
59
|
"build": "vite build",
|
package/server.mjs
CHANGED
|
@@ -1,50 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
import { createReadStream, existsSync, statSync } from "node:fs";
|
|
2
|
+
// Local or self-hosted deBug dashboard: `npx @debugkit/dashboard`, or `pnpm build && pnpm start` here.
|
|
3
|
+
// The same handler runs hosted in Firebase (handler.mjs) and on AWS Lambda (lambda.mjs).
|
|
5
4
|
import { createServer } from "node:http";
|
|
6
|
-
import { extname, join, normalize } from "node:path";
|
|
7
|
-
import { Readable } from "node:stream";
|
|
8
|
-
import { fileURLToPath } from "node:url";
|
|
9
5
|
|
|
10
6
|
try {
|
|
11
7
|
process.loadEnvFile(process.env.DEBUG_ENV_FILE ?? ".env");
|
|
12
8
|
} catch {}
|
|
13
9
|
process.env.NODE_ENV ??= "production";
|
|
14
10
|
|
|
15
|
-
const
|
|
16
|
-
const { default: app } = await import("./dist/server/server.js");
|
|
11
|
+
const { createHandler } = await import("./handler.mjs");
|
|
17
12
|
const port = Number(process.env.PORT ?? 4400);
|
|
18
13
|
const host = process.env.HOST ?? "127.0.0.1"; // bind to localhost by default; set HOST=0.0.0.0 behind a proxy
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
createServer(async (req, res) => {
|
|
23
|
-
try {
|
|
24
|
-
const url = new URL(req.url ?? "/", `http://${req.headers.host ?? "localhost"}`);
|
|
25
|
-
const file = normalize(join(root, decodeURIComponent(url.pathname)));
|
|
26
|
-
if (file.startsWith(root) && url.pathname !== "/" && existsSync(file) && statSync(file).isFile()) {
|
|
27
|
-
res.writeHead(200, {
|
|
28
|
-
"content-type": TYPES[extname(file)] ?? "application/octet-stream",
|
|
29
|
-
"cache-control": url.pathname.startsWith("/assets/") ? "public, max-age=31536000, immutable" : "no-cache",
|
|
30
|
-
});
|
|
31
|
-
return createReadStream(file).pipe(res);
|
|
32
|
-
}
|
|
33
|
-
const body = req.method === "GET" || req.method === "HEAD" ? undefined : Readable.toWeb(req);
|
|
34
|
-
const request = new Request(url, { method: req.method, headers: req.headers, body, duplex: "half" });
|
|
35
|
-
const response = await app.fetch(request);
|
|
36
|
-
const headers = {};
|
|
37
|
-
response.headers.forEach((v, k) => {
|
|
38
|
-
if (k !== "set-cookie") headers[k] = v;
|
|
39
|
-
});
|
|
40
|
-
const cookies = response.headers.getSetCookie?.() ?? [];
|
|
41
|
-
if (cookies.length) headers["set-cookie"] = cookies;
|
|
42
|
-
res.writeHead(response.status, headers);
|
|
43
|
-
if (response.body && req.method !== "HEAD") Readable.fromWeb(response.body).pipe(res);
|
|
44
|
-
else res.end();
|
|
45
|
-
} catch (err) {
|
|
46
|
-
console.error(err);
|
|
47
|
-
if (!res.headersSent) res.writeHead(500);
|
|
48
|
-
res.end("Internal error");
|
|
49
|
-
}
|
|
50
|
-
}).listen(port, host, () => console.log(`deBug dashboard on http://${host}:${port}`));
|
|
15
|
+
createServer(createHandler()).listen(port, host, () => console.log(`deBug dashboard on http://${host}:${port}`));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,_ as t,c as n,w as r}from"./preload-helper-CDziuvpw.js";import{c as i,s as a}from"./index-D12jr1bm.js";import{i as o}from"./ui-BiRMJGWB.js";var s=r();function c(){let{user:r}=a.useRouteContext(),c=e();return(0,s.jsxs)(`div`,{className:`min-h-screen`,children:[(0,s.jsx)(`header`,{className:`sticky top-0 z-10 border-b border-line bg-bg/90 backdrop-blur`,children:(0,s.jsxs)(`div`,{className:`mx-auto flex max-w-7xl items-center justify-between gap-4 px-4 py-3 sm:px-6`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-5`,children:[(0,s.jsx)(t,{to:`/`,search:{},className:`shrink-0`,children:(0,s.jsx)(o,{})}),(0,s.jsxs)(`nav`,{className:`flex items-center gap-3 text-sm`,"aria-label":`Main`,children:[(0,s.jsx)(t,{to:`/`,search:{},className:`text-muted hover:text-ink`,activeProps:{className:`font-medium text-ink`},activeOptions:{exact:!0},children:`Overview`}),(0,s.jsx)(t,{to:`/settings`,search:{},className:`text-muted hover:text-ink`,activeProps:{className:`font-medium text-ink`},children:`Settings`})]})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,s.jsx)(`span`,{className:`hidden text-muted sm:inline`,children:r.email}),(0,s.jsx)(`button`,{className:`rounded-md border border-line px-2.5 py-1 hover:bg-panel-2`,onClick:async()=>{await n(),await c.invalidate(),await c.navigate({to:`/login`})},children:`Sign out`})]})]})}),(0,s.jsx)(i,{})]})}export{c as component};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{S as e,W as t,_ as n,q as r,v as i,w as a}from"./preload-helper-CDziuvpw.js";import{r as o,t as s}from"./charts-C0zeGTzu.js";import{a as c,c as l,n as u,o as d,r as f,s as p,t as m}from"./ui-BiRMJGWB.js";import{a as h,i as g,r as _}from"./index-D12jr1bm.js";var v=r(t()),y=a();function b(){let e=_.useLoaderData(),t=_.useSearch(),{flow:r}=t,a=i({from:_.fullPath});if(!e)return(0,y.jsx)(w,{});let{totals:v,range:b}=e,C=b.preset===`custom`?`range`:b.preset,E=t.status??`open`,D=e.issues.filter(e=>E===`all`?!0:E===`open`?e.status===`open`||e.status===`regressed`:e.status===E),O=r?D.filter(e=>(e.flow??`untagged`)===r):D,k=t=>e.issues.filter(e=>t===`open`?e.status===`open`||e.status===`regressed`:e.status===t).length,A=v.changePct;return(0,y.jsxs)(`main`,{className:`mx-auto max-w-7xl space-y-5 px-4 py-6 sm:px-6`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`p`,{className:`text-xs uppercase tracking-wide text-muted`,children:[`Overview · `,b.label]}),(0,y.jsxs)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:[`What's going wrong in `,e.app]})]}),(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(g,{value:b,today:e.generatedAt.slice(0,10),onChange:e=>a({search:t=>({...t,...e})})},`${b.preset}${b.from}${b.to}`),e.apps.length>1&&(0,y.jsx)(`select`,{"aria-label":`App`,value:e.app,onChange:e=>a({search:t=>({...t,app:e.target.value,flow:void 0})}),className:`rounded-md border border-line bg-panel px-2 py-1.5 text-sm`,children:e.apps.map(e=>(0,y.jsx)(`option`,{children:e},e))})]})]}),(0,y.jsx)(h,{rangeFrom:b.from,retention:e.retention}),(0,y.jsx)(`section`,{"aria-label":`Summary`,className:`rounded-xl border border-line bg-panel p-4 sm:p-5`,children:(0,y.jsx)(`ul`,{className:`space-y-1.5 text-[15px] leading-relaxed`,children:e.narrative.map((e,t)=>(0,y.jsx)(`li`,{className:t===0?`font-medium`:`text-ink/90`,children:e},t))})}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,y.jsx)(p,{label:`Errors (${C})`,value:v.errorsRange.toLocaleString(),tone:v.criticalIssues?`critical`:void 0,hint:A===null?`not enough earlier data to compare`:A>500?`▲ from ${v.errorsPrev.toLocaleString()} in the previous ${b.span}`:`${A>0?`▲`:A<0?`▼`:`•`} ${Math.abs(A)}% vs previous ${b.span}`}),(0,y.jsx)(p,{label:`Critical issues`,value:v.criticalIssues,tone:v.criticalIssues?`critical`:void 0,hint:`≥ threshold occurrences in 24h`}),(0,y.jsx)(p,{label:`Crash-free users (${C})`,value:x(e.health.crashFreeUsersRate),tone:e.health.crashFreeUsersRate!==null&&e.health.crashFreeUsersRate<.99?`high`:void 0,hint:`${e.health.users.toLocaleString()} users · ${e.health.crashedUsers.toLocaleString()} crashed`}),(0,y.jsx)(p,{label:`Crash-free sessions (${C})`,value:x(e.health.crashFreeRate),tone:e.health.crashFreeRate!==null&&e.health.crashFreeRate<.99?`high`:void 0,hint:`${e.health.sessionsRange.toLocaleString()} sessions · ${v.activeIssues} active issues`})]}),(0,y.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-5`,children:[(0,y.jsx)(`div`,{className:`min-w-0 lg:col-span-3`,children:(0,y.jsxs)(m,{title:`Where the app is failing`,subtitle:`Errors in ${b.label} by flow, coloured by worst severity. Click a bar to filter issues.`,children:[(0,y.jsx)(s,{data:e.flows,onSelect:e=>a({search:t=>({...t,flow:t.flow===e?void 0:e})})}),(0,y.jsx)(u,{columns:[`Flow`,`Severity`,`Errors 24h`,`Errors (${C})`,`Issues`,`Failure rate (${C})`],rows:e.flows.map(e=>[e.critical?`${e.flow} (critical)`:e.flow,e.severity,e.errors24h,e.errorsRange,e.issues,e.failureRate===null?`—`:`${Math.round(e.failureRate*100)}%`])})]})}),(0,y.jsx)(`div`,{className:`min-w-0 lg:col-span-2`,children:(0,y.jsxs)(m,{title:`Error trend`,subtitle:`Errors per ${b.granularity}, ${b.label} (UTC)`,children:[(0,y.jsx)(o,{data:e.trend,markers:e.releases.map(e=>({day:e.firstDay,label:e.release}))}),e.releases.length>0&&(0,y.jsxs)(`p`,{className:`mt-2 text-xs text-muted`,children:[`Dashed lines: a release's first sessions (`,e.releases.map(e=>e.release).join(`, `),`).`]}),(0,y.jsx)(u,{columns:[`Day`,`Errors`,`Events`],rows:e.trend.map(e=>[e.day,e.errors,e.events])})]})})]}),(0,y.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-2`,children:[(0,y.jsx)(m,{title:`Release health`,subtitle:`Share of sessions without a crash or unhandled error, per app version, in ${b.label}. Recorded automatically by the SDK.`,children:e.health.releases.length?(0,y.jsx)(`div`,{className:`-mx-4 overflow-x-auto sm:mx-0`,children:(0,y.jsxs)(`table`,{className:`tabular w-full min-w-[420px] text-left text-sm`,children:[(0,y.jsx)(`thead`,{className:`text-xs text-muted`,children:(0,y.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,y.jsx)(`th`,{className:`px-4 py-2 font-medium sm:px-2`,children:`Version`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Sessions`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Crash-free`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Error-free`})]})}),(0,y.jsx)(`tbody`,{children:e.health.releases.map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,y.jsx)(`td`,{className:`px-4 py-2 font-medium sm:px-2`,children:e.version}),(0,y.jsx)(`td`,{className:`px-2 py-2 text-right text-muted`,children:e.sessions.toLocaleString()}),(0,y.jsx)(`td`,{className:`px-2 py-2 text-right font-semibold ${S(e.crashFreeRate)}`,children:x(e.crashFreeRate)}),(0,y.jsx)(`td`,{className:`px-2 py-2 text-right`,children:x(e.errorFreeRate)})]},e.version))})]})}):(0,y.jsx)(`p`,{className:`text-sm text-muted`,children:`No sessions yet. They're recorded automatically from SDK 0.2.`})}),(0,y.jsx)(m,{title:`Failing endpoints`,subtitle:`Requests that returned 5xx, timed out or failed in ${b.label}. Captured automatically from fetch and XHR.`,children:e.health.endpoints.length?(0,y.jsx)(d,{rows:e.health.endpoints.map(e=>({key:e.endpoint,value:e.failuresRange}))}):(0,y.jsx)(`p`,{className:`text-sm text-muted`,children:`No failed requests.`})})]}),(e.steps.length>0||e.timings.length>0)&&(0,y.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-2`,children:[e.steps.length>0&&(0,y.jsx)(m,{title:`Steps that fail`,subtitle:`track() outcomes per step in ${b.label}, most failures first.${r?` Filtered to ${r}.`:``}`,children:(0,y.jsx)(`div`,{className:`-mx-4 overflow-x-auto sm:mx-0`,children:(0,y.jsxs)(`table`,{className:`tabular w-full min-w-[420px] text-left text-sm`,children:[(0,y.jsx)(`thead`,{className:`text-xs text-muted`,children:(0,y.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,y.jsx)(`th`,{className:`px-4 py-2 font-medium sm:px-2`,children:`Flow · step`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Tries`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Failed`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Failure rate`})]})}),(0,y.jsx)(`tbody`,{children:e.steps.filter(e=>!r||e.flow===r).slice(0,8).map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,y.jsxs)(`td`,{className:`px-4 py-2 font-mono text-xs sm:px-2`,children:[e.flow,` · `,e.step]}),(0,y.jsx)(`td`,{className:`px-2 py-2 text-right text-muted`,children:(e.successes+e.failures).toLocaleString()}),(0,y.jsx)(`td`,{className:`px-2 py-2 text-right`,children:e.failures.toLocaleString()}),(0,y.jsx)(`td`,{className:`px-2 py-2 text-right font-semibold ${e.failureRate!==null&&e.failureRate>=.1?`text-sev-critical`:``}`,children:e.failureRate===null?`—`:`${Math.round(e.failureRate*100)}%`})]},`${e.flow}|${e.step}`))})]})})}),e.timings.length>0&&(0,y.jsxs)(m,{title:`Response times`,subtitle:`Busiest endpoints in ${b.label}. Measured by the SDK on real devices.`,children:[(0,y.jsx)(`div`,{className:`-mx-4 overflow-x-auto sm:mx-0`,children:(0,y.jsxs)(`table`,{className:`tabular w-full min-w-[420px] text-left text-sm`,children:[(0,y.jsx)(`thead`,{className:`text-xs text-muted`,children:(0,y.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,y.jsx)(`th`,{className:`px-4 py-2 font-medium sm:px-2`,children:`Endpoint`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Requests`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`p50`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`p95`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Failed`})]})}),(0,y.jsx)(`tbody`,{children:e.timings.map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,y.jsx)(`td`,{className:`max-w-[220px] truncate px-4 py-2 font-mono text-xs sm:px-2`,title:e.endpoint,children:e.endpoint}),(0,y.jsx)(`td`,{className:`px-2 py-2 text-right text-muted`,children:e.requests.toLocaleString()}),(0,y.jsx)(`td`,{className:`px-2 py-2 text-right`,children:T(e.p50)}),(0,y.jsx)(`td`,{className:`px-2 py-2 text-right font-semibold ${e.p95!==null&&e.p95>=3e3?`text-sev-high`:``}`,children:T(e.p95)}),(0,y.jsx)(`td`,{className:`px-2 py-2 text-right ${e.errorRate>=.05?`font-semibold text-sev-critical`:`text-muted`}`,children:`${(e.errorRate*100).toFixed(+(e.errorRate<.1))}%`})]},e.endpoint))})]})}),(0,y.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:`p50/p95: half / 95% of requests finished within this time.`})]})]}),(0,y.jsx)(m,{title:r?`Issues in ${r}`:`Issues by severity`,subtitle:`Grouped errors seen in ${b.label}. Severity is set by occurrences in the last 24 hours.`,right:(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1 text-xs`,children:[r&&(0,y.jsx)(`button`,{className:`mr-2 text-accent`,onClick:()=>a({search:e=>({...e,flow:void 0})}),children:`Clear flow ×`}),[`open`,`resolved`,`ignored`,`all`].map(e=>(0,y.jsxs)(`button`,{onClick:()=>a({search:t=>({...t,status:e===`open`?void 0:e})}),className:`rounded-md border px-2 py-1 capitalize ${E===e?`border-accent bg-accent-soft text-accent`:`border-line text-muted hover:bg-panel-2`}`,children:[e,e!==`all`&&(0,y.jsx)(`span`,{className:`ml-1 opacity-70`,children:k(e)})]},e))]}),children:(0,y.jsx)(`div`,{className:`-mx-4 overflow-x-auto sm:mx-0`,children:(0,y.jsxs)(`table`,{className:`tabular w-full min-w-[640px] text-left text-sm`,children:[(0,y.jsx)(`thead`,{className:`text-xs text-muted`,children:(0,y.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,y.jsx)(`th`,{className:`px-4 py-2 font-medium sm:px-2`,children:`Severity`}),(0,y.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`Issue`}),(0,y.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`Flow`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Users`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`24h`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:C===`24h`?`Total`:C===`range`?`Range`:C}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Last seen`})]})}),(0,y.jsxs)(`tbody`,{children:[O.map(t=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-panel-2`,children:[(0,y.jsx)(`td`,{className:`px-4 py-2.5 sm:px-2`,children:(0,y.jsx)(c,{severity:t.severity})}),(0,y.jsxs)(`td`,{className:`max-w-[420px] px-2 py-2.5`,children:[(0,y.jsx)(n,{to:`/issues/$fingerprint`,params:{fingerprint:t.fingerprint},search:{app:e.app,range:b.preset===`14d`?void 0:b.preset,...b.preset===`custom`?{from:b.from,to:b.to}:{}},className:`block truncate font-medium hover:text-accent`,children:t.title}),t.culprit&&(0,y.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:t.culprit}),(0,y.jsx)(f,{issue:t})]}),(0,y.jsx)(`td`,{className:`px-2 py-2.5 text-xs`,children:t.flow??(0,y.jsx)(`span`,{className:`text-muted`,children:`untagged`})}),(0,y.jsx)(`td`,{className:`px-2 py-2.5 text-right text-muted`,children:t.users??`—`}),(0,y.jsx)(`td`,{className:`px-2 py-2.5 text-right font-semibold`,children:t.count24h}),(0,y.jsx)(`td`,{className:`px-2 py-2.5 text-right text-muted`,children:C===`24h`?t.countTotal:t.countRange}),(0,y.jsx)(`td`,{className:`px-2 py-2.5 text-right text-xs text-muted`,children:l(t.lastSeen)})]},t.fingerprint)),!O.length&&(0,y.jsx)(`tr`,{children:(0,y.jsx)(`td`,{colSpan:7,className:`px-2 py-6 text-center text-muted`,children:`No issues.`})})]})]})})}),(0,y.jsxs)(`div`,{className:`grid gap-5 md:grid-cols-3`,children:[(0,y.jsx)(m,{title:`By network`,subtitle:`Errors, ${b.label}`,children:(0,y.jsx)(d,{rows:e.breakdowns.network.map(e=>({key:e.key,value:e.errors}))})}),(0,y.jsx)(m,{title:`By country`,subtitle:`Errors, ${b.label}. From the device's timezone, not its IP.`,children:(0,y.jsx)(d,{rows:e.breakdowns.country.map(e=>({key:e.key,value:e.errors}))})}),(0,y.jsx)(m,{title:`By OS`,subtitle:`Errors, ${b.label}`,children:(0,y.jsx)(d,{rows:e.breakdowns.os.map(e=>({key:e.key,value:e.errors}))})}),(0,y.jsx)(m,{title:`By app version`,subtitle:`Errors, ${b.label}`,children:(0,y.jsx)(d,{rows:e.breakdowns.appVersion.map(e=>({key:e.key,value:e.errors}))})}),(0,y.jsx)(m,{title:`By device`,subtitle:`Errors, ${b.label}`,children:(0,y.jsx)(d,{rows:e.breakdowns.deviceModel.map(e=>({key:e.key,value:e.errors}))})})]}),(0,y.jsxs)(`p`,{className:`pb-6 text-xs text-muted`,children:[`Machine-readable: `,(0,y.jsxs)(`code`,{children:[`GET /api/summary?app=`,e.app]}),` returns this page as JSON with field descriptions.`]})]})}function x(e){return e===null?`—`:`${(Math.floor(e*1e3)/10).toFixed(1)}%`}function S(e){return e===null?``:e<.98?`text-sev-critical`:e<.995?`text-sev-high`:``}var C=[{title:`A written summary`,when:`after the first error`,detail:`How many errors in the last 24 hours, the worst part of the app, the top issue and the release that's struggling, in plain sentences.`},{title:`Issues by severity`,when:`after the first error`,detail:`Errors grouped by cause. Severity comes from how often each happened in the last 24 hours. Open one for the stack trace and the steps that led to it.`},{title:`Release health`,when:`as soon as the app starts`,detail:`Every app launch is a session. You'll see the share of sessions per version that ran without a crash or an unhandled error.`},{title:`Failing endpoints`,when:`after the first failed request`,detail:`Requests that timed out, failed or returned 5xx, captured from fetch and XHR without any code from you.`},{title:`Where the app is failing`,when:`once you tag flows`,detail:`Errors by flow, like auth.login or checkout.payment. Wrap a step in deBug.track() and each flow also gets a failure rate.`},{title:`Breakdowns`,when:`after the first error`,detail:`Errors split by OS, app version and device model, so you can see who is affected.`}];function w(){let t=e();return(0,v.useEffect)(()=>{let e=setInterval(()=>void t.invalidate(),5e3);return()=>clearInterval(e)},[t]),(0,y.jsxs)(`main`,{className:`mx-auto max-w-4xl space-y-6 px-4 py-10 sm:px-6`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-xs uppercase tracking-wide text-muted`,children:`Connected · waiting for the first event`}),(0,y.jsx)(`h1`,{className:`mt-1 text-2xl font-semibold tracking-tight`,children:`Your dashboard is ready, and empty for now.`}),(0,y.jsxs)(`p`,{className:`mt-2 max-w-2xl text-sm text-muted`,children:[`Nothing has arrived yet. Run your app with the SDK initialised, or send a test event with `,(0,y.jsx)(`code`,{children:`npx debugkit test`}),` (or `,(0,y.jsx)(`code`,{children:`npx @debugkit/cli test`}),`). This page fills in on its own.`]})]}),(0,y.jsxs)(`section`,{"aria-labelledby":`see-h`,className:`rounded-xl border border-line bg-panel p-4 sm:p-5`,children:[(0,y.jsx)(`h2`,{id:`see-h`,className:`text-sm font-semibold`,children:`What you'll see here`}),(0,y.jsx)(`ul`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:C.map(e=>(0,y.jsxs)(`li`,{className:`rounded-lg border border-line p-3`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,y.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,y.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-muted`,children:e.when})]}),(0,y.jsx)(`p`,{className:`mt-1 text-sm text-ink/80`,children:e.detail})]},e.title))})]}),(0,y.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,y.jsxs)(`section`,{"aria-labelledby":`auto-h`,className:`rounded-xl border border-line bg-panel p-4 sm:p-5`,children:[(0,y.jsx)(`h2`,{id:`auto-h`,className:`text-sm font-semibold`,children:`Recorded automatically`}),(0,y.jsxs)(`p`,{className:`mt-1 text-xs text-muted`,children:[`Once `,(0,y.jsx)(`code`,{children:`init()`}),` runs, with no other code.`]}),(0,y.jsxs)(`ul`,{className:`mt-3 list-disc space-y-1 pl-5 text-sm`,children:[(0,y.jsx)(`li`,{children:`Crashes and unhandled promise rejections`}),(0,y.jsx)(`li`,{children:`Failed, timed-out and 5xx requests, with the code that made them`}),(0,y.jsx)(`li`,{children:`Sessions, for crash-free rates per release`}),(0,y.jsx)(`li`,{children:`Screens visited, buttons clicked, console warnings, app backgrounded or offline`}),(0,y.jsx)(`li`,{children:`Device, OS, app version and network on every event`})]})]}),(0,y.jsxs)(`section`,{"aria-labelledby":`manual-h`,className:`rounded-xl border border-line bg-panel p-4 sm:p-5`,children:[(0,y.jsx)(`h2`,{id:`manual-h`,className:`text-sm font-semibold`,children:`What you add`}),(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Only what the app can't know on its own.`}),(0,y.jsx)(`pre`,{className:`mt-3 overflow-x-auto rounded-md bg-panel-2 p-3 text-xs leading-relaxed`,children:`// in a try/catch you already have
|
|
2
|
-
catch (err) {
|
|
3
|
-
deBug.error(err, { flow: "checkout.payment", step: "charge" });
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
// success or failure of a step, plus the error
|
|
7
|
-
await deBug.track("auth.login", "submit_otp", () => verifyOtp(code));`})]})]})]})}function T(e){return e===null?`—`:Number.isFinite(e)?e>=1e3?`≤ ${(e/1e3).toFixed(e%1e3?1:0)} s`:`≤ ${e} ms`:`> 10 s`}export{b as component};
|