@debugkit/dashboard 0.6.1 → 0.8.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 (58) hide show
  1. package/dist/client/assets/_authed-CNObwuZh.js +7 -0
  2. package/dist/client/assets/_authed-CuP-He8G.js +1 -0
  3. package/dist/client/assets/{charts-XyOWJI9T.js → charts-CUvev8lV.js} +7 -7
  4. package/dist/client/assets/copy-button-ORgLIh59.js +1 -0
  5. package/dist/client/assets/customers-DTMEprFQ.js +1 -0
  6. package/dist/client/assets/endpoints-lMSO2CdM.js +1 -0
  7. package/dist/client/assets/events._eventId-bWag-i8J.js +3 -0
  8. package/dist/client/assets/index-BNpacHyi.js +10 -0
  9. package/dist/client/assets/invite._token-CxXek2SP.js +1 -0
  10. package/dist/client/assets/issues._fingerprint-BQr85TVY.js +1 -0
  11. package/dist/client/assets/login-Dlk3GyyC.js +1 -0
  12. package/dist/client/assets/sessions._sessionId-3wNImMqM.js +1 -0
  13. package/dist/client/assets/settings-CzbEYB7k.js +1 -0
  14. package/dist/client/assets/src-Dq5mIUf0.js +3 -0
  15. package/dist/client/assets/styles-DPsgRH7g.css +2 -0
  16. package/dist/client/assets/team-Bud2-07A.js +1 -0
  17. package/dist/client/assets/timeline-BSDhQPpY.js +1 -0
  18. package/dist/client/assets/ui-CEv2y56s.js +1 -0
  19. package/dist/server/assets/{_authed-CrjuC0O3.js → _authed-DkkRwdZl.js} +19 -5
  20. package/dist/server/assets/{_authed-C-sIPXSO.js → _authed-DsB8kjZB.js} +318 -126
  21. package/dist/server/assets/_tanstack-start-manifest_v-D1_ErrJK.js +97 -0
  22. package/dist/server/assets/copy-button-D3RddzTw.js +52 -0
  23. package/dist/server/assets/customers-CvSLt_xV.js +163 -0
  24. package/dist/server/assets/{demo-BsMMDk_F.js → demo-BRTkdmQJ.js} +25 -4
  25. package/dist/server/assets/{dynamodb-Zkk1-mgz.js → dynamodb-B0V3ZO20.js} +45 -17
  26. package/dist/server/assets/endpoints-mPQXpH8C.js +371 -0
  27. package/dist/server/assets/{queries-BJxX3Kjp.js → errors-C2KEDL7l.js} +842 -62
  28. package/dist/server/assets/events._eventId-pkQBQ9sL.js +765 -0
  29. package/dist/server/assets/{firestore-C52q_vwM.js → firestore-Jd-LeWZI.js} +15 -6
  30. package/dist/server/assets/fns-B3PHbFwV.js +1295 -0
  31. package/dist/server/assets/{fns-DwGaMi8S.js → fns-Di0vMpkQ.js} +25 -3
  32. package/dist/server/assets/{invite._token-xnpnkdRv.js → invite._token-LwWF5YxP.js} +3 -3
  33. package/dist/server/assets/{issues._fingerprint-e7ubdJf0.js → issues._fingerprint-DAA0QCuA.js} +89 -11
  34. package/dist/server/assets/{login-EopnOJXA.js → login-DqjCU4DJ.js} +3 -3
  35. package/dist/server/assets/{memory-BssaqdZm.js → memory-aqsrtEUn.js} +377 -26
  36. package/dist/server/assets/router-C0Dauj2C.js +510 -0
  37. package/dist/server/assets/sessions._sessionId-D7JPV0M4.js +264 -0
  38. package/dist/server/assets/{settings-CaJN69N6.js → settings-Drjd64d7.js} +165 -5
  39. package/dist/server/assets/{src-D83GYTrp.js → src-C4fNgijW.js} +1 -1
  40. package/dist/server/assets/{team-B1UcM1jA.js → team-D7iXYnSE.js} +3 -3
  41. package/dist/server/assets/timeline-MDRNDhiA.js +132 -0
  42. package/dist/server/assets/{ui-BJokJdYa.js → ui-B_XHlLUQ.js} +53 -13
  43. package/dist/server/server.js +37 -21
  44. package/package.json +4 -4
  45. package/dist/client/assets/_authed-BN39b-7H.js +0 -1
  46. package/dist/client/assets/_authed-CspAf0jN.js +0 -7
  47. package/dist/client/assets/index-Bfb2UOzB.js +0 -10
  48. package/dist/client/assets/invite._token-B4HN51-h.js +0 -1
  49. package/dist/client/assets/issues._fingerprint-BV1QrETY.js +0 -1
  50. package/dist/client/assets/login-COlvJ5Je.js +0 -1
  51. package/dist/client/assets/preload-helper-Dscj_TcA.js +0 -3
  52. package/dist/client/assets/settings-Dl4EWeWC.js +0 -1
  53. package/dist/client/assets/styles-DztngwT9.css +0 -2
  54. package/dist/client/assets/team-7Zekz_Er.js +0 -1
  55. package/dist/client/assets/ui-C0HGOza2.js +0 -1
  56. package/dist/server/assets/_tanstack-start-manifest_v-CqaE4wze.js +0 -61
  57. package/dist/server/assets/fns-mbUIXXep.js +0 -529
  58. package/dist/server/assets/router-G99085_Q.js +0 -315
@@ -0,0 +1,163 @@
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-B_XHlLUQ.js";
3
+ import { l as Route } from "./router-C0Dauj2C.js";
4
+ import { useEffect, useState } from "react";
5
+ import { Link, useNavigate } from "@tanstack/react-router";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ // src/routes/_authed/customers.tsx?tsr-split=component
8
+ /** "No errors", "3 errors, all caught", "3 errors, 1 caught". */
9
+ function errorCount(errors, handled) {
10
+ if (!errors) return "No errors";
11
+ const n = `${errors} error${errors === 1 ? "" : "s"}`;
12
+ return handled === errors ? `${n}, ${errors === 1 ? "caught" : "all caught"}` : handled ? `${n}, ${handled} caught` : n;
13
+ }
14
+ var MATCHED = {
15
+ id: "customer number",
16
+ anonymousId: "install id"
17
+ };
18
+ function CustomersPage() {
19
+ const { apps, app, store, lookup, missingIndex } = Route.useLoaderData();
20
+ const search = Route.useSearch();
21
+ const navigate = useNavigate({ from: Route.fullPath });
22
+ const [q, setQ] = useState(search.q ?? "");
23
+ useEffect(() => setQ(search.q ?? ""), [search.q]);
24
+ const where = app ?? (apps.length > 1 ? "any app" : apps[0]);
25
+ return /* @__PURE__ */ jsxs("main", {
26
+ className: "mx-auto max-w-5xl space-y-5 px-4 py-6 sm:px-6",
27
+ children: [
28
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h1", {
29
+ className: "text-xl font-semibold tracking-tight",
30
+ children: "Find a customer"
31
+ }), /* @__PURE__ */ jsx("p", {
32
+ className: "mt-1 text-sm text-muted",
33
+ children: "A customer number in any format (0841234567, 27841234567, +27 84 123 4567) or an install id. Their sessions are listed newest first."
34
+ })] }),
35
+ /* @__PURE__ */ jsxs("form", {
36
+ role: "search",
37
+ className: "flex flex-wrap items-center gap-2",
38
+ onSubmit: (e) => {
39
+ e.preventDefault();
40
+ navigate({ search: (s) => ({
41
+ ...s,
42
+ q: q.trim() || void 0
43
+ }) });
44
+ },
45
+ children: [
46
+ /* @__PURE__ */ jsx("input", {
47
+ type: "search",
48
+ "aria-label": "Customer number or install id",
49
+ value: q,
50
+ onChange: (e) => setQ(e.target.value),
51
+ placeholder: "Customer number or install id",
52
+ autoFocus: true,
53
+ className: "min-w-0 flex-1 rounded-md border border-line bg-panel px-3 py-2 font-mono text-sm text-ink sm:max-w-md"
54
+ }),
55
+ apps.length > 1 && /* @__PURE__ */ jsxs("select", {
56
+ "aria-label": "App",
57
+ value: app ?? "",
58
+ onChange: (e) => navigate({ search: (s) => ({
59
+ ...s,
60
+ app: e.target.value || void 0
61
+ }) }),
62
+ className: "rounded-md border border-line bg-panel px-2 py-2 text-sm",
63
+ children: [/* @__PURE__ */ jsx("option", {
64
+ value: "",
65
+ children: "All apps"
66
+ }), apps.map((a) => /* @__PURE__ */ jsx("option", { children: a }, a))]
67
+ }),
68
+ /* @__PURE__ */ jsx("button", {
69
+ type: "submit",
70
+ className: "rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:opacity-90",
71
+ children: "Find"
72
+ })
73
+ ]
74
+ }),
75
+ missingIndex && /* @__PURE__ */ jsx("p", {
76
+ className: "text-sm text-muted",
77
+ children: "Firestore needs deBug's new indexes on events (user.id, ts) and (user.anonymousId, ts). Deploy them with: firebase deploy --only firestore:indexes, using deBug's firestore.indexes.json. They take a few minutes to build."
78
+ }),
79
+ !apps.length && /* @__PURE__ */ jsx("p", {
80
+ className: "text-sm text-muted",
81
+ children: "No apps have sent events yet."
82
+ }),
83
+ lookup && (lookup.sessions.length === 0 ? /* @__PURE__ */ jsxs("p", {
84
+ className: "text-sm text-muted",
85
+ children: [
86
+ "No sessions found for ",
87
+ /* @__PURE__ */ jsx("span", {
88
+ className: "font-mono text-ink",
89
+ children: lookup.query
90
+ }),
91
+ " in ",
92
+ where,
93
+ ". Events are kept for the retention period only, and a customer number is only known once the app sets it.",
94
+ store === "dynamodb" && " On DynamoDB, only events stored since deBug started keeping them by customer can be found."
95
+ ]
96
+ }) : /* @__PURE__ */ jsxs(Card, {
97
+ title: `${lookup.sessions.length} session${lookup.sessions.length === 1 ? "" : "s"}`,
98
+ subtitle: `Matched by ${lookup.matched.map((m) => MATCHED[m]).join(" and ")}. Only sessions with a stored error or flow event are listed.`,
99
+ children: [/* @__PURE__ */ jsx("ul", {
100
+ className: "divide-y divide-line",
101
+ children: lookup.sessions.map((s) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(Link, {
102
+ to: "/sessions/$sessionId",
103
+ params: { sessionId: s.sessionId },
104
+ search: { app: s.app },
105
+ className: "grid grid-cols-[1fr_auto] items-center gap-x-4 gap-y-1 px-1 py-2.5 hover:bg-panel-2 sm:grid-cols-[11rem_6.5rem_1fr_auto]",
106
+ children: [
107
+ /* @__PURE__ */ jsxs("span", {
108
+ className: "text-sm",
109
+ title: `First stored event ${s.start}, last ${s.end}`,
110
+ children: [clock(s.end), /* @__PURE__ */ jsx("span", {
111
+ className: "block text-xs text-muted",
112
+ children: timeAgo(s.end)
113
+ })]
114
+ }),
115
+ /* @__PURE__ */ jsx("span", {
116
+ className: "justify-self-end sm:justify-self-start",
117
+ children: /* @__PURE__ */ jsx(OutcomeBadge, { outcome: s.outcome })
118
+ }),
119
+ /* @__PURE__ */ jsxs("span", {
120
+ className: "min-w-0 text-sm",
121
+ children: [
122
+ /* @__PURE__ */ jsx("span", {
123
+ className: "text-muted",
124
+ children: "App "
125
+ }),
126
+ joined([s.context.app.version, s.context.app.build && `(${s.context.app.build})`]) ?? "—",
127
+ /* @__PURE__ */ jsx("span", {
128
+ className: "text-muted",
129
+ children: " · "
130
+ }),
131
+ joined([s.context.device.brand, s.context.device.model]) ?? joined([s.context.os.name, s.context.os.version]) ?? "—",
132
+ !app && apps.length > 1 && /* @__PURE__ */ jsxs("span", {
133
+ className: "text-muted",
134
+ children: [" · ", s.app]
135
+ }),
136
+ s.user.id && s.user.id !== lookup.query && /* @__PURE__ */ jsx("span", {
137
+ className: "ml-2 font-mono text-xs text-muted",
138
+ children: s.user.id
139
+ })
140
+ ]
141
+ }),
142
+ /* @__PURE__ */ jsxs("span", {
143
+ className: "text-xs text-muted sm:text-right",
144
+ children: [errorCount(s.errors, s.handled), s.failedFlows > 0 && /* @__PURE__ */ jsxs("span", {
145
+ className: "block font-medium text-sev-high",
146
+ children: [
147
+ s.failedFlows,
148
+ " failed flow",
149
+ s.failedFlows === 1 ? "" : "s"
150
+ ]
151
+ })]
152
+ })
153
+ ]
154
+ }) }, s.sessionId))
155
+ }), lookup.truncated && /* @__PURE__ */ jsx("p", {
156
+ className: "mt-3 text-xs text-muted",
157
+ children: "This customer has more stored events than one lookup reads: older sessions are left out, and the oldest one listed may be only partly read."
158
+ })]
159
+ }))
160
+ ]
161
+ });
162
+ }
163
+ export { CustomersPage as component };
@@ -1,5 +1,5 @@
1
- import { t as MemoryStore } from "./memory-BssaqdZm.js";
2
- import { v as ingest } from "./queries-BJxX3Kjp.js";
1
+ import { t as MemoryStore } from "./memory-aqsrtEUn.js";
2
+ import { C as ingest } from "./errors-C2KEDL7l.js";
3
3
  // src/server/demo.ts
4
4
  /**
5
5
  * Builds a realistic 14-day dataset for a fictional app by pushing synthetic SDK
@@ -146,7 +146,26 @@ async function seedDemo() {
146
146
  method: "GET",
147
147
  url: "/v1/feed",
148
148
  status: 502,
149
- message: "GET /v1/feed responded 502"
149
+ message: "GET /v1/feed responded 502",
150
+ captured: {
151
+ request: {
152
+ query: "page=2&session=[redacted]",
153
+ headers: {
154
+ accept: "application/json",
155
+ authorization: "[redacted]",
156
+ "x-app-version": "2.4.0"
157
+ }
158
+ },
159
+ response: {
160
+ status: 502,
161
+ headers: {
162
+ "content-type": "text/html",
163
+ server: "nginx"
164
+ },
165
+ body: "<html><head><title>502 Bad Gateway</title></head><body><center><h1>502 Bad Gateway</h1></center></body></html>",
166
+ bodySize: 108
167
+ }
168
+ }
150
169
  }
151
170
  },
152
171
  {
@@ -269,8 +288,10 @@ async function seedDemo() {
269
288
  method: r.method,
270
289
  url: r.url,
271
290
  status: r.status,
272
- durationMs: r.status ? 2210 : 3e4
291
+ durationMs: r.status ? 2210 : 3e4,
292
+ ...r.captured?.request
273
293
  },
294
+ ...r.captured ? { response: r.captured.response } : {},
274
295
  breadcrumbs: (sc.crumbs ?? []).map((c) => ({
275
296
  ts,
276
297
  level: c.level ?? "info",
@@ -1,5 +1,5 @@
1
- import { f as coalesceRollups, s as isRegression } from "./memory-BssaqdZm.js";
2
- import "./src-D83GYTrp.js";
1
+ import { l as isRegression, r as coalesceRollups } from "./memory-aqsrtEUn.js";
2
+ import "./src-C4fNgijW.js";
3
3
  import { BatchWriteCommand, GetCommand, PutCommand, QueryCommand, UpdateCommand } from "@aws-sdk/lib-dynamodb";
4
4
  // ../../packages/adapters/src/dynamodb.ts
5
5
  /**
@@ -11,6 +11,9 @@ import { BatchWriteCommand, GetCommand, PutCommand, QueryCommand, UpdateCommand
11
11
  * APP#{app}#ROLLUP#{dimension} | {day}#{key} RollupRow (ADD counters)
12
12
  * APP#{app}#ISSUEEV#{fp} | {ts}#{id} StoredEvent (error events by issue)
13
13
  * APP#{app}#EV#{day} | {ts}#{id} StoredEvent (all events by day)
14
+ * APP#{app}#SESSEV#{sessionId} | {ts}#{id} StoredEvent (all events by session)
15
+ * APP#{app}#USEREV#id#{userId} | {ts}#{id} StoredEvent (by customer number, user.id)
16
+ * APP#{app}#USEREV#anonymousId#{anonymousId} | {ts}#{id} StoredEvent (by install id)
14
17
  * APP#{app}#SETTINGS | app AppSettings
15
18
  * APP#{app}#USERS#{scope} | {member} { lastDay } (hashed ids; for "users affected")
16
19
  *
@@ -132,17 +135,11 @@ var DynamoStore = class {
132
135
  ...e,
133
136
  ttl: ttl(e)
134
137
  };
135
- const rows = [{
136
- pk: `APP#${e.app}#EV#${e.day}`,
138
+ return [`APP#${e.app}#EV#${e.day}`, ...copyKeys(e)].map((pk) => ({
139
+ pk,
137
140
  sk,
138
141
  ...base
139
- }];
140
- if (e.fingerprint) rows.push({
141
- pk: `APP#${e.app}#ISSUEEV#${e.fingerprint}`,
142
- sk,
143
- ...base
144
- });
145
- return rows;
142
+ }));
146
143
  });
147
144
  for (let i = 0; i < items.length; i += 25) {
148
145
  let req = { [this.table]: items.slice(i, i + 25).map((Item) => ({ PutRequest: { Item } })) };
@@ -355,13 +352,10 @@ var DynamoStore = class {
355
352
  const items = await this.queryAll({ pk: `APP#${app}#EV#${day}` });
356
353
  for (const item of items) {
357
354
  const ttl = Math.floor(Date.parse(item.receivedAt) / 1e3) + retentionDays * 86400;
358
- const keys = [{
359
- pk: item.pk,
360
- sk: item.sk
361
- }, ...item.fingerprint ? [{
362
- pk: `APP#${app}#ISSUEEV#${item.fingerprint}`,
355
+ const keys = [item.pk, ...copyKeys(item)].map((pk) => ({
356
+ pk,
363
357
  sk: item.sk
364
- }] : []];
358
+ }));
365
359
  await Promise.all(keys.map((Key) => this.doc.send(new UpdateCommand({
366
360
  TableName: this.table,
367
361
  Key,
@@ -406,6 +400,30 @@ var DynamoStore = class {
406
400
  between: [`${fromDay}#`, `${toDay}#￿`]
407
401
  })).map((i) => clean(i));
408
402
  }
403
+ async listSessionEvents(app, sessionId, { limit = 500 } = {}) {
404
+ return (await this.newest(`APP#${app}#SESSEV#${sessionId}`, limit)).map((i) => clean(i)).reverse();
405
+ }
406
+ /** A partition's newest `limit` items, a page at a time: a query stops at 1 MB, well short of 500 events with trails. */
407
+ async newest(pk, limit) {
408
+ const items = [];
409
+ let ExclusiveStartKey;
410
+ do {
411
+ const out = await this.doc.send(new QueryCommand({
412
+ TableName: this.table,
413
+ KeyConditionExpression: "pk = :pk",
414
+ ExpressionAttributeValues: { ":pk": pk },
415
+ ScanIndexForward: false,
416
+ Limit: limit - items.length,
417
+ ExclusiveStartKey
418
+ }));
419
+ items.push(...out.Items ?? []);
420
+ ExclusiveStartKey = out.LastEvaluatedKey;
421
+ } while (ExclusiveStartKey && items.length < limit);
422
+ return items;
423
+ }
424
+ async listUserEvents(app, field, values, { limit = 500 } = {}) {
425
+ return (await Promise.all(values.map((v) => this.newest(userKey(app, field, v), limit)))).flat().sort((a, b) => String(b.sk).localeCompare(String(a.sk))).slice(0, limit).map((i) => clean(i));
426
+ }
409
427
  async listIssueEvents(app, fp, { limit = 50 } = {}) {
410
428
  return ((await this.doc.send(new QueryCommand({
411
429
  TableName: this.table,
@@ -435,6 +453,16 @@ var DynamoStore = class {
435
453
  return items;
436
454
  }
437
455
  };
456
+ var userKey = (app, field, value) => `APP#${app}#USEREV#${field}#${value}`;
457
+ /** The partitions an event is copied into besides its day: by issue, session and user. */
458
+ function copyKeys(e) {
459
+ return [
460
+ ...e.fingerprint ? [`APP#${e.app}#ISSUEEV#${e.fingerprint}`] : [],
461
+ ...e.sessionId ? [`APP#${e.app}#SESSEV#${e.sessionId}`] : [],
462
+ ...e.user?.id ? [userKey(e.app, "id", e.user.id)] : [],
463
+ ...e.user?.anonymousId ? [userKey(e.app, "anonymousId", e.user.anonymousId)] : []
464
+ ];
465
+ }
438
466
  function clean(item) {
439
467
  const { pk: _p, sk: _s, ttl: _t, ...rest } = item;
440
468
  return rest;
@@ -0,0 +1,371 @@
1
+ import { n as RetentionNote, t as RangePicker } from "./range-picker-0zbSGr3Z.js";
2
+ import { a as joined, i as clock } from "./timeline-MDRNDhiA.js";
3
+ import { l as timeAgo, t as Card } from "./ui-B_XHlLUQ.js";
4
+ import { c as Route } from "./router-C0Dauj2C.js";
5
+ import { Link, useNavigate } from "@tanstack/react-router";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ // src/routes/_authed/endpoints.tsx?tsr-split=component
8
+ var SORTS = {
9
+ failing: "Most failures",
10
+ slow: "Slowest",
11
+ busy: "Busiest"
12
+ };
13
+ function EndpointsPage() {
14
+ const report = Route.useLoaderData();
15
+ const { sort = "failing" } = Route.useSearch();
16
+ const navigate = useNavigate({ from: Route.fullPath });
17
+ if (!report) return /* @__PURE__ */ jsx("main", {
18
+ className: "mx-auto max-w-3xl px-4 py-10 sm:px-6",
19
+ children: /* @__PURE__ */ jsx("h1", {
20
+ className: "text-xl font-semibold",
21
+ children: "No apps have sent events yet"
22
+ })
23
+ });
24
+ const { range, services, selected } = report;
25
+ const endpoints = sorted(report.endpoints, sort);
26
+ return /* @__PURE__ */ jsxs("main", {
27
+ className: "mx-auto max-w-7xl space-y-5 px-4 py-6 sm:px-6",
28
+ children: [
29
+ /* @__PURE__ */ jsxs("div", {
30
+ className: "flex flex-wrap items-end justify-between gap-3",
31
+ children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h1", {
32
+ className: "text-xl font-semibold tracking-tight",
33
+ children: "Endpoints"
34
+ }), /* @__PURE__ */ jsxs("p", {
35
+ className: "mt-1 text-sm text-muted",
36
+ children: [
37
+ "Which backend services and calls fail or are slow in ",
38
+ range.label,
39
+ "."
40
+ ]
41
+ })] }), /* @__PURE__ */ jsxs("div", {
42
+ className: "flex flex-wrap items-center gap-2",
43
+ children: [/* @__PURE__ */ jsx(RangePicker, {
44
+ value: range,
45
+ today: report.generatedAt.slice(0, 10),
46
+ onChange: (r) => navigate({ search: (s) => ({
47
+ ...s,
48
+ ...r
49
+ }) })
50
+ }, `${range.preset}${range.from}${range.to}`), report.apps.length > 1 && /* @__PURE__ */ jsx("select", {
51
+ "aria-label": "App",
52
+ value: report.app,
53
+ onChange: (e) => navigate({ search: (s) => ({
54
+ ...s,
55
+ app: e.target.value,
56
+ endpoint: void 0
57
+ }) }),
58
+ className: "rounded-md border border-line bg-panel px-2 py-1.5 text-sm",
59
+ children: report.apps.map((a) => /* @__PURE__ */ jsx("option", { children: a }, a))
60
+ })]
61
+ })]
62
+ }),
63
+ /* @__PURE__ */ jsx(RetentionNote, {
64
+ rangeFrom: range.from,
65
+ retention: report.retention
66
+ }),
67
+ selected && /* @__PURE__ */ jsx(EndpointDetail, {
68
+ app: report.app,
69
+ row: selected.endpoint,
70
+ failures: selected.failures
71
+ }),
72
+ report.missing && /* @__PURE__ */ jsxs("p", {
73
+ className: "rounded-lg border border-line bg-panel-2 px-3 py-2 text-sm text-muted",
74
+ children: [
75
+ /* @__PURE__ */ jsx("span", {
76
+ className: "font-mono text-ink",
77
+ children: report.missing
78
+ }),
79
+ " had no calls or failures in ",
80
+ range.label,
81
+ "."
82
+ ]
83
+ }),
84
+ endpoints.length === 0 ? /* @__PURE__ */ jsxs("p", {
85
+ className: "text-sm text-muted",
86
+ children: [
87
+ "No API calls recorded in ",
88
+ range.label,
89
+ ". Calls are counted when the SDK's network capture is on, and failures when they're stored as errors."
90
+ ]
91
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [services.length > 1 && /* @__PURE__ */ jsx(Services, { rows: services }), /* @__PURE__ */ jsxs(Card, {
92
+ title: `${endpoints.length} endpoint${endpoints.length === 1 ? "" : "s"}`,
93
+ subtitle: "Calls, failure rate and timings count every call the SDK saw. Statuses and backend codes count the stored failures, which the SDK samples.",
94
+ right: /* @__PURE__ */ jsx("span", {
95
+ className: "flex gap-1 text-xs",
96
+ role: "group",
97
+ "aria-label": "Sort endpoints",
98
+ children: Object.keys(SORTS).map((k) => /* @__PURE__ */ jsx(Link, {
99
+ to: "/endpoints",
100
+ search: (s) => ({
101
+ ...s,
102
+ sort: k === "failing" ? void 0 : k
103
+ }),
104
+ "aria-pressed": sort === k,
105
+ className: `whitespace-nowrap rounded-md border px-2 py-1 ${sort === k ? "border-ink text-ink" : "border-line text-muted hover:text-ink"}`,
106
+ children: SORTS[k]
107
+ }, k))
108
+ }),
109
+ children: [
110
+ /* @__PURE__ */ jsx("div", {
111
+ className: "-mx-4 overflow-x-auto sm:mx-0",
112
+ children: /* @__PURE__ */ jsxs("table", {
113
+ className: "tabular w-full min-w-[720px] text-left text-sm",
114
+ children: [/* @__PURE__ */ jsx("thead", {
115
+ className: "text-xs text-muted",
116
+ children: /* @__PURE__ */ jsxs("tr", {
117
+ className: "border-b border-line",
118
+ children: [
119
+ /* @__PURE__ */ jsx("th", {
120
+ className: "px-4 py-2 font-medium sm:px-2",
121
+ children: "Endpoint"
122
+ }),
123
+ /* @__PURE__ */ jsx("th", {
124
+ className: "px-2 py-2 text-right font-medium",
125
+ children: "Calls"
126
+ }),
127
+ /* @__PURE__ */ jsx("th", {
128
+ className: "px-2 py-2 text-right font-medium",
129
+ children: "Failed"
130
+ }),
131
+ /* @__PURE__ */ jsx("th", {
132
+ className: "px-2 py-2 text-right font-medium",
133
+ children: "p50"
134
+ }),
135
+ /* @__PURE__ */ jsx("th", {
136
+ className: "px-2 py-2 text-right font-medium",
137
+ children: "p95"
138
+ }),
139
+ /* @__PURE__ */ jsx("th", {
140
+ className: "px-2 py-2 font-medium",
141
+ children: "Statuses"
142
+ }),
143
+ /* @__PURE__ */ jsx("th", {
144
+ className: "px-2 py-2 font-medium",
145
+ children: "Backend codes"
146
+ })
147
+ ]
148
+ })
149
+ }), /* @__PURE__ */ jsx("tbody", { children: endpoints.map((r) => /* @__PURE__ */ jsxs("tr", {
150
+ className: `border-b border-line last:border-0 ${selected?.endpoint.endpoint === r.endpoint ? "bg-panel-2" : ""}`,
151
+ children: [
152
+ /* @__PURE__ */ jsx("td", {
153
+ className: "max-w-[320px] px-4 py-2 sm:px-2",
154
+ children: /* @__PURE__ */ jsx(Link, {
155
+ to: "/endpoints",
156
+ search: (s) => ({
157
+ ...s,
158
+ endpoint: r.endpoint
159
+ }),
160
+ className: "block hover:underline",
161
+ title: r.endpoint,
162
+ children: /* @__PURE__ */ jsx(EndpointName, { row: r })
163
+ })
164
+ }),
165
+ /* @__PURE__ */ jsx("td", {
166
+ className: "px-2 py-2 text-right text-muted",
167
+ children: count(r.calls)
168
+ }),
169
+ /* @__PURE__ */ jsx("td", {
170
+ className: `px-2 py-2 text-right ${r.failureRate !== null && r.failureRate >= .05 ? "font-semibold text-sev-critical" : "text-muted"}`,
171
+ children: r.failureRate !== null ? pct(r.failureRate) : r.failures ? `${r.failures} stored` : "—"
172
+ }),
173
+ /* @__PURE__ */ jsx("td", {
174
+ className: "px-2 py-2 text-right",
175
+ children: ms(r.p50)
176
+ }),
177
+ /* @__PURE__ */ jsx("td", {
178
+ className: `px-2 py-2 text-right font-semibold ${r.p95 !== null && r.p95 >= 3e3 ? "text-sev-high" : ""}`,
179
+ children: ms(r.p95)
180
+ }),
181
+ /* @__PURE__ */ jsx("td", {
182
+ className: "px-2 py-2",
183
+ children: /* @__PURE__ */ jsx(Counts, { items: r.statuses })
184
+ }),
185
+ /* @__PURE__ */ jsx("td", {
186
+ className: "px-2 py-2",
187
+ children: /* @__PURE__ */ jsx(Counts, { items: r.backendCodes })
188
+ })
189
+ ]
190
+ }, r.endpoint)) })]
191
+ })
192
+ }),
193
+ /* @__PURE__ */ jsx("p", {
194
+ className: "mt-2 text-xs text-muted",
195
+ children: "Failed: calls the SDK counted as failed (status 400 and above on mobile). p50/p95: half / 95% of calls finished within this time. \"—\": the SDK sent no request timings for that endpoint."
196
+ }),
197
+ report.truncated && /* @__PURE__ */ jsx("p", {
198
+ className: "mt-1 text-xs text-muted",
199
+ children: "There were more stored failures than one page reads: statuses, backend codes and failure lists may be undercounted. Pick a shorter period for exact ones."
200
+ })
201
+ ]
202
+ })] })
203
+ ]
204
+ });
205
+ }
206
+ function EndpointDetail({ app, row, failures }) {
207
+ return /* @__PURE__ */ jsxs(Card, {
208
+ title: joined([
209
+ row.service,
210
+ row.method,
211
+ row.path
212
+ ]) ?? row.endpoint,
213
+ subtitle: `${row.failures} stored failure${row.failures === 1 ? "" : "s"} in this period${row.lastFailure ? `, the last ${timeAgo(row.lastFailure)}` : ""}. Newest first.`,
214
+ children: [/* @__PURE__ */ jsxs("div", {
215
+ className: "mb-3 flex flex-wrap gap-x-6 gap-y-1 text-sm",
216
+ children: [
217
+ /* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("span", {
218
+ className: "text-muted",
219
+ children: "Calls "
220
+ }), count(row.calls)] }),
221
+ /* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("span", {
222
+ className: "text-muted",
223
+ children: "Failure rate "
224
+ }), rate(row.failureRate)] }),
225
+ /* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("span", {
226
+ className: "text-muted",
227
+ children: "p50 "
228
+ }), ms(row.p50)] }),
229
+ /* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("span", {
230
+ className: "text-muted",
231
+ children: "p95 "
232
+ }), ms(row.p95)] }),
233
+ /* @__PURE__ */ jsx(Link, {
234
+ to: "/endpoints",
235
+ search: (s) => ({
236
+ ...s,
237
+ endpoint: void 0
238
+ }),
239
+ className: "ml-auto text-xs text-muted hover:text-ink hover:underline",
240
+ children: "Close"
241
+ })
242
+ ]
243
+ }), failures.length === 0 ? /* @__PURE__ */ jsx("p", {
244
+ className: "text-sm text-muted",
245
+ children: "No stored failures for this endpoint in this period."
246
+ }) : /* @__PURE__ */ jsx("ul", {
247
+ className: "divide-y divide-line",
248
+ children: failures.map((f) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(Link, {
249
+ to: "/events/$eventId",
250
+ params: { eventId: f.eventId },
251
+ search: {
252
+ app,
253
+ issue: f.fingerprint
254
+ },
255
+ className: "grid grid-cols-[1fr_auto] gap-x-4 gap-y-0.5 px-1 py-2 text-sm hover:bg-panel-2 sm:grid-cols-[11rem_5rem_1fr_auto]",
256
+ children: [
257
+ /* @__PURE__ */ jsx("span", {
258
+ title: f.ts,
259
+ children: clock(f.ts)
260
+ }),
261
+ /* @__PURE__ */ jsx("span", {
262
+ className: "justify-self-end font-semibold text-sev-critical sm:justify-self-start",
263
+ children: f.status
264
+ }),
265
+ /* @__PURE__ */ jsx("span", {
266
+ className: "min-w-0 break-words text-muted",
267
+ children: joined([
268
+ f.backendCode && `code ${f.backendCode}`,
269
+ f.backendTitle && `"${f.backendTitle}"`,
270
+ f.errorKind,
271
+ f.traceId && `trace ${f.traceId.slice(0, 8)}…`
272
+ ], " · ") ?? "No backend detail"
273
+ }),
274
+ /* @__PURE__ */ jsxs("span", {
275
+ className: "font-mono text-xs text-muted sm:text-right",
276
+ children: [f.userId ?? "", f.durationMs !== void 0 ? ` · ${f.durationMs} ms` : ""]
277
+ })
278
+ ]
279
+ }) }, f.eventId))
280
+ })]
281
+ });
282
+ }
283
+ /** Endpoints added up per backend service: which one is failing or slow, at a glance. */
284
+ function Services({ rows }) {
285
+ return /* @__PURE__ */ jsxs(Card, {
286
+ title: "By service",
287
+ subtitle: "Each backend service's endpoints added up. The slowest p95 is its slowest endpoint's.",
288
+ children: [/* @__PURE__ */ jsx("ul", {
289
+ className: "grid gap-2 sm:grid-cols-2 lg:grid-cols-3",
290
+ children: rows.map((r) => /* @__PURE__ */ jsxs("li", {
291
+ className: "rounded-lg border border-line px-3 py-2 text-sm",
292
+ children: [/* @__PURE__ */ jsxs("div", {
293
+ className: "flex items-baseline justify-between gap-2",
294
+ children: [/* @__PURE__ */ jsx("span", {
295
+ className: r.service ? "font-medium" : "text-muted",
296
+ children: r.service ?? "Unnamed hosts"
297
+ }), /* @__PURE__ */ jsxs("span", {
298
+ className: `tabular ${r.failureRate !== null && r.failureRate >= .05 ? "font-semibold text-sev-critical" : "text-muted"}`,
299
+ children: [rate(r.failureRate), " failed"]
300
+ })]
301
+ }), /* @__PURE__ */ jsxs("div", {
302
+ className: "tabular mt-0.5 text-xs text-muted",
303
+ children: [
304
+ count(r.calls),
305
+ " calls · ",
306
+ r.endpoints,
307
+ " endpoint",
308
+ r.endpoints === 1 ? "" : "s",
309
+ " · slowest p95 ",
310
+ /* @__PURE__ */ jsx("span", {
311
+ className: r.worstP95 !== null && r.worstP95 >= 3e3 ? "font-semibold text-sev-high" : "",
312
+ children: ms(r.worstP95)
313
+ }),
314
+ r.failures > 0 && ` · ${r.failures} stored failure${r.failures === 1 ? "" : "s"}`
315
+ ]
316
+ })]
317
+ }, r.service ?? ""))
318
+ }), rows.some((r) => !r.service) && /* @__PURE__ */ jsx("p", {
319
+ className: "mt-2 text-xs text-muted",
320
+ children: "Name hosts in Settings, or set the SDK's network.baseUrls, to group unnamed ones."
321
+ })]
322
+ });
323
+ }
324
+ /** The endpoints in the order picked: most failures (as the server sends them), slowest p95, or most calls. */
325
+ function sorted(rows, sort) {
326
+ if (sort === "failing") return rows;
327
+ const by = sort === "slow" ? (r) => r.p95 === null ? -1 : Number.isFinite(r.p95) ? r.p95 : 1e9 : (r) => r.calls ?? -1;
328
+ return [...rows].sort((a, b) => by(b) - by(a));
329
+ }
330
+ var count = (n) => n === null ? "—" : n.toLocaleString();
331
+ var rate = (r) => r === null ? "—" : pct(r);
332
+ function EndpointName({ row }) {
333
+ return /* @__PURE__ */ jsxs("span", {
334
+ className: "break-words",
335
+ children: [row.service && /* @__PURE__ */ jsxs("span", {
336
+ className: "font-medium",
337
+ children: [row.service, " "]
338
+ }), /* @__PURE__ */ jsx("span", {
339
+ className: "font-mono text-xs",
340
+ children: joined([row.method, row.path])
341
+ })]
342
+ });
343
+ }
344
+ function Counts({ items }) {
345
+ if (!items.length) return /* @__PURE__ */ jsx("span", {
346
+ className: "text-muted",
347
+ children: "—"
348
+ });
349
+ return /* @__PURE__ */ jsxs("span", {
350
+ className: "flex flex-wrap gap-1",
351
+ children: [items.slice(0, 3).map((c) => /* @__PURE__ */ jsxs("span", {
352
+ className: "rounded bg-panel-2 px-1.5 py-0.5 font-mono text-[11px]",
353
+ children: [c.key, /* @__PURE__ */ jsxs("span", {
354
+ className: "text-muted",
355
+ children: [" ×", c.count]
356
+ })]
357
+ }, c.key)), items.length > 3 && /* @__PURE__ */ jsxs("span", {
358
+ className: "text-[11px] text-muted",
359
+ children: ["+", items.length - 3]
360
+ })]
361
+ });
362
+ }
363
+ function pct(r) {
364
+ return `${(r * 100).toFixed(r < .1 ? 1 : 0)}%`;
365
+ }
366
+ function ms(v) {
367
+ if (v === null) return "—";
368
+ if (!Number.isFinite(v)) return "> 10 s";
369
+ return v >= 1e3 ? `≤ ${(v / 1e3).toFixed(v % 1e3 ? 1 : 0)} s` : `≤ ${v} ms`;
370
+ }
371
+ export { EndpointsPage as component };