@debugkit/dashboard 0.0.0-stage → 0.3.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 +30 -0
- package/dist/client/assets/_authed-BDx4Txp7.js +7 -0
- package/dist/client/assets/_authed-D6P9RBN1.js +1 -0
- package/dist/client/assets/charts-Covhtva2.js +55 -0
- package/dist/client/assets/index-BKQXehfa.js +12 -0
- package/dist/client/assets/issues._fingerprint-DtAqk0rC.js +1 -0
- package/dist/client/assets/login-Da8b3hjR.js +1 -0
- package/dist/client/assets/styles-CZZRuG1z.css +2 -0
- package/dist/client/assets/ui-DnKidKVi.js +1 -0
- package/dist/server/assets/_authed-BjmBAX3l.js +482 -0
- package/dist/server/assets/_authed-x9Ku8dyL.js +40 -0
- package/dist/server/assets/_tanstack-start-manifest_v-CY7PP5UB.js +40 -0
- package/dist/server/assets/charts-CNlV7Pga.js +221 -0
- package/dist/server/assets/demo-DTdlXNgj.js +333 -0
- package/dist/server/assets/dynamodb-DejcakaF.js +187 -0
- package/dist/server/assets/empty-plugin-adapters-BsRz-CQL.js +4 -0
- package/dist/server/assets/firestore-BH-gx9no.js +112 -0
- package/dist/server/assets/fns-CgB12FUN.js +31 -0
- package/dist/server/assets/fns-Yg8sT1Cb.js +87 -0
- package/dist/server/assets/issues._fingerprint-C2EdByPH.js +255 -0
- package/dist/server/assets/login-BMGNYcxB.js +107 -0
- package/dist/server/assets/memory-4DwW5cTO.js +59 -0
- package/dist/server/assets/queries-DIVV-5j6.js +4274 -0
- package/dist/server/assets/rollups-JXbazRNh.js +22 -0
- package/dist/server/assets/router-D2L7-BwF.js +222 -0
- package/dist/server/assets/src-D5jyi_C4.js +235 -0
- package/dist/server/assets/start-t09PGpZL.js +3 -0
- package/dist/server/assets/ui-Lv-KcOoP.js +131 -0
- package/dist/server/server.js +7825 -0
- package/package.json +52 -3
- package/scripts/hash-password.mjs +17 -0
- package/server.mjs +50 -0
- package/README.md +0 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// ../../packages/adapters/src/rollups.ts
|
|
2
|
+
/** Merge increments with the same target so each batch does one write per row. */
|
|
3
|
+
function coalesceRollups(incs) {
|
|
4
|
+
const map = /* @__PURE__ */ new Map();
|
|
5
|
+
for (const i of incs) {
|
|
6
|
+
const id = rollupId(i);
|
|
7
|
+
const row = map.get(id) ?? {
|
|
8
|
+
app: i.app,
|
|
9
|
+
day: i.day,
|
|
10
|
+
dimension: i.dimension,
|
|
11
|
+
key: i.key,
|
|
12
|
+
errors: 0,
|
|
13
|
+
events: 0
|
|
14
|
+
};
|
|
15
|
+
if (i.kind === "error") row.errors += i.by;
|
|
16
|
+
else row.events += i.by;
|
|
17
|
+
map.set(id, row);
|
|
18
|
+
}
|
|
19
|
+
return [...map.values()];
|
|
20
|
+
}
|
|
21
|
+
var rollupId = (r) => `${r.day}__${r.dimension}__${encodeURIComponent(r.key)}`;
|
|
22
|
+
export { rollupId as n, coalesceRollups as t };
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { i as getSessionUser, n as getLoginInfo, r as getOverview, t as getIssueDetail } from "./fns-CgB12FUN.js";
|
|
2
|
+
import { n as ingest, r as parseIngestKeys, t as CORS_HEADERS } from "./src-D5jyi_C4.js";
|
|
3
|
+
import { a as authorizeApi, d as getLocalWriteStore, f as getStore, n as buildIssueDetail, p as config, r as buildSummary, t as SUMMARY_FIELDS } from "./queries-DIVV-5j6.js";
|
|
4
|
+
import { HeadContent, Outlet, Scripts, createFileRoute, createRootRoute, createRouter, lazyRouteComponent, notFound, redirect } from "@tanstack/react-router";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// \0rolldown/runtime.js
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __exportAll = (all, no_symbols) => {
|
|
9
|
+
let target = {};
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
|
+
return target;
|
|
16
|
+
};
|
|
17
|
+
// src/styles.css?url
|
|
18
|
+
var styles_default = "/assets/styles-CZZRuG1z.css";
|
|
19
|
+
// src/routes/__root.tsx
|
|
20
|
+
var Route$7 = createRootRoute({
|
|
21
|
+
head: () => ({
|
|
22
|
+
meta: [
|
|
23
|
+
{ charSet: "utf-8" },
|
|
24
|
+
{
|
|
25
|
+
name: "viewport",
|
|
26
|
+
content: "width=device-width, initial-scale=1"
|
|
27
|
+
},
|
|
28
|
+
{ title: "deBug" },
|
|
29
|
+
{
|
|
30
|
+
name: "robots",
|
|
31
|
+
content: "noindex"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
links: [{
|
|
35
|
+
rel: "stylesheet",
|
|
36
|
+
href: styles_default
|
|
37
|
+
}, {
|
|
38
|
+
rel: "icon",
|
|
39
|
+
href: "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><rect width='32' height='32' rx='8' fill='%23d1242f'/><text x='16' y='22' font-size='16' text-anchor='middle' fill='white' font-family='sans-serif' font-weight='700'>dB</text></svg>"
|
|
40
|
+
}]
|
|
41
|
+
}),
|
|
42
|
+
shellComponent: RootDocument,
|
|
43
|
+
component: Outlet
|
|
44
|
+
});
|
|
45
|
+
function RootDocument({ children }) {
|
|
46
|
+
return /* @__PURE__ */ jsxs("html", {
|
|
47
|
+
lang: "en",
|
|
48
|
+
children: [/* @__PURE__ */ jsx("head", { children: /* @__PURE__ */ jsx(HeadContent, {}) }), /* @__PURE__ */ jsxs("body", {
|
|
49
|
+
className: "min-h-screen",
|
|
50
|
+
children: [children, /* @__PURE__ */ jsx(Scripts, {})]
|
|
51
|
+
})]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
// src/routes/_authed.tsx
|
|
55
|
+
var $$splitComponentImporter$3 = () => import("./_authed-x9Ku8dyL.js");
|
|
56
|
+
var Route$6 = createFileRoute("/_authed")({
|
|
57
|
+
beforeLoad: async () => {
|
|
58
|
+
const user = await getSessionUser();
|
|
59
|
+
if (!user) throw redirect({ to: "/login" });
|
|
60
|
+
return { user };
|
|
61
|
+
},
|
|
62
|
+
component: lazyRouteComponent($$splitComponentImporter$3, "component")
|
|
63
|
+
});
|
|
64
|
+
// src/routes/login.tsx
|
|
65
|
+
var $$splitComponentImporter$2 = () => import("./login-BMGNYcxB.js");
|
|
66
|
+
var Route$5 = createFileRoute("/login")({
|
|
67
|
+
beforeLoad: async () => {
|
|
68
|
+
if (await getSessionUser()) throw redirect({ to: "/" });
|
|
69
|
+
},
|
|
70
|
+
loader: () => getLoginInfo(),
|
|
71
|
+
component: lazyRouteComponent($$splitComponentImporter$2, "component")
|
|
72
|
+
});
|
|
73
|
+
// src/routes/_authed/index.tsx
|
|
74
|
+
var $$splitComponentImporter$1 = () => import("./_authed-BjmBAX3l.js");
|
|
75
|
+
var Route$4 = createFileRoute("/_authed/")({
|
|
76
|
+
validateSearch: (s) => ({
|
|
77
|
+
app: typeof s.app === "string" ? s.app : void 0,
|
|
78
|
+
flow: typeof s.flow === "string" ? s.flow : void 0
|
|
79
|
+
}),
|
|
80
|
+
loaderDeps: ({ search }) => ({ app: search.app }),
|
|
81
|
+
loader: ({ deps }) => getOverview({ data: { app: deps.app } }),
|
|
82
|
+
component: lazyRouteComponent($$splitComponentImporter$1, "component")
|
|
83
|
+
});
|
|
84
|
+
// src/routes/api/ingest.ts
|
|
85
|
+
/**
|
|
86
|
+
* POST /api/ingest — local development ingest, available only in demo mode.
|
|
87
|
+
* Point the SDK at http://localhost:4400/api/ingest with ingestKey "pk_local".
|
|
88
|
+
* In production, events go to the ingest function in your own cloud instead.
|
|
89
|
+
*/
|
|
90
|
+
var Route$3 = createFileRoute("/api/ingest")({ server: { handlers: {
|
|
91
|
+
OPTIONS: async () => new Response(null, {
|
|
92
|
+
status: 204,
|
|
93
|
+
headers: CORS_HEADERS
|
|
94
|
+
}),
|
|
95
|
+
POST: async ({ request }) => {
|
|
96
|
+
const store = await getLocalWriteStore();
|
|
97
|
+
if (!store) return Response.json({
|
|
98
|
+
ok: false,
|
|
99
|
+
error: "Local ingest is only available when DEBUG_STORE is demo or memory. Send events to your cloud ingest function."
|
|
100
|
+
}, {
|
|
101
|
+
status: 404,
|
|
102
|
+
headers: CORS_HEADERS
|
|
103
|
+
});
|
|
104
|
+
const out = await ingest(await request.text(), request.headers.get("x-debug-key") ?? void 0, {
|
|
105
|
+
store,
|
|
106
|
+
keys: parseIngestKeys(config().localIngestKeys)
|
|
107
|
+
});
|
|
108
|
+
return Response.json(out.body, {
|
|
109
|
+
status: out.status,
|
|
110
|
+
headers: CORS_HEADERS
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
} } });
|
|
114
|
+
// src/routes/api/summary.ts
|
|
115
|
+
/** GET /api/summary?app=<id> — the overview as JSON, for agents and scripts. */
|
|
116
|
+
var Route$2 = createFileRoute("/api/summary")({ server: { handlers: { GET: async ({ request }) => {
|
|
117
|
+
if (!authorizeApi(request)) return Response.json({ error: "unauthorized" }, { status: 401 });
|
|
118
|
+
const app = new URL(request.url).searchParams.get("app") ?? void 0;
|
|
119
|
+
const summary = await buildSummary(await getStore(), app, config().severity);
|
|
120
|
+
if (!summary) return Response.json({ error: "no data" }, { status: 404 });
|
|
121
|
+
return Response.json({
|
|
122
|
+
...summary,
|
|
123
|
+
_fields: SUMMARY_FIELDS,
|
|
124
|
+
_severityThresholds24h: config().severity
|
|
125
|
+
});
|
|
126
|
+
} } } });
|
|
127
|
+
// src/routes/_authed/issues.$fingerprint.tsx
|
|
128
|
+
var $$splitComponentImporter = () => import("./issues._fingerprint-C2EdByPH.js");
|
|
129
|
+
var Route$1 = createFileRoute("/_authed/issues/$fingerprint")({
|
|
130
|
+
validateSearch: (s) => ({ app: typeof s.app === "string" ? s.app : "" }),
|
|
131
|
+
loaderDeps: ({ search }) => ({ app: search.app }),
|
|
132
|
+
loader: async ({ params, deps }) => {
|
|
133
|
+
const d = await getIssueDetail({ data: {
|
|
134
|
+
app: deps.app,
|
|
135
|
+
fingerprint: params.fingerprint
|
|
136
|
+
} });
|
|
137
|
+
if (!d) throw notFound();
|
|
138
|
+
return d;
|
|
139
|
+
},
|
|
140
|
+
component: lazyRouteComponent($$splitComponentImporter, "component")
|
|
141
|
+
});
|
|
142
|
+
// src/routes/api/issues/$fingerprint.ts
|
|
143
|
+
/** GET /api/issues/<fingerprint>?app=<id> — one issue with breakdowns, sample stack, breadcrumbs and hints. */
|
|
144
|
+
var Route = createFileRoute("/api/issues/$fingerprint")({ server: { handlers: { GET: async ({ request, params }) => {
|
|
145
|
+
if (!authorizeApi(request)) return Response.json({ error: "unauthorized" }, { status: 401 });
|
|
146
|
+
const app = new URL(request.url).searchParams.get("app");
|
|
147
|
+
if (!app) return Response.json({ error: "app query param required" }, { status: 400 });
|
|
148
|
+
const detail = await buildIssueDetail(await getStore(), app, params.fingerprint, config().severity);
|
|
149
|
+
if (!detail) return Response.json({ error: "not found" }, { status: 404 });
|
|
150
|
+
return Response.json(detail);
|
|
151
|
+
} } } });
|
|
152
|
+
// src/routeTree.gen.ts
|
|
153
|
+
var AuthedRoute = Route$6.update({
|
|
154
|
+
id: "/_authed",
|
|
155
|
+
getParentRoute: () => Route$7
|
|
156
|
+
});
|
|
157
|
+
var LoginRoute = Route$5.update({
|
|
158
|
+
id: "/login",
|
|
159
|
+
path: "/login",
|
|
160
|
+
getParentRoute: () => Route$7
|
|
161
|
+
});
|
|
162
|
+
var AuthedIndexRoute = Route$4.update({
|
|
163
|
+
id: "/",
|
|
164
|
+
path: "/",
|
|
165
|
+
getParentRoute: () => AuthedRoute
|
|
166
|
+
});
|
|
167
|
+
var ApiIngestRoute = Route$3.update({
|
|
168
|
+
id: "/api/ingest",
|
|
169
|
+
path: "/api/ingest",
|
|
170
|
+
getParentRoute: () => Route$7
|
|
171
|
+
});
|
|
172
|
+
var ApiSummaryRoute = Route$2.update({
|
|
173
|
+
id: "/api/summary",
|
|
174
|
+
path: "/api/summary",
|
|
175
|
+
getParentRoute: () => Route$7
|
|
176
|
+
});
|
|
177
|
+
var AuthedIssuesFingerprintRoute = Route$1.update({
|
|
178
|
+
id: "/issues/$fingerprint",
|
|
179
|
+
path: "/issues/$fingerprint",
|
|
180
|
+
getParentRoute: () => AuthedRoute
|
|
181
|
+
});
|
|
182
|
+
var ApiIssuesFingerprintRoute = Route.update({
|
|
183
|
+
id: "/api/issues/$fingerprint",
|
|
184
|
+
path: "/api/issues/$fingerprint",
|
|
185
|
+
getParentRoute: () => Route$7
|
|
186
|
+
});
|
|
187
|
+
var AuthedRouteChildren = {
|
|
188
|
+
AuthedIndexRoute,
|
|
189
|
+
AuthedIssuesFingerprintRoute
|
|
190
|
+
};
|
|
191
|
+
var rootRouteChildren = {
|
|
192
|
+
AuthedRoute: AuthedRoute._addFileChildren(AuthedRouteChildren),
|
|
193
|
+
LoginRoute,
|
|
194
|
+
ApiIngestRoute,
|
|
195
|
+
ApiSummaryRoute,
|
|
196
|
+
ApiIssuesFingerprintRoute
|
|
197
|
+
};
|
|
198
|
+
var routeTree = Route$7._addFileChildren(rootRouteChildren)._addFileTypes();
|
|
199
|
+
// src/router.tsx
|
|
200
|
+
var router_exports = /* @__PURE__ */ __exportAll({ getRouter: () => getRouter });
|
|
201
|
+
function getRouter() {
|
|
202
|
+
return createRouter({
|
|
203
|
+
routeTree,
|
|
204
|
+
scrollRestoration: true,
|
|
205
|
+
defaultPreload: "intent",
|
|
206
|
+
defaultErrorComponent: ({ error }) => /* @__PURE__ */ jsxs("div", {
|
|
207
|
+
className: "mx-auto max-w-xl p-8",
|
|
208
|
+
children: [/* @__PURE__ */ jsx("h1", {
|
|
209
|
+
className: "text-lg font-semibold",
|
|
210
|
+
children: "Something went wrong"
|
|
211
|
+
}), /* @__PURE__ */ jsx("pre", {
|
|
212
|
+
className: "mt-3 overflow-auto rounded-md bg-panel-2 p-3 text-xs",
|
|
213
|
+
children: error instanceof Error ? error.message : String(error)
|
|
214
|
+
})]
|
|
215
|
+
}),
|
|
216
|
+
defaultNotFoundComponent: () => /* @__PURE__ */ jsx("div", {
|
|
217
|
+
className: "p-8 text-muted",
|
|
218
|
+
children: "Not found."
|
|
219
|
+
})
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
export { Route$6 as a, getRouter, Route$5 as i, Route$1 as n, Route$4 as r, router_exports as t };
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { h as parseStack, m as Envelope } from "./queries-DIVV-5j6.js";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
// ../../packages/ingest/src/fingerprint.ts
|
|
4
|
+
/** Strip volatile parts so "User 123 not found" and "User 456 not found" group together. */
|
|
5
|
+
function normaliseMessage(msg) {
|
|
6
|
+
return msg.replace(/https?:\/\/\S+/g, "<url>").replace(/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi, "<uuid>").replace(/\b[0-9a-f]{16,}\b/gi, "<hex>").replace(/[\w.+-]+@[\w-]+\.[\w.]+/g, "<email>").replace(/\d+(\.\d+)?/g, "<n>").replace(/(["'`]).*?\1/g, "<str>").trim().slice(0, 300);
|
|
7
|
+
}
|
|
8
|
+
/** Remove build hashes / absolute prefixes so the same code location matches across builds and devices. */
|
|
9
|
+
function normaliseFile(file) {
|
|
10
|
+
if (!file) return "";
|
|
11
|
+
let f = file.replace(/\/\/&.*$/, "").replace(/[?#].*$/, "").replace(/^[a-z]+:\/\/[^/]+/i, "");
|
|
12
|
+
if (/\.(?:js)?bundle$/.test(f)) return f.replace(/^.*\//, "");
|
|
13
|
+
for (const root of [
|
|
14
|
+
"/src/",
|
|
15
|
+
"/lib/",
|
|
16
|
+
"/app/"
|
|
17
|
+
]) {
|
|
18
|
+
const i = f.lastIndexOf(root);
|
|
19
|
+
if (i >= 0) {
|
|
20
|
+
f = f.slice(i + 1);
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return f.replace(/\.[0-9a-f]{6,}\./g, ".");
|
|
25
|
+
}
|
|
26
|
+
function topInAppFrame(frames) {
|
|
27
|
+
return frames?.find((f) => f.inApp !== false && f.file) ?? frames?.[0];
|
|
28
|
+
}
|
|
29
|
+
function culpritOf(e) {
|
|
30
|
+
const f = topInAppFrame(e.error.frames);
|
|
31
|
+
if (!f) return void 0;
|
|
32
|
+
const loc = normaliseFile(f.file) + (f.line ? `:${f.line}` : "");
|
|
33
|
+
return f.fn ? `${f.fn} (${loc})` : loc;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Fingerprint = error name + top in-app frame (function + file, not line, so small edits
|
|
37
|
+
* don't split issues) + flow. Falls back to the normalised message when there's no stack.
|
|
38
|
+
*/
|
|
39
|
+
function fingerprint(e) {
|
|
40
|
+
const f = topInAppFrame(e.error.frames);
|
|
41
|
+
const r = e.request;
|
|
42
|
+
const where = r ? `${r.method.toUpperCase()} ${r.url} ${r.status ? `${Math.floor(r.status / 100)}xx` : "failed"}` : f ? `${f.fn ?? "?"}@${normaliseFile(f.file)}` : normaliseMessage(e.error.message);
|
|
43
|
+
return createHash("sha256").update([
|
|
44
|
+
e.error.name,
|
|
45
|
+
where,
|
|
46
|
+
e.flow ?? ""
|
|
47
|
+
].join("|")).digest("hex").slice(0, 24);
|
|
48
|
+
}
|
|
49
|
+
function titleOf(e) {
|
|
50
|
+
return `${e.error.name}: ${e.error.message}`.slice(0, 200);
|
|
51
|
+
}
|
|
52
|
+
// ../../packages/ingest/src/index.ts
|
|
53
|
+
/** "pk_abc:megaton-native,pk_def:other-app" → { pk_abc: "megaton-native", ... } */
|
|
54
|
+
function parseIngestKeys(raw) {
|
|
55
|
+
const out = {};
|
|
56
|
+
for (const pair of (raw ?? "").split(",").map((s) => s.trim()).filter(Boolean)) {
|
|
57
|
+
const [key, app] = pair.split(":");
|
|
58
|
+
if (key && app) out[key] = app;
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
var dayOf = (iso) => iso.slice(0, 10);
|
|
63
|
+
/** Clamp client clocks: events claiming to be from the future or very old are pinned to receipt time. */
|
|
64
|
+
function sanitiseTs(ts, now) {
|
|
65
|
+
const t = Date.parse(ts);
|
|
66
|
+
const n = now.getTime();
|
|
67
|
+
if (Number.isNaN(t) || t > n + 3e5 || t < n - 6048e5) return now.toISOString();
|
|
68
|
+
return new Date(t).toISOString();
|
|
69
|
+
}
|
|
70
|
+
function enrich(ctx) {
|
|
71
|
+
return {
|
|
72
|
+
...ctx,
|
|
73
|
+
os: {
|
|
74
|
+
...ctx.os,
|
|
75
|
+
name: ctx.os.name.toLowerCase()
|
|
76
|
+
},
|
|
77
|
+
runtime: {
|
|
78
|
+
...ctx.runtime,
|
|
79
|
+
name: ctx.runtime.name.toLowerCase()
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** Platform-agnostic ingest. Wrap with ./firebase or ./lambda to deploy. */
|
|
84
|
+
async function ingest(rawBody, ingestKey, opts) {
|
|
85
|
+
const now = opts.now?.() ?? /* @__PURE__ */ new Date();
|
|
86
|
+
if (!ingestKey || !opts.keys[ingestKey]) return {
|
|
87
|
+
status: 401,
|
|
88
|
+
body: {
|
|
89
|
+
ok: false,
|
|
90
|
+
error: "invalid ingest key"
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
if (Buffer.byteLength(rawBody) > (opts.maxBytes ?? 524288)) return {
|
|
94
|
+
status: 413,
|
|
95
|
+
body: {
|
|
96
|
+
ok: false,
|
|
97
|
+
error: "payload too large"
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
let json;
|
|
101
|
+
try {
|
|
102
|
+
json = JSON.parse(rawBody);
|
|
103
|
+
} catch {
|
|
104
|
+
return {
|
|
105
|
+
status: 400,
|
|
106
|
+
body: {
|
|
107
|
+
ok: false,
|
|
108
|
+
error: "invalid json"
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const parsed = Envelope.safeParse(json);
|
|
113
|
+
if (!parsed.success) return {
|
|
114
|
+
status: 400,
|
|
115
|
+
body: {
|
|
116
|
+
ok: false,
|
|
117
|
+
error: "invalid envelope",
|
|
118
|
+
issues: parsed.error.flatten()
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const env = parsed.data;
|
|
122
|
+
const app = env.context.app.id;
|
|
123
|
+
if (opts.keys[ingestKey] !== app && opts.keys[ingestKey] !== "*") return {
|
|
124
|
+
status: 403,
|
|
125
|
+
body: {
|
|
126
|
+
ok: false,
|
|
127
|
+
error: `key not allowed for app ${app}`
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const context = enrich(env.context);
|
|
131
|
+
const receivedAt = now.toISOString();
|
|
132
|
+
const stored = [];
|
|
133
|
+
const rollups = [];
|
|
134
|
+
const issues = /* @__PURE__ */ new Map();
|
|
135
|
+
for (const raw of env.events) {
|
|
136
|
+
const event = {
|
|
137
|
+
...raw,
|
|
138
|
+
ts: sanitiseTs(raw.ts, now)
|
|
139
|
+
};
|
|
140
|
+
if (event.type === "error" && !event.error.frames?.length && event.error.stack) event.error.frames = parseStack(event.error.stack);
|
|
141
|
+
const day = dayOf(event.ts);
|
|
142
|
+
if (event.type === "session") {
|
|
143
|
+
rollups.push({
|
|
144
|
+
app,
|
|
145
|
+
day,
|
|
146
|
+
dimension: "session",
|
|
147
|
+
key: `${context.app.version || "unknown"}|${event.status}`,
|
|
148
|
+
kind: "event",
|
|
149
|
+
by: 1
|
|
150
|
+
});
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
const kind = event.type === "error" ? "error" : "event";
|
|
154
|
+
const inc = (dimension, key) => rollups.push({
|
|
155
|
+
app,
|
|
156
|
+
day,
|
|
157
|
+
dimension,
|
|
158
|
+
key: key || "unknown",
|
|
159
|
+
kind,
|
|
160
|
+
by: 1
|
|
161
|
+
});
|
|
162
|
+
let fp;
|
|
163
|
+
if (event.type === "error") {
|
|
164
|
+
fp = fingerprint(event);
|
|
165
|
+
const cur = issues.get(fp);
|
|
166
|
+
const se = {
|
|
167
|
+
app,
|
|
168
|
+
day,
|
|
169
|
+
fingerprint: fp,
|
|
170
|
+
event,
|
|
171
|
+
context,
|
|
172
|
+
user: env.user,
|
|
173
|
+
sessionId: env.session.id,
|
|
174
|
+
receivedAt
|
|
175
|
+
};
|
|
176
|
+
issues.set(fp, {
|
|
177
|
+
app,
|
|
178
|
+
fingerprint: fp,
|
|
179
|
+
title: titleOf(event),
|
|
180
|
+
culprit: culpritOf(event),
|
|
181
|
+
flow: event.flow,
|
|
182
|
+
by: (cur?.by ?? 0) + 1,
|
|
183
|
+
ts: cur && cur.ts > event.ts ? cur.ts : event.ts,
|
|
184
|
+
firstTs: cur && cur.firstTs < event.ts ? cur.firstTs : event.ts,
|
|
185
|
+
lastEvent: cur && cur.ts > event.ts ? cur.lastEvent : se
|
|
186
|
+
});
|
|
187
|
+
inc("issue", fp);
|
|
188
|
+
if (event.request) inc("endpoint", `${event.request.method.toUpperCase()} ${event.request.url}`);
|
|
189
|
+
rollups.push({
|
|
190
|
+
app,
|
|
191
|
+
day: event.ts.slice(0, 13),
|
|
192
|
+
dimension: "issueHour",
|
|
193
|
+
key: fp,
|
|
194
|
+
kind,
|
|
195
|
+
by: 1
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
inc("total", "all");
|
|
199
|
+
inc("flow", event.flow ?? "untagged");
|
|
200
|
+
inc("os", `${context.os.name} ${context.os.version ?? ""}`.trim());
|
|
201
|
+
inc("appVersion", context.app.version);
|
|
202
|
+
inc("deviceModel", context.device.model);
|
|
203
|
+
if (event.type === "event" && event.outcome && event.flow) inc("flowOutcome", `${event.flow}|${event.outcome}`);
|
|
204
|
+
stored.push({
|
|
205
|
+
app,
|
|
206
|
+
day,
|
|
207
|
+
fingerprint: fp,
|
|
208
|
+
event,
|
|
209
|
+
context,
|
|
210
|
+
user: env.user,
|
|
211
|
+
sessionId: env.session.id,
|
|
212
|
+
receivedAt
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
await opts.store.registerApp(app);
|
|
216
|
+
await Promise.all([
|
|
217
|
+
stored.length ? opts.store.writeEvents(stored) : void 0,
|
|
218
|
+
opts.store.upsertIssues([...issues.values()]),
|
|
219
|
+
opts.store.incrementRollups(rollups)
|
|
220
|
+
]);
|
|
221
|
+
return {
|
|
222
|
+
status: 202,
|
|
223
|
+
body: {
|
|
224
|
+
ok: true,
|
|
225
|
+
accepted: env.events.length
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
var CORS_HEADERS = {
|
|
230
|
+
"access-control-allow-origin": "*",
|
|
231
|
+
"access-control-allow-methods": "POST, OPTIONS",
|
|
232
|
+
"access-control-allow-headers": "content-type, x-debug-key",
|
|
233
|
+
"access-control-max-age": "86400"
|
|
234
|
+
};
|
|
235
|
+
export { ingest as n, parseIngestKeys as r, CORS_HEADERS as t };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// ../../node_modules/.pnpm/@tanstack+react-start@1.169.5_esbuild@0.27.7_react-dom@19.3.1_react@19.3.1__react@19.3._3cc71d2a6f56c1c816631914bf53ba03/node_modules/@tanstack/react-start/dist/plugin/default-entry/start.ts
|
|
2
|
+
var startInstance = void 0;
|
|
3
|
+
export { startInstance };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
// src/components/ui.tsx
|
|
3
|
+
function Logo() {
|
|
4
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
5
|
+
className: "inline-flex items-center gap-2 font-semibold tracking-tight",
|
|
6
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
7
|
+
className: "grid h-7 w-7 place-items-center rounded-md bg-sev-critical text-[11px] font-bold text-white",
|
|
8
|
+
children: "dB"
|
|
9
|
+
}), /* @__PURE__ */ jsxs("span", { children: ["de", /* @__PURE__ */ jsx("span", {
|
|
10
|
+
className: "text-sev-critical",
|
|
11
|
+
children: "Bug"
|
|
12
|
+
})] })]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
var SEV_STYLE = {
|
|
16
|
+
critical: "bg-sev-critical text-white",
|
|
17
|
+
high: "bg-sev-high text-white",
|
|
18
|
+
medium: "bg-sev-medium text-black",
|
|
19
|
+
low: "bg-panel-2 text-muted border border-line"
|
|
20
|
+
};
|
|
21
|
+
function SeverityBadge({ severity }) {
|
|
22
|
+
return /* @__PURE__ */ jsx("span", {
|
|
23
|
+
className: `inline-flex items-center rounded px-1.5 py-0.5 text-[11px] font-semibold uppercase tracking-wide ${SEV_STYLE[severity]}`,
|
|
24
|
+
children: severity
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function Card({ title, subtitle, children, right }) {
|
|
28
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
29
|
+
className: "rounded-xl border border-line bg-panel p-4 sm:p-5",
|
|
30
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
31
|
+
className: "mb-3 flex items-start justify-between gap-3",
|
|
32
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h2", {
|
|
33
|
+
className: "text-sm font-semibold",
|
|
34
|
+
children: title
|
|
35
|
+
}), subtitle && /* @__PURE__ */ jsx("p", {
|
|
36
|
+
className: "mt-0.5 text-xs text-muted",
|
|
37
|
+
children: subtitle
|
|
38
|
+
})] }), right]
|
|
39
|
+
}), children]
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function Stat({ label, value, hint, tone }) {
|
|
43
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
44
|
+
className: "rounded-xl border border-line bg-panel p-4",
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ jsx("div", {
|
|
47
|
+
className: "text-xs text-muted",
|
|
48
|
+
children: label
|
|
49
|
+
}),
|
|
50
|
+
/* @__PURE__ */ jsx("div", {
|
|
51
|
+
className: `tabular mt-1 text-2xl font-semibold ${tone === "critical" ? "text-sev-critical" : tone === "high" ? "text-sev-high" : "text-ink"}`,
|
|
52
|
+
children: value
|
|
53
|
+
}),
|
|
54
|
+
hint && /* @__PURE__ */ jsx("div", {
|
|
55
|
+
className: "mt-1 text-xs text-muted",
|
|
56
|
+
children: hint
|
|
57
|
+
})
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/** Collapsible table with the exact numbers behind a chart. */
|
|
62
|
+
function DataTable({ columns, rows }) {
|
|
63
|
+
return /* @__PURE__ */ jsxs("details", {
|
|
64
|
+
className: "mt-3 text-xs",
|
|
65
|
+
children: [/* @__PURE__ */ jsx("summary", {
|
|
66
|
+
className: "cursor-pointer text-muted hover:text-ink",
|
|
67
|
+
children: "View data"
|
|
68
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
69
|
+
className: "mt-2 max-h-64 overflow-auto rounded-md border border-line",
|
|
70
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
71
|
+
className: "tabular w-full text-left",
|
|
72
|
+
children: [/* @__PURE__ */ jsx("thead", {
|
|
73
|
+
className: "sticky top-0 bg-panel-2",
|
|
74
|
+
children: /* @__PURE__ */ jsx("tr", { children: columns.map((c) => /* @__PURE__ */ jsx("th", {
|
|
75
|
+
className: "px-2 py-1 font-medium",
|
|
76
|
+
children: c
|
|
77
|
+
}, c)) })
|
|
78
|
+
}), /* @__PURE__ */ jsx("tbody", { children: rows.map((r, i) => /* @__PURE__ */ jsx("tr", {
|
|
79
|
+
className: "border-t border-line",
|
|
80
|
+
children: r.map((v, j) => /* @__PURE__ */ jsx("td", {
|
|
81
|
+
className: "px-2 py-1",
|
|
82
|
+
children: v
|
|
83
|
+
}, j))
|
|
84
|
+
}, i)) })]
|
|
85
|
+
})
|
|
86
|
+
})]
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/** Horizontal share bars — used for small categorical breakdowns where a full chart is overkill. */
|
|
90
|
+
function ShareBars({ rows, total }) {
|
|
91
|
+
const sum = total ?? rows.reduce((a, r) => a + r.value, 0);
|
|
92
|
+
if (!rows.length) return /* @__PURE__ */ jsx("p", {
|
|
93
|
+
className: "text-xs text-muted",
|
|
94
|
+
children: "No data."
|
|
95
|
+
});
|
|
96
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
97
|
+
className: "space-y-2",
|
|
98
|
+
children: rows.map((r) => {
|
|
99
|
+
const share = sum ? r.value / sum : 0;
|
|
100
|
+
return /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsxs("div", {
|
|
101
|
+
className: "flex justify-between gap-2 text-xs",
|
|
102
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
103
|
+
className: "truncate",
|
|
104
|
+
children: r.key
|
|
105
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
106
|
+
className: "tabular shrink-0 text-muted",
|
|
107
|
+
children: [
|
|
108
|
+
r.value.toLocaleString(),
|
|
109
|
+
" · ",
|
|
110
|
+
Math.round(share * 100),
|
|
111
|
+
"%"
|
|
112
|
+
]
|
|
113
|
+
})]
|
|
114
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
115
|
+
className: "mt-1 h-1.5 rounded-full bg-panel-2",
|
|
116
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
117
|
+
className: "h-1.5 rounded-full bg-[var(--chart-errors)]",
|
|
118
|
+
style: { width: `${Math.max(2, share * 100)}%` }
|
|
119
|
+
})
|
|
120
|
+
})] }, r.key);
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function timeAgo(iso, now = Date.now()) {
|
|
125
|
+
const s = Math.max(0, Math.round((now - Date.parse(iso)) / 1e3));
|
|
126
|
+
if (s < 60) return `${s}s ago`;
|
|
127
|
+
if (s < 3600) return `${Math.round(s / 60)}m ago`;
|
|
128
|
+
if (s < 86400) return `${Math.round(s / 3600)}h ago`;
|
|
129
|
+
return `${Math.round(s / 86400)}d ago`;
|
|
130
|
+
}
|
|
131
|
+
export { ShareBars as a, SeverityBadge as i, DataTable as n, Stat as o, Logo as r, timeAgo as s, Card as t };
|