@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,765 @@
1
+ import { t as CopyButton } from "./copy-button-D3RddzTw.js";
2
+ import { a as joined, i as clock, n as ICON, o as offset, t as CrumbBody } from "./timeline-MDRNDhiA.js";
3
+ import { t as Card } from "./ui-B_XHlLUQ.js";
4
+ import { i as Route } from "./router-C0Dauj2C.js";
5
+ import { useEffect, useState } from "react";
6
+ import { Link } from "@tanstack/react-router";
7
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ // src/lib/support-summary.ts
9
+ /** 084•••4567: enough to confirm with the caller, not enough to copy around. */
10
+ function maskCustomer(id) {
11
+ if (/^[+\d\s\-()]+$/.test(id)) {
12
+ const digits = id.replace(/\D/g, "");
13
+ const local = /^27\d{9}$/.test(digits) ? `0${digits.slice(2)}` : digits;
14
+ if (local.length >= 8) return `${local.slice(0, 3)}•••${local.slice(-4)}`;
15
+ }
16
+ if (/^\d{5,}$/.test(id)) return `•••${id.slice(-3)}`;
17
+ return id.length > 8 ? `${id.slice(0, 3)}•••${id.slice(-3)}` : id;
18
+ }
19
+ /** Phone-number-like runs in free text (an error message), masked like the customer number. */
20
+ function maskNumbersIn(text) {
21
+ return text.replace(/\+?\d[\d \-]{6,}\d/g, (m) => maskCustomer(m));
22
+ }
23
+ /**
24
+ * "16 Nov 2026, 10:42 SAST": the date, and the time in the phone's own time zone (UTC when it
25
+ * didn't say), so a ticket read later or elsewhere still says when.
26
+ */
27
+ function ticketTime(iso, timeZone) {
28
+ const fmt = (tz) => new Intl.DateTimeFormat("en-GB", {
29
+ day: "numeric",
30
+ month: "short",
31
+ year: "numeric",
32
+ hour: "2-digit",
33
+ minute: "2-digit",
34
+ hour12: false,
35
+ timeZone: tz,
36
+ timeZoneName: "short"
37
+ }).format(new Date(iso));
38
+ try {
39
+ return fmt(timeZone ?? "UTC");
40
+ } catch {
41
+ return fmt("UTC");
42
+ }
43
+ }
44
+ /** "Dashboard → Buy" reads as moving to Buy; a single name is the screen itself. */
45
+ function screenOf(t) {
46
+ if (t.category !== "navigation") return void 0;
47
+ const parts = t.message.split(/\s*(?:→|->)\s*/).filter(Boolean);
48
+ if (!parts.length) return void 0;
49
+ return parts.length > 1 ? {
50
+ from: parts[parts.length - 2],
51
+ to: parts[parts.length - 1]
52
+ } : { to: parts[0] };
53
+ }
54
+ /** The screens visited, in order, each once in a row. */
55
+ function screensOf(timeline) {
56
+ const out = [];
57
+ for (const t of timeline) {
58
+ const s = screenOf(t);
59
+ if (!s) continue;
60
+ if (s.from && !out.length) out.push(s.from);
61
+ if (out[out.length - 1] !== s.to) out.push(s.to);
62
+ }
63
+ return out;
64
+ }
65
+ /** The label of a tap: data.label (the SDK's touch boundary), or the quoted name in "Tapped "Pay"". */
66
+ function tapLabel(t) {
67
+ if (t.category !== "ui") return void 0;
68
+ const label = t.data?.label;
69
+ if (typeof label === "string" && label) return label;
70
+ return /^tapped\s+["“]?(.+?)["”]?$/i.exec(t.message)?.[1];
71
+ }
72
+ /** What the app showed: data.shown, or a "Showed …" / "Alert: …" breadcrumb. */
73
+ function shownOf(t) {
74
+ const shown = t.data?.shown;
75
+ if (typeof shown === "string" && shown) return shown;
76
+ if (t.category !== "ui" && t.category !== "log") return void 0;
77
+ return /^(?:showed|shown|alert|toast)\b\s*:?\s+["“]?(.+?)["”]?$/i.exec(t.message)?.[1];
78
+ }
79
+ var quote = (s) => `"${s}"`;
80
+ /** "The payments service answered 402 "Insufficient funds" (trace 4f2c…)." */
81
+ function callSentence(call) {
82
+ const who = call.service ? `The ${call.service} service` : `The backend (${[call.method, call.path].filter(Boolean).join(" ")})`;
83
+ const trace = call.traceId ? ` (trace ${call.traceId.slice(0, 4)}…)` : "";
84
+ if (call.outcome === "sessionExpired") return `${who} said their session had expired${call.status ? ` (${call.status})` : ""}${trace}.`;
85
+ if (call.status === void 0) {
86
+ const why = call.outcome && call.outcome !== "answered" ? call.outcome : call.errorKind;
87
+ return `${who} didn't answer${why ? ` (${why})` : ""}${trace}.`;
88
+ }
89
+ const said = call.backendTitle ? ` ${quote(call.backendTitle)}` : "";
90
+ const code = call.backendCode ? `, code ${call.backendCode}` : "";
91
+ return `${who} answered ${call.status}${said}${code}${trace}.`;
92
+ }
93
+ function supportSummary(d, formatTime) {
94
+ const sentences = [];
95
+ const os = [d.context.os.name && cap(d.context.os.name), d.context.os.version].filter(Boolean).join(" ");
96
+ const who = d.user.id ? `Customer ${maskCustomer(d.user.id)}` : "A signed-out customer";
97
+ const app = d.context.app.version ? `app ${d.context.app.version}` : void 0;
98
+ sentences.push(`${formatTime(d.ts)} · ${who}${os || app ? ` on ${[os, app].filter(Boolean).join(", ")}` : ""}.`);
99
+ const screens = screensOf(d.timeline).slice(-5);
100
+ const lastNav = d.timeline.map((t) => t.category === "navigation").lastIndexOf(true);
101
+ const tap = d.timeline.slice(lastNav + 1).reverse().map(tapLabel).find(Boolean);
102
+ const steps = [screens.length > 1 ? `Went ${screens.join(" → ")}` : screens.length ? `Was on ${screens[0]}` : void 0, tap && `tapped ${quote(tap)}`].filter(Boolean).join(", ");
103
+ if (steps) sentences.push(`${upperFirst(steps)}.`);
104
+ if (d.request) sentences.push(callSentence(d.request));
105
+ else sentences.push(`The app ${d.handled ? "reported" : "hit"} an error: ${maskNumbersIn(`${d.error.name}: ${d.error.message}`)}.`);
106
+ const after = d.after ?? [];
107
+ const failedAt = d.timeline.map((t) => !!t.api?.failed).lastIndexOf(true);
108
+ const saw = [...d.timeline.slice(failedAt >= 0 ? failedAt + 1 : d.timeline.length), ...after.slice(0, 3)].map(shownOf).find(Boolean);
109
+ const next = after.map(screenOf).find(Boolean);
110
+ const back = next && screens.includes(next.to) ? `went back to ${next.to}` : next ? `went to ${next.to}` : void 0;
111
+ if (saw || back) sentences.push(`${saw ? `They saw ${quote(saw)}${back ? ` and ${back}` : ""}` : `They ${back}`}.`);
112
+ return {
113
+ sentences,
114
+ screens,
115
+ saw
116
+ };
117
+ }
118
+ /** The summary for a ticket: the sentences, then the event link and the trace id. */
119
+ function ticketText(summary, link, traceId) {
120
+ return [
121
+ summary.sentences.join(" "),
122
+ "",
123
+ `Event: ${link}`,
124
+ ...traceId ? [`Trace: ${traceId}`] : []
125
+ ].join("\n");
126
+ }
127
+ var upperFirst = (s) => s.charAt(0).toUpperCase() + s.slice(1);
128
+ var cap = (s) => s === "ios" ? "iOS" : s.charAt(0).toUpperCase() + s.slice(1);
129
+ // src/lib/exchange-view.ts
130
+ /** The SDK's "[binary 12 KB, image/png]", with the size or the type left out when it didn't know them. */
131
+ var BINARY = /^\[binary(?: ([\d.]+ ?[KMG]?B))?(?:, ([^\]]+))?\]$/i;
132
+ /** The SDK's cut "…[truncated, 48 KB total]", or ingest's "…[truncated]". */
133
+ var CUT = /…\[truncated(?:, ([\d.]+ ?[KMG]?B) total)?\]$/;
134
+ /** A byte count: "512 B", "47 KB", "1.2 MB". */
135
+ function size(bytes) {
136
+ return bytes < 1024 ? `${bytes} B` : bytes < 1048576 ? `${Math.round(bytes / 1024)} KB` : `${(bytes / 1024 / 1024).toFixed(1)} MB`;
137
+ }
138
+ /** Text without a cut marker, and whether it had one. */
139
+ function uncut(text) {
140
+ const m = CUT.exec(text);
141
+ return m ? {
142
+ text: text.slice(0, m.index),
143
+ cut: true,
144
+ total: m[1]
145
+ } : {
146
+ text,
147
+ cut: false
148
+ };
149
+ }
150
+ function bodyView(side) {
151
+ const body = side.body;
152
+ if (body === void 0) return void 0;
153
+ const bin = BINARY.exec(body.trim());
154
+ if (bin) {
155
+ const bytes = bin[1] ?? (side.bodySize !== void 0 ? size(side.bodySize) : void 0);
156
+ return {
157
+ text: "",
158
+ raw: "",
159
+ json: false,
160
+ cut: false,
161
+ binary: true,
162
+ note: `Binary${bytes ? `, ${bytes}` : ""}${bin[2] ? ` (${bin[2]})` : ""}: not captured.`
163
+ };
164
+ }
165
+ const u = uncut(body);
166
+ const cut = u.cut || !!side.truncated;
167
+ const total = u.total ?? (side.bodySize !== void 0 ? `${side.bodySize.toLocaleString("en")} characters` : void 0);
168
+ const note = cut ? `Cut after ${u.text.length.toLocaleString("en")} characters${total ? ` of ${total}` : ""}: the rest wasn't captured.` : void 0;
169
+ const base = {
170
+ raw: u.text,
171
+ cut,
172
+ binary: false,
173
+ note
174
+ };
175
+ if (!u.text.trim()) return {
176
+ ...base,
177
+ text: "",
178
+ json: false,
179
+ note: note ?? "Empty body."
180
+ };
181
+ try {
182
+ return {
183
+ ...base,
184
+ text: JSON.stringify(JSON.parse(u.text), null, 2),
185
+ json: true
186
+ };
187
+ } catch {
188
+ return {
189
+ ...base,
190
+ text: u.text,
191
+ json: false
192
+ };
193
+ }
194
+ }
195
+ /** Single-quoted for a POSIX shell: nothing inside is expanded. */
196
+ var sh = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
197
+ /**
198
+ * The request as a cURL command, quoted so pasting it runs nothing but curl. It's what the SDK
199
+ * captured, so the command starts with a comment saying what to fill in: secrets show as
200
+ * "[redacted]", ids in the path as ":id", a cut or binary body isn't the one sent, and HOST stands
201
+ * in when the SDK named the call by its path only.
202
+ */
203
+ function curlOf(x) {
204
+ const r = x.request;
205
+ const query = r.query !== void 0 ? uncut(r.query) : void 0;
206
+ const base = r.fullUrl ?? `https://HOST${r.url.startsWith("/") ? "" : "/"}${r.url}`;
207
+ const url = query?.text ? `${base}?${query.text}` : base;
208
+ const parts = [`curl -X ${sh(r.method)} ${sh(url)}`];
209
+ for (const [k, v] of Object.entries(r.headers ?? {})) parts.push(`-H ${sh(`${k}: ${v}`)}`);
210
+ const body = bodyView(r);
211
+ if (body && !body.binary) parts.push(`--data-raw ${sh(body.raw)}`);
212
+ const fill = [
213
+ [
214
+ JSON.stringify(r.headers ?? {}),
215
+ r.body ?? "",
216
+ r.query ?? ""
217
+ ].some((t) => t.includes("[redacted]")) && "secrets show as [redacted]",
218
+ /\/:id(\/|$)/.test(r.url) && "ids in the path show as :id",
219
+ !r.fullUrl && "replace HOST",
220
+ query?.cut && "the query was cut",
221
+ body?.cut && "the body was cut",
222
+ body?.binary && "the binary body wasn't captured"
223
+ ].filter(Boolean);
224
+ const command = parts.join(" \\\n ");
225
+ return {
226
+ command: fill.length ? `# From deBug, as captured: ${fill.join("; ")}.\n${command}` : command,
227
+ complete: fill.length === 0
228
+ };
229
+ }
230
+ // src/routes/_authed/events.$eventId.tsx?tsr-split=component
231
+ function EventPage() {
232
+ const d = Route.useLoaderData();
233
+ const { range, from, to, view } = Route.useSearch();
234
+ const issueSearch = {
235
+ app: d.app,
236
+ range,
237
+ from,
238
+ to
239
+ };
240
+ const step = (id) => ({
241
+ to: "/events/$eventId",
242
+ params: { eventId: id },
243
+ search: {
244
+ ...issueSearch,
245
+ issue: d.issue.fingerprint,
246
+ view
247
+ }
248
+ });
249
+ const support = view === "support";
250
+ const stepClass = "rounded-md border border-line px-2 py-1 text-xs hover:bg-panel-2";
251
+ return /* @__PURE__ */ jsxs("main", {
252
+ className: "mx-auto max-w-7xl space-y-5 px-4 py-6 sm:px-6",
253
+ children: [
254
+ /* @__PURE__ */ jsxs("div", {
255
+ className: "flex flex-wrap items-center justify-between gap-2 text-sm",
256
+ children: [/* @__PURE__ */ jsxs(Link, {
257
+ to: "/issues/$fingerprint",
258
+ params: { fingerprint: d.issue.fingerprint },
259
+ search: issueSearch,
260
+ className: "text-muted hover:text-ink",
261
+ children: ["← ", d.issue.title]
262
+ }), /* @__PURE__ */ jsxs("nav", {
263
+ "aria-label": "Other occurrences",
264
+ className: "flex gap-2",
265
+ children: [d.newer ? /* @__PURE__ */ jsx(Link, {
266
+ ...step(d.newer),
267
+ className: stepClass,
268
+ children: "← Newer"
269
+ }) : null, d.older ? /* @__PURE__ */ jsx(Link, {
270
+ ...step(d.older),
271
+ className: stepClass,
272
+ children: "Older →"
273
+ }) : null]
274
+ })]
275
+ }),
276
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("p", {
277
+ className: "text-xs uppercase tracking-wide text-muted",
278
+ children: [
279
+ "Occurrence · ",
280
+ clock(d.ts),
281
+ " · ",
282
+ d.handled ? "caught by the app" : "uncaught",
283
+ d.flow ? ` · ${d.flow}${d.step ? ` · ${d.step}` : ""}` : ""
284
+ ]
285
+ }), /* @__PURE__ */ jsxs("h1", {
286
+ className: "mt-1 break-words text-xl font-semibold tracking-tight",
287
+ children: [
288
+ d.error.name,
289
+ ": ",
290
+ d.error.message
291
+ ]
292
+ })] }),
293
+ /* @__PURE__ */ jsx(Who, { d }),
294
+ /* @__PURE__ */ jsx(Summary, {
295
+ d,
296
+ support,
297
+ search: {
298
+ ...issueSearch,
299
+ issue: d.issue.fingerprint,
300
+ view
301
+ }
302
+ }),
303
+ support ? /* @__PURE__ */ jsx(Card, {
304
+ title: "What they did",
305
+ subtitle: "Screens, taps and failed calls before the error, and after it when the session went on.",
306
+ children: /* @__PURE__ */ jsx(Timeline, {
307
+ items: d.timeline.filter(forSupport),
308
+ after: d.after.filter(forSupport),
309
+ errorTs: d.ts,
310
+ errorText: "The error"
311
+ })
312
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
313
+ className: "grid gap-5 lg:grid-cols-5",
314
+ children: [/* @__PURE__ */ jsx("div", {
315
+ className: "min-w-0 lg:col-span-3",
316
+ children: /* @__PURE__ */ jsx(Card, {
317
+ title: "Timeline",
318
+ subtitle: "What happened before the error, in order. Times are from the device, relative to the error.",
319
+ children: /* @__PURE__ */ jsx(Timeline, {
320
+ items: d.timeline,
321
+ errorTs: d.ts,
322
+ errorText: `${d.error.name}: ${d.error.message}`
323
+ })
324
+ })
325
+ }), /* @__PURE__ */ jsxs("div", {
326
+ className: "min-w-0 space-y-5 lg:col-span-2",
327
+ children: [d.request && /* @__PURE__ */ jsx(Card, {
328
+ title: "Request",
329
+ subtitle: "The call that failed.",
330
+ children: /* @__PURE__ */ jsx(RequestPanel, {
331
+ call: d.request,
332
+ exchange: d.exchange
333
+ })
334
+ }), /* @__PURE__ */ jsxs(Card, {
335
+ title: "Device and app",
336
+ children: [
337
+ /* @__PURE__ */ jsx(Facts, { rows: [
338
+ ["OS", joined([d.context.os.name, d.context.os.version])],
339
+ ["Device", joined([d.context.device.brand, d.context.device.model])],
340
+ ["App", joined([d.context.app.version, d.context.app.build && `(${d.context.app.build})`])],
341
+ ["Update", d.context.app.update],
342
+ ["Environment", d.context.app.environment],
343
+ ["Runtime", joined([
344
+ d.context.runtime.name,
345
+ d.context.runtime.version,
346
+ d.context.runtime.engine
347
+ ])],
348
+ ["Network", joined([d.context.network?.type, d.context.network?.effectiveType])],
349
+ ["Locale", joined([d.context.locale, d.context.timezone], " · ")]
350
+ ] }),
351
+ /* @__PURE__ */ jsx("h3", {
352
+ className: "mb-2 mt-4 text-xs font-medium text-muted",
353
+ children: "Tags"
354
+ }),
355
+ d.tags.length ? /* @__PURE__ */ jsx(Facts, {
356
+ mono: true,
357
+ rows: d.tags.map((t) => [t.key, t.value])
358
+ }) : /* @__PURE__ */ jsx("p", {
359
+ className: "text-sm text-muted",
360
+ children: "No tags on this event."
361
+ })
362
+ ]
363
+ })]
364
+ })]
365
+ }), /* @__PURE__ */ jsx(Card, {
366
+ title: "Stack trace",
367
+ subtitle: "The app's own code first, then libraries and the runtime.",
368
+ children: d.frames.length ? /* @__PURE__ */ jsx("ol", {
369
+ className: "space-y-1 font-mono text-xs",
370
+ children: d.frames.map((f, i) => /* @__PURE__ */ jsxs("li", {
371
+ className: `rounded px-2 py-1 ${f.inApp ? "bg-accent-soft text-ink" : "text-muted"}`,
372
+ children: [
373
+ /* @__PURE__ */ jsx("span", {
374
+ className: "font-semibold",
375
+ children: f.fn ?? "<anonymous>"
376
+ }),
377
+ " ",
378
+ /* @__PURE__ */ jsxs("span", {
379
+ className: "break-all",
380
+ children: [
381
+ f.file,
382
+ ":",
383
+ f.line,
384
+ ":",
385
+ f.col
386
+ ]
387
+ }),
388
+ !f.inApp && /* @__PURE__ */ jsx("span", {
389
+ className: "ml-2 text-[10px] uppercase tracking-wide",
390
+ children: "library"
391
+ })
392
+ ]
393
+ }, i))
394
+ }) : /* @__PURE__ */ jsx("pre", {
395
+ className: "overflow-auto whitespace-pre-wrap text-xs text-muted",
396
+ children: d.stack ?? "No stack trace captured."
397
+ })
398
+ })] })
399
+ ]
400
+ });
401
+ }
402
+ /** The support summary, the Support / Developer switch, and "Copy for ticket". */
403
+ function Summary({ d, support, search }) {
404
+ const summary = supportSummary(d, (iso) => ticketTime(iso, d.context.timezone));
405
+ const [origin, setOrigin] = useState("");
406
+ useEffect(() => setOrigin(window.location.origin), []);
407
+ const link = `${origin}/events/${encodeURIComponent(d.id)}?app=${encodeURIComponent(d.app)}&issue=${encodeURIComponent(d.issue.fingerprint)}${support ? "&view=support" : ""}`;
408
+ const tab = (on) => `rounded-md px-2.5 py-1 text-xs ${on ? "bg-panel-2 font-medium text-ink" : "text-muted hover:text-ink"}`;
409
+ return /* @__PURE__ */ jsxs("section", {
410
+ "aria-label": "Support summary",
411
+ className: "rounded-xl border border-line bg-panel p-4 sm:p-5",
412
+ children: [
413
+ /* @__PURE__ */ jsxs("div", {
414
+ className: "mb-2 flex flex-wrap items-center justify-between gap-2",
415
+ children: [/* @__PURE__ */ jsx("h2", {
416
+ className: "text-sm font-semibold",
417
+ children: "What happened"
418
+ }), /* @__PURE__ */ jsxs("div", {
419
+ className: "flex items-center gap-2",
420
+ children: [/* @__PURE__ */ jsxs("span", {
421
+ className: "flex rounded-md border border-line p-0.5",
422
+ role: "group",
423
+ "aria-label": "View",
424
+ children: [/* @__PURE__ */ jsx(Link, {
425
+ to: "/events/$eventId",
426
+ params: { eventId: d.id },
427
+ search: {
428
+ ...search,
429
+ view: "support"
430
+ },
431
+ replace: true,
432
+ "aria-pressed": support,
433
+ className: tab(support),
434
+ children: "Support"
435
+ }), /* @__PURE__ */ jsx(Link, {
436
+ to: "/events/$eventId",
437
+ params: { eventId: d.id },
438
+ search: {
439
+ ...search,
440
+ view: void 0
441
+ },
442
+ replace: true,
443
+ "aria-pressed": !support,
444
+ className: tab(!support),
445
+ children: "Developer"
446
+ })]
447
+ }), /* @__PURE__ */ jsx(CopyButton, {
448
+ text: ticketText(summary, link, d.request?.traceId),
449
+ label: "Copy for ticket",
450
+ ariaLabel: "Copy the summary, event link and trace id for a ticket"
451
+ })]
452
+ })]
453
+ }),
454
+ /* @__PURE__ */ jsx("p", {
455
+ className: "text-[15px] leading-relaxed",
456
+ suppressHydrationWarning: true,
457
+ children: summary.sentences.join(" ")
458
+ }),
459
+ support && (summary.screens.length > 0 || summary.saw) && /* @__PURE__ */ jsxs("dl", {
460
+ className: "mt-3 grid grid-cols-[minmax(6rem,auto)_1fr] gap-x-4 gap-y-1 text-sm",
461
+ children: [summary.screens.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", {
462
+ className: "text-muted",
463
+ children: "Screens"
464
+ }), /* @__PURE__ */ jsx("dd", {
465
+ className: "min-w-0 break-words",
466
+ children: summary.screens.join(" → ")
467
+ })] }), summary.saw && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", {
468
+ className: "text-muted",
469
+ children: "They saw"
470
+ }), /* @__PURE__ */ jsxs("dd", {
471
+ className: "min-w-0 break-words",
472
+ children: [
473
+ "\"",
474
+ summary.saw,
475
+ "\""
476
+ ]
477
+ })] })]
478
+ })
479
+ ]
480
+ });
481
+ }
482
+ /** The steps support follows: screens, taps, what the app showed, and calls that failed. */
483
+ function forSupport(t) {
484
+ return t.category === "navigation" || t.category === "ui" || !!t.api?.failed || !!shownOf(t);
485
+ }
486
+ /** Who it happened to, and the ids that lead to their session and their other sessions. */
487
+ function Who({ d }) {
488
+ const customer = d.user.id;
489
+ return /* @__PURE__ */ jsxs("section", {
490
+ "aria-label": "Customer and session",
491
+ className: "flex flex-wrap items-center gap-x-6 gap-y-2 rounded-xl border border-line bg-panel px-4 py-3 text-sm",
492
+ children: [
493
+ /* @__PURE__ */ jsxs("span", { children: [
494
+ /* @__PURE__ */ jsx("span", {
495
+ className: "text-muted",
496
+ children: "Customer "
497
+ }),
498
+ customer ? /* @__PURE__ */ jsx("span", {
499
+ className: "break-all font-mono",
500
+ children: customer
501
+ }) : /* @__PURE__ */ jsx("span", {
502
+ className: "text-muted",
503
+ children: "not signed in"
504
+ }),
505
+ customer && /* @__PURE__ */ jsx("span", {
506
+ className: "ml-2",
507
+ children: /* @__PURE__ */ jsx(CopyButton, {
508
+ text: customer,
509
+ label: "Copy",
510
+ ariaLabel: "Copy customer id"
511
+ })
512
+ })
513
+ ] }),
514
+ d.user.anonymousId && /* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("span", {
515
+ className: "text-muted",
516
+ children: "Install "
517
+ }), /* @__PURE__ */ jsx("span", {
518
+ className: "break-all font-mono text-xs",
519
+ children: d.user.anonymousId
520
+ })] }),
521
+ /* @__PURE__ */ jsxs("span", { children: [
522
+ /* @__PURE__ */ jsx("span", {
523
+ className: "text-muted",
524
+ children: "Session "
525
+ }),
526
+ /* @__PURE__ */ jsx("span", {
527
+ className: "break-all font-mono text-xs",
528
+ children: d.sessionId
529
+ }),
530
+ /* @__PURE__ */ jsx("span", {
531
+ className: "ml-2",
532
+ children: /* @__PURE__ */ jsx(CopyButton, {
533
+ text: d.sessionId,
534
+ label: "Copy",
535
+ ariaLabel: "Copy session id"
536
+ })
537
+ })
538
+ ] }),
539
+ /* @__PURE__ */ jsx(Link, {
540
+ to: "/sessions/$sessionId",
541
+ params: { sessionId: d.sessionId },
542
+ search: { app: d.app },
543
+ className: "text-accent hover:underline",
544
+ children: "Whole session →"
545
+ })
546
+ ]
547
+ });
548
+ }
549
+ /** The trail up to the error, and with `after`, what came after it. */
550
+ function Timeline({ items, after = [], errorTs, errorText }) {
551
+ if (!items.length && !after.length) return /* @__PURE__ */ jsx("p", {
552
+ className: "text-sm text-muted",
553
+ children: "No breadcrumbs. The SDK records screens, taps and requests on its own once it's set up; see the README."
554
+ });
555
+ const row = (t, key) => /* @__PURE__ */ jsxs("li", {
556
+ className: `grid grid-cols-[4.5rem_1.25rem_1fr] gap-2 rounded-md px-2 py-1.5 text-sm ${t.failed ? "bg-sev-critical/10" : t.level === "warning" ? "bg-sev-medium/10" : ""}`,
557
+ children: [
558
+ /* @__PURE__ */ jsx("span", {
559
+ className: "tabular pt-0.5 text-right text-xs text-muted",
560
+ title: t.ts,
561
+ children: offset(t.ts, errorTs)
562
+ }),
563
+ /* @__PURE__ */ jsx("span", {
564
+ "aria-hidden": true,
565
+ className: `pt-0.5 text-center ${t.failed ? "text-sev-critical" : "text-muted"}`,
566
+ children: ICON[t.category]
567
+ }),
568
+ /* @__PURE__ */ jsx("div", {
569
+ className: "min-w-0",
570
+ children: /* @__PURE__ */ jsx(CrumbBody, { item: t })
571
+ })
572
+ ]
573
+ }, key);
574
+ return /* @__PURE__ */ jsxs("ol", {
575
+ className: "space-y-2",
576
+ children: [
577
+ items.map((t, i) => row(t, `b${i}`)),
578
+ /* @__PURE__ */ jsxs("li", {
579
+ className: "grid grid-cols-[4.5rem_1.25rem_1fr] gap-2 rounded-md bg-sev-critical/15 px-2 py-1.5 text-sm font-medium text-sev-critical",
580
+ children: [
581
+ /* @__PURE__ */ jsx("span", {
582
+ className: "tabular pt-0.5 text-right text-xs",
583
+ children: "0 s"
584
+ }),
585
+ /* @__PURE__ */ jsx("span", {
586
+ "aria-hidden": true,
587
+ className: "pt-0.5 text-center",
588
+ children: "✕"
589
+ }),
590
+ /* @__PURE__ */ jsx("span", {
591
+ className: "break-words",
592
+ children: errorText
593
+ })
594
+ ]
595
+ }),
596
+ after.map((t, i) => row(t, `a${i}`))
597
+ ]
598
+ });
599
+ }
600
+ /** The failed call; with what the SDK captured, its request and response in tabs of their own. */
601
+ function RequestPanel({ call, exchange }) {
602
+ const [tab, setTab] = useState("call");
603
+ if (!exchange) return /* @__PURE__ */ jsx(CallFacts, { call });
604
+ const tabs = [
605
+ ["call", "Call"],
606
+ ["request", "Request"],
607
+ ...exchange.response ? [["response", "Response"]] : []
608
+ ];
609
+ const ids = tabs.map(([id]) => id);
610
+ const onKey = (e) => {
611
+ const i = ids.indexOf(tab);
612
+ const next = e.key === "ArrowRight" ? ids[(i + 1) % ids.length] : e.key === "ArrowLeft" ? ids[(i - 1 + ids.length) % ids.length] : e.key === "Home" ? ids[0] : e.key === "End" ? ids[ids.length - 1] : void 0;
613
+ if (!next) return;
614
+ e.preventDefault();
615
+ setTab(next);
616
+ document.getElementById(`req-tab-${next}`)?.focus();
617
+ };
618
+ return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
619
+ role: "tablist",
620
+ "aria-label": "Request details",
621
+ onKeyDown: onKey,
622
+ className: "mb-3 flex gap-1 border-b border-line",
623
+ children: tabs.map(([id, label]) => /* @__PURE__ */ jsx("button", {
624
+ type: "button",
625
+ role: "tab",
626
+ id: `req-tab-${id}`,
627
+ "aria-selected": tab === id,
628
+ "aria-controls": `req-panel-${id}`,
629
+ tabIndex: tab === id ? 0 : -1,
630
+ onClick: () => setTab(id),
631
+ className: `-mb-px border-b-2 px-2.5 py-1.5 text-sm ${tab === id ? "border-ink font-medium text-ink" : "border-transparent text-muted hover:text-ink"}`,
632
+ children: label
633
+ }, id))
634
+ }), tabs.map(([id]) => /* @__PURE__ */ jsxs("div", {
635
+ role: "tabpanel",
636
+ id: `req-panel-${id}`,
637
+ "aria-labelledby": `req-tab-${id}`,
638
+ hidden: tab !== id,
639
+ tabIndex: 0,
640
+ children: [
641
+ id === "call" && /* @__PURE__ */ jsx(CallFacts, { call }),
642
+ id === "request" && /* @__PURE__ */ jsx(RequestSide, { exchange }),
643
+ id === "response" && exchange.response && /* @__PURE__ */ jsx(Side, {
644
+ side: exchange.response,
645
+ first: ["Status", String(exchange.response.status)]
646
+ })
647
+ ]
648
+ }, id))] });
649
+ }
650
+ function RequestSide({ exchange }) {
651
+ const r = exchange.request;
652
+ const curl = curlOf(exchange);
653
+ const query = r.query !== void 0 ? uncut(r.query) : void 0;
654
+ return /* @__PURE__ */ jsxs("div", {
655
+ className: "space-y-3",
656
+ children: [/* @__PURE__ */ jsx(Side, {
657
+ side: r,
658
+ first: ["Call", /* @__PURE__ */ jsxs("span", {
659
+ className: "break-all font-mono text-xs",
660
+ children: [
661
+ r.method,
662
+ " ",
663
+ r.fullUrl ?? r.url,
664
+ query?.text ? `?${query.text}` : "",
665
+ query?.cut ? " (query cut)" : ""
666
+ ]
667
+ })]
668
+ }), /* @__PURE__ */ jsxs("div", {
669
+ className: "flex flex-wrap items-center gap-2",
670
+ children: [/* @__PURE__ */ jsx(CopyButton, {
671
+ text: curl.command,
672
+ label: "Copy as cURL",
673
+ ariaLabel: "Copy the request as a cURL command"
674
+ }), /* @__PURE__ */ jsxs("span", {
675
+ className: "text-xs text-muted",
676
+ children: [
677
+ "Redacted as captured: secrets show as [redacted]",
678
+ curl.complete ? "" : ", and the command's first line says what to fill in",
679
+ "."
680
+ ]
681
+ })]
682
+ })]
683
+ });
684
+ }
685
+ /** Headers and body of one side of the call. */
686
+ function Side({ side, first }) {
687
+ const body = bodyView(side);
688
+ const headers = Object.entries(side.headers ?? {}).sort(([a], [b]) => a.localeCompare(b));
689
+ const sized = side.bodySize === void 0 ? void 0 : body?.binary ? size(side.bodySize) : `${side.bodySize.toLocaleString("en")} characters`;
690
+ return /* @__PURE__ */ jsxs("div", {
691
+ className: "space-y-3",
692
+ children: [
693
+ /* @__PURE__ */ jsx(Facts, { rows: [first, ["Body size", sized]] }),
694
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
695
+ className: "mb-1.5 text-xs font-medium text-muted",
696
+ children: "Headers"
697
+ }), headers.length ? /* @__PURE__ */ jsx(Facts, {
698
+ mono: true,
699
+ rows: headers
700
+ }) : /* @__PURE__ */ jsx("p", {
701
+ className: "text-sm text-muted",
702
+ children: "None captured."
703
+ })] }),
704
+ /* @__PURE__ */ jsxs("div", { children: [
705
+ /* @__PURE__ */ jsxs("h3", {
706
+ className: "mb-1.5 text-xs font-medium text-muted",
707
+ children: ["Body", body?.json ? " (JSON)" : ""]
708
+ }),
709
+ body?.note && /* @__PURE__ */ jsx("p", {
710
+ className: "mb-1.5 rounded-md bg-sev-medium/10 px-2 py-1 text-xs",
711
+ children: body.note
712
+ }),
713
+ body?.text ? /* @__PURE__ */ jsx("pre", {
714
+ className: "max-h-96 overflow-auto whitespace-pre-wrap break-all rounded-md border border-line bg-panel-2 p-2 font-mono text-[11px] leading-relaxed",
715
+ children: body.text
716
+ }) : !body?.note && /* @__PURE__ */ jsx("p", {
717
+ className: "text-sm text-muted",
718
+ children: "None captured."
719
+ })
720
+ ] })
721
+ ]
722
+ });
723
+ }
724
+ function CallFacts({ call }) {
725
+ return /* @__PURE__ */ jsx(Facts, { rows: [
726
+ ["Service", call.service],
727
+ ["Endpoint", joined([call.method, call.path])],
728
+ ["Status", call.status !== void 0 ? String(call.status) : "no answer"],
729
+ ["Outcome", call.outcome],
730
+ ["Kind", call.errorKind],
731
+ ["Backend", joined([call.backendCode, call.backendTitle], " · ")],
732
+ ["Backend errors", call.backendErrors],
733
+ ["Trace", call.traceId ? /* @__PURE__ */ jsxs("span", {
734
+ className: "flex flex-wrap items-center gap-2",
735
+ children: [/* @__PURE__ */ jsx("span", {
736
+ className: "break-all font-mono text-xs",
737
+ children: call.traceId
738
+ }), /* @__PURE__ */ jsx(CopyButton, {
739
+ text: call.traceId,
740
+ label: "Copy",
741
+ ariaLabel: "Copy trace id"
742
+ })]
743
+ }) : void 0],
744
+ ["Duration", call.durationMs !== void 0 ? `${call.durationMs} ms` : void 0],
745
+ ["Retry", call.retry === void 0 ? void 0 : String(call.retry)]
746
+ ] });
747
+ }
748
+ /** Label/value rows; empty values are left out. */
749
+ function Facts({ rows, mono }) {
750
+ const shown = rows.filter(([, v]) => v !== void 0 && v !== "");
751
+ return /* @__PURE__ */ jsx("dl", {
752
+ className: "grid grid-cols-[minmax(6rem,auto)_1fr] gap-x-4 gap-y-1.5 text-sm",
753
+ children: shown.map(([k, v]) => /* @__PURE__ */ jsxs("div", {
754
+ className: "contents",
755
+ children: [/* @__PURE__ */ jsx("dt", {
756
+ className: `text-muted ${mono ? "break-all font-mono text-xs" : ""}`,
757
+ children: k
758
+ }), /* @__PURE__ */ jsx("dd", {
759
+ className: `min-w-0 break-words ${mono ? "font-mono text-xs" : ""}`,
760
+ children: v
761
+ })]
762
+ }, k))
763
+ });
764
+ }
765
+ export { EventPage as component };