@mushi-mushi/web 1.14.1 → 1.17.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 +50 -9
- package/README.md +4 -1
- package/dist/index.cjs +403 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -4
- package/dist/index.d.ts +41 -4
- package/dist/index.js +404 -68
- package/dist/index.js.map +1 -1
- package/dist/mushi.loader.global.js +2172 -0
- package/dist/mushi.loader.global.js.map +1 -0
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createLogger, noopLogger, createApiClient, createPreFilter, createOfflineQueue, createRateLimiter, createPiiScrubber, createBreadcrumbBuffer, getReporterToken, getDeviceFingerprintHash, MAX_SCREENSHOT_DATA_URL_BYTES, getSessionId, captureEnvironment, newUuid, DEFAULT_API_ENDPOINT, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INTERNAL_HEADER, normaliseThrown } from '@mushi-mushi/core';
|
|
1
|
+
import { resolveEnvConfig, createLogger, noopLogger, createApiClient, createPreFilter, createOfflineQueue, createRateLimiter, createPiiScrubber, createBreadcrumbBuffer, getReporterToken, getDeviceFingerprintHash, MAX_SCREENSHOT_DATA_URL_BYTES, getSessionId, captureEnvironment, newUuid, DEFAULT_API_ENDPOINT, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INTERNAL_HEADER, parseIdentityToken, normaliseThrown } from '@mushi-mushi/core';
|
|
2
2
|
|
|
3
3
|
// src/capture/compress-screenshot.ts
|
|
4
4
|
async function compressScreenshotDataUrl(dataUrl, maxBytes = MAX_SCREENSHOT_DATA_URL_BYTES) {
|
|
@@ -479,8 +479,8 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
479
479
|
|
|
480
480
|
@keyframes mushi-pulse {
|
|
481
481
|
0% { box-shadow: 0 0 0 0 ${widgetAccent}; opacity: 1; }
|
|
482
|
-
70% { box-shadow: 0 0 0 8px
|
|
483
|
-
100% { box-shadow: 0 0 0 0
|
|
482
|
+
70% { box-shadow: 0 0 0 8px ${widgetAccent}00; opacity: 0.5; }
|
|
483
|
+
100% { box-shadow: 0 0 0 0 ${widgetAccent}00; opacity: 1; }
|
|
484
484
|
}
|
|
485
485
|
|
|
486
486
|
.mushi-panel {
|
|
@@ -1368,6 +1368,20 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1368
1368
|
.mushi-success-receipt-warn {
|
|
1369
1369
|
color: ${widgetAccent};
|
|
1370
1370
|
}
|
|
1371
|
+
.mushi-success-my-reports {
|
|
1372
|
+
display: block;
|
|
1373
|
+
margin: 12px auto 0;
|
|
1374
|
+
font-size: 12px;
|
|
1375
|
+
font-family: ${fontMono};
|
|
1376
|
+
color: ${widgetAccent};
|
|
1377
|
+
text-decoration: underline;
|
|
1378
|
+
text-underline-offset: 2px;
|
|
1379
|
+
background: none;
|
|
1380
|
+
border: none;
|
|
1381
|
+
cursor: pointer;
|
|
1382
|
+
padding: 4px 2px;
|
|
1383
|
+
}
|
|
1384
|
+
.mushi-success-my-reports:hover { opacity: 0.75; }
|
|
1371
1385
|
.mushi-success-sla {
|
|
1372
1386
|
margin-top: 2px;
|
|
1373
1387
|
font-family: ${fontDisplay};
|
|
@@ -1626,12 +1640,18 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1626
1640
|
position: fixed;
|
|
1627
1641
|
left: 0;
|
|
1628
1642
|
right: 0;
|
|
1629
|
-
height
|
|
1643
|
+
/* min-height (not fixed height) + border-box so the safe-area padding
|
|
1644
|
+
below extends the bar into the notch/home-indicator zone instead of
|
|
1645
|
+
letting content bleed under the status bar (mobile safe-area bleed
|
|
1646
|
+
fix \u2014 Workstream C). Horizontal padding also clears the left/right
|
|
1647
|
+
insets for landscape notches. */
|
|
1648
|
+
box-sizing: border-box;
|
|
1649
|
+
min-height: 36px;
|
|
1630
1650
|
display: flex;
|
|
1631
1651
|
align-items: center;
|
|
1632
1652
|
justify-content: center;
|
|
1633
1653
|
gap: 10px;
|
|
1634
|
-
padding: 0 16px;
|
|
1654
|
+
padding: 0 calc(16px + env(safe-area-inset-right, 0px)) 0 calc(16px + env(safe-area-inset-left, 0px));
|
|
1635
1655
|
font-family: ${fontMono};
|
|
1636
1656
|
font-size: 12px;
|
|
1637
1657
|
letter-spacing: 0.04em;
|
|
@@ -1641,8 +1661,8 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1641
1661
|
animation: mushi-banner-slide-in 0.3s ${easeStamp} both;
|
|
1642
1662
|
}
|
|
1643
1663
|
|
|
1644
|
-
.mushi-banner.top { top: 0; }
|
|
1645
|
-
.mushi-banner.bottom { bottom: 0; }
|
|
1664
|
+
.mushi-banner.top { top: 0; padding-top: env(safe-area-inset-top, 0px); }
|
|
1665
|
+
.mushi-banner.bottom { bottom: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
|
|
1646
1666
|
|
|
1647
1667
|
/* --- neon variant (electric lime \u2014 dev / beta tool aesthetic) --- */
|
|
1648
1668
|
.mushi-banner.neon {
|
|
@@ -1853,6 +1873,28 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1853
1873
|
}
|
|
1854
1874
|
.mushi-banner.neon .mushi-banner-dismiss:hover { background: rgba(0,0,0,0.18) !important; }
|
|
1855
1875
|
|
|
1876
|
+
/* "My reports" link in the simple (non-rich) banner layout */
|
|
1877
|
+
.mushi-banner-my-reports {
|
|
1878
|
+
background: transparent;
|
|
1879
|
+
border: none;
|
|
1880
|
+
cursor: pointer;
|
|
1881
|
+
font-size: 11px;
|
|
1882
|
+
font-family: ${fontMono};
|
|
1883
|
+
opacity: 0.75;
|
|
1884
|
+
color: inherit;
|
|
1885
|
+
padding: 2px 6px;
|
|
1886
|
+
border-radius: 3px;
|
|
1887
|
+
white-space: nowrap;
|
|
1888
|
+
flex-shrink: 0;
|
|
1889
|
+
transition: opacity 0.15s, background 0.15s;
|
|
1890
|
+
margin-left: 4px;
|
|
1891
|
+
}
|
|
1892
|
+
.mushi-banner-my-reports:hover {
|
|
1893
|
+
opacity: 1;
|
|
1894
|
+
background: rgba(0,0,0,0.10);
|
|
1895
|
+
}
|
|
1896
|
+
.mushi-banner.neon .mushi-banner-my-reports:hover { background: rgba(0,0,0,0.18); }
|
|
1897
|
+
|
|
1856
1898
|
@keyframes mushi-banner-slide-in {
|
|
1857
1899
|
from { transform: translateY(calc(-1 * 100%)); opacity: 0.5; }
|
|
1858
1900
|
to { transform: translateY(0); opacity: 1; }
|
|
@@ -1894,12 +1936,33 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1894
1936
|
.mushi-xapp-app-name{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;margin:0 0 6px}
|
|
1895
1937
|
.mushi-xapp-group{margin-bottom:14px}
|
|
1896
1938
|
.mushi-label{display:block;font-weight:600;margin-bottom:6px}
|
|
1939
|
+
|
|
1940
|
+
/* \u2500\u2500 Assistant tab (P5) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
1941
|
+
.mushi-assistant{display:flex;flex-direction:column;height:100%;min-height:0;max-height:60vh}
|
|
1942
|
+
.mushi-assistant-log{flex:1;min-height:120px;overflow-y:auto;display:flex;flex-direction:column;gap:8px;padding:4px 2px 8px}
|
|
1943
|
+
.mushi-assistant-greeting{font:400 14px/1.5 ${fontBody};color:${inkMuted};padding:6px 2px}
|
|
1944
|
+
.mushi-assistant-suggestions{display:flex;flex-wrap:wrap;gap:6px;margin-top:4px}
|
|
1945
|
+
.mushi-assistant-chip{background:${widgetAccentWash};color:${widgetAccentInk};border:1px solid ${ruleStrong};border-radius:999px;padding:5px 12px;font-size:12px;cursor:pointer;font-family:${fontBody};transition:background .15s}
|
|
1946
|
+
.mushi-assistant-chip:hover{background:${isDark ? "rgba(255,90,71,0.22)" : "rgba(224,60,44,0.14)"}}
|
|
1947
|
+
.mushi-assistant-chip:focus-visible{outline:2px solid ${widgetAccent};outline-offset:2px}
|
|
1948
|
+
.mushi-assistant-msg{max-width:85%;padding:8px 12px;border-radius:12px;font:400 14px/1.45 ${fontBody};white-space:pre-wrap;word-break:break-word}
|
|
1949
|
+
.mushi-assistant-msg-user{align-self:flex-end;background:${widgetAccent};color:#fff;border-bottom-right-radius:4px}
|
|
1950
|
+
.mushi-assistant-msg-bot{align-self:flex-start;background:${isDark ? "rgba(255,255,255,0.06)" : "rgba(0,0,0,0.05)"};color:${ink};border-bottom-left-radius:4px}
|
|
1951
|
+
.mushi-assistant-thinking{opacity:0.6;font-size:18px;letter-spacing:2px}
|
|
1952
|
+
.mushi-assistant-error{align-self:flex-start;color:${isDark ? "#F87171" : "#DC2626"};font-size:12px;padding:4px 2px}
|
|
1953
|
+
.mushi-assistant-form{display:flex;align-items:flex-end;gap:8px;border-top:1px solid ${rule};padding-top:8px}
|
|
1954
|
+
.mushi-assistant-input{flex:1;resize:none;max-height:120px;border:1px solid ${ruleStrong};border-radius:10px;padding:8px 12px;font:400 14px/1.4 ${fontBody};background:${paper};color:${ink}}
|
|
1955
|
+
.mushi-assistant-input:focus-visible{outline:2px solid ${widgetAccent};outline-offset:1px}
|
|
1956
|
+
.mushi-assistant-submit{flex-shrink:0;width:36px;height:36px;border:none;border-radius:50%;background:${widgetAccent};color:#fff;font-size:18px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:transform .15s,opacity .15s}
|
|
1957
|
+
.mushi-assistant-submit:hover{transform:translateY(-1px)}
|
|
1958
|
+
.mushi-assistant-submit:disabled{opacity:0.5;cursor:default;transform:none}
|
|
1959
|
+
.mushi-assistant-submit:focus-visible{outline:2px solid ${widgetAccent};outline-offset:2px}
|
|
1897
1960
|
`;
|
|
1898
1961
|
}
|
|
1899
1962
|
|
|
1900
1963
|
// src/version.ts
|
|
1901
1964
|
var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
|
|
1902
|
-
var MUSHI_SDK_VERSION = "1.
|
|
1965
|
+
var MUSHI_SDK_VERSION = "1.17.0" ;
|
|
1903
1966
|
|
|
1904
1967
|
// src/widget-helpers.ts
|
|
1905
1968
|
var CATEGORY_ICONS = {
|
|
@@ -2045,8 +2108,43 @@ function renderStep(ctx) {
|
|
|
2045
2108
|
return renderAccountStep(ctx);
|
|
2046
2109
|
case "cross-app-reports":
|
|
2047
2110
|
return renderCrossAppReportsStep(ctx);
|
|
2111
|
+
case "assistant":
|
|
2112
|
+
return renderAssistantStep(ctx);
|
|
2048
2113
|
}
|
|
2049
2114
|
}
|
|
2115
|
+
function renderAssistantStep(ctx) {
|
|
2116
|
+
const label = ctx.callbacks.assistantLabel || "Ask";
|
|
2117
|
+
const greeting = ctx.callbacks.assistantGreeting || "Ask me anything about this app.";
|
|
2118
|
+
const suggestions = ctx.callbacks.assistantSuggestions ?? [];
|
|
2119
|
+
const empty = ctx.assistantTurns.length === 0;
|
|
2120
|
+
const transcript = empty ? `<div class="mushi-assistant-greeting">${escapeHtml(greeting)}</div>
|
|
2121
|
+
${suggestions.length ? `<div class="mushi-assistant-suggestions">${suggestions.map((s) => `<button type="button" class="mushi-assistant-chip" data-action="assistant-suggest" data-value="${escapeHtml(s)}">${escapeHtml(s)}</button>`).join("")}</div>` : ""}` : ctx.assistantTurns.map((turn) => {
|
|
2122
|
+
const cls = turn.role === "user" ? "mushi-assistant-msg-user" : "mushi-assistant-msg-bot";
|
|
2123
|
+
const opts = turn.options && turn.options.length ? `<div class="mushi-assistant-suggestions">${turn.options.map((o) => `<button type="button" class="mushi-assistant-chip" data-action="assistant-suggest" data-value="${escapeHtml(o)}">${escapeHtml(o)}</button>`).join("")}</div>` : "";
|
|
2124
|
+
return `<div class="mushi-assistant-msg ${cls}">${escapeHtml(turn.text)}</div>${opts}`;
|
|
2125
|
+
}).join("");
|
|
2126
|
+
const thinking = ctx.assistantSending ? `<div class="mushi-assistant-msg mushi-assistant-msg-bot mushi-assistant-thinking">\u2026</div>` : "";
|
|
2127
|
+
const error = ctx.assistantError ? `<div class="mushi-assistant-error" role="alert">${escapeHtml(ctx.assistantError)}</div>` : "";
|
|
2128
|
+
return `
|
|
2129
|
+
${renderHeader(ctx, { title: label, showBack: true })}
|
|
2130
|
+
<div class="mushi-assistant">
|
|
2131
|
+
<div class="mushi-assistant-log">
|
|
2132
|
+
${transcript}
|
|
2133
|
+
${thinking}
|
|
2134
|
+
${error}
|
|
2135
|
+
</div>
|
|
2136
|
+
<form class="mushi-assistant-form" data-action="assistant-send">
|
|
2137
|
+
<textarea
|
|
2138
|
+
class="mushi-assistant-input"
|
|
2139
|
+
rows="1"
|
|
2140
|
+
placeholder="Type your question\u2026"
|
|
2141
|
+
${ctx.assistantSending ? "disabled" : ""}
|
|
2142
|
+
></textarea>
|
|
2143
|
+
<button type="submit" class="mushi-assistant-submit" ${ctx.assistantSending ? "disabled" : ""} aria-label="Send">\u2191</button>
|
|
2144
|
+
</form>
|
|
2145
|
+
</div>
|
|
2146
|
+
`;
|
|
2147
|
+
}
|
|
2050
2148
|
function renderOutdatedBanner(ctx) {
|
|
2051
2149
|
if (!ctx.sdkFreshness) return "";
|
|
2052
2150
|
if (ctx.config.outdatedBanner === "off" || ctx.config.outdatedBanner === "console-only") return "";
|
|
@@ -2536,6 +2634,9 @@ function renderSuccessStep(ctx) {
|
|
|
2536
2634
|
${renderSuccessReceipt(ctx)}
|
|
2537
2635
|
${ctx.rewardsState ? renderSuccessRewards(ctx) : ""}
|
|
2538
2636
|
${ctx.config.betaMode?.enabled ? renderBetaSuccessFooter(ctx) : ""}
|
|
2637
|
+
<button type="button" class="mushi-link-btn mushi-success-my-reports" data-action="view-my-reports">
|
|
2638
|
+
\u{1F4EC} Track this report ›
|
|
2639
|
+
</button>
|
|
2539
2640
|
</div>
|
|
2540
2641
|
</div>
|
|
2541
2642
|
`;
|
|
@@ -2666,7 +2767,6 @@ function renderSuccessRewards(ctx) {
|
|
|
2666
2767
|
|
|
2667
2768
|
// src/widget.ts
|
|
2668
2769
|
var MushiWidget = class _MushiWidget {
|
|
2669
|
-
// double-submit guard
|
|
2670
2770
|
constructor(config = {}, callbacks, sdkVersion = MUSHI_SDK_VERSION) {
|
|
2671
2771
|
this.sdkVersion = sdkVersion;
|
|
2672
2772
|
this.config = {
|
|
@@ -2790,6 +2890,7 @@ var MushiWidget = class _MushiWidget {
|
|
|
2790
2890
|
lastSubmitQueuedOffline = false;
|
|
2791
2891
|
/** Whether the user has clicked ✕ on the header banner this session. */
|
|
2792
2892
|
bannerDismissed = false;
|
|
2893
|
+
bannerResizeObserver = null;
|
|
2793
2894
|
/** Persisted FAB position when draggable is enabled. */
|
|
2794
2895
|
fabPos = null;
|
|
2795
2896
|
/** Cleanup fn for visualViewport keyboard listener. */
|
|
@@ -2811,6 +2912,12 @@ var MushiWidget = class _MushiWidget {
|
|
|
2811
2912
|
magicLinkEmail = "";
|
|
2812
2913
|
magicLinkError = "";
|
|
2813
2914
|
magicLinkSending = false;
|
|
2915
|
+
// double-submit guard
|
|
2916
|
+
// ─── Assistant tab (P5) ──────────────────────────────────────────
|
|
2917
|
+
assistantTurns = [];
|
|
2918
|
+
assistantThreadId = null;
|
|
2919
|
+
assistantSending = false;
|
|
2920
|
+
assistantError = null;
|
|
2814
2921
|
mount() {
|
|
2815
2922
|
if (this.host.isConnected) return;
|
|
2816
2923
|
this.syncHostChromeState();
|
|
@@ -2914,10 +3021,18 @@ var MushiWidget = class _MushiWidget {
|
|
|
2914
3021
|
this.viaFeatureRequest = true;
|
|
2915
3022
|
this.step = "details";
|
|
2916
3023
|
} else if (options?.category) {
|
|
2917
|
-
this.selectedCategory = options.category;
|
|
2918
|
-
this.selectedIntent = null;
|
|
2919
3024
|
const custom = this.resolveCustomCategory(options.category);
|
|
2920
|
-
|
|
3025
|
+
const builtIn = ["bug", "slow", "visual", "confusing", "other"];
|
|
3026
|
+
const isKnown = builtIn.includes(options.category) || custom !== void 0;
|
|
3027
|
+
if (!isKnown) {
|
|
3028
|
+
this.selectedCategory = null;
|
|
3029
|
+
this.selectedIntent = null;
|
|
3030
|
+
this.step = "category";
|
|
3031
|
+
} else {
|
|
3032
|
+
this.selectedCategory = options.category;
|
|
3033
|
+
this.selectedIntent = null;
|
|
3034
|
+
this.step = custom && (!custom.intents || custom.intents.length === 0) ? "details" : "intent";
|
|
3035
|
+
}
|
|
2921
3036
|
} else {
|
|
2922
3037
|
this.selectedCategory = null;
|
|
2923
3038
|
this.selectedIntent = null;
|
|
@@ -2932,6 +3047,58 @@ var MushiWidget = class _MushiWidget {
|
|
|
2932
3047
|
this.render();
|
|
2933
3048
|
this.callbacks.onClose();
|
|
2934
3049
|
}
|
|
3050
|
+
/** Open the panel directly on the assistant ("Ask") tab. */
|
|
3051
|
+
openAssistantTab() {
|
|
3052
|
+
if (!this.callbacks.assistantEnabled) {
|
|
3053
|
+
this.open();
|
|
3054
|
+
return;
|
|
3055
|
+
}
|
|
3056
|
+
if (!this.isOpen) {
|
|
3057
|
+
this.isOpen = true;
|
|
3058
|
+
this.callbacks.onOpen();
|
|
3059
|
+
}
|
|
3060
|
+
this.step = "assistant";
|
|
3061
|
+
this.assistantError = null;
|
|
3062
|
+
this.render();
|
|
3063
|
+
setTimeout(() => {
|
|
3064
|
+
this.shadow.querySelector(".mushi-assistant-input")?.focus();
|
|
3065
|
+
}, 0);
|
|
3066
|
+
}
|
|
3067
|
+
/** Send one assistant turn and re-render as the reply streams back. */
|
|
3068
|
+
async sendAssistantMessage(message) {
|
|
3069
|
+
const text = message.trim();
|
|
3070
|
+
if (!text || this.assistantSending || !this.callbacks.onAssistantAsk) return;
|
|
3071
|
+
this.assistantSending = true;
|
|
3072
|
+
this.assistantError = null;
|
|
3073
|
+
this.assistantTurns.push({ role: "user", text });
|
|
3074
|
+
this.render();
|
|
3075
|
+
try {
|
|
3076
|
+
const reply = await this.callbacks.onAssistantAsk(text, this.assistantThreadId);
|
|
3077
|
+
if (reply) {
|
|
3078
|
+
if (reply.threadId) this.assistantThreadId = reply.threadId;
|
|
3079
|
+
if (reply.kind === "clarify") {
|
|
3080
|
+
this.assistantTurns.push({
|
|
3081
|
+
role: "assistant",
|
|
3082
|
+
text: reply.question ?? "Could you tell me a bit more?",
|
|
3083
|
+
...reply.options && reply.options.length ? { options: reply.options } : {}
|
|
3084
|
+
});
|
|
3085
|
+
} else {
|
|
3086
|
+
this.assistantTurns.push({ role: "assistant", text: reply.text ?? "\u2026" });
|
|
3087
|
+
}
|
|
3088
|
+
} else {
|
|
3089
|
+
this.assistantError = "No response \u2014 please try again.";
|
|
3090
|
+
}
|
|
3091
|
+
} catch {
|
|
3092
|
+
this.assistantError = "Something went wrong. Please try again.";
|
|
3093
|
+
} finally {
|
|
3094
|
+
this.assistantSending = false;
|
|
3095
|
+
this.render();
|
|
3096
|
+
setTimeout(() => {
|
|
3097
|
+
const log = this.shadow.querySelector(".mushi-assistant-log");
|
|
3098
|
+
if (log) log.scrollTop = log.scrollHeight;
|
|
3099
|
+
}, 0);
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
2935
3102
|
/**
|
|
2936
3103
|
* Briefly highlight the trigger button (a soft pulse + tooltip) without
|
|
2937
3104
|
* opening the full reporter panel. Use for first-session welcome nudges
|
|
@@ -3246,27 +3413,49 @@ var MushiWidget = class _MushiWidget {
|
|
|
3246
3413
|
const action = this.config.environments[this.detectEnvironment()];
|
|
3247
3414
|
return action !== "never" && action !== "manual";
|
|
3248
3415
|
}
|
|
3249
|
-
/** Height of the banner in px —
|
|
3416
|
+
/** Height of the banner in px — used as a fallback before first layout. */
|
|
3250
3417
|
static BANNER_HEIGHT = 36;
|
|
3251
|
-
/** CSS property applied to
|
|
3418
|
+
/** CSS property applied to documentElement so host-app content doesn't slide under the banner. */
|
|
3252
3419
|
static BODY_NUDGE_PROP = "--mushi-banner-offset";
|
|
3253
|
-
applyBodyNudge(position) {
|
|
3254
|
-
const h = `${
|
|
3420
|
+
applyBodyNudge(position, heightPx = _MushiWidget.BANNER_HEIGHT) {
|
|
3421
|
+
const h = `${heightPx}px`;
|
|
3422
|
+
document.documentElement.style.setProperty(_MushiWidget.BODY_NUDGE_PROP, h);
|
|
3255
3423
|
if (position === "top") {
|
|
3256
|
-
document.
|
|
3257
|
-
|
|
3424
|
+
if (document.body.dataset.mushiBannerNudged === "top") {
|
|
3425
|
+
document.body.style.paddingTop = h;
|
|
3426
|
+
} else if (!document.body.style.paddingTop) {
|
|
3258
3427
|
document.body.style.paddingTop = h;
|
|
3259
3428
|
document.body.dataset.mushiBannerNudged = "top";
|
|
3260
3429
|
}
|
|
3261
3430
|
} else {
|
|
3262
|
-
document.
|
|
3263
|
-
|
|
3431
|
+
if (document.body.dataset.mushiBannerNudged === "bottom") {
|
|
3432
|
+
document.body.style.paddingBottom = h;
|
|
3433
|
+
} else if (!document.body.style.paddingBottom) {
|
|
3264
3434
|
document.body.style.paddingBottom = h;
|
|
3265
3435
|
document.body.dataset.mushiBannerNudged = "bottom";
|
|
3266
3436
|
}
|
|
3267
3437
|
}
|
|
3268
3438
|
}
|
|
3439
|
+
/**
|
|
3440
|
+
* Schedule a height measurement after the next paint and set up a ResizeObserver
|
|
3441
|
+
* so --mushi-banner-offset always tracks the actual rendered banner height
|
|
3442
|
+
* (which can exceed BANNER_HEIGHT when safe-area-inset-top is in play on iOS,
|
|
3443
|
+
* or when rich-layout text wraps on narrow viewports).
|
|
3444
|
+
*/
|
|
3445
|
+
trackBannerHeight(banner, position) {
|
|
3446
|
+
const update = () => {
|
|
3447
|
+
const h = banner.getBoundingClientRect().height;
|
|
3448
|
+
if (h > 0) this.applyBodyNudge(position, h);
|
|
3449
|
+
};
|
|
3450
|
+
requestAnimationFrame(update);
|
|
3451
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
3452
|
+
this.bannerResizeObserver = new ResizeObserver(update);
|
|
3453
|
+
this.bannerResizeObserver.observe(banner);
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3269
3456
|
removeBodyNudge() {
|
|
3457
|
+
this.bannerResizeObserver?.disconnect();
|
|
3458
|
+
this.bannerResizeObserver = null;
|
|
3270
3459
|
document.documentElement.style.removeProperty(_MushiWidget.BODY_NUDGE_PROP);
|
|
3271
3460
|
const nudged = document.body.dataset.mushiBannerNudged;
|
|
3272
3461
|
if (nudged === "top") {
|
|
@@ -3375,6 +3564,8 @@ var MushiWidget = class _MushiWidget {
|
|
|
3375
3564
|
}, true);
|
|
3376
3565
|
}
|
|
3377
3566
|
}
|
|
3567
|
+
appendDivider(true);
|
|
3568
|
+
appendAction("\u{1F4EC} My reports", () => this.openReporter(), true);
|
|
3378
3569
|
banner.appendChild(nav);
|
|
3379
3570
|
banner.appendChild(dismissBtn);
|
|
3380
3571
|
} else {
|
|
@@ -3390,10 +3581,17 @@ var MushiWidget = class _MushiWidget {
|
|
|
3390
3581
|
featBtn.addEventListener("click", () => this.open({ featureRequest: true }));
|
|
3391
3582
|
banner.appendChild(featBtn);
|
|
3392
3583
|
}
|
|
3584
|
+
const myReportsBtn = document.createElement("button");
|
|
3585
|
+
myReportsBtn.className = "mushi-banner-my-reports";
|
|
3586
|
+
myReportsBtn.textContent = "\u{1F4EC} My reports";
|
|
3587
|
+
myReportsBtn.setAttribute("aria-label", "View my submitted reports");
|
|
3588
|
+
myReportsBtn.addEventListener("click", () => this.openReporter());
|
|
3589
|
+
banner.appendChild(myReportsBtn);
|
|
3393
3590
|
banner.appendChild(dismissBtn);
|
|
3394
3591
|
}
|
|
3395
3592
|
this.shadow.appendChild(banner);
|
|
3396
3593
|
this.applyBodyNudge(position);
|
|
3594
|
+
this.trackBannerHeight(banner, position);
|
|
3397
3595
|
}
|
|
3398
3596
|
effectiveTrigger() {
|
|
3399
3597
|
if (!this.config.smartHide || typeof window === "undefined") return this.config.trigger;
|
|
@@ -3447,6 +3645,8 @@ var MushiWidget = class _MushiWidget {
|
|
|
3447
3645
|
const theme = this.getTheme();
|
|
3448
3646
|
const pos = this.config.position;
|
|
3449
3647
|
const t = this.locale;
|
|
3648
|
+
this.bannerResizeObserver?.disconnect();
|
|
3649
|
+
this.bannerResizeObserver = null;
|
|
3450
3650
|
this.shadow.innerHTML = "";
|
|
3451
3651
|
const style = document.createElement("style");
|
|
3452
3652
|
style.textContent = getWidgetStyles(theme, this.config.accent ?? "", this.config.accentText ?? "");
|
|
@@ -3553,6 +3753,28 @@ var MushiWidget = class _MushiWidget {
|
|
|
3553
3753
|
}
|
|
3554
3754
|
return maxBottom > 0 ? Math.ceil(maxBottom) + gap : null;
|
|
3555
3755
|
}
|
|
3756
|
+
/**
|
|
3757
|
+
* Minimum bottom-offset in px so a bottom-anchored trigger clears avoided
|
|
3758
|
+
* elements (tab bars, fixed CTAs). Mirrors {@link computeAvoidTopPx}.
|
|
3759
|
+
*/
|
|
3760
|
+
computeAvoidBottomPx(gap = 8) {
|
|
3761
|
+
const sels = this.config.avoidSelectors;
|
|
3762
|
+
if (!sels?.length) return null;
|
|
3763
|
+
let maxClearance = 0;
|
|
3764
|
+
for (const sel of sels) {
|
|
3765
|
+
try {
|
|
3766
|
+
const el = document.querySelector(sel);
|
|
3767
|
+
if (!el) continue;
|
|
3768
|
+
const r = el.getBoundingClientRect();
|
|
3769
|
+
if (r.width > 0 && r.height > 0) {
|
|
3770
|
+
const clearance = window.innerHeight - r.top + gap;
|
|
3771
|
+
if (clearance > maxClearance) maxClearance = clearance;
|
|
3772
|
+
}
|
|
3773
|
+
} catch {
|
|
3774
|
+
}
|
|
3775
|
+
}
|
|
3776
|
+
return maxClearance > 0 ? Math.ceil(maxClearance) : null;
|
|
3777
|
+
}
|
|
3556
3778
|
applyInsetVars(el) {
|
|
3557
3779
|
const { anchor } = this.config;
|
|
3558
3780
|
if (anchor && Object.keys(anchor).length > 0) {
|
|
@@ -3575,13 +3797,20 @@ var MushiWidget = class _MushiWidget {
|
|
|
3575
3797
|
});
|
|
3576
3798
|
el.style.setProperty("--mushi-safe-area", this.config.respectSafeArea ? "1" : "0");
|
|
3577
3799
|
}
|
|
3578
|
-
const isTopAnchored = anchor?.top !== void 0 || this.config.position?.startsWith("top")
|
|
3800
|
+
const isTopAnchored = anchor?.top !== void 0 || this.config.position?.startsWith("top");
|
|
3801
|
+
const isBottomAnchored = anchor?.bottom !== void 0 || this.config.position?.startsWith("bottom") || !this.config.position;
|
|
3579
3802
|
if (isTopAnchored) {
|
|
3580
3803
|
const avoidPx = this.computeAvoidTopPx();
|
|
3581
3804
|
if (avoidPx !== null) {
|
|
3582
3805
|
el.style.setProperty("--mushi-top", `${avoidPx}px`);
|
|
3583
3806
|
}
|
|
3584
3807
|
}
|
|
3808
|
+
if (isBottomAnchored) {
|
|
3809
|
+
const avoidBottomPx = this.computeAvoidBottomPx();
|
|
3810
|
+
if (avoidBottomPx !== null) {
|
|
3811
|
+
el.style.setProperty("--mushi-bottom", `${avoidBottomPx}px`);
|
|
3812
|
+
}
|
|
3813
|
+
}
|
|
3585
3814
|
}
|
|
3586
3815
|
// ─── Draggable FAB ──────────────────────────────────────────────────────────
|
|
3587
3816
|
/** Storage key for the FAB position, scoped to projectId when available. */
|
|
@@ -3818,7 +4047,10 @@ var MushiWidget = class _MushiWidget {
|
|
|
3818
4047
|
resolveCustomCategory: (id) => this.resolveCustomCategory(id),
|
|
3819
4048
|
effectiveMinLength: () => this.effectiveMinLength(),
|
|
3820
4049
|
categoryLabel: (id) => this.categoryLabel(id),
|
|
3821
|
-
categoryIcon: (id) => this.categoryIcon(id)
|
|
4050
|
+
categoryIcon: (id) => this.categoryIcon(id),
|
|
4051
|
+
assistantTurns: this.assistantTurns,
|
|
4052
|
+
assistantSending: this.assistantSending,
|
|
4053
|
+
assistantError: this.assistantError
|
|
3822
4054
|
};
|
|
3823
4055
|
}
|
|
3824
4056
|
attachHandlers(panel) {
|
|
@@ -3847,9 +4079,38 @@ var MushiWidget = class _MushiWidget {
|
|
|
3847
4079
|
this.step = "reports";
|
|
3848
4080
|
} else if (this.step === "roadmap") {
|
|
3849
4081
|
this.step = "category";
|
|
4082
|
+
} else if (this.step === "assistant") {
|
|
4083
|
+
this.step = "category";
|
|
3850
4084
|
}
|
|
3851
4085
|
this.render();
|
|
3852
4086
|
});
|
|
4087
|
+
panel.querySelector('[data-action="assistant"]')?.addEventListener("click", () => {
|
|
4088
|
+
this.openAssistantTab();
|
|
4089
|
+
});
|
|
4090
|
+
panel.querySelectorAll('[data-action="assistant-suggest"]').forEach((btn) => {
|
|
4091
|
+
btn.addEventListener("click", () => {
|
|
4092
|
+
const value = btn.dataset.value;
|
|
4093
|
+
if (value) void this.sendAssistantMessage(value);
|
|
4094
|
+
});
|
|
4095
|
+
});
|
|
4096
|
+
{
|
|
4097
|
+
const form = panel.querySelector('[data-action="assistant-send"]');
|
|
4098
|
+
if (form) {
|
|
4099
|
+
const input = form.querySelector(".mushi-assistant-input");
|
|
4100
|
+
form.addEventListener("submit", (e) => {
|
|
4101
|
+
e.preventDefault();
|
|
4102
|
+
const value = input?.value ?? "";
|
|
4103
|
+
if (input) input.value = "";
|
|
4104
|
+
void this.sendAssistantMessage(value);
|
|
4105
|
+
});
|
|
4106
|
+
input?.addEventListener("keydown", (e) => {
|
|
4107
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
4108
|
+
e.preventDefault();
|
|
4109
|
+
form.requestSubmit();
|
|
4110
|
+
}
|
|
4111
|
+
});
|
|
4112
|
+
}
|
|
4113
|
+
}
|
|
3853
4114
|
panel.querySelector('[data-action="reports"]')?.addEventListener("click", () => {
|
|
3854
4115
|
void this.loadReporterReports();
|
|
3855
4116
|
});
|
|
@@ -3939,6 +4200,9 @@ var MushiWidget = class _MushiWidget {
|
|
|
3939
4200
|
panel.querySelector('[data-action="reporter-not-fixed"]')?.addEventListener("click", () => {
|
|
3940
4201
|
void this.submitReporterReopen();
|
|
3941
4202
|
});
|
|
4203
|
+
panel.querySelector('[data-action="view-my-reports"]')?.addEventListener("click", () => {
|
|
4204
|
+
void this.loadReporterReports();
|
|
4205
|
+
});
|
|
3942
4206
|
panel.querySelector('[data-action="copy-report-id"]')?.addEventListener("click", (e) => {
|
|
3943
4207
|
const btn = e.currentTarget;
|
|
3944
4208
|
const id = btn.dataset.copyId;
|
|
@@ -4259,6 +4523,18 @@ var MushiWidget = class _MushiWidget {
|
|
|
4259
4523
|
if (this.isOpen) this.close();
|
|
4260
4524
|
this.open();
|
|
4261
4525
|
}
|
|
4526
|
+
/**
|
|
4527
|
+
* Open the widget directly to the reporter's "My reports" history view.
|
|
4528
|
+
* Can be called from host apps via `sdk.openReporter()` or triggered by
|
|
4529
|
+
* the banner's "My reports" link button.
|
|
4530
|
+
*/
|
|
4531
|
+
openReporter() {
|
|
4532
|
+
if (!this.isOpen) {
|
|
4533
|
+
this.isOpen = true;
|
|
4534
|
+
this.render();
|
|
4535
|
+
}
|
|
4536
|
+
void this.loadReporterReports();
|
|
4537
|
+
}
|
|
4262
4538
|
recorderSelectCategory(category) {
|
|
4263
4539
|
if (!this.isOpen) this.open();
|
|
4264
4540
|
if (this.step !== "category") {
|
|
@@ -4737,16 +5013,10 @@ function matchesUrl(url, matcher) {
|
|
|
4737
5013
|
}
|
|
4738
5014
|
function normalizeUrlPrefix(url) {
|
|
4739
5015
|
if (!url) return null;
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
try {
|
|
4745
|
-
const parsed = new URL(url);
|
|
4746
|
-
return parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1" || parsed.hostname === "::1" || parsed.hostname.endsWith(".localhost");
|
|
4747
|
-
} catch {
|
|
4748
|
-
return /\blocalhost\b|127\.0\.0\.1/.test(url);
|
|
4749
|
-
}
|
|
5016
|
+
const normalized = normalizeComparableUrl(url);
|
|
5017
|
+
let end = normalized.length;
|
|
5018
|
+
while (end > 0 && normalized.charCodeAt(end - 1) === 47) end--;
|
|
5019
|
+
return normalized.slice(0, end);
|
|
4750
5020
|
}
|
|
4751
5021
|
function normalizeComparableUrl(url) {
|
|
4752
5022
|
try {
|
|
@@ -4911,19 +5181,26 @@ function createScreenshotCapture(options = {}) {
|
|
|
4911
5181
|
try {
|
|
4912
5182
|
ctx.drawImage(img, 0, 0, width, height);
|
|
4913
5183
|
URL.revokeObjectURL(url);
|
|
4914
|
-
|
|
5184
|
+
const dataUrl = canvas.toDataURL("image/jpeg", 0.7);
|
|
5185
|
+
resolve(dataUrl);
|
|
4915
5186
|
} catch {
|
|
4916
5187
|
URL.revokeObjectURL(url);
|
|
4917
|
-
|
|
5188
|
+
activeOptions.onFailed?.("taint");
|
|
5189
|
+
emitScreenshotFailed("taint");
|
|
5190
|
+
resolve(null);
|
|
4918
5191
|
}
|
|
4919
5192
|
};
|
|
4920
5193
|
img.onerror = () => {
|
|
4921
5194
|
URL.revokeObjectURL(url);
|
|
4922
|
-
|
|
5195
|
+
activeOptions.onFailed?.("error");
|
|
5196
|
+
emitScreenshotFailed("error");
|
|
5197
|
+
resolve(null);
|
|
4923
5198
|
};
|
|
4924
5199
|
img.src = url;
|
|
4925
5200
|
});
|
|
4926
5201
|
} catch {
|
|
5202
|
+
activeOptions.onFailed?.("error");
|
|
5203
|
+
emitScreenshotFailed("error");
|
|
4927
5204
|
return null;
|
|
4928
5205
|
}
|
|
4929
5206
|
}
|
|
@@ -4934,6 +5211,12 @@ function createScreenshotCapture(options = {}) {
|
|
|
4934
5211
|
}
|
|
4935
5212
|
};
|
|
4936
5213
|
}
|
|
5214
|
+
function emitScreenshotFailed(reason) {
|
|
5215
|
+
try {
|
|
5216
|
+
document.dispatchEvent(new CustomEvent("mushi:screenshot_failed", { detail: { reason }, bubbles: false }));
|
|
5217
|
+
} catch {
|
|
5218
|
+
}
|
|
5219
|
+
}
|
|
4937
5220
|
var DEFAULT_REDACT_SELECTORS = [
|
|
4938
5221
|
'input[type="password"]',
|
|
4939
5222
|
"[data-mushi-redact]"
|
|
@@ -4989,10 +5272,28 @@ function stripTaintSources(root) {
|
|
|
4989
5272
|
const href = link.getAttribute("href");
|
|
4990
5273
|
if (!href || isCrossOriginUrl(href, pageOrigin)) link.remove();
|
|
4991
5274
|
}
|
|
5275
|
+
for (const styleEl of root.querySelectorAll("style")) {
|
|
5276
|
+
const cleaned = stripCssUrlRefs(styleEl.textContent ?? "", pageOrigin);
|
|
5277
|
+
if (cleaned !== styleEl.textContent) styleEl.textContent = cleaned;
|
|
5278
|
+
}
|
|
5279
|
+
for (const el of root.querySelectorAll("[style]")) {
|
|
5280
|
+
const s = el.getAttribute("style");
|
|
5281
|
+
if (!s) continue;
|
|
5282
|
+
const cleaned = stripCssUrlRefs(s, pageOrigin);
|
|
5283
|
+
if (cleaned !== s) el.setAttribute("style", cleaned);
|
|
5284
|
+
}
|
|
4992
5285
|
for (const script of root.querySelectorAll("script")) {
|
|
4993
5286
|
script.remove();
|
|
4994
5287
|
}
|
|
4995
5288
|
}
|
|
5289
|
+
function stripCssUrlRefs(css, pageOrigin) {
|
|
5290
|
+
return css.replace(/url\(\s*(['"]?)([^)'"]+)\1\s*\)/gi, (_match, _q, href) => {
|
|
5291
|
+
const trimmed = href.trim();
|
|
5292
|
+
if (!trimmed || trimmed.startsWith("data:") || trimmed.startsWith("#")) return _match;
|
|
5293
|
+
if (isCrossOriginUrl(trimmed, pageOrigin)) return "none";
|
|
5294
|
+
return _match;
|
|
5295
|
+
});
|
|
5296
|
+
}
|
|
4996
5297
|
function isCrossOriginUrl(raw, pageOrigin) {
|
|
4997
5298
|
if (!raw || raw.startsWith("data:") || raw.startsWith("blob:")) return false;
|
|
4998
5299
|
try {
|
|
@@ -5002,24 +5303,6 @@ function isCrossOriginUrl(raw, pageOrigin) {
|
|
|
5002
5303
|
return true;
|
|
5003
5304
|
}
|
|
5004
5305
|
}
|
|
5005
|
-
function buildDegradedScreenshot(width, height) {
|
|
5006
|
-
const canvas = document.createElement("canvas");
|
|
5007
|
-
const ctx = canvas.getContext("2d");
|
|
5008
|
-
if (!ctx) return null;
|
|
5009
|
-
canvas.width = width;
|
|
5010
|
-
canvas.height = height;
|
|
5011
|
-
ctx.fillStyle = "#111827";
|
|
5012
|
-
ctx.fillRect(0, 0, width, height);
|
|
5013
|
-
ctx.fillStyle = "#e5e7eb";
|
|
5014
|
-
ctx.font = "13px system-ui, sans-serif";
|
|
5015
|
-
ctx.fillText("Screenshot: layout captured (external media stripped)", 16, 28);
|
|
5016
|
-
ctx.fillText(`${width}\xD7${height}px`, 16, 48);
|
|
5017
|
-
try {
|
|
5018
|
-
return canvas.toDataURL("image/jpeg", 0.7);
|
|
5019
|
-
} catch {
|
|
5020
|
-
return null;
|
|
5021
|
-
}
|
|
5022
|
-
}
|
|
5023
5306
|
function maskElement(el) {
|
|
5024
5307
|
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
|
|
5025
5308
|
el.value = "";
|
|
@@ -6329,16 +6612,17 @@ var Mushi = class {
|
|
|
6329
6612
|
createLogger({ scope: "mushi", level: "warn", format: "pretty" }).warn("Already initialized \u2014 call destroy() first to reinitialize");
|
|
6330
6613
|
return instance;
|
|
6331
6614
|
}
|
|
6332
|
-
|
|
6333
|
-
|
|
6615
|
+
const resolved = { ...resolveEnvConfig(), ...config };
|
|
6616
|
+
if (!resolved.projectId) {
|
|
6617
|
+
throw new Error("[mushi] projectId is required \u2014 set NEXT_PUBLIC_MUSHI_PROJECT_ID / VITE_MUSHI_PROJECT_ID / MUSHI_PROJECT_ID or pass it explicitly");
|
|
6334
6618
|
}
|
|
6335
|
-
if (!
|
|
6336
|
-
throw new Error("[mushi] apiKey is required");
|
|
6619
|
+
if (!resolved.apiKey) {
|
|
6620
|
+
throw new Error("[mushi] apiKey is required \u2014 set NEXT_PUBLIC_MUSHI_API_KEY / VITE_MUSHI_API_KEY / MUSHI_API_KEY or pass it explicitly");
|
|
6337
6621
|
}
|
|
6338
|
-
if (
|
|
6622
|
+
if (resolved.enabled === false) {
|
|
6339
6623
|
return createNoopInstance();
|
|
6340
6624
|
}
|
|
6341
|
-
instance = createInstance(
|
|
6625
|
+
instance = createInstance(resolved);
|
|
6342
6626
|
return instance;
|
|
6343
6627
|
}
|
|
6344
6628
|
static getInstance() {
|
|
@@ -6356,10 +6640,15 @@ function createInstance(config) {
|
|
|
6356
6640
|
const bootstrapConfig = applyPresetConfig(config);
|
|
6357
6641
|
let activeConfig = bootstrapConfig;
|
|
6358
6642
|
const log = config.debug ?? false ? createLogger({ scope: "mushi", level: "debug", format: "pretty" }) : noopLogger;
|
|
6643
|
+
let userToken = null;
|
|
6644
|
+
let currentPageContext = null;
|
|
6359
6645
|
const apiClient2 = createApiClient({
|
|
6360
6646
|
projectId: bootstrapConfig.projectId,
|
|
6361
6647
|
apiKey: bootstrapConfig.apiKey,
|
|
6362
|
-
...bootstrapConfig.apiEndpoint ? { apiEndpoint: bootstrapConfig.apiEndpoint } : {}
|
|
6648
|
+
...bootstrapConfig.apiEndpoint ? { apiEndpoint: bootstrapConfig.apiEndpoint } : {},
|
|
6649
|
+
getUserToken: () => userToken,
|
|
6650
|
+
sdkPackage: MUSHI_SDK_PACKAGE,
|
|
6651
|
+
sdkVersion: MUSHI_SDK_VERSION
|
|
6363
6652
|
});
|
|
6364
6653
|
const preFilter = createPreFilter(bootstrapConfig.preFilter);
|
|
6365
6654
|
const offlineQueue = createOfflineQueue(bootstrapConfig.offline);
|
|
@@ -6420,12 +6709,12 @@ function createInstance(config) {
|
|
|
6420
6709
|
return;
|
|
6421
6710
|
}
|
|
6422
6711
|
const status = statusResult.data;
|
|
6423
|
-
if (!status.is_tester) {
|
|
6712
|
+
if (!status.is_tester || !status.tester_id) {
|
|
6424
6713
|
clearTesterJwt();
|
|
6425
6714
|
return;
|
|
6426
6715
|
}
|
|
6427
6716
|
widget.setTesterSession(jwt, {
|
|
6428
|
-
id:
|
|
6717
|
+
id: status.tester_id,
|
|
6429
6718
|
public_handle: status.public_handle ?? null,
|
|
6430
6719
|
display_name: status.display_name ?? null
|
|
6431
6720
|
});
|
|
@@ -6778,6 +7067,19 @@ function createInstance(config) {
|
|
|
6778
7067
|
},
|
|
6779
7068
|
onTesterSignOut() {
|
|
6780
7069
|
clearTesterJwt();
|
|
7070
|
+
},
|
|
7071
|
+
// ── Assistant tab (P5) ───────────────────────────────────────────────
|
|
7072
|
+
assistantEnabled: bootstrapConfig.assistant?.enabled === true,
|
|
7073
|
+
...bootstrapConfig.assistant?.label ? { assistantLabel: bootstrapConfig.assistant.label } : {},
|
|
7074
|
+
...bootstrapConfig.assistant?.greeting ? { assistantGreeting: bootstrapConfig.assistant.greeting } : {},
|
|
7075
|
+
...bootstrapConfig.assistant?.suggestions ? { assistantSuggestions: bootstrapConfig.assistant.suggestions } : {},
|
|
7076
|
+
async onAssistantAsk(message, threadId) {
|
|
7077
|
+
const res = await apiClient2.askAssistant({
|
|
7078
|
+
message,
|
|
7079
|
+
threadId,
|
|
7080
|
+
context: currentPageContext
|
|
7081
|
+
});
|
|
7082
|
+
return res.ok ? res.data ?? null : null;
|
|
6781
7083
|
}
|
|
6782
7084
|
}, MUSHI_SDK_VERSION);
|
|
6783
7085
|
syncCaptureModules();
|
|
@@ -6867,8 +7169,8 @@ function createInstance(config) {
|
|
|
6867
7169
|
}).catch((err) => {
|
|
6868
7170
|
log.debug("Runtime SDK config fetch failed", { error: err instanceof Error ? err.message : String(err) });
|
|
6869
7171
|
});
|
|
6870
|
-
} else
|
|
6871
|
-
log.debug("Runtime SDK config
|
|
7172
|
+
} else {
|
|
7173
|
+
log.debug("Runtime SDK config disabled via runtimeConfig:false; using static bootstrap config");
|
|
6872
7174
|
}
|
|
6873
7175
|
void checkSdkFreshness();
|
|
6874
7176
|
log.info("Initialized", { projectId: config.projectId });
|
|
@@ -7154,6 +7456,9 @@ function createInstance(config) {
|
|
|
7154
7456
|
setTrigger(trigger) {
|
|
7155
7457
|
widget.setTrigger(trigger);
|
|
7156
7458
|
},
|
|
7459
|
+
openReporter() {
|
|
7460
|
+
widget.openReporter();
|
|
7461
|
+
},
|
|
7157
7462
|
close() {
|
|
7158
7463
|
widget.close();
|
|
7159
7464
|
},
|
|
@@ -7323,6 +7628,28 @@ function createInstance(config) {
|
|
|
7323
7628
|
}
|
|
7324
7629
|
}
|
|
7325
7630
|
},
|
|
7631
|
+
identifyWithToken(token) {
|
|
7632
|
+
userToken = token && typeof token === "string" ? token : null;
|
|
7633
|
+
if (userToken) {
|
|
7634
|
+
const claims = parseIdentityToken(userToken);
|
|
7635
|
+
if (claims?.sub) {
|
|
7636
|
+
userInfo = {
|
|
7637
|
+
id: claims.sub,
|
|
7638
|
+
...claims.email ? { email: claims.email } : {},
|
|
7639
|
+
...claims.name ? { name: claims.name } : {}
|
|
7640
|
+
};
|
|
7641
|
+
}
|
|
7642
|
+
breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken()" });
|
|
7643
|
+
} else {
|
|
7644
|
+
breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken(null)" });
|
|
7645
|
+
}
|
|
7646
|
+
},
|
|
7647
|
+
publishPageContext(context) {
|
|
7648
|
+
currentPageContext = context && context.route ? context : null;
|
|
7649
|
+
},
|
|
7650
|
+
openAssistant() {
|
|
7651
|
+
widget.openAssistantTab();
|
|
7652
|
+
},
|
|
7326
7653
|
addBreadcrumb(crumb) {
|
|
7327
7654
|
breadcrumbs.add(crumb);
|
|
7328
7655
|
},
|
|
@@ -7446,6 +7773,9 @@ function mergeRuntimeConfig(config, runtime) {
|
|
|
7446
7773
|
const nativeTrigger = runtime.native?.triggerMode;
|
|
7447
7774
|
const runtimeLauncher = runtime.widget?.launcher;
|
|
7448
7775
|
const widgetTrigger = runtimeLauncher ?? runtime.widget?.trigger ?? (nativeTrigger === "none" || nativeTrigger === "shake" ? "manual" : void 0);
|
|
7776
|
+
const explicitHidden = runtimeLauncher === "hidden" || runtime.widget?.trigger === "hidden";
|
|
7777
|
+
const hostTrigger = config.widget?.trigger;
|
|
7778
|
+
const safeWidgetTrigger = widgetTrigger === "hidden" && !explicitHidden && hostTrigger && hostTrigger !== "hidden" ? hostTrigger : widgetTrigger;
|
|
7449
7779
|
const runtimeWidget = runtime.widget;
|
|
7450
7780
|
const runtimeBannerVariant = runtimeWidget?.bannerVariant;
|
|
7451
7781
|
const runtimeBannerPosition = runtimeWidget?.bannerPosition;
|
|
@@ -7469,7 +7799,7 @@ function mergeRuntimeConfig(config, runtime) {
|
|
|
7469
7799
|
widget: {
|
|
7470
7800
|
...config.widget,
|
|
7471
7801
|
...runtime.widget,
|
|
7472
|
-
...
|
|
7802
|
+
...safeWidgetTrigger ? { trigger: safeWidgetTrigger } : {},
|
|
7473
7803
|
...derivedBannerConfig ? { bannerConfig: derivedBannerConfig } : {},
|
|
7474
7804
|
// betaMode is local-only: set by the host app, not the dashboard.
|
|
7475
7805
|
// Restore it after the runtime spread so it is never silently cleared.
|
|
@@ -7545,9 +7875,7 @@ function resolveApiEndpoint(config) {
|
|
|
7545
7875
|
return config.apiEndpoint ?? DEFAULT_API_ENDPOINT;
|
|
7546
7876
|
}
|
|
7547
7877
|
function shouldUseRuntimeConfig(config) {
|
|
7548
|
-
|
|
7549
|
-
if (config.runtimeConfig === true) return true;
|
|
7550
|
-
return !isLocalhostEndpoint(resolveApiEndpoint(config));
|
|
7878
|
+
return config.runtimeConfig !== false;
|
|
7551
7879
|
}
|
|
7552
7880
|
async function runDiagnostics(options) {
|
|
7553
7881
|
const endpoint = await probeApiEndpoint(options.apiEndpoint);
|
|
@@ -7702,6 +8030,8 @@ function createNoopInstance() {
|
|
|
7702
8030
|
},
|
|
7703
8031
|
setTrigger: () => {
|
|
7704
8032
|
},
|
|
8033
|
+
openReporter: () => {
|
|
8034
|
+
},
|
|
7705
8035
|
destroy: () => {
|
|
7706
8036
|
instance = null;
|
|
7707
8037
|
},
|
|
@@ -7709,6 +8039,12 @@ function createNoopInstance() {
|
|
|
7709
8039
|
captureException: async () => null,
|
|
7710
8040
|
identify: () => {
|
|
7711
8041
|
},
|
|
8042
|
+
identifyWithToken: () => {
|
|
8043
|
+
},
|
|
8044
|
+
publishPageContext: () => {
|
|
8045
|
+
},
|
|
8046
|
+
openAssistant: () => {
|
|
8047
|
+
},
|
|
7712
8048
|
addBreadcrumb: () => {
|
|
7713
8049
|
},
|
|
7714
8050
|
getBreadcrumbs: () => [],
|