@mushi-mushi/web 1.21.1 → 1.22.1
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.
- package/README.md +134 -403
- package/dist/index.cjs +77 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +78 -4
- package/dist/index.js.map +1 -1
- package/dist/mushi.loader.global.js +409 -409
- package/dist/mushi.loader.global.js.map +1 -1
- package/package.json +11 -12
package/README.md
CHANGED
|
@@ -2,278 +2,180 @@
|
|
|
2
2
|
|
|
3
3
|
> **Your AI wrote it. Mushi tells you why it broke.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Framework-agnostic browser SDK for [Mushi Mushi](https://www.npmjs.com/package/mushi-mushi) — an embeddable bug-reporting widget that captures a screenshot, the route, the user's note, and the last few seconds of console + network activity, then hands you a plain-English diagnosis in your editor. Renders inside a Shadow DOM, so your CSS never leaks in or out.
|
|
6
6
|
|
|
7
|
-
> **One-command setup:** `npx mushi-mushi` installs this package for vanilla-JS apps (or alongside
|
|
7
|
+
> **One-command setup:** `npx mushi-mushi` installs this package for vanilla-JS apps (or alongside a framework SDK).
|
|
8
8
|
>
|
|
9
|
-
> **Framework SDKs:** [`@mushi-mushi/react`](https://npmjs.com/package/@mushi-mushi/react) (Next.js / React) · [`@mushi-mushi/vue`](https://npmjs.com/package/@mushi-mushi/vue)
|
|
10
|
-
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- On-device pre-filter (blocks spam before server submission)
|
|
20
|
-
- Client-side rate limiting (token bucket self-throttle)
|
|
21
|
-
- Light/dark theme with auto-detection (`prefers-color-scheme`)
|
|
22
|
-
- **Trigger modes** (0.6+) — `auto` / `edge-tab` / `attach` (bring-your-own-button) / `manual` / `hidden`, plus `smartHide`, `hideOnSelector`, `hideOnRoutes`, configurable `inset` and `respectSafeArea`
|
|
23
|
-
- **Runtime trigger APIs** — `Mushi.show()`, `Mushi.hide()`, `Mushi.attachTo(selector)`, `Mushi.setTrigger(mode)`, `Mushi.openWith(category)`
|
|
24
|
-
- **Widget anchor** (0.9+) — `widget.anchor` accepts raw CSS (including `var()` and `env()`) so the launcher honours your app shell's tab bars, docks, mini-players, and cookie banners without Shadow-DOM patching
|
|
25
|
-
- **Presets** (0.9+) — `preset: 'production-calm' | 'beta-loud' | 'internal-debug' | 'manual-only'` flips a coherent bundle of widget / capture / proactive defaults so prod apps stay quiet and internal builds stay loud
|
|
26
|
-
- **Proactive triggers** — rage click, long task, API cascade failure detection
|
|
27
|
-
- **Report fatigue prevention** — session limits, cooldowns, permanent suppression
|
|
28
|
-
- **Privacy controls** (0.9.1+) — `privacy.maskSelectors`, `privacy.blockSelectors`, `privacy.allowUserRemoveScreenshot` for selector-level screenshot redaction and a one-tap "Remove screenshot" button in the panel
|
|
29
|
-
- **Repro timeline** (0.10+) — auto-captures route changes, clicks, and SDK lifecycle into a normalised `MushiReport.timeline`; pair with `Mushi.setScreen({ name, route, feature })` for screen-level grouping in the admin
|
|
30
|
-
- **Session replay** (1.11+) — opt-in `capture.replay: 'rrweb' | 'lite' | 'sentry' | 'off'` records a rolling buffer that attaches to the report on submit. rrweb masks all text and inputs by default, records continuously from init, and trims while preserving the most recent full snapshot so replays stay playable. Default `'off'`
|
|
31
|
-
- **Screenshot annotation** (1.11+) — a "Mark up" button in the panel opens an interactive overlay (highlight / blur / arrow) so reporters can circle the problem and redact sensitive regions before submitting
|
|
32
|
-
- **Screenshot preview & consent** (1.19+) — the details step renders the attached screenshot as a visible `<img>` preview (not just a checkmark label) with a **Remove** control and a configurable privacy caption (`widget.screenshotSensitiveHint`: `true` = localized default, `string` = custom copy, `false` = hide caption). Preview stays in sync through the annotate flow. See [`docs/SDK_SCREENSHOT_PREVIEW.md`](../../docs/SDK_SCREENSHOT_PREVIEW.md)
|
|
33
|
-
- **Payload size guard** (1.11+) — reports are size-checked client-side; oversized payloads are progressively degraded (drop replay buffer → drop screenshot) and dropped with a `report:failed` event if still too large, so a single large report can never wedge the offline queue
|
|
34
|
-
- **Two-way replies** (0.11+) — the panel ships a "Your reports" view that polls comments authored by the dev team and lets the reporter reply, all signed with HMAC against the public API key (no auth user required)
|
|
35
|
-
- **Passive inventory discovery** (0.12+) — opt-in `capture.discoverInventory` ships throttled, PII-free observations (route template, page title, `[data-testid]` values, recent fetch paths, query-param **keys** only, sha256 of user/session id) to `POST /v1/sdk/discovery`. The Mushi server aggregates them into a 30-day `discovery_observed_inventory` view and Claude Sonnet drafts a first-pass `inventory.yaml` proposal you can accept on `/inventory ▸ Discovery`. See `MushiDiscoverInventoryConfig` in [`@mushi-mushi/core`](../core)
|
|
36
|
-
- **SDK observability** (1.0+) — Sentry-style breadcrumb buffer, sticky tags, and a structured `Mushi.captureException(err)` that auto-attaches them. `installAutoBreadcrumbs()` ships route changes, `console.error/warn`, and `[data-testid]` clicks for free. PII is scrubbed from breadcrumb messages and tag string values at report-snapshot time, before anything leaves the browser
|
|
37
|
-
- **Sentry handshake v2** (1.0+) — auto-detects `@sentry/browser` v7 / v8 / v9 and captures the full active scope (`eventId`, `replayId`, `traceId`, `spanId`, `transaction`, `release`, `environment`, `user`, tags, breadcrumbs, issue URL) into `MushiReport.sentryContext`. Tags every Sentry event with `mushi.report_id`, so the admin's report drawer can deep-link `Open in Sentry` and Sentry's issue page can deep-link back into Mushi
|
|
38
|
-
- **SDK identity & freshness** (0.8+) — every report ships `sdkPackage` + `sdkVersion`; the widget polls `/v1/sdk/latest-version` and surfaces an outdated banner (configurable via `widget.outdatedBanner`)
|
|
39
|
-
- **Self-noise filters** (0.7.1+) — internal Mushi requests are tagged with `X-Mushi-Internal` and excluded from network capture + `apiCascade`; configurable `capture.ignoreUrls` and `proactive.apiCascade.ignoreUrls` for host-app endpoints you also don't want counted
|
|
40
|
-
- **`Mushi.diagnose()`** (0.7.1+) — one-call CSP / runtime-config / capture / widget health check (also runs without an init for pre-install smoke tests)
|
|
41
|
-
- Keyboard-first: `Esc` to close, `⌘/Ctrl + Enter` to submit, focus-trapped panel
|
|
42
|
-
- Honours `prefers-reduced-motion` (animations collapse to instant)
|
|
43
|
-
|
|
44
|
-
## Design language — "Mushi Mushi Editorial"
|
|
45
|
-
|
|
46
|
-
The widget is intentionally not a generic SaaS chatbot. The visual system is
|
|
47
|
-
defined in [`src/styles.ts`](./src/styles.ts) and uses:
|
|
48
|
-
|
|
49
|
-
- **Paper + sumi ink** — warm washi cream surface (`#F8F4ED`), deep ink type
|
|
50
|
-
(`#0E0D0B`), and a subtle paper grain. No flat white modal.
|
|
51
|
-
- **Vermillion 朱** (`#E03C2C`) — single signature accent, used as a hanko
|
|
52
|
-
stamp colour for the active state, focus underline, submit button, and the
|
|
53
|
-
success-step 朱印 ring.
|
|
54
|
-
- **System serif display** — Iowan Old Style → Palatino → Georgia stack for
|
|
55
|
-
headings. Pure system fonts: zero web-font fetch, zero FOUT.
|
|
56
|
-
- **Mono metadata** — `ui-monospace` for the `01 / 03` step ledger and
|
|
57
|
-
receipt timestamp, evoking a printer's contents page.
|
|
58
|
-
- **Rule lines, not boxes** — categories render as an editorial contents
|
|
59
|
-
list with 1px hairline separators.
|
|
60
|
-
|
|
61
|
-
All design tokens are named by **material** (`paper`, `ink`, `rule`,
|
|
62
|
-
`vermillion`) rather than role (`primary`, `secondary`) so the palette is
|
|
63
|
-
hard to dilute via a generic rename later.
|
|
64
|
-
|
|
65
|
-
## Contents
|
|
66
|
-
|
|
67
|
-
### Proactive Manager (`proactive-manager.ts`)
|
|
68
|
-
|
|
69
|
-
Controls report prompt frequency to prevent fatigue:
|
|
70
|
-
- `maxProactivePerSession` (default 2) — cap per browser session
|
|
71
|
-
- `dismissCooldownHours` (default 24) — suppress after dismissal
|
|
72
|
-
- `suppressAfterDismissals` (default 3) — permanently disable after N consecutive dismissals
|
|
73
|
-
- Smart dedup — same trigger type not shown twice per session
|
|
74
|
-
|
|
75
|
-
### Proactive Triggers (`proactive-triggers.ts`)
|
|
76
|
-
|
|
77
|
-
Auto-detects conditions that should prompt the user:
|
|
78
|
-
- **Rage click** — 3+ clicks in < 500ms on same element
|
|
79
|
-
- **Long task** — > 5s main thread block (PerformanceObserver)
|
|
80
|
-
- **API cascade** — 3+ failed requests in 10s window
|
|
81
|
-
- **Error boundary** — global `window.error` and `unhandledrejection` events (opt-in via `errorBoundary: true`)
|
|
82
|
-
|
|
83
|
-
Each trigger respects its config flag — set `rageClick: false` to disable rage click detection, etc.
|
|
84
|
-
|
|
85
|
-
## Known Limitations
|
|
86
|
-
|
|
87
|
-
**Screenshot capture** uses canvas/SVG `foreignObject` serialization. This does not work with cross-origin iframes, tainted `<canvas>` elements, or pages with strict CSP. Best-effort on single-origin SPAs.
|
|
88
|
-
|
|
89
|
-
## Bundle Size
|
|
90
|
-
|
|
91
|
-
~7 KB brotli, enforced at **80 KB gzipped** (105 KB uncompressed) via `size-limit` in CI — budget raised for the 2026 editorial widget refresh + screenshot preview/consent surface + verified-identity display, `screenshotProvider` hook, and the widget theme-token unification (`getWidgetThemeVars` / `build-widget-theme`). Requires `@mushi-mushi/core` as a dependency (not bundled inline). The `./test-utils` entry is a separate artifact and is never pulled into production bundles.
|
|
92
|
-
|
|
93
|
-
## Quick Start
|
|
9
|
+
> **Framework SDKs:** [`@mushi-mushi/react`](https://npmjs.com/package/@mushi-mushi/react) (Next.js / React) · [`@mushi-mushi/vue`](https://npmjs.com/package/@mushi-mushi/vue) · [`@mushi-mushi/svelte`](https://npmjs.com/package/@mushi-mushi/svelte) · [`@mushi-mushi/angular`](https://npmjs.com/package/@mushi-mushi/angular) · [`@mushi-mushi/react-native`](https://npmjs.com/package/@mushi-mushi/react-native) · [`@mushi-mushi/capacitor`](https://npmjs.com/package/@mushi-mushi/capacitor)
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @mushi-mushi/web
|
|
15
|
+
# or: npx mushi-mushi
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick start
|
|
94
19
|
|
|
95
20
|
```typescript
|
|
96
21
|
import { Mushi } from '@mushi-mushi/web';
|
|
97
22
|
|
|
98
23
|
Mushi.init({
|
|
99
|
-
projectId: 'proj_xxx',
|
|
100
|
-
apiKey: '
|
|
24
|
+
projectId: 'proj_xxx', // UUID from Admin → Projects
|
|
25
|
+
apiKey: 'mushi_xxx', // report:write key from Admin → Settings → API Keys
|
|
101
26
|
widget: { position: 'bottom-right', theme: 'auto' },
|
|
102
27
|
capture: { console: true, network: true, screenshot: 'on-report' },
|
|
103
28
|
});
|
|
104
29
|
```
|
|
105
30
|
|
|
106
|
-
|
|
31
|
+
That's the whole integration. A floating 🐛 launcher appears; a report is one click away.
|
|
107
32
|
|
|
108
|
-
|
|
109
|
-
menu, settings page, or beta banner. Mushi will not inject any UI of its own.
|
|
33
|
+
## What you get
|
|
110
34
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
trigger: 'attach',
|
|
117
|
-
attachToSelector: '[data-mushi-feedback]',
|
|
118
|
-
},
|
|
119
|
-
});
|
|
35
|
+
- **Shadow-DOM widget** — full CSS isolation, light/dark auto-theme, keyboard-first (`Esc` / `⌘+Enter`), honours `prefers-reduced-motion`.
|
|
36
|
+
- **Capture** — screenshot, console ring buffer, network (fetch interceptor), Web Vitals, and a repro timeline of routes + clicks.
|
|
37
|
+
- **Resilient by default** — IndexedDB offline queue with auto-sync, on-device spam pre-filter, client-side rate limiting, and a payload-size guard that degrades gracefully instead of wedging the queue.
|
|
38
|
+
- **Never blocks your UI** — the host element is zero-sized with `pointer-events: none`; only the visible controls opt back in. Verify at runtime with `Mushi.diagnose()`.
|
|
39
|
+
- **Privacy-first** — selector-level screenshot masking/blocking, a one-tap "Remove screenshot" control, and a built-in PII scrubber.
|
|
120
40
|
|
|
121
|
-
|
|
122
|
-
mushi.hide();
|
|
123
|
-
```
|
|
41
|
+
## Trigger modes
|
|
124
42
|
|
|
125
|
-
|
|
43
|
+
Choose where and when the launcher shows — `auto`, `edge-tab`, `attach` (bring your own button), `manual`, or `hidden` — plus viewport-aware `smartHide`, route/selector suppression, and `anchor` CSS that tracks your app shell's tab bars or mini-players.
|
|
126
44
|
|
|
127
45
|
```typescript
|
|
128
|
-
Mushi.
|
|
46
|
+
// Bring your own launcher — Mushi injects no UI of its own.
|
|
47
|
+
const mushi = Mushi.init({
|
|
129
48
|
projectId: 'proj_xxx',
|
|
130
49
|
apiKey: 'mushi_xxx',
|
|
131
|
-
widget: {
|
|
132
|
-
trigger: 'auto',
|
|
133
|
-
smartHide: { onMobile: 'edge-tab', onScroll: 'shrink', onIdleMs: 900 },
|
|
134
|
-
inset: { bottom: 96, right: 20 },
|
|
135
|
-
hideOnSelector: '[data-fullscreen-player]',
|
|
136
|
-
hideOnRoutes: ['/checkout/payment'],
|
|
137
|
-
respectSafeArea: true,
|
|
138
|
-
},
|
|
50
|
+
widget: { trigger: 'attach', attachToSelector: '[data-mushi-feedback]' },
|
|
139
51
|
});
|
|
52
|
+
mushi.attachTo('#support-menu-feedback');
|
|
140
53
|
```
|
|
141
54
|
|
|
142
|
-
|
|
143
|
-
full posture matrix (`auto` / `edge-tab` / `attach` / `manual` / `hidden`).
|
|
55
|
+
→ Full posture matrix in [Trigger modes](https://kensaur.us/mushi-mushi/docs/concepts/trigger-modes). Coherent defaults via [SDK presets](https://kensaur.us/mushi-mushi/docs/sdks/presets) (`production-calm` / `beta-loud` / `internal-debug` / `manual-only`).
|
|
144
56
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
Proactive triggers are wired into `Mushi.init()` automatically when `config.proactive` is provided. The SDK opens the widget when a trigger fires, gated by fatigue prevention:
|
|
57
|
+
<details>
|
|
58
|
+
<summary><b>Proactive triggers</b> — open the widget on rage clicks, long tasks, or API cascades</summary>
|
|
148
59
|
|
|
149
60
|
```typescript
|
|
150
61
|
Mushi.init({
|
|
151
62
|
projectId: 'proj_xxx',
|
|
152
|
-
apiKey: '
|
|
63
|
+
apiKey: 'mushi_xxx',
|
|
153
64
|
proactive: {
|
|
154
65
|
rageClick: true,
|
|
155
66
|
longTask: true,
|
|
156
67
|
apiCascade: true,
|
|
157
|
-
errorBoundary: true,
|
|
158
|
-
cooldown: {
|
|
159
|
-
maxProactivePerSession: 2,
|
|
160
|
-
dismissCooldownHours: 24,
|
|
161
|
-
suppressAfterDismissals: 3,
|
|
162
|
-
},
|
|
68
|
+
errorBoundary: true, // catch global error / unhandledrejection
|
|
69
|
+
cooldown: { maxProactivePerSession: 2, dismissCooldownHours: 24, suppressAfterDismissals: 3 },
|
|
163
70
|
},
|
|
164
71
|
});
|
|
165
72
|
```
|
|
166
73
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
```typescript
|
|
170
|
-
import { createProactiveManager, setupProactiveTriggers } from '@mushi-mushi/web';
|
|
74
|
+
Each trigger respects its config flag (set `rageClick: false` to disable). Fatigue prevention (session limits, cooldowns, permanent suppression) is always on.
|
|
75
|
+
</details>
|
|
171
76
|
|
|
172
|
-
|
|
77
|
+
<details>
|
|
78
|
+
<summary><b>Privacy & screenshot redaction</b></summary>
|
|
173
79
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
80
|
+
```typescript
|
|
81
|
+
Mushi.init({
|
|
82
|
+
projectId: 'proj_xxx',
|
|
83
|
+
apiKey: 'mushi_xxx',
|
|
84
|
+
privacy: {
|
|
85
|
+
maskSelectors: ['[data-private]', 'input'], // painted over before serialisation
|
|
86
|
+
blockSelectors: ['[data-payment]', '[data-auth-token]'], // removed entirely
|
|
87
|
+
allowUserRemoveScreenshot: true, // one-tap "Remove screenshot" in panel
|
|
179
88
|
},
|
|
180
89
|
});
|
|
181
90
|
```
|
|
182
91
|
|
|
183
|
-
|
|
92
|
+
The details step renders the attached screenshot as a visible preview (not just a checkmark) with a **Remove** control and a configurable privacy caption (`widget.screenshotSensitiveHint`). A "Mark up" overlay lets reporters highlight / blur / arrow before submitting.
|
|
93
|
+
</details>
|
|
184
94
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
or a flaky local Supabase stack can no longer make Mushi report on Mushi:
|
|
95
|
+
<details>
|
|
96
|
+
<summary><b>Session replay</b> — opt-in rolling buffer attached on submit</summary>
|
|
188
97
|
|
|
189
98
|
```typescript
|
|
190
99
|
Mushi.init({
|
|
191
100
|
projectId: 'proj_xxx',
|
|
192
101
|
apiKey: 'mushi_xxx',
|
|
193
|
-
// 'auto' (default) skips the runtime-config fetch on localhost endpoints —
|
|
194
|
-
// pass `true` to force it everywhere, `false` to disable entirely.
|
|
195
|
-
runtimeConfig: 'auto',
|
|
196
102
|
capture: {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
enabled: true,
|
|
203
|
-
ignoreUrls: ['https://feature-flags.example.com'],
|
|
204
|
-
},
|
|
103
|
+
// 'rrweb' — full DOM replay (lazy-loaded; text + inputs masked by default)
|
|
104
|
+
// 'lite' — dependency-free coarse fallback
|
|
105
|
+
// 'sentry'— reuse an installed @sentry/replay session
|
|
106
|
+
// 'off' — default
|
|
107
|
+
replay: 'rrweb',
|
|
205
108
|
},
|
|
206
109
|
});
|
|
207
|
-
|
|
208
|
-
const health = await Mushi.diagnose();
|
|
209
|
-
// → { apiEndpointReachable, cspAllowsEndpoint, widgetMounted, shadowDomAvailable,
|
|
210
|
-
// dialogSupported, runtimeConfigLoaded, captureScreenshotAvailable,
|
|
211
|
-
// captureNetworkIntercepting, sdkVersion,
|
|
212
|
-
// widgetHostPointerSafe, widgetHostBounds, widgetSuppressed, bannerRendered }
|
|
213
|
-
//
|
|
214
|
-
// widgetHostPointerSafe — true when the host element is zero-sized and
|
|
215
|
-
// pointer-events:none (i.e. the SDK cannot block any host-app touch targets).
|
|
216
|
-
// widgetSuppressed — true when hidden by hideOnSelector / hideOnRoutes / hide().
|
|
217
|
-
// bannerRendered — true when trigger:'banner' and banner is visible.
|
|
218
110
|
```
|
|
219
111
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
of accidentally booting the widget.
|
|
112
|
+
Records continuously from init (so you capture the moments *before* the report), trimmed to a rolling window. Already on Sentry Replay? See [coexistence](https://kensaur.us/mushi-mushi/docs/sdks/sentry-replay-coexistence).
|
|
113
|
+
</details>
|
|
223
114
|
|
|
224
|
-
|
|
115
|
+
<details>
|
|
116
|
+
<summary><b>Power-user APIs</b> — identify, tags, breadcrumbs, structured exception capture</summary>
|
|
225
117
|
|
|
226
|
-
|
|
227
|
-
|
|
118
|
+
```typescript
|
|
119
|
+
const mushi = Mushi.init({ projectId: 'proj_xxx', apiKey: 'mushi_xxx' });
|
|
228
120
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
121
|
+
mushi.identify('usr_42', { email: 'aya@example.com', segment: 'beta' });
|
|
122
|
+
mushi.setTags({ plan: 'pro', region: 'apac' });
|
|
123
|
+
mushi.addBreadcrumb({ category: 'business', message: 'cart.checkout_started', data: { itemCount: 3 } });
|
|
232
124
|
|
|
233
|
-
|
|
234
|
-
|
|
125
|
+
try {
|
|
126
|
+
await runCheckout();
|
|
127
|
+
} catch (err) {
|
|
128
|
+
// Normalises any throw, attaches breadcrumbs + sticky tags + Sentry context.
|
|
129
|
+
mushi.captureException(err, { level: 'error', tags: { surface: 'checkout' } });
|
|
130
|
+
}
|
|
131
|
+
```
|
|
235
132
|
|
|
236
|
-
|
|
133
|
+
`installAutoBreadcrumbs()` ships route changes, `console.error/warn`, and `[data-testid]` clicks for free. PII is scrubbed before anything leaves the browser. Auto-detects `@sentry/browser` v7–v9 and captures the active scope into `MushiReport.sentryContext`, with deep-links both ways.
|
|
134
|
+
</details>
|
|
237
135
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
console.assert(health.widgetHostPointerSafe, 'Mushi host is blocking UI!');
|
|
241
|
-
```
|
|
136
|
+
<details>
|
|
137
|
+
<summary><b>Two-way replies & Rewards</b> — let reporters follow up and earn points, no login</summary>
|
|
242
138
|
|
|
243
|
-
|
|
139
|
+
The widget's "Your reports" tab lets reporters see team replies and respond, signed via HMAC against the public API key (no auth user required): `mushi.listMyReports()`, `mushi.listMyComments(id)`, `mushi.replyToReport(id, text)`. Call `mushi.identify()` and add a `rewards` block to track activity, tiers, and points. See [Rewards & contributor identity](https://kensaur.us/mushi-mushi/docs/concepts/rewards).
|
|
140
|
+
</details>
|
|
244
141
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
both the trigger button and the banner** (they are unified — no surface leaks through):
|
|
142
|
+
<details>
|
|
143
|
+
<summary><b>Runtime control & self-noise filters</b> — imperative APIs and CSP-safe defaults</summary>
|
|
248
144
|
|
|
249
145
|
```typescript
|
|
250
|
-
Mushi.init({
|
|
146
|
+
const mushi = Mushi.init({
|
|
251
147
|
projectId: 'proj_xxx',
|
|
252
148
|
apiKey: 'mushi_xxx',
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
},
|
|
149
|
+
// 'auto' (default) skips the runtime-config fetch on localhost endpoints;
|
|
150
|
+
// pass `true` to force everywhere, `false` to disable entirely.
|
|
151
|
+
runtimeConfig: 'auto',
|
|
152
|
+
capture: { network: true, ignoreUrls: [/\/api\/internal\//] },
|
|
153
|
+
proactive: { apiCascade: { enabled: true, ignoreUrls: ['https://feature-flags.example.com'] } },
|
|
259
154
|
});
|
|
155
|
+
|
|
156
|
+
mushi.show();
|
|
157
|
+
mushi.hide();
|
|
158
|
+
mushi.setTrigger('manual'); // switch posture at runtime
|
|
159
|
+
mushi.openWith('bug'); // open straight into a category
|
|
160
|
+
mushi.attachTo('#support-menu'); // bind the launcher to your element
|
|
260
161
|
```
|
|
261
162
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
on every hide path.
|
|
163
|
+
Internal Mushi requests are tagged `X-Mushi-Internal` and excluded from network capture + `apiCascade`, so an unconfigured CSP or a flaky local Supabase stack can never make Mushi report on Mushi. For advanced composition, `createProactiveManager()` and `setupProactiveTriggers()` are exported so you can wire friction detection into your own UI.
|
|
164
|
+
</details>
|
|
265
165
|
|
|
266
|
-
>
|
|
267
|
-
>
|
|
268
|
-
> of Chromium-based WebViews still route touch events to `fixed` overlay elements that
|
|
269
|
-
> sit at a certain z-index. Use `hideOnSelector` or `Mushi.hide()` for the safest
|
|
270
|
-
> experience in native shells.
|
|
166
|
+
<details>
|
|
167
|
+
<summary><b>Repro timeline</b> — <code>setScreen()</code> and the "what happened before" trail</summary>
|
|
271
168
|
|
|
272
|
-
|
|
169
|
+
```typescript
|
|
170
|
+
const mushi = Mushi.init({ /* ... */ });
|
|
171
|
+
mushi.setScreen({ name: 'Chat', route: '/chat', feature: 'roleplay' });
|
|
172
|
+
```
|
|
273
173
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
174
|
+
The SDK auto-records route changes (`pushState` / `popstate` / `hashchange`), clicks (with selector + text snippet), and screen events into a 120-entry ring buffer, shipped as `MushiReport.timeline`. The admin renders it as a chronological "what happened before the report" card.
|
|
175
|
+
</details>
|
|
176
|
+
|
|
177
|
+
<details>
|
|
178
|
+
<summary><b>Rich banner layout</b> — <code>trigger: 'banner'</code> with remote-driven copy</summary>
|
|
277
179
|
|
|
278
180
|
```typescript
|
|
279
181
|
Mushi.init({
|
|
@@ -283,252 +185,81 @@ Mushi.init({
|
|
|
283
185
|
trigger: 'banner',
|
|
284
186
|
bannerConfig: {
|
|
285
187
|
variant: 'brand', // 'neon' | 'brand' | 'subtle'
|
|
286
|
-
position: 'top',
|
|
188
|
+
position: 'top',
|
|
287
189
|
message: 'Mushi is in beta — spotted something off? Tell us.',
|
|
288
190
|
label: 'Beta', // pill before the message; `false` hides it
|
|
289
191
|
bugCta: '🐛 Report a bug',
|
|
290
192
|
featureCta: true,
|
|
291
|
-
links: [
|
|
292
|
-
{ label: 'My submissions', href: 'https://app.example.com/feedback' },
|
|
293
|
-
{ label: 'Request a feature', featureRequest: true }, // opens widget in feature mode
|
|
294
|
-
],
|
|
193
|
+
links: [{ label: 'My submissions', href: 'https://app.example.com/feedback' }],
|
|
295
194
|
},
|
|
296
195
|
},
|
|
297
196
|
});
|
|
298
197
|
```
|
|
299
198
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
- `links[].href` opens in a new tab with `rel="noopener noreferrer"`; omit
|
|
303
|
-
`href` and set `featureRequest: true` to open the widget instead.
|
|
304
|
-
- `message` and `label` can also be driven remotely per-project from the
|
|
305
|
-
dashboard runtime config (`bannerMessage` / `bannerLabel`), so you can change
|
|
306
|
-
the copy without a deploy. `links` are local-config only.
|
|
307
|
-
- Without `message`, the banner keeps the original compact button-only layout —
|
|
308
|
-
existing integrations are unchanged.
|
|
199
|
+
All banner text renders via `textContent` (never HTML), so CMS-sourced copy can't inject markup. `message` and `label` can also be driven remotely per project from the dashboard runtime config — change copy without a deploy.
|
|
200
|
+
</details>
|
|
309
201
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
```typescript
|
|
313
|
-
Mushi.init({
|
|
314
|
-
projectId: 'proj_xxx',
|
|
315
|
-
apiKey: 'mushi_xxx',
|
|
316
|
-
// production-calm = manual trigger, screenshot only on report, no proactive prompts
|
|
317
|
-
// beta-loud = proactive triggers + console + network always on
|
|
318
|
-
// internal-debug = above + verbose debug + always-on screenshot
|
|
319
|
-
// manual-only = trigger only, every proactive surface off
|
|
320
|
-
preset: 'production-calm',
|
|
321
|
-
widget: {
|
|
322
|
-
// Raw CSS strings (including `var()` and `env()`) win over `position` /
|
|
323
|
-
// `inset` so the launcher tracks your app shell's tab bars or mini-player.
|
|
324
|
-
anchor: {
|
|
325
|
-
bottom: 'calc(var(--app-dock-h, 0px) + env(safe-area-inset-bottom))',
|
|
326
|
-
right: 'calc(0.75rem + env(safe-area-inset-right))',
|
|
327
|
-
},
|
|
328
|
-
brandFooter: true,
|
|
329
|
-
outdatedBanner: 'auto',
|
|
330
|
-
},
|
|
331
|
-
});
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
### Privacy and screenshot redaction
|
|
335
|
-
|
|
336
|
-
```typescript
|
|
337
|
-
Mushi.init({
|
|
338
|
-
projectId: 'proj_xxx',
|
|
339
|
-
apiKey: 'mushi_xxx',
|
|
340
|
-
privacy: {
|
|
341
|
-
maskSelectors: ['[data-private]', 'input', '.thai-answer-draft'],
|
|
342
|
-
blockSelectors: ['[data-payment]', '[data-auth-token]'],
|
|
343
|
-
allowUserRemoveScreenshot: true,
|
|
344
|
-
},
|
|
345
|
-
});
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
`maskSelectors` paints a solid block over matching elements before serialisation;
|
|
349
|
-
`blockSelectors` removes them entirely. `allowUserRemoveScreenshot` adds a
|
|
350
|
-
"Remove screenshot" affordance next to the attachment chip in the panel, so the
|
|
351
|
-
reporter can yank a screenshot they didn't realise contained sensitive data.
|
|
352
|
-
|
|
353
|
-
### Session replay (1.11+)
|
|
202
|
+
<details>
|
|
203
|
+
<summary><b>Passive inventory discovery</b> — opt-in, PII-free route observations</summary>
|
|
354
204
|
|
|
355
205
|
```typescript
|
|
356
206
|
Mushi.init({
|
|
357
207
|
projectId: 'proj_xxx',
|
|
358
208
|
apiKey: 'mushi_xxx',
|
|
359
209
|
capture: {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
210
|
+
discoverInventory: {
|
|
211
|
+
enabled: true,
|
|
212
|
+
throttleMs: 60_000,
|
|
213
|
+
routeTemplates: ['/practice/[id]', '/lessons/[slug]'],
|
|
214
|
+
},
|
|
365
215
|
},
|
|
366
216
|
});
|
|
367
217
|
```
|
|
368
218
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
window while preserving the most recent full snapshot — replays stay playable.
|
|
372
|
-
All text and inputs are masked by default. The events ride along on
|
|
373
|
-
`MushiReport.replayEvents`; the server only persists them when the project has
|
|
374
|
-
opted into replay storage. If a report grows too large, the replay buffer is the
|
|
375
|
-
first thing dropped (then the screenshot) before the report itself is ever
|
|
376
|
-
discarded — see **Payload size guard** above.
|
|
219
|
+
Ships throttled, PII-free observations (route template, page title, `[data-testid]` values, recent fetch paths, query-param **keys** only, hashed user/session id) to `POST /v1/sdk/discovery`. The server aggregates them and drafts a first-pass `inventory.yaml` you can accept in **/inventory ▸ Discovery**. See [Inventory & gates](https://kensaur.us/mushi-mushi/docs/concepts/inventory-and-gates).
|
|
220
|
+
</details>
|
|
377
221
|
|
|
378
|
-
|
|
222
|
+
## Host pass-through contract
|
|
379
223
|
|
|
380
|
-
|
|
381
|
-
const mushi = Mushi.init({ /* ... */ });
|
|
382
|
-
mushi.setScreen({ name: 'Chat', route: '/chat', feature: 'roleplay' });
|
|
383
|
-
```
|
|
384
|
-
|
|
385
|
-
The SDK auto-records `route` (initial + `pushState` / `popstate` / `hashchange`),
|
|
386
|
-
`click` (with selector + text snippet), and `screen` events into a 120-entry
|
|
387
|
-
ring buffer. Submissions ship the trail as `MushiReport.timeline` and the admin
|
|
388
|
-
console renders it as a chronological "what happened before the report" card on
|
|
389
|
-
`/reports/:id`.
|
|
390
|
-
|
|
391
|
-
### Power-user APIs (1.0+)
|
|
392
|
-
|
|
393
|
-
Once `Mushi.init()` has resolved (cloud or self-hosted) the returned instance
|
|
394
|
-
exposes a Sentry-style observability surface that ships on every subsequent
|
|
395
|
-
report — without you having to plumb it through the report payload yourself:
|
|
224
|
+
Mushi never blocks your app's UI. The host element (`#mushi-mushi-widget`) is `position: fixed`, zero-sized, with `pointer-events: none` — only the visible controls opt back into `pointer-events: auto` inside the Shadow DOM. In native WebView shells (iOS WKWebView, some Android Chromium builds) where `pointer-events: none` isn't always honoured on fixed overlays, use `hideOnSelector` or `Mushi.hide()` during fullscreen flows. Verify at runtime:
|
|
396
225
|
|
|
397
226
|
```typescript
|
|
398
|
-
const
|
|
399
|
-
|
|
400
|
-
// Identify the active reporter (also sent to Sentry if @sentry/browser is loaded).
|
|
401
|
-
mushi.identify('usr_42', { email: 'aya@example.com', segment: 'beta' });
|
|
402
|
-
|
|
403
|
-
// Sticky scalar tags. Up to 64 keys; values are string | number | boolean.
|
|
404
|
-
mushi.setTag('feature', 'checkout-v2');
|
|
405
|
-
mushi.setTags({ plan: 'pro', region: 'apac', experiment: 'B' });
|
|
406
|
-
mushi.clearTag('experiment');
|
|
407
|
-
|
|
408
|
-
// Manual breadcrumbs — route changes / console.error / [data-testid] clicks
|
|
409
|
-
// are captured automatically by `installAutoBreadcrumbs`.
|
|
410
|
-
mushi.addBreadcrumb({
|
|
411
|
-
category: 'business',
|
|
412
|
-
level: 'info',
|
|
413
|
-
message: 'cart.checkout_started',
|
|
414
|
-
data: { itemCount: 3, currency: 'JPY' },
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
// Structured exception capture. Accepts Error, string, plain object, null,
|
|
418
|
-
// or undefined — anything `try { } catch (e) { }` can land on. The SDK
|
|
419
|
-
// normalises the throw, attaches the breadcrumb buffer + sticky tags +
|
|
420
|
-
// Sentry context, and submits as a `bug` report.
|
|
421
|
-
try {
|
|
422
|
-
await runCheckout();
|
|
423
|
-
} catch (err) {
|
|
424
|
-
mushi.captureException(err, {
|
|
425
|
-
level: 'error',
|
|
426
|
-
tags: { surface: 'checkout' },
|
|
427
|
-
extras: { orderId: 'ord_123' },
|
|
428
|
-
});
|
|
429
|
-
}
|
|
227
|
+
const health = await Mushi.diagnose();
|
|
228
|
+
console.assert(health.widgetHostPointerSafe, 'Mushi host is blocking UI!');
|
|
430
229
|
```
|
|
431
230
|
|
|
432
|
-
|
|
433
|
-
`reports.tags` (jsonb, GIN-indexed), and `reports.sentry_trace_id` /
|
|
434
|
-
`sentry_release` / `sentry_environment` (text, btree-indexed) make the
|
|
435
|
-
admin's `/reports` page filterable by `tags @> '{feature: checkout-v2}'`,
|
|
436
|
-
`?trace=…`, `?release=…`, `?sentryEnv=…` in O(index-lookup) instead of an
|
|
437
|
-
O(full-scan) traversal of `custom_metadata`.
|
|
438
|
-
|
|
439
|
-
### Two-way replies (Your reports)
|
|
440
|
-
|
|
441
|
-
The widget mounts a "Your reports" tab that lists this reporter's history,
|
|
442
|
-
unread admin replies (with a count badge on the trigger), and a reply input.
|
|
443
|
-
Calls are signed with an HMAC over `projectId.timestamp.sha256(reporterToken)`
|
|
444
|
-
using the public API key as the secret, so no Supabase auth is required.
|
|
231
|
+
## Health check
|
|
445
232
|
|
|
446
233
|
```typescript
|
|
447
|
-
Mushi.
|
|
448
|
-
|
|
449
|
-
apiKey: 'mushi_xxx',
|
|
450
|
-
widget: { brandFooter: true, outdatedBanner: 'auto' },
|
|
451
|
-
});
|
|
234
|
+
const health = await Mushi.diagnose();
|
|
235
|
+
// → { apiEndpointReachable, cspAllowsEndpoint, widgetMounted, widgetHostPointerSafe, ... }
|
|
452
236
|
```
|
|
453
237
|
|
|
454
|
-
|
|
455
|
-
`GET /v1/reporter/reports/:id/comments`, `POST /v1/reporter/reports/:id/reply`.
|
|
456
|
-
The DB-side `report_comments_fanout_to_reporter` trigger creates a
|
|
457
|
-
`reporter_notifications` row whenever a `visible_to_reporter` admin comment
|
|
458
|
-
lands, so the unread count stays in sync without polling.
|
|
238
|
+
Runs **before** `Mushi.init()` too — call it from a debug console or installer wizard to surface CSP / endpoint problems with zero risk of booting the widget.
|
|
459
239
|
|
|
460
|
-
|
|
240
|
+
## Test utilities
|
|
461
241
|
|
|
462
|
-
|
|
463
|
-
Mushi.init({
|
|
464
|
-
projectId: 'proj_xxx',
|
|
465
|
-
apiKey: 'mushi_xxx',
|
|
466
|
-
capture: {
|
|
467
|
-
// `true` enables defaults (60s per-route throttle, heuristic
|
|
468
|
-
// route normalisation). Pass an object for fine-grained control.
|
|
469
|
-
discoverInventory: {
|
|
470
|
-
enabled: true,
|
|
471
|
-
throttleMs: 60_000,
|
|
472
|
-
// Optional — your framework's known route templates so we don't
|
|
473
|
-
// have to guess `/practice/abc-123` → `/practice/[id]`.
|
|
474
|
-
routeTemplates: ['/practice/[id]', '/lessons/[slug]'],
|
|
475
|
-
},
|
|
476
|
-
},
|
|
477
|
-
});
|
|
478
|
-
```
|
|
242
|
+
Deterministic Playwright / jsdom helpers, published as a separate entry-point so production bundles pay nothing for them:
|
|
479
243
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
```jsonc
|
|
483
|
-
{
|
|
484
|
-
"route": "/practice/[id]",
|
|
485
|
-
"page_title": "Practice — Glot.it",
|
|
486
|
-
"dom_summary": "…≤200 chars…",
|
|
487
|
-
"testids": ["practice-submit", "practice-hint"],
|
|
488
|
-
"network_paths": ["/api/practice/run", "/rest/v1/answers"],
|
|
489
|
-
"query_param_keys": ["lang"],
|
|
490
|
-
"user_id_hash": "sha256(…)",
|
|
491
|
-
"observed_at": "2026-05-04T12:00:00Z"
|
|
492
|
-
}
|
|
244
|
+
```ts
|
|
245
|
+
import { triggerBug, openReport, waitForQueueDrain, expectMushiReady } from '@mushi-mushi/web/test-utils';
|
|
493
246
|
```
|
|
494
247
|
|
|
495
|
-
|
|
496
|
-
hit **Generate proposal**, then **Accept** to write the LLM-drafted
|
|
497
|
-
`inventory.yaml` into the project. Nothing else changes about the SDK —
|
|
498
|
-
the discovery channel is independent of the bug-report widget and stays
|
|
499
|
-
quiet under `prefers-reduced-motion` / when the tab is hidden.
|
|
248
|
+
Every helper no-ops when `Mushi.getInstance()` returns `null`, so cloud-vs-local conditional-wiring tests don't need a branch.
|
|
500
249
|
|
|
501
|
-
##
|
|
250
|
+
## Known limitations
|
|
502
251
|
|
|
503
|
-
|
|
504
|
-
entry-point so production bundles pay nothing for them:
|
|
252
|
+
Screenshot capture uses canvas / SVG `foreignObject` serialization — it does not work with cross-origin iframes, tainted `<canvas>` elements, or pages with strict CSP. Best-effort on single-origin SPAs.
|
|
505
253
|
|
|
506
|
-
|
|
507
|
-
import { triggerBug, openReport, waitForQueueDrain } from '@mushi-mushi/web/test-utils';
|
|
508
|
-
```
|
|
254
|
+
## Bundle size
|
|
509
255
|
|
|
510
|
-
|
|
511
|
-
|------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
|
|
512
|
-
| `triggerBug(opts?)` | Submit a report bypassing the widget. Returns the server-assigned id. |
|
|
513
|
-
| `openReport(cat?)` | Open the widget programmatically without submitting. |
|
|
514
|
-
| `openMushiWidget(cat?)` | Alias for `openReport` — Playwright-friendly name for the dogfood contract suite. |
|
|
515
|
-
| `waitForQueueDrain` | Resolve once the offline queue is empty (number remaining at timeout). |
|
|
516
|
-
| `expectMushiReady(opts?)` | Resolve with a `MushiDiagnosticsResult` once the SDK is initialised and reachable. Fails if `apiEndpointReachable === false`. |
|
|
517
|
-
| `expectNoMushiSelfCascade()` | Run an action and assert no internal Mushi request fired the `api_cascade` proactive trigger. Catches CSP / runtime-config self-noise. |
|
|
518
|
-
|
|
519
|
-
Every helper no-ops when `Mushi.getInstance()` returns `null`, so
|
|
520
|
-
conditional-wiring tests (e.g. cloud vs local targets) don't need to
|
|
521
|
-
branch. For browser-context use in Playwright's `page.evaluate`, import
|
|
522
|
-
the SDK via the app's own bundle (`window.__mushi__` in dev builds) or
|
|
523
|
-
POST to `/v1/reports` directly — `page.evaluate` has no npm resolver in
|
|
524
|
-
the browser context.
|
|
256
|
+
~7 KB brotli, enforced at 80 KB gzipped (105 KB uncompressed) in CI. Requires `@mushi-mushi/core` (installed automatically, not bundled inline). The widget's visual system — washi paper, sumi ink, vermillion 朱 accent, system serif — lives in [`src/styles.ts`](./src/styles.ts).
|
|
525
257
|
|
|
526
258
|
## License
|
|
527
259
|
|
|
528
260
|
MIT
|
|
529
261
|
|
|
530
|
-
|
|
531
262
|
<!-- mushi-readme-stats-footer -->
|
|
532
263
|
---
|
|
533
264
|
|
|
534
|
-
<sub>Monorepo scale (June 2026):
|
|
265
|
+
<sub>Monorepo scale (June 2026): 51 edge functions · 298 SQL migrations · 13 outbound plugins · 11 inbound adapters · 19 pipeline agents. Canonical counts: <a href="https://github.com/kensaurus/mushi-mushi/blob/master/docs/stats.md">docs/stats.md</a> · <code>pnpm docs-stats</code></sub>
|