@debugkit/dashboard 0.9.0 → 0.10.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 (79) hide show
  1. package/dist/client/assets/_authed-3se5Egqg.js +1 -0
  2. package/dist/client/assets/_authed-BfFWbTOO.js +1 -0
  3. package/dist/client/assets/app-code-BKWbvUMR.js +1 -0
  4. package/dist/client/assets/closed-issues-Cl-8l4oR.js +1 -0
  5. package/dist/client/assets/{copy-button-BJkvWYRY.js → copy-button-BwRd5q7l.js} +1 -1
  6. package/dist/client/assets/customers-Cf-R8BOg.js +1 -0
  7. package/dist/client/assets/empty-state-njgr1sWu.js +7 -0
  8. package/dist/client/assets/endpoints-BMqAUNyE.js +1 -0
  9. package/dist/client/assets/events._eventId-CVRZJ-bU.js +2 -0
  10. package/dist/client/assets/exchange-view-DVwSLcXF.js +2 -0
  11. package/dist/client/assets/index-DEnCDILF.js +10 -0
  12. package/dist/client/assets/{invite._token-DiDJMnQu.js → invite._token-CKAfd5iB.js} +1 -1
  13. package/dist/client/assets/issues._fingerprint-Cm72LNM_.js +55 -0
  14. package/dist/client/assets/login-BTxOhEbN.js +1 -0
  15. package/dist/client/assets/request-panel-DmtFRF8Z.js +1 -0
  16. package/dist/client/assets/services._service-CU1a45f3.js +1 -0
  17. package/dist/client/assets/{sessions._sessionId-B0NxM46y.js → sessions._sessionId-LRo3QNQP.js} +1 -1
  18. package/dist/client/assets/settings-Ctzvl2LL.js +1 -0
  19. package/dist/client/assets/src-BiKxgjA_.js +3 -0
  20. package/dist/client/assets/styles-Tcq0pvWj.css +2 -0
  21. package/dist/client/assets/{team-BRuVQ2bU.js → team-xlrjhEGp.js} +1 -1
  22. package/dist/client/assets/{timeline-BIGo9MCA.js → timeline-WXE49N62.js} +1 -1
  23. package/dist/client/assets/ui-DRjjeSWy.js +1 -0
  24. package/dist/client/assets/{version-banner-VFvyqbPh.js → version-banner-BYe4PVzv.js} +1 -1
  25. package/dist/server/assets/_authed-Bn-IktVS.js +120 -0
  26. package/dist/server/assets/_authed-RXh7GpoE.js +252 -0
  27. package/dist/server/assets/_tanstack-start-manifest_v-C4dQ3MxD.js +122 -0
  28. package/dist/server/assets/app-code-BQL_FcSx.js +212 -0
  29. package/dist/server/assets/app-name-BcbY1BZN.js +11 -0
  30. package/dist/server/assets/closed-issues-o9U80FXv.js +45 -0
  31. package/dist/server/assets/config-Bp8m0B8q.js +57 -0
  32. package/dist/server/assets/{customers-827fC5I3.js → customers-CD84Bz4P.js} +11 -6
  33. package/dist/server/assets/{demo-DDNiXCgj.js → demo-D-o8m75S.js} +222 -6
  34. package/dist/server/assets/{dynamodb-Cd4blXkh.js → dynamodb-CcH0cp7R.js} +2 -2
  35. package/dist/server/assets/empty-state-wz34oAi8.js +163 -0
  36. package/dist/server/assets/endpoints-8N389Poe.js +248 -0
  37. package/dist/server/assets/{endpoints-_T0NSOyA.js → endpoints-C0Cxc_-x.js} +38 -36
  38. package/dist/server/assets/{events._eventId-Dcsu4oVO.js → events._eventId-BOHkNO5W.js} +90 -351
  39. package/dist/server/assets/exchange-view-DzoSBt_R.js +112 -0
  40. package/dist/server/assets/{firestore-c8Sz2Q4O.js → firestore-DyvYMiz3.js} +2 -2
  41. package/dist/server/assets/{fns-BiUOnY1_.js → fns-BcVGbSID.js} +20 -7
  42. package/dist/server/assets/fns-DE03YExD.js +831 -0
  43. package/dist/server/assets/{invite._token-7DjEeeaD.js → invite._token-DhlACkIe.js} +3 -3
  44. package/dist/server/assets/{issues._fingerprint-vc9r3jgg.js → issues._fingerprint-BBd-_Nn5.js} +400 -28
  45. package/dist/server/assets/{login-CwKAx9Bj.js → login-CbfdHJvg.js} +3 -3
  46. package/dist/server/assets/{memory-Bv4C8uyK.js → memory-CZBUh1Zc.js} +75 -3
  47. package/dist/server/assets/{errors-Po4Tt5zd.js → queries-wha4cZbw.js} +1394 -128
  48. package/dist/server/assets/request-panel-DpCSwl2q.js +162 -0
  49. package/dist/server/assets/{router-Dk3XHn7B.js → router-BXkzR89j.js} +195 -91
  50. package/dist/server/assets/services._service-DWjFFGON.js +309 -0
  51. package/dist/server/assets/{sessions._sessionId-BvXxK9qF.js → sessions._sessionId-DDspiPTe.js} +2 -2
  52. package/dist/server/assets/{settings-B9NLQjl1.js → settings-DCLIaZ_p.js} +146 -25
  53. package/dist/server/assets/{src-oWPSAvXv.js → src-B2GKPQyN.js} +1 -1
  54. package/dist/server/assets/{team-Bsm2wFG0.js → team-jd_TmWP4.js} +3 -3
  55. package/dist/server/assets/ui-C3pl0edn.js +302 -0
  56. package/dist/server/assets/{version-banner-nf-yZurq.js → version-banner-BX34ijG5.js} +1 -1
  57. package/dist/server/assets/{versions-BOlL8jam.js → versions-YI_zK1ql.js} +3 -3
  58. package/dist/server/assets/warm-C3GbXP1_.js +16 -0
  59. package/dist/server/server.js +37 -29
  60. package/package.json +4 -4
  61. package/dist/client/assets/_authed-C29P68T-.js +0 -1
  62. package/dist/client/assets/_authed-D-dYbHoP.js +0 -7
  63. package/dist/client/assets/charts--S1o8iId.js +0 -55
  64. package/dist/client/assets/customers-Cwx5qEO1.js +0 -1
  65. package/dist/client/assets/endpoints-zz1TotR2.js +0 -1
  66. package/dist/client/assets/events._eventId-Bx6TfUjv.js +0 -3
  67. package/dist/client/assets/index-COHr_cc3.js +0 -10
  68. package/dist/client/assets/issues._fingerprint-Cv522h2j.js +0 -1
  69. package/dist/client/assets/login-CKkpc0t5.js +0 -1
  70. package/dist/client/assets/settings-CIlF10MI.js +0 -1
  71. package/dist/client/assets/src-BKSiJUs3.js +0 -3
  72. package/dist/client/assets/styles-GAsMUS4-.css +0 -2
  73. package/dist/client/assets/ui-CaEZB1j2.js +0 -1
  74. package/dist/server/assets/_authed-BJWDiF9i.js +0 -92
  75. package/dist/server/assets/_authed-X9u_5JUy.js +0 -902
  76. package/dist/server/assets/_tanstack-start-manifest_v-C6vaeBdY.js +0 -90
  77. package/dist/server/assets/charts-DzTVqJ8z.js +0 -238
  78. package/dist/server/assets/fns-CVbk8Gf9.js +0 -1310
  79. package/dist/server/assets/ui-SAkSlP7f.js +0 -193
@@ -0,0 +1,212 @@
1
+ import { t as EmptyState } from "./empty-state-wz34oAi8.js";
2
+ import { n as RetentionNote, t as RangePicker } from "./range-picker-0zbSGr3Z.js";
3
+ import { t as ClosedIssues } from "./closed-issues-o9U80FXv.js";
4
+ import { c as LevelRow, f as levelName, m as toneClass, o as IssueLabels, p as timeAgo } from "./ui-C3pl0edn.js";
5
+ import { W as plural } from "./queries-wha4cZbw.js";
6
+ import { d as Route } from "./router-BXkzR89j.js";
7
+ import { Link, useNavigate } from "@tanstack/react-router";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ // src/routes/_authed/app-code.tsx?tsr-split=component
10
+ /**
11
+ * The App code box, one level down: the app's own crashes and code errors (not failed calls,
12
+ * which belong to their service), worst first, each one click from its cause and fix. Resolved
13
+ * and ignored ones sit apart at the bottom.
14
+ */
15
+ function AppCodePage() {
16
+ const report = Route.useLoaderData();
17
+ const search = Route.useSearch();
18
+ const navigate = useNavigate({ from: Route.fullPath });
19
+ if (!report) return /* @__PURE__ */ jsx(EmptyState, {});
20
+ const { range, tile, open, closed } = report;
21
+ const keep = {
22
+ app: report.app,
23
+ range: search.range,
24
+ from: search.from,
25
+ to: search.to
26
+ };
27
+ const now = Date.parse(report.generatedAt);
28
+ return /* @__PURE__ */ jsxs("main", {
29
+ className: "mx-auto max-w-7xl space-y-5 px-4 py-6 sm:px-6",
30
+ children: [
31
+ /* @__PURE__ */ jsxs("div", {
32
+ className: "flex flex-wrap items-center justify-between gap-3",
33
+ children: [/* @__PURE__ */ jsxs("nav", {
34
+ "aria-label": "Breadcrumb",
35
+ className: "text-sm text-muted",
36
+ children: [
37
+ /* @__PURE__ */ jsx(Link, {
38
+ to: "/",
39
+ search: keep,
40
+ className: "hover:text-ink hover:underline",
41
+ children: "Health"
42
+ }),
43
+ /* @__PURE__ */ jsx("span", {
44
+ "aria-hidden": true,
45
+ children: " › "
46
+ }),
47
+ /* @__PURE__ */ jsx("span", {
48
+ className: "text-ink",
49
+ "aria-current": "page",
50
+ children: "App code"
51
+ })
52
+ ]
53
+ }), /* @__PURE__ */ jsx(RangePicker, {
54
+ value: range,
55
+ today: report.generatedAt.slice(0, 10),
56
+ onChange: (r) => navigate({ search: (s) => ({
57
+ ...s,
58
+ ...r
59
+ }) })
60
+ }, `${range.preset}${range.from}${range.to}`)]
61
+ }),
62
+ /* @__PURE__ */ jsx(RetentionNote, {
63
+ rangeFrom: range.from,
64
+ retention: report.retention
65
+ }),
66
+ /* @__PURE__ */ jsxs("header", { children: [
67
+ /* @__PURE__ */ jsxs("p", {
68
+ className: "text-xs font-bold uppercase tracking-wide",
69
+ children: [/* @__PURE__ */ jsx("span", {
70
+ className: toneClass(tile.level, "text"),
71
+ children: levelName(tile.level)
72
+ }), tile.live && /* @__PURE__ */ jsx("span", {
73
+ className: `ml-2 normal-case ${toneClass(tile.level, "text")}`,
74
+ children: "· Still happening"
75
+ })]
76
+ }),
77
+ /* @__PURE__ */ jsx("h1", {
78
+ className: "mt-1 text-2xl font-semibold tracking-tight",
79
+ children: "App code"
80
+ }),
81
+ /* @__PURE__ */ jsxs("p", {
82
+ className: "mt-1 text-sm text-muted",
83
+ children: [
84
+ "Crashes and code errors in the app itself, in ",
85
+ range.label,
86
+ ", worst first. Failed calls are on their service's page."
87
+ ]
88
+ })
89
+ ] }),
90
+ search.tests && /* @__PURE__ */ jsx(TestErrors, {
91
+ issues: report.tests,
92
+ keep,
93
+ now
94
+ }),
95
+ open.length ? /* @__PURE__ */ jsx("ol", {
96
+ className: "space-y-3",
97
+ "aria-label": "Open crashes and code errors, worst first",
98
+ children: open.map((i) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(LevelRow, {
99
+ level: i.severity,
100
+ aside: plural(i.countRange, "time"),
101
+ children: /* @__PURE__ */ jsx(Problem, {
102
+ issue: i,
103
+ keep,
104
+ now
105
+ })
106
+ }) }, i.fingerprint))
107
+ }) : /* @__PURE__ */ jsxs("p", {
108
+ className: "rounded-lg border border-level-healthy-edge bg-level-healthy-bg px-3 py-2 text-sm text-level-healthy-fg",
109
+ children: [
110
+ "No open crashes or code errors in ",
111
+ range.label,
112
+ "."
113
+ ]
114
+ }),
115
+ /* @__PURE__ */ jsx(ClosedIssues, {
116
+ issues: closed,
117
+ keep,
118
+ now
119
+ })
120
+ ]
121
+ });
122
+ }
123
+ /** One crash or code error: what, where in the code, how often, and the way to its cause and fix. */
124
+ function Problem({ issue: i, keep, now }) {
125
+ const versions = [i.firstVersion, i.lastVersion].filter((v, n, all) => v && all.indexOf(v) === n);
126
+ return /* @__PURE__ */ jsxs(Link, {
127
+ to: "/issues/$fingerprint",
128
+ params: { fingerprint: i.fingerprint },
129
+ search: {
130
+ ...keep,
131
+ app: keep.app ?? ""
132
+ },
133
+ className: "group -m-1 flex flex-wrap items-center justify-between gap-2 rounded-lg p-1 hover:bg-panel-2 focus-visible:outline-2 focus-visible:outline-accent",
134
+ children: [/* @__PURE__ */ jsxs("span", {
135
+ className: "min-w-0 break-words",
136
+ children: [
137
+ /* @__PURE__ */ jsx("span", {
138
+ className: "font-medium",
139
+ children: i.title
140
+ }),
141
+ i.culprit && /* @__PURE__ */ jsx("span", {
142
+ className: "block font-mono text-xs text-muted",
143
+ children: i.culprit
144
+ }),
145
+ /* @__PURE__ */ jsxs("span", {
146
+ className: "tabular block text-xs text-muted",
147
+ children: [
148
+ plural(i.countRange, "time"),
149
+ i.users ? ` · ${plural(i.users, "customer")}` : "",
150
+ versions.length ? ` · app ${versions.join("–")}` : "",
151
+ " · last ",
152
+ timeAgo(i.lastSeen, now)
153
+ ]
154
+ }),
155
+ /* @__PURE__ */ jsx(IssueLabels, { issue: i })
156
+ ]
157
+ }), /* @__PURE__ */ jsx("span", {
158
+ className: "shrink-0 text-xs font-semibold text-accent group-hover:underline",
159
+ children: "Cause and fix →"
160
+ })]
161
+ });
162
+ }
163
+ /** Errors the app made on purpose to test deBug: shown only when asked for, never counted. */
164
+ function TestErrors({ issues, keep, now }) {
165
+ return /* @__PURE__ */ jsxs("section", {
166
+ id: "test-errors",
167
+ "aria-labelledby": "tests-h",
168
+ className: "rounded-xl border border-line bg-panel p-4",
169
+ children: [
170
+ /* @__PURE__ */ jsxs("h2", {
171
+ id: "tests-h",
172
+ className: "text-sm font-semibold",
173
+ children: [
174
+ "Test errors (",
175
+ issues.length,
176
+ ")"
177
+ ]
178
+ }),
179
+ /* @__PURE__ */ jsx("p", {
180
+ className: "mt-0.5 text-sm text-muted",
181
+ children: "Why they're folded away: the app made them on purpose to check deBug works (tagged test=true), so they never count toward any box, total, rate or alert."
182
+ }),
183
+ issues.length ? /* @__PURE__ */ jsx("ul", {
184
+ className: "mt-3 space-y-1.5 text-sm",
185
+ children: issues.map((i) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(Link, {
186
+ to: "/issues/$fingerprint",
187
+ params: { fingerprint: i.fingerprint },
188
+ search: {
189
+ ...keep,
190
+ app: keep.app ?? ""
191
+ },
192
+ className: "flex flex-wrap justify-between gap-2 rounded px-1 py-0.5 hover:bg-panel-2",
193
+ children: [/* @__PURE__ */ jsx("span", {
194
+ className: "min-w-0 break-words",
195
+ children: i.title
196
+ }), /* @__PURE__ */ jsxs("span", {
197
+ className: "shrink-0 text-xs text-muted",
198
+ children: [
199
+ plural(i.countRange, "time"),
200
+ " · last ",
201
+ timeAgo(i.lastSeen, now)
202
+ ]
203
+ })]
204
+ }) }, i.fingerprint))
205
+ }) : /* @__PURE__ */ jsx("p", {
206
+ className: "mt-3 text-sm text-muted",
207
+ children: "None in this period."
208
+ })
209
+ ]
210
+ });
211
+ }
212
+ export { AppCodePage as component };
@@ -0,0 +1,11 @@
1
+ /** Check a display name from Settings. Returns the cleaned name ("" to go back to the id), or what's wrong. */
2
+ function validAppName(x) {
3
+ if (typeof x !== "string") return "The app name must be text";
4
+ if (/[\u0000-\u001f\u007f]/.test(x)) return "The app name can't have line breaks or control characters";
5
+ const name = x.trim().replace(/\s+/g, " ");
6
+ if (name.length > 60) return `Use an app name of up to 60 characters`;
7
+ return { name };
8
+ }
9
+ /** What people see an app as: its display name, else its id. */
10
+ var appLabel = (id, name) => name?.trim() || id;
11
+ export { validAppName as n, appLabel as t };
@@ -0,0 +1,45 @@
1
+ import { p as timeAgo } from "./ui-C3pl0edn.js";
2
+ import { Link } from "@tanstack/react-router";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ // src/components/closed-issues.tsx
5
+ /**
6
+ * Resolved and ignored issues, folded away at the bottom of a page: where to find one again and
7
+ * reopen it from its page.
8
+ */
9
+ function ClosedIssues({ issues, keep, now }) {
10
+ if (!issues.length) return null;
11
+ return /* @__PURE__ */ jsxs("details", {
12
+ className: "rounded-xl border border-line bg-panel p-4 text-sm",
13
+ children: [/* @__PURE__ */ jsxs("summary", {
14
+ className: "cursor-pointer font-semibold text-muted hover:text-ink",
15
+ children: [
16
+ "Resolved or ignored (",
17
+ issues.length,
18
+ ")"
19
+ ]
20
+ }), /* @__PURE__ */ jsx("ul", {
21
+ className: "mt-3 space-y-1.5",
22
+ children: issues.map((i) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(Link, {
23
+ to: "/issues/$fingerprint",
24
+ params: { fingerprint: i.fingerprint },
25
+ search: {
26
+ ...keep,
27
+ app: keep.app ?? ""
28
+ },
29
+ className: "flex flex-wrap justify-between gap-2 rounded px-1 py-0.5 hover:bg-panel-2",
30
+ children: [/* @__PURE__ */ jsx("span", {
31
+ className: "min-w-0 break-words",
32
+ children: i.title
33
+ }), /* @__PURE__ */ jsxs("span", {
34
+ className: "shrink-0 text-xs text-muted",
35
+ children: [
36
+ i.status === "resolved" ? `Resolved${i.resolvedIn ? ` in ${i.resolvedIn}` : ""}` : "Ignored",
37
+ " · last ",
38
+ timeAgo(i.lastSeen, now)
39
+ ]
40
+ })]
41
+ }) }, i.fingerprint))
42
+ })]
43
+ });
44
+ }
45
+ export { ClosedIssues as t };
@@ -0,0 +1,57 @@
1
+ import { d as DEFAULT_SEVERITY_THRESHOLDS } from "./memory-CZBUh1Zc.js";
2
+ import { randomBytes } from "node:crypto";
3
+ // src/server/config.ts
4
+ var loaded = false;
5
+ function loadEnv() {
6
+ if (loaded) return;
7
+ loaded = true;
8
+ try {
9
+ process.loadEnvFile?.(process.env.DEBUG_ENV_FILE ?? ".env");
10
+ } catch {}
11
+ }
12
+ var generatedSecret;
13
+ function config() {
14
+ loadEnv();
15
+ const env = process.env;
16
+ const store = env.DEBUG_STORE ?? "demo";
17
+ let secret = env.DEBUG_SESSION_SECRET;
18
+ if (!secret || secret.length < 32) {
19
+ if (store !== "demo" && store !== "memory") throw new Error("DEBUG_SESSION_SECRET must be set (≥32 chars) when not in demo mode. Try: openssl rand -hex 32");
20
+ secret = generatedSecret ??= randomBytes(32).toString("hex");
21
+ }
22
+ const num = (v, d) => v && !Number.isNaN(Number(v)) ? Number(v) : d;
23
+ const severity = {
24
+ critical: num(env.DEBUG_SEVERITY_CRITICAL, DEFAULT_SEVERITY_THRESHOLDS.critical),
25
+ high: num(env.DEBUG_SEVERITY_HIGH, DEFAULT_SEVERITY_THRESHOLDS.high),
26
+ medium: num(env.DEBUG_SEVERITY_MEDIUM, DEFAULT_SEVERITY_THRESHOLDS.medium)
27
+ };
28
+ return {
29
+ store,
30
+ sessionSecret: secret,
31
+ users: env.DEBUG_DASHBOARD_USERS ?? "",
32
+ apiToken: env.DEBUG_API_TOKEN,
33
+ /** Demo mode: keys accepted by POST /api/ingest. "*" = any app. */
34
+ localIngestKeys: env.DEBUG_LOCAL_INGEST_KEYS ?? "pk_local:*",
35
+ firestoreRoot: env.DEBUG_FIRESTORE_ROOT ?? "debug_apps",
36
+ dynamoTable: env.DEBUG_DYNAMO_TABLE ?? "debug",
37
+ severity,
38
+ /** The ingest function's admin routes (…/admin) and their token, for changing settings. */
39
+ adminUrl: env.DEBUG_ADMIN_URL?.replace(/\/+$/, ""),
40
+ adminToken: env.DEBUG_ADMIN_TOKEN,
41
+ /** The CLI environment this dashboard belongs to ("preview"), for commands it suggests (`--env preview`). */
42
+ environment: /^[a-z][a-z0-9-]{0,30}$/.test(env.DEBUG_ENVIRONMENT ?? "") ? env.DEBUG_ENVIRONMENT : void 0,
43
+ /** The deployment's default retention (what ingest uses before an app has a setting). */
44
+ retentionDays: num(env.DEBUG_RETENTION_DAYS, 0) || void 0,
45
+ /** "Create issue" buttons on the issue page. */
46
+ trackers: {
47
+ linear: env.DEBUG_LINEAR === "1" || !!env.DEBUG_LINEAR_TEAM,
48
+ linearTeam: env.DEBUG_LINEAR_TEAM || void 0,
49
+ githubRepo: env.DEBUG_GITHUB_REPO || void 0,
50
+ dashboardUrl: env.DEBUG_DASHBOARD_URL || void 0
51
+ },
52
+ secureCookies: env.NODE_ENV === "production" && env.DEBUG_INSECURE_COOKIES !== "1",
53
+ /** Firebase Hosting only forwards a cookie named __session to the function behind it. */
54
+ cookieName: /^[A-Za-z0-9_]{1,40}$/.test(env.DEBUG_COOKIE_NAME ?? "") ? env.DEBUG_COOKIE_NAME : "debug_session"
55
+ };
56
+ }
57
+ export { config as t };
@@ -1,6 +1,8 @@
1
1
  import { a as joined, i as clock, r as OutcomeBadge } from "./timeline-MDRNDhiA.js";
2
- import { l as timeAgo, t as Card } from "./ui-SAkSlP7f.js";
3
- import { l as Route } from "./router-Dk3XHn7B.js";
2
+ import { t as appLabel } from "./app-name-BcbY1BZN.js";
3
+ import { n as Card, p as timeAgo, t as AppOptions } from "./ui-C3pl0edn.js";
4
+ import "./memory-CZBUh1Zc.js";
5
+ import { u as Route } from "./router-BXkzR89j.js";
4
6
  import { useEffect, useState } from "react";
5
7
  import { Link, useNavigate } from "@tanstack/react-router";
6
8
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -16,12 +18,12 @@ var MATCHED = {
16
18
  anonymousId: "install id"
17
19
  };
18
20
  function CustomersPage() {
19
- const { apps, app, store, lookup, missingIndex } = Route.useLoaderData();
21
+ const { apps, app, store, lookup, missingIndex, names } = Route.useLoaderData();
20
22
  const search = Route.useSearch();
21
23
  const navigate = useNavigate({ from: Route.fullPath });
22
24
  const [q, setQ] = useState(search.q ?? "");
23
25
  useEffect(() => setQ(search.q ?? ""), [search.q]);
24
- const where = app ?? (apps.length > 1 ? "any app" : apps[0]);
26
+ const where = app ? appLabel(app, names[app]) : apps.length > 1 ? "any app" : apps[0] && appLabel(apps[0], names[apps[0]]);
25
27
  return /* @__PURE__ */ jsxs("main", {
26
28
  className: "mx-auto max-w-5xl space-y-5 px-4 py-6 sm:px-6",
27
29
  children: [
@@ -63,7 +65,10 @@ function CustomersPage() {
63
65
  children: [/* @__PURE__ */ jsx("option", {
64
66
  value: "",
65
67
  children: "All apps"
66
- }), apps.map((a) => /* @__PURE__ */ jsx("option", { children: a }, a))]
68
+ }), /* @__PURE__ */ jsx(AppOptions, {
69
+ apps,
70
+ names
71
+ })]
67
72
  }),
68
73
  /* @__PURE__ */ jsx("button", {
69
74
  type: "submit",
@@ -131,7 +136,7 @@ function CustomersPage() {
131
136
  joined([s.context.device.brand, s.context.device.model]) ?? joined([s.context.os.name, s.context.os.version]) ?? "—",
132
137
  !app && apps.length > 1 && /* @__PURE__ */ jsxs("span", {
133
138
  className: "text-muted",
134
- children: [" · ", s.app]
139
+ children: [" · ", appLabel(s.app, names[s.app])]
135
140
  }),
136
141
  s.user.id && s.user.id !== lookup.query && /* @__PURE__ */ jsx("span", {
137
142
  className: "ml-2 font-mono text-xs text-muted",
@@ -1,6 +1,6 @@
1
- import { t as MemoryStore } from "./memory-Bv4C8uyK.js";
2
- import { C as ingest } from "./errors-Po4Tt5zd.js";
3
- import { n as version } from "./versions-BOlL8jam.js";
1
+ import { t as MemoryStore } from "./memory-CZBUh1Zc.js";
2
+ import { k as ingest } from "./queries-wha4cZbw.js";
3
+ import { n as version } from "./versions-YI_zK1ql.js";
4
4
  // src/server/demo.ts
5
5
  /**
6
6
  * Builds a realistic 14-day dataset for a fictional app by pushing synthetic SDK
@@ -10,7 +10,7 @@ async function seedDemo() {
10
10
  const store = new MemoryStore();
11
11
  const rand = mulberry32(42);
12
12
  const pick = (xs) => xs[Math.floor(rand() * xs.length)];
13
- const keys = { pk_demo: "megaton-native" };
13
+ const keys = DEMO_KEYS;
14
14
  const now = Date.now();
15
15
  let seq = 0;
16
16
  const devices = [
@@ -383,7 +383,7 @@ async function seedDemo() {
383
383
  },
384
384
  context: {
385
385
  app: {
386
- id: "megaton-native",
386
+ id: "megatron-native",
387
387
  version: appVersion,
388
388
  build: appVersion.replace(/\./g, "") + "0",
389
389
  environment: "production"
@@ -418,8 +418,224 @@ async function seedDemo() {
418
418
  if (out.status !== 202) throw new Error(`demo seed rejected: ${JSON.stringify(out.body)}`);
419
419
  }
420
420
  }
421
+ await seedUpstreamOutage(store, keys, now);
422
+ await store.putSettings(DEMO_APP, { displayName: "Megatron Native" });
421
423
  return store;
422
424
  }
425
+ /** Our gateway, and the part of it that passes calls on to Cell C (the upstream). */
426
+ var DEMO_GATEWAY = "api.megatron.example";
427
+ var DEMO_UPSTREAM = `${DEMO_GATEWAY}/ppd/api/balance`;
428
+ /**
429
+ * The upstream story: Cell C's balance service stops answering in the last few minutes, for many
430
+ * customers at once. Settings names our gateway "ours" and its /ppd/api/balance path "upstream,
431
+ * Cell C", so Health reads it as a Cell C outage, not our backend or the app. It has its own
432
+ * random generator and runs after the rest, so the other stories don't change.
433
+ */
434
+ async function seedUpstreamOutage(store, keys, now) {
435
+ await store.putSettings(DEMO_APP, { hosts: [{
436
+ match: DEMO_GATEWAY,
437
+ name: "Megatron API",
438
+ kind: "ours",
439
+ owner: "backend"
440
+ }, {
441
+ match: DEMO_UPSTREAM,
442
+ name: "Balance",
443
+ kind: "upstream",
444
+ provider: "Cell C",
445
+ owner: "third_party"
446
+ }] });
447
+ const send = upstreamSender(store, keys);
448
+ for (let h = 336; h >= 1; h--) {
449
+ const ts = (/* @__PURE__ */ new Date(now - h * 36e5 - 12e5)).toISOString();
450
+ await send(ts, `user_${h % 400}`, [{
451
+ type: "metric",
452
+ id: send.id(),
453
+ ts,
454
+ name: "http",
455
+ key: BALANCE_KEY,
456
+ count: 3,
457
+ errors: 0,
458
+ buckets: [
459
+ 0,
460
+ 0,
461
+ 0,
462
+ 1,
463
+ 2,
464
+ 0,
465
+ 0,
466
+ 0,
467
+ 0,
468
+ 0,
469
+ 0,
470
+ 0,
471
+ 0
472
+ ]
473
+ }, {
474
+ type: "metric",
475
+ id: send.id(),
476
+ ts,
477
+ name: "http",
478
+ key: ACCOUNT_KEY,
479
+ count: 4,
480
+ errors: 0,
481
+ buckets: [
482
+ 0,
483
+ 2,
484
+ 2,
485
+ 0,
486
+ 0,
487
+ 0,
488
+ 0,
489
+ 0,
490
+ 0,
491
+ 0,
492
+ 0,
493
+ 0,
494
+ 0
495
+ ]
496
+ }]);
497
+ }
498
+ await upstreamBurst(send, now);
499
+ }
500
+ var DEMO_APP = "megatron-native";
501
+ var DEMO_KEYS = { pk_demo: DEMO_APP };
502
+ var BALANCE_URL = `${DEMO_UPSTREAM}/getBalances`;
503
+ var BALANCE_KEY = `POST ${BALANCE_URL}`;
504
+ var ACCOUNT_KEY = `GET ${DEMO_GATEWAY}/v1/account`;
505
+ /** Sends the upstream story's envelopes through the real ingest, with ids of its own. */
506
+ function upstreamSender(store, keys, prefix = "evt_up") {
507
+ let seq = 0;
508
+ const id = () => `${prefix}_${(seq++).toString().padStart(8, "0")}`;
509
+ const send = async (ts, userId, events) => {
510
+ const env = {
511
+ sdk: {
512
+ name: "@debugkit/sdk",
513
+ version
514
+ },
515
+ context: {
516
+ app: {
517
+ id: DEMO_APP,
518
+ version: "2.4.0",
519
+ build: "2400",
520
+ environment: "production"
521
+ },
522
+ os: {
523
+ name: seq % 5 < 3 ? "android" : "ios",
524
+ version: "14"
525
+ },
526
+ device: {
527
+ model: "Phone",
528
+ manufacturer: "Generic",
529
+ type: "phone"
530
+ },
531
+ runtime: {
532
+ name: "react-native",
533
+ version: "0.79",
534
+ engine: "hermes"
535
+ },
536
+ network: { type: "cellular" },
537
+ timezone: "Africa/Johannesburg",
538
+ locale: "en-ZA"
539
+ },
540
+ user: {
541
+ id: userId,
542
+ anonymousId: `anon_${userId}`
543
+ },
544
+ session: {
545
+ id: `sess_${prefix}_${seq}`,
546
+ startedAt: ts
547
+ },
548
+ events
549
+ };
550
+ const out = await ingest(JSON.stringify(env), "pk_demo", {
551
+ store,
552
+ keys,
553
+ now: () => new Date(Date.parse(ts) + 1e3)
554
+ });
555
+ if (out.status !== 202) throw new Error(`demo seed rejected: ${JSON.stringify(out.body)}`);
556
+ };
557
+ return Object.assign(send, { id });
558
+ }
559
+ /** The 8 minutes before `now`: Cell C's balance service answers 503 or nothing, for 7 customers. */
560
+ async function upstreamBurst(send, now) {
561
+ for (let k = 0; k < 7; k++) {
562
+ const ts = (/* @__PURE__ */ new Date(now - (8 - k) * 6e4)).toISOString();
563
+ const timedOut = k % 3 === 2;
564
+ await send(ts, `user_up_${k}`, [{
565
+ type: "metric",
566
+ id: send.id(),
567
+ ts,
568
+ name: "http",
569
+ key: BALANCE_KEY,
570
+ count: 2,
571
+ errors: 2,
572
+ buckets: [
573
+ 0,
574
+ 0,
575
+ 0,
576
+ 0,
577
+ 0,
578
+ 0,
579
+ 0,
580
+ 0,
581
+ 0,
582
+ 0,
583
+ 0,
584
+ 1,
585
+ 1
586
+ ]
587
+ }, {
588
+ type: "error",
589
+ id: send.id(),
590
+ ts,
591
+ flow: "balance.view",
592
+ handled: true,
593
+ tags: { source: "network" },
594
+ error: timedOut ? {
595
+ name: "NetworkError",
596
+ message: `${BALANCE_KEY} timed out`
597
+ } : {
598
+ name: "HttpError",
599
+ message: `${BALANCE_KEY} responded 503`
600
+ },
601
+ request: {
602
+ method: "POST",
603
+ url: BALANCE_URL,
604
+ status: timedOut ? void 0 : 503,
605
+ durationMs: timedOut ? 3e4 : 8200
606
+ },
607
+ ...timedOut ? {} : { response: {
608
+ status: 503,
609
+ headers: { "content-type": "application/json" },
610
+ body: "{\"code\":\"30007\",\"message\":\"Balance lookup unsuccessful: upstream unavailable\"}"
611
+ } },
612
+ breadcrumbs: [{
613
+ ts,
614
+ level: "info",
615
+ category: "navigation",
616
+ message: "Home → Balance"
617
+ }, {
618
+ ts,
619
+ level: "error",
620
+ category: "network",
621
+ message: `${BALANCE_KEY} → ${timedOut ? "timed out (30000ms)" : "503 (8200ms)"}`
622
+ }]
623
+ }]);
624
+ }
625
+ }
626
+ /**
627
+ * The demo is seeded once, so "the last 15 minutes" would soon be empty: every 5 minutes, Cell C
628
+ * stays down for another burst, and the dashboard forgets what it read. The timer doesn't keep the
629
+ * process alive. Returns a stop function.
630
+ */
631
+ function keepUpstreamDown(store, onChange, everyMs = 3e5) {
632
+ let n = 0;
633
+ const timer = setInterval(() => {
634
+ upstreamBurst(upstreamSender(store, DEMO_KEYS, `evt_up${++n}`), Date.now()).then(onChange, (err) => console.warn(`deBug demo: couldn't add the Cell C burst: ${err.message}`));
635
+ }, everyMs);
636
+ timer.unref?.();
637
+ return () => clearInterval(timer);
638
+ }
423
639
  function mulberry32(seed) {
424
640
  return () => {
425
641
  seed |= 0;
@@ -429,4 +645,4 @@ function mulberry32(seed) {
429
645
  return ((t ^ t >>> 14) >>> 0) / 4294967296;
430
646
  };
431
647
  }
432
- export { seedDemo };
648
+ export { keepUpstreamDown, seedDemo };
@@ -1,5 +1,5 @@
1
- import { o as versionKey, p as isRegression, s as coalesceRollups } from "./memory-Bv4C8uyK.js";
2
- import "./src-oWPSAvXv.js";
1
+ import { b as isRegression, o as versionKey, s as coalesceRollups } from "./memory-CZBUh1Zc.js";
2
+ import "./src-B2GKPQyN.js";
3
3
  import { BatchWriteCommand, GetCommand, PutCommand, QueryCommand, UpdateCommand } from "@aws-sdk/lib-dynamodb";
4
4
  // ../../packages/adapters/src/dynamodb.ts
5
5
  /**