@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.
Files changed (33) hide show
  1. package/.env.example +30 -0
  2. package/dist/client/assets/_authed-BDx4Txp7.js +7 -0
  3. package/dist/client/assets/_authed-D6P9RBN1.js +1 -0
  4. package/dist/client/assets/charts-Covhtva2.js +55 -0
  5. package/dist/client/assets/index-BKQXehfa.js +12 -0
  6. package/dist/client/assets/issues._fingerprint-DtAqk0rC.js +1 -0
  7. package/dist/client/assets/login-Da8b3hjR.js +1 -0
  8. package/dist/client/assets/styles-CZZRuG1z.css +2 -0
  9. package/dist/client/assets/ui-DnKidKVi.js +1 -0
  10. package/dist/server/assets/_authed-BjmBAX3l.js +482 -0
  11. package/dist/server/assets/_authed-x9Ku8dyL.js +40 -0
  12. package/dist/server/assets/_tanstack-start-manifest_v-CY7PP5UB.js +40 -0
  13. package/dist/server/assets/charts-CNlV7Pga.js +221 -0
  14. package/dist/server/assets/demo-DTdlXNgj.js +333 -0
  15. package/dist/server/assets/dynamodb-DejcakaF.js +187 -0
  16. package/dist/server/assets/empty-plugin-adapters-BsRz-CQL.js +4 -0
  17. package/dist/server/assets/firestore-BH-gx9no.js +112 -0
  18. package/dist/server/assets/fns-CgB12FUN.js +31 -0
  19. package/dist/server/assets/fns-Yg8sT1Cb.js +87 -0
  20. package/dist/server/assets/issues._fingerprint-C2EdByPH.js +255 -0
  21. package/dist/server/assets/login-BMGNYcxB.js +107 -0
  22. package/dist/server/assets/memory-4DwW5cTO.js +59 -0
  23. package/dist/server/assets/queries-DIVV-5j6.js +4274 -0
  24. package/dist/server/assets/rollups-JXbazRNh.js +22 -0
  25. package/dist/server/assets/router-D2L7-BwF.js +222 -0
  26. package/dist/server/assets/src-D5jyi_C4.js +235 -0
  27. package/dist/server/assets/start-t09PGpZL.js +3 -0
  28. package/dist/server/assets/ui-Lv-KcOoP.js +131 -0
  29. package/dist/server/server.js +7825 -0
  30. package/package.json +52 -3
  31. package/scripts/hash-password.mjs +17 -0
  32. package/server.mjs +50 -0
  33. package/README.md +0 -3
@@ -0,0 +1,187 @@
1
+ import { t as coalesceRollups } from "./rollups-JXbazRNh.js";
2
+ import { BatchWriteCommand, GetCommand, PutCommand, QueryCommand, UpdateCommand } from "@aws-sdk/lib-dynamodb";
3
+ // ../../packages/adapters/src/dynamodb.ts
4
+ /**
5
+ * Single-table layout. Table needs: partition key `pk` (S), sort key `sk` (S),
6
+ * and TTL enabled on attribute `ttl`.
7
+ *
8
+ * APPS | {app} app marker
9
+ * APP#{app}#ISSUE | {fingerprint} Issue
10
+ * APP#{app}#ROLLUP#{dimension} | {day}#{key} RollupRow (ADD counters)
11
+ * APP#{app}#ISSUEEV#{fp} | {ts}#{id} StoredEvent (error events by issue)
12
+ * APP#{app}#EV#{day} | {ts}#{id} StoredEvent (all events by day)
13
+ */
14
+ var DynamoStore = class {
15
+ doc;
16
+ opts;
17
+ constructor(doc, opts) {
18
+ this.doc = doc;
19
+ this.opts = opts;
20
+ }
21
+ get table() {
22
+ return this.opts.table;
23
+ }
24
+ async registerApp(app) {
25
+ await this.doc.send(new PutCommand({
26
+ TableName: this.table,
27
+ Item: {
28
+ pk: "APPS",
29
+ sk: app
30
+ }
31
+ }));
32
+ }
33
+ async writeEvents(events) {
34
+ const ttl = (e) => Math.floor(Date.parse(e.receivedAt) / 1e3) + (this.opts.retentionDays ?? 30) * 86400;
35
+ const items = events.flatMap((e) => {
36
+ const sk = `${e.event.ts}#${e.event.id}`;
37
+ const base = {
38
+ ...e,
39
+ ttl: ttl(e)
40
+ };
41
+ const rows = [{
42
+ pk: `APP#${e.app}#EV#${e.day}`,
43
+ sk,
44
+ ...base
45
+ }];
46
+ if (e.fingerprint) rows.push({
47
+ pk: `APP#${e.app}#ISSUEEV#${e.fingerprint}`,
48
+ sk,
49
+ ...base
50
+ });
51
+ return rows;
52
+ });
53
+ for (let i = 0; i < items.length; i += 25) {
54
+ let req = { [this.table]: items.slice(i, i + 25).map((Item) => ({ PutRequest: { Item } })) };
55
+ for (let attempt = 0; req && Object.keys(req).length && attempt < 5; attempt++) {
56
+ req = (await this.doc.send(new BatchWriteCommand({ RequestItems: req }))).UnprocessedItems;
57
+ if (req && Object.keys(req).length) await new Promise((r) => setTimeout(r, 50 * 2 ** attempt));
58
+ }
59
+ }
60
+ }
61
+ async upsertIssues(updates) {
62
+ await Promise.all(updates.map(async (u) => {
63
+ await this.doc.send(new UpdateCommand({
64
+ TableName: this.table,
65
+ Key: {
66
+ pk: `APP#${u.app}#ISSUE`,
67
+ sk: u.fingerprint
68
+ },
69
+ UpdateExpression: "ADD #count :by SET app = :app, fingerprint = :fp, title = :title, flow = :flow, culprit = :culprit, firstSeen = if_not_exists(firstSeen, :first)",
70
+ ExpressionAttributeNames: { "#count": "count" },
71
+ ExpressionAttributeValues: {
72
+ ":by": u.by,
73
+ ":app": u.app,
74
+ ":fp": u.fingerprint,
75
+ ":title": u.title,
76
+ ":flow": u.flow ?? null,
77
+ ":culprit": u.culprit ?? null,
78
+ ":first": u.firstTs
79
+ }
80
+ }));
81
+ await this.doc.send(new UpdateCommand({
82
+ TableName: this.table,
83
+ Key: {
84
+ pk: `APP#${u.app}#ISSUE`,
85
+ sk: u.fingerprint
86
+ },
87
+ UpdateExpression: "SET lastSeen = :ts, lastEvent = :ev",
88
+ ConditionExpression: "attribute_not_exists(lastSeen) OR lastSeen < :ts",
89
+ ExpressionAttributeValues: {
90
+ ":ts": u.ts,
91
+ ":ev": u.lastEvent
92
+ }
93
+ })).catch((e) => {
94
+ if (e.name !== "ConditionalCheckFailedException") throw e;
95
+ });
96
+ await this.doc.send(new UpdateCommand({
97
+ TableName: this.table,
98
+ Key: {
99
+ pk: `APP#${u.app}#ISSUE`,
100
+ sk: u.fingerprint
101
+ },
102
+ UpdateExpression: "SET firstSeen = :first",
103
+ ConditionExpression: "firstSeen > :first",
104
+ ExpressionAttributeValues: { ":first": u.firstTs }
105
+ })).catch((e) => {
106
+ if (e.name !== "ConditionalCheckFailedException") throw e;
107
+ });
108
+ }));
109
+ }
110
+ async incrementRollups(incs) {
111
+ await Promise.all(coalesceRollups(incs).map((r) => this.doc.send(new UpdateCommand({
112
+ TableName: this.table,
113
+ Key: {
114
+ pk: `APP#${r.app}#ROLLUP#${r.dimension}`,
115
+ sk: `${r.day}#${r.key}`
116
+ },
117
+ UpdateExpression: "ADD errors :e, events :v SET app = :app, #day = :day, dimension = :dim, #key = :key",
118
+ ExpressionAttributeNames: {
119
+ "#day": "day",
120
+ "#key": "key"
121
+ },
122
+ ExpressionAttributeValues: {
123
+ ":e": r.errors,
124
+ ":v": r.events,
125
+ ":app": r.app,
126
+ ":day": r.day,
127
+ ":dim": r.dimension,
128
+ ":key": r.key
129
+ }
130
+ }))));
131
+ }
132
+ async listApps() {
133
+ return (await this.queryAll({ pk: "APPS" })).map((i) => i.sk).sort();
134
+ }
135
+ async listIssues(app, { limit = 200 } = {}) {
136
+ return (await this.queryAll({ pk: `APP#${app}#ISSUE` })).sort((a, b) => b.lastSeen.localeCompare(a.lastSeen)).slice(0, limit).map(clean);
137
+ }
138
+ async getIssue(app, fp) {
139
+ const out = await this.doc.send(new GetCommand({
140
+ TableName: this.table,
141
+ Key: {
142
+ pk: `APP#${app}#ISSUE`,
143
+ sk: fp
144
+ }
145
+ }));
146
+ return out.Item ? clean(out.Item) : null;
147
+ }
148
+ async getRollups(app, dimension, fromDay, toDay) {
149
+ return (await this.queryAll({
150
+ pk: `APP#${app}#ROLLUP#${dimension}`,
151
+ between: [`${fromDay}#`, `${toDay}#￿`]
152
+ })).map((i) => clean(i));
153
+ }
154
+ async listIssueEvents(app, fp, { limit = 50 } = {}) {
155
+ return ((await this.doc.send(new QueryCommand({
156
+ TableName: this.table,
157
+ KeyConditionExpression: "pk = :pk",
158
+ ExpressionAttributeValues: { ":pk": `APP#${app}#ISSUEEV#${fp}` },
159
+ ScanIndexForward: false,
160
+ Limit: limit
161
+ }))).Items ?? []).map((i) => clean(i));
162
+ }
163
+ async queryAll({ pk, between }) {
164
+ const items = [];
165
+ let ExclusiveStartKey;
166
+ do {
167
+ const out = await this.doc.send(new QueryCommand({
168
+ TableName: this.table,
169
+ KeyConditionExpression: between ? "pk = :pk AND sk BETWEEN :a AND :b" : "pk = :pk",
170
+ ExpressionAttributeValues: between ? {
171
+ ":pk": pk,
172
+ ":a": between[0],
173
+ ":b": between[1]
174
+ } : { ":pk": pk },
175
+ ExclusiveStartKey
176
+ }));
177
+ items.push(...out.Items ?? []);
178
+ ExclusiveStartKey = out.LastEvaluatedKey;
179
+ } while (ExclusiveStartKey);
180
+ return items;
181
+ }
182
+ };
183
+ function clean(item) {
184
+ const { pk: _p, sk: _s, ttl: _t, ...rest } = item;
185
+ return rest;
186
+ }
187
+ export { DynamoStore };
@@ -0,0 +1,4 @@
1
+ // ../../node_modules/.pnpm/@tanstack+start-server-core@1.169.45/node_modules/@tanstack/start-server-core/dist/esm/empty-plugin-adapters.js
2
+ var pluginSerializationAdapters = [];
3
+ var hasPluginAdapters = false;
4
+ export { hasPluginAdapters, pluginSerializationAdapters };
@@ -0,0 +1,112 @@
1
+ import { n as rollupId, t as coalesceRollups } from "./rollups-JXbazRNh.js";
2
+ import { FieldValue, Timestamp } from "firebase-admin/firestore";
3
+ // ../../packages/adapters/src/firestore.ts
4
+ /**
5
+ * Firestore layout (all under one root collection so it's easy to find / secure / delete):
6
+ *
7
+ * {root}/{app} app marker
8
+ * {root}/{app}/issues/{fingerprint} Issue
9
+ * {root}/{app}/rollups/{day__dim__key} RollupRow (counters via FieldValue.increment)
10
+ * {root}/{app}/events/{eventId} StoredEvent + expireAt (enable a TTL policy on `expireAt`)
11
+ *
12
+ * Composite index needed: rollups (dimension ASC, day ASC). See firestore.indexes.json.
13
+ */
14
+ var FirestoreStore = class {
15
+ db;
16
+ opts;
17
+ constructor(db, opts = {}) {
18
+ this.db = db;
19
+ this.opts = opts;
20
+ }
21
+ get root() {
22
+ return this.db.collection(this.opts.root ?? "debug_apps");
23
+ }
24
+ app(app) {
25
+ return this.root.doc(app);
26
+ }
27
+ async registerApp(app) {
28
+ await this.app(app).set({
29
+ id: app,
30
+ updatedAt: FieldValue.serverTimestamp()
31
+ }, { merge: true });
32
+ }
33
+ async writeEvents(events) {
34
+ const days = this.opts.retentionDays ?? 30;
35
+ for (const chunk of chunks(events, 400)) {
36
+ const batch = this.db.batch();
37
+ for (const e of chunk) {
38
+ const expireAt = Timestamp.fromMillis(Date.parse(e.receivedAt) + days * 864e5);
39
+ batch.set(this.app(e.app).collection("events").doc(e.event.id), {
40
+ ...strip(e),
41
+ ts: e.event.ts,
42
+ expireAt
43
+ });
44
+ }
45
+ await batch.commit();
46
+ }
47
+ }
48
+ async upsertIssues(updates) {
49
+ await Promise.all(updates.map((u) => this.db.runTransaction(async (tx) => {
50
+ const ref = this.app(u.app).collection("issues").doc(u.fingerprint);
51
+ const cur = (await tx.get(ref)).data();
52
+ const newer = !cur || u.ts >= cur.lastSeen;
53
+ tx.set(ref, strip({
54
+ app: u.app,
55
+ fingerprint: u.fingerprint,
56
+ title: u.title,
57
+ culprit: u.culprit,
58
+ flow: u.flow,
59
+ firstSeen: cur && cur.firstSeen < u.firstTs ? cur.firstSeen : u.firstTs,
60
+ lastSeen: newer ? u.ts : cur.lastSeen,
61
+ count: FieldValue.increment(u.by),
62
+ ...newer ? { lastEvent: strip(u.lastEvent) } : {}
63
+ }), { merge: true });
64
+ })));
65
+ }
66
+ async incrementRollups(incs) {
67
+ const rows = coalesceRollups(incs);
68
+ for (const chunk of chunks(rows, 400)) {
69
+ const batch = this.db.batch();
70
+ for (const r of chunk) batch.set(this.app(r.app).collection("rollups").doc(rollupId(r)), {
71
+ app: r.app,
72
+ day: r.day,
73
+ dimension: r.dimension,
74
+ key: r.key,
75
+ errors: FieldValue.increment(r.errors),
76
+ events: FieldValue.increment(r.events)
77
+ }, { merge: true });
78
+ await batch.commit();
79
+ }
80
+ }
81
+ async listApps() {
82
+ return (await this.root.select().get()).docs.map((d) => d.id).sort();
83
+ }
84
+ async listIssues(app, { limit = 200 } = {}) {
85
+ return (await this.app(app).collection("issues").orderBy("lastSeen", "desc").limit(limit).get()).docs.map((d) => d.data());
86
+ }
87
+ async getIssue(app, fp) {
88
+ const snap = await this.app(app).collection("issues").doc(fp).get();
89
+ return snap.exists ? snap.data() : null;
90
+ }
91
+ async getRollups(app, dimension, fromDay, toDay) {
92
+ return (await this.app(app).collection("rollups").where("dimension", "==", dimension).where("day", ">=", fromDay).where("day", "<=", toDay).get()).docs.map((d) => d.data());
93
+ }
94
+ async listIssueEvents(app, fp, { limit = 50 } = {}) {
95
+ return (await this.app(app).collection("events").where("fingerprint", "==", fp).orderBy("ts", "desc").limit(limit).get()).docs.map((d) => {
96
+ const { expireAt: _e, ts: _t, ...rest } = d.data();
97
+ return rest;
98
+ });
99
+ }
100
+ };
101
+ /** Firestore rejects `undefined` values; drop them recursively. */
102
+ function strip(v) {
103
+ if (Array.isArray(v)) return v.map(strip);
104
+ if (v && typeof v === "object" && v.constructor === Object) return Object.fromEntries(Object.entries(v).filter(([, x]) => x !== void 0).map(([k, x]) => [k, strip(x)]));
105
+ return v;
106
+ }
107
+ function chunks(xs, n) {
108
+ const out = [];
109
+ for (let i = 0; i < xs.length; i += n) out.push(xs.slice(i, i + n));
110
+ return out;
111
+ }
112
+ export { FirestoreStore };
@@ -0,0 +1,31 @@
1
+ import { n as TSS_SERVER_FUNCTION, r as getServerFnById, t as createServerFn } from "../server.js";
2
+ // ../../node_modules/.pnpm/@tanstack+start-server-core@1.169.45/node_modules/@tanstack/start-server-core/dist/esm/createSsrRpc.js
3
+ var createSsrRpc = (functionId) => {
4
+ const url = "/_serverFn/" + functionId;
5
+ const serverFnMeta = { id: functionId };
6
+ const fn = async (...args) => {
7
+ return (await getServerFnById(functionId, { origin: "server" }))(...args);
8
+ };
9
+ return Object.assign(fn, {
10
+ url,
11
+ serverFnMeta,
12
+ [TSS_SERVER_FUNCTION]: true
13
+ });
14
+ };
15
+ // src/server/fns.ts
16
+ var getSessionUser = createServerFn({ method: "GET" }).handler(createSsrRpc("1edaae661b4968edee65ebb4a946e246107684704b784b6359bf9af2dfaae23f"));
17
+ var getLoginInfo = createServerFn({ method: "GET" }).handler(createSsrRpc("949e1fa91e479f6ad9193caee7087c38ca21191786f4b2c082ea643cbd30dec1"));
18
+ var login = createServerFn({ method: "POST" }).validator((d) => {
19
+ if (typeof d?.email !== "string" || typeof d?.password !== "string") throw new Error("email and password required");
20
+ return {
21
+ email: d.email.slice(0, 200),
22
+ password: d.password.slice(0, 200)
23
+ };
24
+ }).handler(createSsrRpc("a9edf8f42685a06ce282bb7c9f888e3ae39636f350a90750c31a47b27de7dca8"));
25
+ var logout = createServerFn({ method: "POST" }).handler(createSsrRpc("fd40d9026eb7d8fb5ab200daaed9a58f1d7b4eaf5b1ccab3e4cef9b0fedd9bc4"));
26
+ var getOverview = createServerFn({ method: "GET" }).validator((d) => ({ app: typeof d?.app === "string" ? d.app : void 0 })).handler(createSsrRpc("9354c2231554471ec5cde4e9a07b2e32662a8ce0bf29b09b5b930359d374f862"));
27
+ var getIssueDetail = createServerFn({ method: "GET" }).validator((d) => ({
28
+ app: String(d.app),
29
+ fingerprint: String(d.fingerprint)
30
+ })).handler(createSsrRpc("86933afdbcaa1be4a0aa07c4f8e690fdd684edbeab02a49ffdb73e85cadf9933"));
31
+ export { login as a, getSessionUser as i, getLoginInfo as n, logout as o, getOverview as r, getIssueDetail as t };
@@ -0,0 +1,87 @@
1
+ import { n as TSS_SERVER_FUNCTION, t as createServerFn } from "../server.js";
2
+ import { c as endSession, f as getStore, i as DEMO_USER, l as readSession, n as buildIssueDetail, o as checkCredentials, p as config, r as buildSummary, s as demoLoginEnabled, u as startSession } from "./queries-DIVV-5j6.js";
3
+ import { redirect } from "@tanstack/react-router";
4
+ // ../../node_modules/.pnpm/@tanstack+start-server-core@1.169.45/node_modules/@tanstack/start-server-core/dist/esm/createServerRpc.js
5
+ var createServerRpc = (serverFnMeta, splitImportFn) => {
6
+ const url = "/_serverFn/" + serverFnMeta.id;
7
+ return Object.assign(splitImportFn, {
8
+ url,
9
+ serverFnMeta,
10
+ [TSS_SERVER_FUNCTION]: true
11
+ });
12
+ };
13
+ // src/server/fns.ts?tss-serverfn-split
14
+ var getSessionUser_createServerFn_handler = createServerRpc({
15
+ id: "1edaae661b4968edee65ebb4a946e246107684704b784b6359bf9af2dfaae23f",
16
+ name: "getSessionUser",
17
+ filename: "src/server/fns.ts"
18
+ }, (opts) => getSessionUser.__executeServer(opts));
19
+ var getSessionUser = createServerFn({ method: "GET" }).handler(getSessionUser_createServerFn_handler, async () => readSession());
20
+ var getLoginInfo_createServerFn_handler = createServerRpc({
21
+ id: "949e1fa91e479f6ad9193caee7087c38ca21191786f4b2c082ea643cbd30dec1",
22
+ name: "getLoginInfo",
23
+ filename: "src/server/fns.ts"
24
+ }, (opts) => getLoginInfo.__executeServer(opts));
25
+ var getLoginInfo = createServerFn({ method: "GET" }).handler(getLoginInfo_createServerFn_handler, async () => ({
26
+ store: config().store,
27
+ demo: demoLoginEnabled() ? DEMO_USER : null
28
+ }));
29
+ var login_createServerFn_handler = createServerRpc({
30
+ id: "a9edf8f42685a06ce282bb7c9f888e3ae39636f350a90750c31a47b27de7dca8",
31
+ name: "login",
32
+ filename: "src/server/fns.ts"
33
+ }, (opts) => login.__executeServer(opts));
34
+ var login = createServerFn({ method: "POST" }).validator((d) => {
35
+ if (typeof d?.email !== "string" || typeof d?.password !== "string") throw new Error("email and password required");
36
+ return {
37
+ email: d.email.slice(0, 200),
38
+ password: d.password.slice(0, 200)
39
+ };
40
+ }).handler(login_createServerFn_handler, async ({ data }) => {
41
+ const user = checkCredentials(data.email, data.password);
42
+ if (!user) {
43
+ await new Promise((r) => setTimeout(r, 400));
44
+ return {
45
+ ok: false,
46
+ error: "Incorrect email or password."
47
+ };
48
+ }
49
+ startSession(user);
50
+ return { ok: true };
51
+ });
52
+ var logout_createServerFn_handler = createServerRpc({
53
+ id: "fd40d9026eb7d8fb5ab200daaed9a58f1d7b4eaf5b1ccab3e4cef9b0fedd9bc4",
54
+ name: "logout",
55
+ filename: "src/server/fns.ts"
56
+ }, (opts) => logout.__executeServer(opts));
57
+ var logout = createServerFn({ method: "POST" }).handler(logout_createServerFn_handler, async () => {
58
+ endSession();
59
+ return { ok: true };
60
+ });
61
+ function requireUser() {
62
+ const user = readSession();
63
+ if (!user) throw redirect({ to: "/login" });
64
+ return user;
65
+ }
66
+ var getOverview_createServerFn_handler = createServerRpc({
67
+ id: "9354c2231554471ec5cde4e9a07b2e32662a8ce0bf29b09b5b930359d374f862",
68
+ name: "getOverview",
69
+ filename: "src/server/fns.ts"
70
+ }, (opts) => getOverview.__executeServer(opts));
71
+ var getOverview = createServerFn({ method: "GET" }).validator((d) => ({ app: typeof d?.app === "string" ? d.app : void 0 })).handler(getOverview_createServerFn_handler, async ({ data }) => {
72
+ requireUser();
73
+ return buildSummary(await getStore(), data.app, config().severity);
74
+ });
75
+ var getIssueDetail_createServerFn_handler = createServerRpc({
76
+ id: "86933afdbcaa1be4a0aa07c4f8e690fdd684edbeab02a49ffdb73e85cadf9933",
77
+ name: "getIssueDetail",
78
+ filename: "src/server/fns.ts"
79
+ }, (opts) => getIssueDetail.__executeServer(opts));
80
+ var getIssueDetail = createServerFn({ method: "GET" }).validator((d) => ({
81
+ app: String(d.app),
82
+ fingerprint: String(d.fingerprint)
83
+ })).handler(getIssueDetail_createServerFn_handler, async ({ data }) => {
84
+ requireUser();
85
+ return buildIssueDetail(await getStore(), data.app, data.fingerprint, config().severity);
86
+ });
87
+ export { getIssueDetail_createServerFn_handler, getLoginInfo_createServerFn_handler, getOverview_createServerFn_handler, getSessionUser_createServerFn_handler, login_createServerFn_handler, logout_createServerFn_handler };
@@ -0,0 +1,255 @@
1
+ import { n as HourlyChart } from "./charts-CNlV7Pga.js";
2
+ import { a as ShareBars, i as SeverityBadge, n as DataTable, o as Stat, s as timeAgo, t as Card } from "./ui-Lv-KcOoP.js";
3
+ import { n as Route } from "./router-D2L7-BwF.js";
4
+ import { Link } from "@tanstack/react-router";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/routes/_authed/issues.$fingerprint.tsx?tsr-split=component
7
+ function IssuePage() {
8
+ const d = Route.useLoaderData();
9
+ const { issue, sample } = d;
10
+ const ev = sample?.event.type === "error" ? sample.event : null;
11
+ const frames = ev?.error.frames ?? [];
12
+ return /* @__PURE__ */ jsxs("main", {
13
+ className: "mx-auto max-w-7xl space-y-5 px-4 py-6 sm:px-6",
14
+ children: [
15
+ /* @__PURE__ */ jsx(Link, {
16
+ to: "/",
17
+ search: { app: d.app },
18
+ className: "text-sm text-muted hover:text-ink",
19
+ children: "← Overview"
20
+ }),
21
+ /* @__PURE__ */ jsxs("div", { children: [
22
+ /* @__PURE__ */ jsxs("div", {
23
+ className: "flex flex-wrap items-center gap-2 text-xs text-muted",
24
+ children: [
25
+ /* @__PURE__ */ jsx(SeverityBadge, { severity: issue.severity }),
26
+ issue.flow && /* @__PURE__ */ jsx("span", {
27
+ className: "rounded bg-panel-2 px-1.5 py-0.5 font-mono",
28
+ children: issue.flow
29
+ }),
30
+ /* @__PURE__ */ jsxs("span", { children: [
31
+ "First seen ",
32
+ timeAgo(issue.firstSeen),
33
+ " · last seen ",
34
+ timeAgo(issue.lastSeen)
35
+ ] })
36
+ ]
37
+ }),
38
+ /* @__PURE__ */ jsx("h1", {
39
+ className: "mt-2 break-words text-xl font-semibold tracking-tight sm:text-2xl",
40
+ children: issue.title
41
+ }),
42
+ issue.culprit && /* @__PURE__ */ jsx("p", {
43
+ className: "mt-1 font-mono text-sm text-muted",
44
+ children: issue.culprit
45
+ })
46
+ ] }),
47
+ /* @__PURE__ */ jsxs("div", {
48
+ className: "grid grid-cols-2 gap-3 lg:grid-cols-4",
49
+ children: [
50
+ /* @__PURE__ */ jsx(Stat, {
51
+ label: "Occurrences (24h)",
52
+ value: issue.count24h,
53
+ tone: issue.severity
54
+ }),
55
+ /* @__PURE__ */ jsx(Stat, {
56
+ label: "Total occurrences",
57
+ value: issue.countTotal.toLocaleString()
58
+ }),
59
+ /* @__PURE__ */ jsx(Stat, {
60
+ label: "Users affected",
61
+ value: d.affectedUsers,
62
+ hint: "in the last 200 events"
63
+ }),
64
+ /* @__PURE__ */ jsx(Stat, {
65
+ label: "Top app version",
66
+ value: d.breakdowns.appVersion[0]?.key ?? "—",
67
+ hint: d.breakdowns.appVersion[0] ? `${Math.round(d.breakdowns.appVersion[0].share * 100)}% of occurrences` : void 0
68
+ })
69
+ ]
70
+ }),
71
+ /* @__PURE__ */ jsx(Card, {
72
+ title: "What to look at",
73
+ subtitle: "Generated from the error, its breadcrumbs and where it happens.",
74
+ children: /* @__PURE__ */ jsx("ol", {
75
+ className: "space-y-3",
76
+ children: d.hints.map((h, i) => /* @__PURE__ */ jsxs("li", {
77
+ className: "flex gap-3",
78
+ children: [/* @__PURE__ */ jsx("span", {
79
+ className: "mt-0.5 grid h-5 w-5 shrink-0 place-items-center rounded-full bg-accent-soft text-[11px] font-semibold text-accent",
80
+ children: i + 1
81
+ }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
82
+ className: "text-sm font-medium",
83
+ children: h.title
84
+ }), /* @__PURE__ */ jsx("div", {
85
+ className: "text-sm text-muted",
86
+ children: h.detail
87
+ })] })]
88
+ }, i))
89
+ })
90
+ }),
91
+ /* @__PURE__ */ jsxs("div", {
92
+ className: "grid gap-5 lg:grid-cols-3",
93
+ children: [/* @__PURE__ */ jsx("div", {
94
+ className: "lg:col-span-2",
95
+ children: /* @__PURE__ */ jsxs(Card, {
96
+ title: "Occurrences per hour",
97
+ subtitle: "Last 48 hours",
98
+ children: [/* @__PURE__ */ jsx(HourlyChart, { data: d.hourly }), /* @__PURE__ */ jsx(DataTable, {
99
+ columns: ["Hour (UTC)", "Count"],
100
+ rows: d.hourly.map((h) => [h.hour, h.count])
101
+ })]
102
+ })
103
+ }), /* @__PURE__ */ jsx(Card, {
104
+ title: "Where it happens",
105
+ subtitle: "Share of recent occurrences",
106
+ children: /* @__PURE__ */ jsx("div", {
107
+ className: "space-y-4",
108
+ children: [
109
+ "os",
110
+ "appVersion",
111
+ "deviceModel",
112
+ "network"
113
+ ].map((k) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
114
+ className: "mb-1.5 text-xs font-medium text-muted",
115
+ children: {
116
+ os: "OS",
117
+ appVersion: "App version",
118
+ deviceModel: "Device",
119
+ network: "Network"
120
+ }[k]
121
+ }), /* @__PURE__ */ jsx(ShareBars, { rows: d.breakdowns[k].map((r) => ({
122
+ key: r.key,
123
+ value: r.count
124
+ })) })] }, k))
125
+ })
126
+ })]
127
+ }),
128
+ /* @__PURE__ */ jsxs("div", {
129
+ className: "grid gap-5 lg:grid-cols-2",
130
+ children: [/* @__PURE__ */ jsx(Card, {
131
+ title: "Stack trace",
132
+ subtitle: "Most recent occurrence. In-app frames highlighted.",
133
+ children: frames.length ? /* @__PURE__ */ jsx("ol", {
134
+ className: "space-y-1 font-mono text-xs",
135
+ children: frames.map((f, i) => /* @__PURE__ */ jsxs("li", {
136
+ className: `rounded px-2 py-1 ${f.inApp ? "bg-accent-soft text-ink" : "text-muted"}`,
137
+ children: [
138
+ /* @__PURE__ */ jsx("span", {
139
+ className: "font-semibold",
140
+ children: f.fn ?? "<anonymous>"
141
+ }),
142
+ " ",
143
+ /* @__PURE__ */ jsxs("span", {
144
+ className: "break-all",
145
+ children: [
146
+ f.file,
147
+ ":",
148
+ f.line,
149
+ ":",
150
+ f.col
151
+ ]
152
+ })
153
+ ]
154
+ }, i))
155
+ }) : /* @__PURE__ */ jsx("pre", {
156
+ className: "overflow-auto whitespace-pre-wrap text-xs text-muted",
157
+ children: ev?.error.stack ?? "No stack trace captured."
158
+ })
159
+ }), /* @__PURE__ */ jsx(Card, {
160
+ title: "Breadcrumbs",
161
+ subtitle: "What the user did right before the error",
162
+ children: ev?.breadcrumbs?.length ? /* @__PURE__ */ jsxs("ol", {
163
+ className: "relative space-y-3 border-l border-line pl-4",
164
+ children: [ev.breadcrumbs.map((b, i) => /* @__PURE__ */ jsxs("li", {
165
+ className: "text-sm",
166
+ children: [
167
+ /* @__PURE__ */ jsx("span", { className: `absolute -left-[5px] mt-1.5 h-2.5 w-2.5 rounded-full ${b.level === "error" ? "bg-sev-critical" : "bg-line"}` }),
168
+ /* @__PURE__ */ jsx("span", {
169
+ className: "mr-2 rounded bg-panel-2 px-1.5 py-0.5 text-[11px] uppercase tracking-wide text-muted",
170
+ children: b.category
171
+ }),
172
+ /* @__PURE__ */ jsx("span", {
173
+ className: "break-words",
174
+ children: b.message
175
+ })
176
+ ]
177
+ }, i)), /* @__PURE__ */ jsxs("li", {
178
+ className: "text-sm font-medium text-sev-critical",
179
+ children: [/* @__PURE__ */ jsx("span", { className: "absolute -left-[5px] mt-1.5 h-2.5 w-2.5 rounded-full bg-sev-critical" }), issue.title]
180
+ })]
181
+ }) : /* @__PURE__ */ jsxs("p", {
182
+ className: "text-sm text-muted",
183
+ children: [
184
+ "No breadcrumbs. Call ",
185
+ /* @__PURE__ */ jsx("code", { children: "deBug.breadcrumb()" }),
186
+ " on navigation and network calls to see the path to the error."
187
+ ]
188
+ })
189
+ })]
190
+ }),
191
+ /* @__PURE__ */ jsx(Card, {
192
+ title: "Recent occurrences",
193
+ children: /* @__PURE__ */ jsx("div", {
194
+ className: "-mx-4 overflow-x-auto sm:mx-0",
195
+ children: /* @__PURE__ */ jsxs("table", {
196
+ className: "tabular w-full min-w-[600px] text-left text-sm",
197
+ children: [/* @__PURE__ */ jsx("thead", {
198
+ className: "text-xs text-muted",
199
+ children: /* @__PURE__ */ jsxs("tr", {
200
+ className: "border-b border-line",
201
+ children: [
202
+ /* @__PURE__ */ jsx("th", {
203
+ className: "px-4 py-2 font-medium sm:px-2",
204
+ children: "When"
205
+ }),
206
+ /* @__PURE__ */ jsx("th", {
207
+ className: "px-2 py-2 font-medium",
208
+ children: "OS"
209
+ }),
210
+ /* @__PURE__ */ jsx("th", {
211
+ className: "px-2 py-2 font-medium",
212
+ children: "Version"
213
+ }),
214
+ /* @__PURE__ */ jsx("th", {
215
+ className: "px-2 py-2 font-medium",
216
+ children: "Device"
217
+ }),
218
+ /* @__PURE__ */ jsx("th", {
219
+ className: "px-2 py-2 font-medium",
220
+ children: "User"
221
+ })
222
+ ]
223
+ })
224
+ }), /* @__PURE__ */ jsx("tbody", { children: d.recent.map((r, i) => /* @__PURE__ */ jsxs("tr", {
225
+ className: "border-b border-line last:border-0",
226
+ children: [
227
+ /* @__PURE__ */ jsx("td", {
228
+ className: "px-4 py-2 text-xs text-muted sm:px-2",
229
+ children: timeAgo(r.ts)
230
+ }),
231
+ /* @__PURE__ */ jsx("td", {
232
+ className: "px-2 py-2",
233
+ children: r.os
234
+ }),
235
+ /* @__PURE__ */ jsx("td", {
236
+ className: "px-2 py-2",
237
+ children: r.appVersion ?? "—"
238
+ }),
239
+ /* @__PURE__ */ jsx("td", {
240
+ className: "px-2 py-2",
241
+ children: r.device ?? "—"
242
+ }),
243
+ /* @__PURE__ */ jsx("td", {
244
+ className: "px-2 py-2 font-mono text-xs text-muted",
245
+ children: r.userId ?? "anonymous"
246
+ })
247
+ ]
248
+ }, i)) })]
249
+ })
250
+ })
251
+ })
252
+ ]
253
+ });
254
+ }
255
+ export { IssuePage as component };