@mushi-mushi/web 1.19.0 → 1.20.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/CONTRIBUTING.md +24 -0
- package/README.md +2 -1
- package/dist/index.cjs +142 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +143 -21
- package/dist/index.js.map +1 -1
- package/dist/mushi.loader.global.js +148 -125
- package/dist/mushi.loader.global.js.map +1 -1
- package/package.json +10 -6
package/CONTRIBUTING.md
CHANGED
|
@@ -27,12 +27,24 @@ pnpm build
|
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
29
|
pnpm dev # Start all dev servers (admin on :6464)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
| Surface | URL |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| Admin console | http://localhost:6464 |
|
|
35
|
+
| Docs site | http://localhost:3000 |
|
|
36
|
+
| CLI console override | `MUSHI_CONSOLE_URL=http://localhost:6464` |
|
|
37
|
+
|
|
38
|
+
```bash
|
|
30
39
|
pnpm test # Run Vitest across all packages
|
|
31
40
|
pnpm typecheck # TypeScript checks
|
|
32
41
|
pnpm lint # ESLint
|
|
33
42
|
pnpm format # Prettier
|
|
43
|
+
pnpm smoke:cli-setup # Playwright: onboarding ?setup=cli + success panel (skips headless if unsigned)
|
|
34
44
|
```
|
|
35
45
|
|
|
46
|
+
Set `CLI_SETUP_SMOKE_STRICT=1` to fail the smoke script when Playwright is not signed in (CI gate).
|
|
47
|
+
|
|
36
48
|
Ad-hoc screenshots captured during UI reviews can live temporarily at the repo
|
|
37
49
|
root, but root-level `*.png` files are intentionally ignored. Canonical
|
|
38
50
|
screenshots that should be versioned belong under `docs/screenshots/`.
|
|
@@ -69,6 +81,18 @@ tooling/
|
|
|
69
81
|
tsconfig/ Shared TypeScript configs
|
|
70
82
|
```
|
|
71
83
|
|
|
84
|
+
## What we don't accept
|
|
85
|
+
|
|
86
|
+
Knowing this upfront saves everyone time.
|
|
87
|
+
|
|
88
|
+
- **Automated / bulk / AI-slop PRs** — any PR that was opened by a script, an LLM agent acting without meaningful human review, or as part of a parallel bounty-farming sweep is closed on sight. The commit history, branch name, or helper scripts included in the PR make this obvious.
|
|
89
|
+
- **PRs that target the wrong base** — all PRs must branch from and target `master`. PRs targeting `main` or any other branch are closed (and will show an inflated diff that is not your work).
|
|
90
|
+
- **One PR per issue, one issue per PR** — splitting or duplicating work just to collect acknowledgements isn't welcome.
|
|
91
|
+
- **Good-first-issues without claiming first** — comment on the issue to claim it before starting. If two people open PRs for the same issue, the one that commented first is prioritised.
|
|
92
|
+
- **Documentation-only PRs that merely duplicate existing content** — if the information already exists (e.g. in another file in this repo), adding a redundant copy adds noise without value.
|
|
93
|
+
|
|
94
|
+
If a PR violates these policies it will be closed with a brief explanation. No hard feelings — a genuine contribution on the same issue is always welcome.
|
|
95
|
+
|
|
72
96
|
## Making Changes
|
|
73
97
|
|
|
74
98
|
1. Create a feature branch from `master`
|
package/README.md
CHANGED
|
@@ -30,6 +30,7 @@ Browser SDK for Mushi Mushi — embeddable bug reporting widget with Shadow DOM
|
|
|
30
30
|
- **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
|
|
31
31
|
- **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'`
|
|
32
32
|
- **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
|
|
33
|
+
- **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
34
|
- **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
35
|
- **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
36
|
- **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)
|
|
@@ -88,7 +89,7 @@ Each trigger respects its config flag — set `rageClick: false` to disable rage
|
|
|
88
89
|
|
|
89
90
|
## Bundle Size
|
|
90
91
|
|
|
91
|
-
~7 KB brotli, enforced at **
|
|
92
|
+
~7 KB brotli, enforced at **74 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 and `screenshotProvider` hook. 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
|
|
|
93
94
|
## Quick Start
|
|
94
95
|
|
package/dist/index.cjs
CHANGED
|
@@ -1134,6 +1134,16 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1134
1134
|
line-height: 1.4;
|
|
1135
1135
|
letter-spacing: 0.02em;
|
|
1136
1136
|
}
|
|
1137
|
+
.mushi-identified-user {
|
|
1138
|
+
margin: 8px 0 0;
|
|
1139
|
+
font-size: 11.5px;
|
|
1140
|
+
color: ${inkMuted};
|
|
1141
|
+
line-height: 1.4;
|
|
1142
|
+
}
|
|
1143
|
+
.mushi-identified-user strong {
|
|
1144
|
+
color: ${ink};
|
|
1145
|
+
font-weight: 600;
|
|
1146
|
+
}
|
|
1137
1147
|
.mushi-annotate-toolbar {
|
|
1138
1148
|
display: flex;
|
|
1139
1149
|
flex-wrap: wrap;
|
|
@@ -2022,7 +2032,13 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
2022
2032
|
.mushi-account-info strong{font:700 14px/1.3 inherit;color:${ink}}
|
|
2023
2033
|
.mushi-account-rank,.mushi-xapp-app-name,.mushi-label{font-size:12px;color:${inkDim};font-family:${fontMono}}
|
|
2024
2034
|
.mushi-account-rank{display:block}
|
|
2025
|
-
.mushi-xapp-app-
|
|
2035
|
+
.mushi-xapp-app-head{display:flex;align-items:center;gap:8px;margin:0 0 6px}
|
|
2036
|
+
.mushi-xapp-app-name{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;margin:0}
|
|
2037
|
+
.mushi-app-icon{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:6px;border:1px solid ${isDark ? "rgba(255,255,255,0.12)" : "rgba(0,0,0,0.1)"};background:#fff;overflow:hidden;flex-shrink:0}
|
|
2038
|
+
.mushi-app-icon-img{display:block;width:16px;height:16px;object-fit:contain}
|
|
2039
|
+
.mushi-app-icon-initials{font-size:9px;font-weight:700;color:${inkDim};line-height:1}
|
|
2040
|
+
.mushi-app-icon-initials-only{background:${isDark ? "rgba(255,255,255,0.06)" : "rgba(0,0,0,0.04)"}}
|
|
2041
|
+
.mushi-header-host-icon{display:block;width:20px;height:20px;border-radius:4px;object-fit:contain}
|
|
2026
2042
|
.mushi-xapp-group{margin-bottom:14px}
|
|
2027
2043
|
.mushi-label{display:block;font-weight:600;margin-bottom:6px}
|
|
2028
2044
|
|
|
@@ -2051,9 +2067,7 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
2051
2067
|
|
|
2052
2068
|
// src/version.ts
|
|
2053
2069
|
var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
|
|
2054
|
-
var MUSHI_SDK_VERSION = "1.
|
|
2055
|
-
|
|
2056
|
-
// src/widget-helpers.ts
|
|
2070
|
+
var MUSHI_SDK_VERSION = "1.20.0" ;
|
|
2057
2071
|
var CATEGORY_ICONS = {
|
|
2058
2072
|
bug: "\u26A0\uFE0F",
|
|
2059
2073
|
slow: "\u{1F40C}",
|
|
@@ -2173,6 +2187,56 @@ function isSubmitShortcut(e) {
|
|
|
2173
2187
|
function escapeHtml(value) {
|
|
2174
2188
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2175
2189
|
}
|
|
2190
|
+
function renderAppIconHtml(opts) {
|
|
2191
|
+
const domain = opts.appDomain ?? core.resolveProjectDomain({
|
|
2192
|
+
project_id: opts.projectId,
|
|
2193
|
+
project_name: opts.appName,
|
|
2194
|
+
project_slug: opts.appSlug ?? ""
|
|
2195
|
+
});
|
|
2196
|
+
const initials = escapeHtml(core.projectInitials(opts.appName));
|
|
2197
|
+
const candidates = core.projectFaviconUrlCandidates({
|
|
2198
|
+
project_id: opts.projectId,
|
|
2199
|
+
project_name: opts.appName,
|
|
2200
|
+
project_slug: opts.appSlug ?? "",
|
|
2201
|
+
sdk_origin: opts.appDomain ? `https://${opts.appDomain}` : null
|
|
2202
|
+
});
|
|
2203
|
+
if (!candidates.length) {
|
|
2204
|
+
return `<span class="mushi-app-icon mushi-app-icon-initials-only" aria-hidden="true">${initials}</span>`;
|
|
2205
|
+
}
|
|
2206
|
+
const encoded = escapeHtml(JSON.stringify(candidates));
|
|
2207
|
+
return `<span class="mushi-app-icon" data-mushi-favicon data-candidates="${encoded}" data-initials="${initials}" aria-hidden="true" title="${escapeHtml(domain ?? opts.appName)}">
|
|
2208
|
+
<img class="mushi-app-icon-img" src="${escapeHtml(candidates[0])}" alt="" referrerpolicy="no-referrer" width="16" height="16" />
|
|
2209
|
+
<span class="mushi-app-icon-initials" hidden>${initials}</span>
|
|
2210
|
+
</span>`;
|
|
2211
|
+
}
|
|
2212
|
+
function bindFaviconFallbacks(root) {
|
|
2213
|
+
root.querySelectorAll("[data-mushi-favicon]").forEach((wrap) => {
|
|
2214
|
+
const img = wrap.querySelector(".mushi-app-icon-img");
|
|
2215
|
+
const fallback = wrap.querySelector(".mushi-app-icon-initials");
|
|
2216
|
+
if (!img || !fallback) return;
|
|
2217
|
+
let candidates = [];
|
|
2218
|
+
try {
|
|
2219
|
+
candidates = JSON.parse(wrap.dataset.candidates ?? "[]");
|
|
2220
|
+
} catch {
|
|
2221
|
+
candidates = [];
|
|
2222
|
+
}
|
|
2223
|
+
let index = 0;
|
|
2224
|
+
const tryNext = () => {
|
|
2225
|
+
index += 1;
|
|
2226
|
+
if (index < candidates.length) {
|
|
2227
|
+
img.src = candidates[index];
|
|
2228
|
+
} else {
|
|
2229
|
+
img.remove();
|
|
2230
|
+
fallback.hidden = false;
|
|
2231
|
+
wrap.classList.add("mushi-app-icon-initials-only");
|
|
2232
|
+
}
|
|
2233
|
+
};
|
|
2234
|
+
img.onerror = tryNext;
|
|
2235
|
+
img.onload = () => {
|
|
2236
|
+
if (core.isLikelyGenericFavicon(img)) tryNext();
|
|
2237
|
+
};
|
|
2238
|
+
});
|
|
2239
|
+
}
|
|
2176
2240
|
|
|
2177
2241
|
// src/widget-render.ts
|
|
2178
2242
|
function renderStep(ctx) {
|
|
@@ -2258,7 +2322,7 @@ function renderHeader(ctx, opts) {
|
|
|
2258
2322
|
const counterHtml = step ? `<span class="mushi-step-counter" aria-label="Step ${step} of ${TOTAL_STEPS}"><b>${pad2(step)}</b> / ${pad2(TOTAL_STEPS)}</span>` : "";
|
|
2259
2323
|
return `
|
|
2260
2324
|
<div class="mushi-header">
|
|
2261
|
-
<div class="mushi-header-mark" aria-hidden="true"
|
|
2325
|
+
<div class="mushi-header-mark" aria-hidden="true">${ctx.pageFaviconHref ? `<img class="mushi-header-host-icon" src="${escapeHtml(ctx.pageFaviconHref)}" alt="" referrerpolicy="no-referrer" width="20" height="20" />` : "\u866B"}</div>
|
|
2262
2326
|
<div class="mushi-header-titles">
|
|
2263
2327
|
${eyebrowHtml}
|
|
2264
2328
|
<h3>${title}</h3>
|
|
@@ -2564,24 +2628,42 @@ function renderCrossAppReportsStep(ctx) {
|
|
|
2564
2628
|
const grouped = /* @__PURE__ */ new Map();
|
|
2565
2629
|
for (const r of reports) {
|
|
2566
2630
|
const key = r.project_id ?? "unknown";
|
|
2567
|
-
if (!grouped.has(key))
|
|
2631
|
+
if (!grouped.has(key)) {
|
|
2632
|
+
grouped.set(key, {
|
|
2633
|
+
name: r.app_name ?? "Unknown App",
|
|
2634
|
+
slug: r.app_slug ?? null,
|
|
2635
|
+
domain: r.app_domain ?? null,
|
|
2636
|
+
reports: []
|
|
2637
|
+
});
|
|
2638
|
+
}
|
|
2568
2639
|
grouped.get(key).reports.push(r);
|
|
2569
2640
|
}
|
|
2570
|
-
const rows = [...grouped.entries()].map(([, group]) =>
|
|
2641
|
+
const rows = [...grouped.entries()].map(([projectId, group]) => {
|
|
2642
|
+
const icon = renderAppIconHtml({
|
|
2643
|
+
projectId,
|
|
2644
|
+
appName: group.name,
|
|
2645
|
+
appSlug: group.slug,
|
|
2646
|
+
appDomain: group.domain
|
|
2647
|
+
});
|
|
2648
|
+
return `
|
|
2571
2649
|
<div class="mushi-xapp-group">
|
|
2572
|
-
<
|
|
2650
|
+
<div class="mushi-xapp-app-head">
|
|
2651
|
+
${icon}
|
|
2652
|
+
<h4 class="mushi-xapp-app-name">${escapeHtml(group.name)}</h4>
|
|
2653
|
+
</div>
|
|
2573
2654
|
${group.reports.map((r) => {
|
|
2574
|
-
|
|
2575
|
-
|
|
2655
|
+
const tone = reporterStatusTone(r.status);
|
|
2656
|
+
return `
|
|
2576
2657
|
<div class="mushi-report-row" data-report-id="${escapeHtml(r.id)}" tabindex="0" role="button">
|
|
2577
2658
|
<span class="mushi-report-status mushi-status-${tone}">${escapeHtml(reporterStatusShort(r.status))}</span>
|
|
2578
2659
|
<span class="mushi-report-title">${escapeHtml(r.title ?? r.category)}</span>
|
|
2579
2660
|
<span class="mushi-report-when">${escapeHtml(formatRelativeTime(r.created_at))}</span>
|
|
2580
2661
|
</div>
|
|
2581
2662
|
`;
|
|
2582
|
-
|
|
2663
|
+
}).join("")}
|
|
2583
2664
|
</div>
|
|
2584
|
-
|
|
2665
|
+
`;
|
|
2666
|
+
}).join("");
|
|
2585
2667
|
return `
|
|
2586
2668
|
${renderHeader(ctx, { title: "My reports", showBack: true, eyebrow: "Mushi \xB7 All apps" })}
|
|
2587
2669
|
<div class="mushi-body">
|
|
@@ -2712,6 +2794,7 @@ function renderDetailsStep(ctx) {
|
|
|
2712
2794
|
${ctx.screenshotHint ? `<figcaption class="mushi-screenshot-hint">\u26A0 ${escapeHtml(ctx.screenshotHint)}</figcaption>` : ""}
|
|
2713
2795
|
</figure>` : ""}
|
|
2714
2796
|
<div class="mushi-error" style="display:none" role="alert"></div>
|
|
2797
|
+
${ctx.identifiedUser ? `<p class="mushi-identified-user" aria-label="Reporting as ${escapeHtml(ctx.identifiedUser.name ?? ctx.identifiedUser.email ?? "")}">\u{1F464} Reporting as <strong>${escapeHtml(ctx.identifiedUser.name ?? ctx.identifiedUser.email ?? "you")}</strong></p>` : ""}
|
|
2715
2798
|
</div>
|
|
2716
2799
|
<div class="mushi-footer">
|
|
2717
2800
|
<span class="mushi-footer-hint" aria-hidden="true">\u2318 + ENTER \u2192 send</span>
|
|
@@ -3006,6 +3089,13 @@ var MushiWidget = class _MushiWidget {
|
|
|
3006
3089
|
fabPos = null;
|
|
3007
3090
|
/** Cleanup fn for visualViewport keyboard listener. */
|
|
3008
3091
|
vvCleanup = null;
|
|
3092
|
+
/**
|
|
3093
|
+
* Host-app user identity forwarded via `Mushi.identify()` or
|
|
3094
|
+
* `Mushi.identifyWithToken()`. Used to show "Reporting as <name>"
|
|
3095
|
+
* in the details step so logged-in users know their report is linked.
|
|
3096
|
+
* Independent of the Mushi tester magic-link session below.
|
|
3097
|
+
*/
|
|
3098
|
+
identifiedUser = null;
|
|
3009
3099
|
/** Mushi tester session JWT — set after in-widget sign-in or by mushi.ts. */
|
|
3010
3100
|
testerJwt = null;
|
|
3011
3101
|
/** Tester identity (public_handle, display_name). */
|
|
@@ -3406,6 +3496,10 @@ var MushiWidget = class _MushiWidget {
|
|
|
3406
3496
|
if (this.isOpen && this.step === "leaderboard") this.render();
|
|
3407
3497
|
}
|
|
3408
3498
|
// ── Community public setters (called by mushi.ts after API calls) ──────────
|
|
3499
|
+
setIdentifiedUser(user) {
|
|
3500
|
+
this.identifiedUser = user;
|
|
3501
|
+
if (this.isOpen) this.render();
|
|
3502
|
+
}
|
|
3409
3503
|
setTesterSession(jwt, info) {
|
|
3410
3504
|
this.testerJwt = jwt;
|
|
3411
3505
|
this.testerInfo = info;
|
|
@@ -4142,6 +4236,7 @@ var MushiWidget = class _MushiWidget {
|
|
|
4142
4236
|
lastReportId: this.lastReportId,
|
|
4143
4237
|
reporterLoading: this.reporterLoading,
|
|
4144
4238
|
locale: this.locale,
|
|
4239
|
+
identifiedUser: this.identifiedUser,
|
|
4145
4240
|
testerReputation: this.testerReputation,
|
|
4146
4241
|
testerInfo: this.testerInfo,
|
|
4147
4242
|
screenshotCapturing: this.screenshotCapturing,
|
|
@@ -4185,11 +4280,13 @@ var MushiWidget = class _MushiWidget {
|
|
|
4185
4280
|
assistantTurns: this.assistantTurns,
|
|
4186
4281
|
assistantSending: this.assistantSending,
|
|
4187
4282
|
assistantError: this.assistantError,
|
|
4188
|
-
showAllCategories: this.showAllCategories
|
|
4283
|
+
showAllCategories: this.showAllCategories,
|
|
4284
|
+
pageFaviconHref: core.readPageFaviconHref()
|
|
4189
4285
|
};
|
|
4190
4286
|
}
|
|
4191
4287
|
attachHandlers(panel) {
|
|
4192
4288
|
const t = this.locale;
|
|
4289
|
+
bindFaviconFallbacks(panel);
|
|
4193
4290
|
panel.querySelector('[data-action="close"]')?.addEventListener("click", () => this.close());
|
|
4194
4291
|
panel.querySelector('[data-action="back"]')?.addEventListener("click", () => {
|
|
4195
4292
|
if (this.step === "intent") {
|
|
@@ -4787,8 +4884,6 @@ function setConsentGranted(projectId, granted) {
|
|
|
4787
4884
|
localStorage.removeItem(getConsentKey(projectId));
|
|
4788
4885
|
}
|
|
4789
4886
|
optedIn = granted;
|
|
4790
|
-
apiClient?.submitActivity(currentUserId ?? "", [], { optedIn: granted }).catch(() => {
|
|
4791
|
-
});
|
|
4792
4887
|
} catch {
|
|
4793
4888
|
}
|
|
4794
4889
|
}
|
|
@@ -6904,7 +6999,9 @@ function createInstance(config) {
|
|
|
6904
6999
|
}
|
|
6905
7000
|
if (activeConfig.capture?.screenshot !== "off") {
|
|
6906
7001
|
const screenshotOptions = { privacy: activeConfig.privacy };
|
|
6907
|
-
if (
|
|
7002
|
+
if (activeConfig.capture?.screenshotProvider) {
|
|
7003
|
+
screenshotCap = null;
|
|
7004
|
+
} else if (screenshotCap) {
|
|
6908
7005
|
screenshotCap.updateOptions(screenshotOptions);
|
|
6909
7006
|
} else {
|
|
6910
7007
|
screenshotCap = createScreenshotCapture(screenshotOptions);
|
|
@@ -6912,7 +7009,7 @@ function createInstance(config) {
|
|
|
6912
7009
|
} else {
|
|
6913
7010
|
screenshotCap = null;
|
|
6914
7011
|
}
|
|
6915
|
-
if (!screenshotCap) pendingScreenshot = null;
|
|
7012
|
+
if (!screenshotCap && !activeConfig.capture?.screenshotProvider) pendingScreenshot = null;
|
|
6916
7013
|
widget.setAllowScreenshotRemove(activeConfig.privacy?.allowUserRemoveScreenshot !== false);
|
|
6917
7014
|
if (activeConfig.capture?.elementSelector !== false) {
|
|
6918
7015
|
elementSelector ??= createElementSelector();
|
|
@@ -6997,7 +7094,22 @@ function createInstance(config) {
|
|
|
6997
7094
|
detachAutoBreadcrumbs = installAutoBreadcrumbs(breadcrumbs);
|
|
6998
7095
|
let screenshotCaptureInFlight = false;
|
|
6999
7096
|
async function takeScreenshotWithoutChrome() {
|
|
7000
|
-
if (
|
|
7097
|
+
if (screenshotCaptureInFlight) return null;
|
|
7098
|
+
const provider = activeConfig.capture?.screenshotProvider;
|
|
7099
|
+
if (provider) {
|
|
7100
|
+
screenshotCaptureInFlight = true;
|
|
7101
|
+
try {
|
|
7102
|
+
const result = await provider();
|
|
7103
|
+
return result ?? null;
|
|
7104
|
+
} catch (err) {
|
|
7105
|
+
log.warn("screenshotProvider threw, falling back to built-in capturer", {
|
|
7106
|
+
error: err instanceof Error ? err.message : String(err)
|
|
7107
|
+
});
|
|
7108
|
+
} finally {
|
|
7109
|
+
screenshotCaptureInFlight = false;
|
|
7110
|
+
}
|
|
7111
|
+
}
|
|
7112
|
+
if (!screenshotCap) return null;
|
|
7001
7113
|
screenshotCaptureInFlight = true;
|
|
7002
7114
|
const panelWasVisible = widget.getIsOpen();
|
|
7003
7115
|
if (panelWasVisible) widget.hidePanel();
|
|
@@ -7017,7 +7129,8 @@ function createInstance(config) {
|
|
|
7017
7129
|
}
|
|
7018
7130
|
async function autoCaptureScreenshot(when) {
|
|
7019
7131
|
const mode = activeConfig.capture?.screenshot;
|
|
7020
|
-
|
|
7132
|
+
const hasCapture = !!screenshotCap || !!activeConfig.capture?.screenshotProvider;
|
|
7133
|
+
if (!hasCapture || mode === "off" || pendingScreenshot) return;
|
|
7021
7134
|
if (when === "open" && mode !== "auto") return;
|
|
7022
7135
|
if (when === "submit" && mode !== "on-report" && mode !== "auto") return;
|
|
7023
7136
|
log.debug("Auto-capturing screenshot", { when, mode });
|
|
@@ -7051,7 +7164,8 @@ function createInstance(config) {
|
|
|
7051
7164
|
emit("widget:closed");
|
|
7052
7165
|
},
|
|
7053
7166
|
onScreenshotRequest: async () => {
|
|
7054
|
-
|
|
7167
|
+
const hasCapture = !!screenshotCap || !!activeConfig.capture?.screenshotProvider;
|
|
7168
|
+
if (!hasCapture || activeConfig.capture?.screenshot === "off") return;
|
|
7055
7169
|
log.debug("Taking screenshot");
|
|
7056
7170
|
pendingScreenshot = await takeScreenshotWithoutChrome();
|
|
7057
7171
|
widget.setScreenshotAttached(pendingScreenshot !== null);
|
|
@@ -7742,6 +7856,9 @@ function createInstance(config) {
|
|
|
7742
7856
|
},
|
|
7743
7857
|
identify(userId, traits) {
|
|
7744
7858
|
userInfo = { id: userId, ...traits?.email ? { email: traits.email } : {}, ...traits?.name ? { name: traits.name } : {} };
|
|
7859
|
+
widget.setIdentifiedUser(
|
|
7860
|
+
userInfo.name || userInfo.email ? { name: userInfo.name, email: userInfo.email } : null
|
|
7861
|
+
);
|
|
7745
7862
|
if (traits) {
|
|
7746
7863
|
for (const [k, v] of Object.entries(traits)) {
|
|
7747
7864
|
if (k !== "email" && k !== "name") customMetadata[`user.${k}`] = v;
|
|
@@ -7790,9 +7907,14 @@ function createInstance(config) {
|
|
|
7790
7907
|
...claims.email ? { email: claims.email } : {},
|
|
7791
7908
|
...claims.name ? { name: claims.name } : {}
|
|
7792
7909
|
};
|
|
7910
|
+
widget.setIdentifiedUser(
|
|
7911
|
+
userInfo.name || userInfo.email ? { name: userInfo.name, email: userInfo.email } : null
|
|
7912
|
+
);
|
|
7793
7913
|
}
|
|
7794
7914
|
breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken()" });
|
|
7795
7915
|
} else {
|
|
7916
|
+
userInfo = null;
|
|
7917
|
+
widget.setIdentifiedUser(null);
|
|
7796
7918
|
breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken(null)" });
|
|
7797
7919
|
}
|
|
7798
7920
|
},
|