@debugkit/dashboard 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/.env.example +30 -0
  2. package/dist/client/assets/_authed-BDx4Txp7.js +7 -0
  3. package/dist/client/assets/_authed-D6P9RBN1.js +1 -0
  4. package/dist/client/assets/charts-Covhtva2.js +55 -0
  5. package/dist/client/assets/index-BKQXehfa.js +12 -0
  6. package/dist/client/assets/issues._fingerprint-DtAqk0rC.js +1 -0
  7. package/dist/client/assets/login-Da8b3hjR.js +1 -0
  8. package/dist/client/assets/styles-CZZRuG1z.css +2 -0
  9. package/dist/client/assets/ui-DnKidKVi.js +1 -0
  10. package/dist/server/assets/_authed-BjmBAX3l.js +482 -0
  11. package/dist/server/assets/_authed-x9Ku8dyL.js +40 -0
  12. package/dist/server/assets/_tanstack-start-manifest_v-CY7PP5UB.js +40 -0
  13. package/dist/server/assets/charts-CNlV7Pga.js +221 -0
  14. package/dist/server/assets/demo-DTdlXNgj.js +333 -0
  15. package/dist/server/assets/dynamodb-DejcakaF.js +187 -0
  16. package/dist/server/assets/empty-plugin-adapters-BsRz-CQL.js +4 -0
  17. package/dist/server/assets/firestore-BH-gx9no.js +112 -0
  18. package/dist/server/assets/fns-CgB12FUN.js +31 -0
  19. package/dist/server/assets/fns-Yg8sT1Cb.js +87 -0
  20. package/dist/server/assets/issues._fingerprint-C2EdByPH.js +255 -0
  21. package/dist/server/assets/login-BMGNYcxB.js +107 -0
  22. package/dist/server/assets/memory-4DwW5cTO.js +59 -0
  23. package/dist/server/assets/queries-DIVV-5j6.js +4274 -0
  24. package/dist/server/assets/rollups-JXbazRNh.js +22 -0
  25. package/dist/server/assets/router-D2L7-BwF.js +222 -0
  26. package/dist/server/assets/src-D5jyi_C4.js +235 -0
  27. package/dist/server/assets/start-t09PGpZL.js +3 -0
  28. package/dist/server/assets/ui-Lv-KcOoP.js +131 -0
  29. package/dist/server/server.js +7825 -0
  30. package/package.json +52 -3
  31. package/scripts/hash-password.mjs +17 -0
  32. package/server.mjs +50 -0
  33. package/README.md +0 -3
package/.env.example ADDED
@@ -0,0 +1,30 @@
1
+ # ---------- Which database to read ----------
2
+ # demo → in-memory sample data, no cloud needed (default)
3
+ # firestore → Firebase / Google Cloud Firestore
4
+ # dynamodb → AWS DynamoDB
5
+ DEBUG_STORE=demo
6
+
7
+ # Firestore: point at a READ-ONLY service account (roles/datastore.viewer).
8
+ # GOOGLE_APPLICATION_CREDENTIALS=./service-account.readonly.json
9
+ # DEBUG_FIRESTORE_ROOT=debug_apps
10
+
11
+ # DynamoDB: uses the normal AWS credential chain (profile, SSO, instance role).
12
+ # Give it a read-only policy on the deBug table.
13
+ # AWS_REGION=af-south-1
14
+ # AWS_PROFILE=debug-readonly
15
+ # DEBUG_DYNAMO_TABLE=debug
16
+
17
+ # ---------- Login ----------
18
+ # Comma-separated email=hash pairs. Generate a hash with: pnpm --filter @debugkit/dashboard hash-password
19
+ # DEBUG_DASHBOARD_USERS=you@company.com=scrypt.<salt>.<hash>
20
+
21
+ # Signs session cookies. At least 32 random characters: openssl rand -hex 32
22
+ # DEBUG_SESSION_SECRET=
23
+
24
+ # Optional bearer token for agents / scripts calling /api/* without a browser session.
25
+ # DEBUG_API_TOKEN=
26
+
27
+ # Severity thresholds (occurrences in the last 24h)
28
+ # DEBUG_SEVERITY_CRITICAL=100
29
+ # DEBUG_SEVERITY_HIGH=25
30
+ # DEBUG_SEVERITY_MEDIUM=5
@@ -0,0 +1,7 @@
1
+ import{_ as e,c as t,d as n,f as r,l as i,m as a,n as o}from"./index-BKQXehfa.js";import{r as s,t as c}from"./charts-Covhtva2.js";import{a as l,i as u,n as d,o as f,s as p,t as m}from"./ui-DnKidKVi.js";var h=e(a()),g=r();function _(){let e=o.useLoaderData(),{flow:n}=o.useSearch(),r=i({from:o.fullPath});if(!e)return(0,g.jsx)(x,{});let{totals:a}=e,h=n?e.issues.filter(e=>(e.flow??`untagged`)===n):e.issues,_=a.changePct;return(0,g.jsxs)(`main`,{className:`mx-auto max-w-7xl space-y-5 px-4 py-6 sm:px-6`,children:[(0,g.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`p`,{className:`text-xs uppercase tracking-wide text-muted`,children:`Overview · last 24h`}),(0,g.jsxs)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:[`What's going wrong in `,e.app]})]}),e.apps.length>1&&(0,g.jsx)(`select`,{"aria-label":`App`,value:e.app,onChange:e=>r({search:{app:e.target.value}}),className:`rounded-md border border-line bg-panel px-2 py-1.5 text-sm`,children:e.apps.map(e=>(0,g.jsx)(`option`,{children:e},e))})]}),(0,g.jsx)(`section`,{"aria-label":`Summary`,className:`rounded-xl border border-line bg-panel p-4 sm:p-5`,children:(0,g.jsx)(`ul`,{className:`space-y-1.5 text-[15px] leading-relaxed`,children:e.narrative.map((e,t)=>(0,g.jsx)(`li`,{className:t===0?`font-medium`:`text-ink/90`,children:e},t))})}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,g.jsx)(f,{label:`Errors (24h)`,value:a.errors24h.toLocaleString(),tone:a.criticalIssues?`critical`:void 0,hint:_===null?`no prior data`:`${_>0?`▲`:_<0?`▼`:`•`} ${Math.abs(_)}% vs previous 24h`}),(0,g.jsx)(f,{label:`Critical issues`,value:a.criticalIssues,tone:a.criticalIssues?`critical`:void 0,hint:`≥ threshold occurrences in 24h`}),(0,g.jsx)(f,{label:`Failing flows`,value:a.failingFlows,hint:`parts of the app with errors in 24h`}),(0,g.jsx)(f,{label:`Crash-free sessions (14d)`,value:v(e.health.crashFreeRate),tone:e.health.crashFreeRate!==null&&e.health.crashFreeRate<.99?`high`:void 0,hint:`${e.health.sessions14d.toLocaleString()} sessions · ${a.activeIssues} active issues`})]}),(0,g.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-5`,children:[(0,g.jsx)(`div`,{className:`lg:col-span-3`,children:(0,g.jsxs)(m,{title:`Where the app is failing`,subtitle:`Errors in the last 24h by flow, coloured by worst severity. Click a bar to filter issues.`,children:[(0,g.jsx)(c,{data:e.flows,onSelect:e=>r({search:t=>({...t,flow:t.flow===e?void 0:e})})}),(0,g.jsx)(d,{columns:[`Flow`,`Severity`,`Errors 24h`,`Errors 14d`,`Issues`,`Failure rate 14d`],rows:e.flows.map(e=>[e.flow,e.severity,e.errors24h,e.errors14d,e.issues,e.failureRate===null?`—`:`${Math.round(e.failureRate*100)}%`])})]})}),(0,g.jsx)(`div`,{className:`lg:col-span-2`,children:(0,g.jsxs)(m,{title:`Error trend`,subtitle:`Errors per day, last 14 days (UTC)`,children:[(0,g.jsx)(s,{data:e.trend}),(0,g.jsx)(d,{columns:[`Day`,`Errors`,`Events`],rows:e.trend.map(e=>[e.day,e.errors,e.events])})]})})]}),(0,g.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-2`,children:[(0,g.jsx)(m,{title:`Release health`,subtitle:`Share of sessions without a crash or unhandled error, per app version (14d). Recorded automatically by the SDK.`,children:e.health.releases.length?(0,g.jsx)(`div`,{className:`-mx-4 overflow-x-auto sm:mx-0`,children:(0,g.jsxs)(`table`,{className:`tabular w-full min-w-[420px] text-left text-sm`,children:[(0,g.jsx)(`thead`,{className:`text-xs text-muted`,children:(0,g.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,g.jsx)(`th`,{className:`px-4 py-2 font-medium sm:px-2`,children:`Version`}),(0,g.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Sessions`}),(0,g.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Crash-free`}),(0,g.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Error-free`})]})}),(0,g.jsx)(`tbody`,{children:e.health.releases.map(e=>(0,g.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,g.jsx)(`td`,{className:`px-4 py-2 font-medium sm:px-2`,children:e.version}),(0,g.jsx)(`td`,{className:`px-2 py-2 text-right text-muted`,children:e.sessions.toLocaleString()}),(0,g.jsx)(`td`,{className:`px-2 py-2 text-right font-semibold ${y(e.crashFreeRate)}`,children:v(e.crashFreeRate)}),(0,g.jsx)(`td`,{className:`px-2 py-2 text-right`,children:v(e.errorFreeRate)})]},e.version))})]})}):(0,g.jsx)(`p`,{className:`text-sm text-muted`,children:`No sessions yet. They're recorded automatically from SDK 0.2.`})}),(0,g.jsx)(m,{title:`Failing endpoints`,subtitle:`Requests that returned 5xx, timed out or failed, 14d. Captured automatically from fetch and XHR.`,children:e.health.endpoints.length?(0,g.jsx)(l,{rows:e.health.endpoints.map(e=>({key:e.endpoint,value:e.failures14d}))}):(0,g.jsx)(`p`,{className:`text-sm text-muted`,children:`No failed requests.`})})]}),(0,g.jsx)(m,{title:n?`Issues in ${n}`:`Issues by severity`,subtitle:`Grouped errors. Severity is set by occurrences in the last 24 hours.`,right:n?(0,g.jsx)(`button`,{className:`text-xs text-accent`,onClick:()=>r({search:e=>({...e,flow:void 0})}),children:`Clear filter ×`}):null,children:(0,g.jsx)(`div`,{className:`-mx-4 overflow-x-auto sm:mx-0`,children:(0,g.jsxs)(`table`,{className:`tabular w-full min-w-[640px] text-left text-sm`,children:[(0,g.jsx)(`thead`,{className:`text-xs text-muted`,children:(0,g.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,g.jsx)(`th`,{className:`px-4 py-2 font-medium sm:px-2`,children:`Severity`}),(0,g.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`Issue`}),(0,g.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`Flow`}),(0,g.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`24h`}),(0,g.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Total`}),(0,g.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Last seen`})]})}),(0,g.jsxs)(`tbody`,{children:[h.map(n=>(0,g.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-panel-2`,children:[(0,g.jsx)(`td`,{className:`px-4 py-2.5 sm:px-2`,children:(0,g.jsx)(u,{severity:n.severity})}),(0,g.jsxs)(`td`,{className:`max-w-[420px] px-2 py-2.5`,children:[(0,g.jsx)(t,{to:`/issues/$fingerprint`,params:{fingerprint:n.fingerprint},search:{app:e.app},className:`block truncate font-medium hover:text-accent`,children:n.title}),n.culprit&&(0,g.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:n.culprit})]}),(0,g.jsx)(`td`,{className:`px-2 py-2.5 text-xs`,children:n.flow??(0,g.jsx)(`span`,{className:`text-muted`,children:`untagged`})}),(0,g.jsx)(`td`,{className:`px-2 py-2.5 text-right font-semibold`,children:n.count24h}),(0,g.jsx)(`td`,{className:`px-2 py-2.5 text-right text-muted`,children:n.countTotal}),(0,g.jsx)(`td`,{className:`px-2 py-2.5 text-right text-xs text-muted`,children:p(n.lastSeen)})]},n.fingerprint)),!h.length&&(0,g.jsx)(`tr`,{children:(0,g.jsx)(`td`,{colSpan:6,className:`px-2 py-6 text-center text-muted`,children:`No issues.`})})]})]})})}),(0,g.jsxs)(`div`,{className:`grid gap-5 md:grid-cols-3`,children:[(0,g.jsx)(m,{title:`By OS`,subtitle:`Errors, 14d`,children:(0,g.jsx)(l,{rows:e.breakdowns.os.map(e=>({key:e.key,value:e.errors}))})}),(0,g.jsx)(m,{title:`By app version`,subtitle:`Errors, 14d`,children:(0,g.jsx)(l,{rows:e.breakdowns.appVersion.map(e=>({key:e.key,value:e.errors}))})}),(0,g.jsx)(m,{title:`By device`,subtitle:`Errors, 14d`,children:(0,g.jsx)(l,{rows:e.breakdowns.deviceModel.map(e=>({key:e.key,value:e.errors}))})})]}),(0,g.jsxs)(`p`,{className:`pb-6 text-xs text-muted`,children:[`Machine-readable: `,(0,g.jsxs)(`code`,{children:[`GET /api/summary?app=`,e.app]}),` returns this page as JSON with field descriptions.`]})]})}function v(e){return e===null?`—`:`${(Math.floor(e*1e3)/10).toFixed(1)}%`}function y(e){return e===null?``:e<.98?`text-sev-critical`:e<.995?`text-sev-high`:``}var b=[{title:`A written summary`,when:`after the first error`,detail:`How many errors in the last 24 hours, the worst part of the app, the top issue and the release that's struggling, in plain sentences.`},{title:`Issues by severity`,when:`after the first error`,detail:`Errors grouped by cause. Severity comes from how often each happened in the last 24 hours. Open one for the stack trace and the steps that led to it.`},{title:`Release health`,when:`as soon as the app starts`,detail:`Every app launch is a session. You'll see the share of sessions per version that ran without a crash or an unhandled error.`},{title:`Failing endpoints`,when:`after the first failed request`,detail:`Requests that timed out, failed or returned 5xx, captured from fetch and XHR without any code from you.`},{title:`Where the app is failing`,when:`once you tag flows`,detail:`Errors by flow, like auth.login or checkout.payment. Wrap a step in deBug.track() and each flow also gets a failure rate.`},{title:`Breakdowns`,when:`after the first error`,detail:`Errors split by OS, app version and device model, so you can see who is affected.`}];function x(){let e=n();return(0,h.useEffect)(()=>{let t=setInterval(()=>void e.invalidate(),5e3);return()=>clearInterval(t)},[e]),(0,g.jsxs)(`main`,{className:`mx-auto max-w-4xl space-y-6 px-4 py-10 sm:px-6`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`p`,{className:`text-xs uppercase tracking-wide text-muted`,children:`Connected · waiting for the first event`}),(0,g.jsx)(`h1`,{className:`mt-1 text-2xl font-semibold tracking-tight`,children:`Your dashboard is ready, and empty for now.`}),(0,g.jsxs)(`p`,{className:`mt-2 max-w-2xl text-sm text-muted`,children:[`Nothing has arrived yet. Run your app with the SDK initialised, or send a test event with `,(0,g.jsx)(`code`,{children:`npx debugkit test`}),`. This page fills in on its own.`]})]}),(0,g.jsxs)(`section`,{"aria-labelledby":`see-h`,className:`rounded-xl border border-line bg-panel p-4 sm:p-5`,children:[(0,g.jsx)(`h2`,{id:`see-h`,className:`text-sm font-semibold`,children:`What you'll see here`}),(0,g.jsx)(`ul`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:b.map(e=>(0,g.jsxs)(`li`,{className:`rounded-lg border border-line p-3`,children:[(0,g.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,g.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,g.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-muted`,children:e.when})]}),(0,g.jsx)(`p`,{className:`mt-1 text-sm text-ink/80`,children:e.detail})]},e.title))})]}),(0,g.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,g.jsxs)(`section`,{"aria-labelledby":`auto-h`,className:`rounded-xl border border-line bg-panel p-4 sm:p-5`,children:[(0,g.jsx)(`h2`,{id:`auto-h`,className:`text-sm font-semibold`,children:`Recorded automatically`}),(0,g.jsxs)(`p`,{className:`mt-1 text-xs text-muted`,children:[`Once `,(0,g.jsx)(`code`,{children:`init()`}),` runs, with no other code.`]}),(0,g.jsxs)(`ul`,{className:`mt-3 list-disc space-y-1 pl-5 text-sm`,children:[(0,g.jsx)(`li`,{children:`Crashes and unhandled promise rejections`}),(0,g.jsx)(`li`,{children:`Failed, timed-out and 5xx requests, with the code that made them`}),(0,g.jsx)(`li`,{children:`Sessions, for crash-free rates per release`}),(0,g.jsx)(`li`,{children:`Screens visited, buttons clicked, console warnings, app backgrounded or offline`}),(0,g.jsx)(`li`,{children:`Device, OS, app version and network on every event`})]})]}),(0,g.jsxs)(`section`,{"aria-labelledby":`manual-h`,className:`rounded-xl border border-line bg-panel p-4 sm:p-5`,children:[(0,g.jsx)(`h2`,{id:`manual-h`,className:`text-sm font-semibold`,children:`What you add`}),(0,g.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Only what the app can't know on its own.`}),(0,g.jsx)(`pre`,{className:`mt-3 overflow-x-auto rounded-md bg-panel-2 p-3 text-xs leading-relaxed`,children:`// in a try/catch you already have
2
+ catch (err) {
3
+ deBug.error(err, { flow: "checkout.payment", step: "charge" });
4
+ }
5
+
6
+ // success or failure of a step, plus the error
7
+ await deBug.track("auth.login", "submit_otp", () => verifyOtp(code));`})]})]})]})}export{_ as component};
@@ -0,0 +1 @@
1
+ import{c as e,d as t,f as n,i as r,o as i,s as a}from"./index-BKQXehfa.js";import{r as o}from"./ui-DnKidKVi.js";var s=n();function c(){let{user:n}=r.useRouteContext(),c=t();return(0,s.jsxs)(`div`,{className:`min-h-screen`,children:[(0,s.jsx)(`header`,{className:`sticky top-0 z-10 border-b border-line bg-bg/90 backdrop-blur`,children:(0,s.jsxs)(`div`,{className:`mx-auto flex max-w-7xl items-center justify-between gap-4 px-4 py-3 sm:px-6`,children:[(0,s.jsx)(e,{to:`/`,search:{},className:`shrink-0`,children:(0,s.jsx)(o,{})}),(0,s.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,s.jsx)(`span`,{className:`hidden text-muted sm:inline`,children:n.email}),(0,s.jsx)(`button`,{className:`rounded-md border border-line px-2.5 py-1 hover:bg-panel-2`,onClick:async()=>{await i(),await c.invalidate(),await c.navigate({to:`/login`})},children:`Sign out`})]})]})}),(0,s.jsx)(a,{})]})}export{c as component};