@mushi-mushi/web 1.27.0 → 1.29.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.
package/README.md CHANGED
@@ -30,6 +30,28 @@ Mushi.init({
30
30
 
31
31
  That's the whole integration. A floating 🐛 launcher appears; a report is one click away.
32
32
 
33
+ ### Same-origin tunnel (ad blockers)
34
+
35
+ Point ingest at a first-party proxy — the same pattern as Sentry `tunnel`.
36
+ Host APIs must allowlist host + project + `/v1/` (empty project list → 503).
37
+
38
+ ```typescript
39
+ Mushi.init({
40
+ projectId: '00000000-0000-0000-0000-000000000000',
41
+ apiKey: 'mushi_xxx',
42
+ tunnel: '/api/mushi-tunnel',
43
+ // Published SDKs that ignore `tunnel` still honor apiEndpoint:
44
+ apiEndpoint: '/api/mushi-tunnel',
45
+ ignoreErrors: ['ResizeObserver loop', /^Script error\.?$/],
46
+ denyUrls: [/chrome-extension:/i],
47
+ replaysOnErrorSampleRate: 0,
48
+ });
49
+ ```
50
+
51
+ `ignoreErrors` / `denyUrls` apply to **automatic** captures only. User widget
52
+ feedback always sends. Pagehide uses `fetch({ keepalive: true })`, then a
53
+ same-origin `sendBeacon` envelope the tunnel unwraps.
54
+
33
55
  ## Runtime config
34
56
 
35
57
  With `runtimeConfig: 'auto'` (default), the SDK fetches console settings from
@@ -105,20 +127,30 @@ The details step renders the attached screenshot as a visible preview (not just
105
127
  <details>
106
128
  <summary><b>Session replay</b> — opt-in rolling buffer attached on submit</summary>
107
129
 
130
+ ```bash
131
+ npm install rrweb # only for replay: 'rrweb' — your app installs it
132
+ ```
133
+
108
134
  ```typescript
109
135
  Mushi.init({
110
136
  projectId: 'proj_xxx',
111
137
  apiKey: 'mushi_xxx',
112
138
  capture: {
113
- // 'rrweb' — full DOM replay (lazy-loaded; text + inputs masked by default)
114
- // 'lite' — dependency-free coarse fallback
139
+ // 'rrweb' — full DOM replay (every text node and input masked)
140
+ // 'lite' — dependency-free, records clicks only
115
141
  // 'sentry'— reuse an installed @sentry/replay session
116
142
  // 'off' — default
117
143
  replay: 'rrweb',
144
+ // Hand the SDK your own import of rrweb.
145
+ rrweb: () => import('rrweb'),
118
146
  },
119
147
  });
120
148
  ```
121
149
 
150
+ `replay: 'rrweb'` needs `rrweb` in your app (`npm install rrweb`). It is an optional peer dependency, so apps that don't record replay don't download it.
151
+
152
+ `rrweb: () => import('rrweb')` is what makes `'rrweb'` mode work in a bundled app. The SDK cannot import rrweb itself: a published package's `import('rrweb')` is invisible to your bundler, so rrweb never reaches your build. An import written in your code is one your bundler sees, and it code-splits rrweb into its own chunk that loads only for sessions sampled into replay. Without the loader the SDK tries a global `rrweb` (the UMD build from a `<script>` tag), then a bare `import('rrweb')` (which resolves only under an import map); if neither works, it records clicks only (`'lite'`) and warns once in the console. The `rrweb` option ships in `@mushi-mushi/web` 1.29.
153
+
122
154
  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).
123
155
  </details>
124
156
 
@@ -130,13 +162,13 @@ const mushi = Mushi.init({ projectId: 'proj_xxx', apiKey: 'mushi_xxx' });
130
162
 
131
163
  mushi.identify('usr_42', { email: 'aya@example.com', segment: 'beta' });
132
164
  mushi.setTags({ plan: 'pro', region: 'apac' });
133
- mushi.addBreadcrumb({ category: 'business', message: 'cart.checkout_started', data: { itemCount: 3 } });
165
+ mushi.addBreadcrumb({ category: 'custom', level: 'info', message: 'cart.checkout_started', data: { itemCount: 3 } });
134
166
 
135
167
  try {
136
168
  await runCheckout();
137
169
  } catch (err) {
138
170
  // Normalises any throw, attaches breadcrumbs + sticky tags + Sentry context.
139
- mushi.captureException(err, { level: 'error', tags: { surface: 'checkout' } });
171
+ mushi.captureException(err, { severity: 'high', tags: { surface: 'checkout' } });
140
172
  }
141
173
  ```
142
174
 
@@ -149,6 +181,25 @@ try {
149
181
  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).
150
182
  </details>
151
183
 
184
+ <details>
185
+ <summary><b>Product analytics</b> — <code>track()</code>, funnels, paths and people in the same console</summary>
186
+
187
+ ```typescript
188
+ const mushi = Mushi.init({
189
+ projectId: 'proj_xxx',
190
+ apiKey: 'mushi_xxx',
191
+ // Optional. Defaults: enabled, consent 'implied', DNT/GPC respected, sampleRate 1.
192
+ analytics: { consent: 'required' },
193
+ });
194
+
195
+ mushi.setConsent('granted'); // only needed with consent: 'required'
196
+ mushi.track('checkout_started', { plan: 'pro' }); // snake_case names, flat properties
197
+ mushi.identify('usr_42'); // stitches earlier anonymous events to the person
198
+ ```
199
+
200
+ Events batch to `POST /v1/sdk/events` (20 per batch or every 5 s, flushed on `pagehide`, spilled to `localStorage` when offline). Names must match `^[a-z][a-z0-9_]{1,63}$`; properties are flat `string | number | boolean | null`, PII-looking keys (`email`, `phone`, `token`, …) are dropped, and string values run through the PII scrubber. `analytics.enabled: false` turns it off; `navigator.doNotTrack` / Global Privacy Control are honoured by default. The console's **Users & Funnels** page reads the same events; retention defaults to 90 days per project.
201
+ </details>
202
+
152
203
  <details>
153
204
  <summary><b>Runtime control &amp; self-noise filters</b> — imperative APIs and CSP-safe defaults</summary>
154
205
 
@@ -263,7 +314,7 @@ Screenshot capture uses canvas / SVG `foreignObject` serialization — it does n
263
314
 
264
315
  ## Bundle size
265
316
 
266
- ~7 KB brotli, enforced at 88 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).
317
+ ~7 KB brotli, enforced at 89.5 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).
267
318
 
268
319
  ## License
269
320
 
@@ -272,4 +323,4 @@ MIT
272
323
  <!-- mushi-readme-stats-footer -->
273
324
  ---
274
325
 
275
- <sub>Monorepo scale (July 2026): 55 edge functions · 328 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>
326
+ <sub>Monorepo scale (July 2026): 59 edge functions · 374 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>
package/dist/headless.cjs CHANGED
@@ -106,8 +106,7 @@ function createNetworkCapture(options = {}) {
106
106
  const originalXhrSend = OriginalXHR ? XMLHttpRequest.prototype.send : null;
107
107
  const originalXhrSetRequestHeader = OriginalXHR ? XMLHttpRequest.prototype.setRequestHeader : null;
108
108
  let activeOptions = options;
109
- let fetchWrapper;
110
- globalThis.fetch = fetchWrapper = async function mushiFetchInterceptor(input, init) {
109
+ const fetchWrapper = async function mushiFetchInterceptor(input, init) {
111
110
  const startTime = Date.now();
112
111
  const method = init?.method?.toUpperCase() ?? "GET";
113
112
  const url = getRequestUrl(input);
@@ -165,6 +164,7 @@ function createNetworkCapture(options = {}) {
165
164
  }
166
165
  }
167
166
  };
167
+ globalThis.fetch = fetchWrapper;
168
168
  const xhrStateMap = typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : null;
169
169
  if (OriginalXHR && originalXhrOpen && originalXhrSend && originalXhrSetRequestHeader && xhrStateMap) {
170
170
  const _originalOpen = originalXhrOpen;
@@ -1062,15 +1062,17 @@ function textSnippet(el) {
1062
1062
  // src/otel.ts
1063
1063
  var SPAN_STATUS_ERROR = 2;
1064
1064
  var warnedMissing = false;
1065
+ var noopOnStart = (_span, _parentContext) => {
1066
+ };
1067
+ var noopOnEnd = (_span) => {
1068
+ };
1065
1069
  function createBrowserOtelSpanProcessor(mushi, options = {}) {
1066
1070
  const errorsOnly = options.errorsOnly ?? true;
1067
1071
  const noOp = {
1068
1072
  // mushi-mushi-allowlist: OTel SpanProcessor requires onStart/onEnd; this no-op processor intentionally does nothing
1069
- onStart: () => {
1070
- },
1073
+ onStart: noopOnStart,
1071
1074
  // mushi-mushi-allowlist: no-op processor — nothing to forward
1072
- onEnd: () => {
1073
- },
1075
+ onEnd: noopOnEnd,
1074
1076
  shutdown: () => Promise.resolve(),
1075
1077
  forceFlush: () => Promise.resolve()
1076
1078
  };
@@ -1085,8 +1087,7 @@ function createBrowserOtelSpanProcessor(mushi, options = {}) {
1085
1087
  }
1086
1088
  return {
1087
1089
  // mushi-mushi-allowlist: OTel SpanProcessor requires onStart; this processor only acts on onEnd
1088
- onStart: () => {
1089
- },
1090
+ onStart: noopOnStart,
1090
1091
  onEnd(span) {
1091
1092
  try {
1092
1093
  const isError = span.status.code === SPAN_STATUS_ERROR;