@streamoid/ui 0.6.46 → 0.6.48

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.
@@ -1,6 +1,6 @@
1
1
  # @streamoid/ui — component router (for AI agents)
2
2
 
3
- 126 components. Full docs for each live beside this file as `<ScName>.md`;
3
+ 127 components. Full docs for each live beside this file as `<ScName>.md`;
4
4
  the same metadata is machine-readable in `components.json`.
5
5
 
6
6
  **How to use this file:** scan for the job you need below, then open only that
@@ -136,6 +136,7 @@ theme-aware (dark on `:root`, light override) — never hardcode a colour.
136
136
  - **`ScBadges`** — use when you need to state a status, a count or a tag next to something — "Revoked", "Active", "1,240 credits", "Needs attention".
137
137
  - **`ScBeacon`** — use when a row or card needs a colour-coded state marker that sits beside a text label ("● Live", "● Needs attention").
138
138
  - **`ScDrawer`** — use when you need a create/edit panel or a detail pane that slides in from the screen edge and stays full height.
139
+ - **`ScErrorBoundary`** — use when you are wrapping an app, a route, or any subtree whose crash would otherwise blank the page.
139
140
  - **`ScGuide`** — use when you are building a product walkthrough / coachmark sequence and need the step card.
140
141
  - **`ScInfoPopup`** — use when a label or a table header needs a short explanation, and you want the standard ⓘ affordance next to it.
141
142
  - **`ScMenuOptions`** — use when you need a row in a profile flyout, an account/settings menu, or a kebab/overflow menu.
@@ -227,6 +228,7 @@ theme-aware (dark on `:root`, light override) — never hardcode a colour.
227
228
  | `ScDefaultCard` | `ScAppListingCard`, `ScStoreCard`, `ScMappingCard`, `ScBriefCard`, `ScRadio` |
228
229
  | `ScDp` | `ScIntialProfileCover`, `ScProfileImageUpdate`, `ScProfile` |
229
230
  | `ScDrawer` | `ScModal`, `ScSidebar`, `StreamoidSidebar`, `ScProfilePopup` |
231
+ | `ScErrorBoundary` | `ScBadges`, `ScToast` |
230
232
  | `ScGoogleSignIn` | `ScButton`, `ScAppSwitchPanel`, `ScAppCard` |
231
233
  | `ScGuide` | `ScInfoPopup`, `ScModal`, `ScDrawer`, `ScBeacon`, `ScPopUpMenu` |
232
234
  | `ScHDivider` | `ScVDivider` |
@@ -0,0 +1,160 @@
1
+ ---
2
+ component: ScErrorBoundary
3
+ package: "@streamoid/ui"
4
+ category: overlays
5
+ status: stable
6
+ renders: div[role="alert"]
7
+ tags: [error, boundary, crash, white-screen, report, exception, telemetry, posthog]
8
+ related: [ScBadges, ScToast]
9
+ do_not_confuse_with: [ScBadges, ScToast]
10
+ ---
11
+
12
+ # ScErrorBoundary
13
+
14
+ **The only place a white screen can be observed.** A render crash produces no
15
+ request — no span, no access-log line, no status code — so every server-side
16
+ signal we have is blind to it. This catches it, shows the user the reference the
17
+ server already minted, and gives them a way to say what happened.
18
+
19
+ ## TL;DR for agents
20
+
21
+ - **Reach for it when:** you are wrapping an app, a route, or any subtree whose
22
+ crash would otherwise blank the page.
23
+ - **Don't reach for it when:** you want to show a handled API failure inline
24
+ (→ a toast or inline message; a boundary only catches *render* errors), or you
25
+ need to catch errors in an event handler or a promise — React boundaries do
26
+ not see those.
27
+ - **Three things that will bite you:**
28
+ 1. It does **not** depend on `posthog-js`, and never will. You pass the client
29
+ in. Nothing is reported until you supply a `reporter`.
30
+ 2. Where a failure never reached a server there is **no reference**, and none
31
+ is invented — the reference line is simply absent.
32
+ 3. Error boundaries must be class components. There is no hook equivalent, so
33
+ this cannot be wrapped in one.
34
+
35
+ ---
36
+
37
+ ## 1. How to use it
38
+
39
+ ### Import
40
+
41
+ ```tsx
42
+ import { ScErrorBoundary, scCreatePostHogReporter } from "@streamoid/ui";
43
+ ```
44
+
45
+ ### Minimal usage
46
+
47
+ ```tsx
48
+ <ScErrorBoundary>
49
+ <App />
50
+ </ScErrorBoundary>
51
+ ```
52
+
53
+ That catches the crash and shows the fallback. It reports nothing — supply a
54
+ `reporter` for that.
55
+
56
+ ```tsx
57
+ <ScErrorBoundary
58
+ service="unified-admin-dashboard"
59
+ reporter={scCreatePostHogReporter(posthog)}
60
+ >
61
+ <App />
62
+ </ScErrorBoundary>
63
+ ```
64
+
65
+ ### Props
66
+
67
+ | Prop | Type | Required | Notes |
68
+ |---|---|---|---|
69
+ | `children` | `ReactNode` | yes | The subtree to guard |
70
+ | `reporter` | `(report: IScErrorReport) => void` | no | Called once on catch, and again if the user submits a note |
71
+ | `service` | `string` | no | The id from `deployment/service.yaml`, recorded on the report so it routes itself |
72
+ | `route` | `string` | no | Defaults to `window.location.pathname` |
73
+ | `fallback` | `({ error, errorRef, report }) => ReactNode` | no | Replaces the default surface entirely |
74
+
75
+ ### Recipes
76
+
77
+ **Report somewhere other than PostHog.** The signature is the whole contract:
78
+
79
+ ```tsx
80
+ <ScErrorBoundary reporter={(report) => myLogger.error(report)}>
81
+ ```
82
+
83
+ **Keep the page usable around a broken panel** by scoping the boundary rather
84
+ than wrapping the whole app:
85
+
86
+ ```tsx
87
+ <ScErrorBoundary route="/billing/invoices" fallback={({ errorRef }) => (
88
+ <InlineNotice>Invoices are unavailable. Reference {errorRef ?? "none"}.</InlineNotice>
89
+ )}>
90
+ <InvoiceTable />
91
+ </ScErrorBoundary>
92
+ ```
93
+
94
+ ## 2. Where to use it
95
+
96
+ At the root of an application, and around any subtree that is worth keeping
97
+ independently alive — a dashboard panel, a table that renders third-party data,
98
+ an editor. Scoping it narrowly is what turns a blank page into a single broken
99
+ card.
100
+
101
+ ## 3. When to use it
102
+
103
+ ### Use it when
104
+
105
+ - A crash in this subtree would otherwise show the user nothing at all.
106
+ - You want the user's own account of what they were doing attached to the error.
107
+
108
+ ### Don't use it — reach for this instead
109
+
110
+ - A handled API error you want to show inline → a toast or an inline message.
111
+ - An error thrown in an event handler or an unawaited promise → React boundaries
112
+ never see these; catch them where they are thrown.
113
+
114
+ ### Don't confuse with
115
+
116
+ - **ScBadges** — a status label, not an error surface.
117
+ - **ScToast** — transient feedback for something that was handled.
118
+
119
+ ## 4. Why to use it
120
+
121
+ Because the failure it catches is the one nothing else can see. A 5xx leaves a
122
+ span, a log line and a status code. A render crash leaves a blank rectangle and a
123
+ user who closes the tab.
124
+
125
+ It also carries the reference forward. The fallback shows `ERR-` plus the first
126
+ twelve characters of the server's trace id, which the request wrapper attached to
127
+ the failing response — so the string the user reads out is the same string that
128
+ finds the trace in SigNoz, with no lookup table in between.
129
+
130
+ ## Gotchas
131
+
132
+ - **No `posthog-js` dependency, deliberately.** This package has five consuming
133
+ applications, and a dependency added here arrives in all of them on the next
134
+ version bump whether they want it or not. A shared component library is the
135
+ wrong place to decide that a product ships an analytics SDK. The host passes
136
+ in the client it already created;`scCreatePostHogReporter` accepts anything
137
+ with a `capture` method and emits PostHog's own `$exception` event, so reports
138
+ land in its error tracking rather than a bespoke event with no view.
139
+ - **A missing reference is a real answer.** A 502 from the edge never reached the
140
+ application, so there is no trace to point at. Showing an invented id sends
141
+ whoever reads it hunting for something that does not exist.
142
+ - **Reporting cannot cause a second failure.** The `reporter` call is wrapped in
143
+ its own try/catch and its errors are swallowed.
144
+ - **The reference is `user-select: all`.** The one thing a person is expected to
145
+ do with this surface is copy that string.
146
+ - **`prompt()` is used for the note.** It is synchronous and unstyled, and the
147
+ trade is deliberate: a custom modal inside an error boundary is more code
148
+ running in a subtree that has already proven it can crash.
149
+
150
+ ## In the wild
151
+
152
+ **No host render site found** — this component is new in `@streamoid/ui@0.6.48`
153
+ and nothing consumes it yet. The first will be `unified-admin-dashboard`, whose
154
+ `utils/request.js` already annotates failures with the `errorRef` this reads.
155
+
156
+ ## Related
157
+
158
+ - `scGetErrorRef(error)` — the reference off an annotated error, exported
159
+ alongside for code that needs it outside a boundary.
160
+ - `scCreatePostHogReporter(client, { service })` — the PostHog adapter.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@streamoid/ui",
3
- "count": 126,
3
+ "count": 127,
4
4
  "components": {
5
5
  "ScAccess": {
6
6
  "doc": "ScAccess.md",
@@ -1073,6 +1073,37 @@
1073
1073
  "alsoExports": [],
1074
1074
  "exported": true
1075
1075
  },
1076
+ "ScErrorBoundary": {
1077
+ "doc": "ScErrorBoundary.md",
1078
+ "source": "src/SC-ErrorBoundary",
1079
+ "category": "overlays",
1080
+ "status": "stable",
1081
+ "renders": "div[role=\"alert\"]",
1082
+ "summary": "The only place a white screen can be observed.",
1083
+ "reachForWhen": "you are wrapping an app, a route, or any subtree whose crash would otherwise blank the page.",
1084
+ "tags": [
1085
+ "error",
1086
+ "boundary",
1087
+ "crash",
1088
+ "white-screen",
1089
+ "report",
1090
+ "exception",
1091
+ "telemetry",
1092
+ "posthog"
1093
+ ],
1094
+ "related": [
1095
+ "ScBadges",
1096
+ "ScToast"
1097
+ ],
1098
+ "doNotConfuseWith": [
1099
+ "ScBadges",
1100
+ "ScToast"
1101
+ ],
1102
+ "requiredProps": [],
1103
+ "usedBy": [],
1104
+ "alsoExports": [],
1105
+ "exported": true
1106
+ },
1076
1107
  "ScGoogleSignIn": {
1077
1108
  "doc": "ScGoogleSignIn.md",
1078
1109
  "source": "src/SC-Google sign in",