@mushi-mushi/web 1.21.1 → 1.22.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 +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 +422 -422
- package/dist/mushi.loader.global.js.map +1 -1
- package/package.json +11 -12
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mushiPalette, resolveWidgetAccent, MUSHI_REPORTER_STATUS, MUSHI_GEOMETRY, MUSHI_Z, MUSHI_MOTION, MUSHI_TYPE, MUSHI_BANNER_BRAND_BORDER, MUSHI_BANNER_NEON, MUSHI_INVERSE, MUSHI_ON_ACCENT, MUSHI_ACCENT_SHADOW, MUSHI_TIER_COLORS, readPageFaviconHref, resolveEnvConfig, createLogger, noopLogger, createApiClient, createPreFilter, createOfflineQueue, createRateLimiter, createPiiScrubber, createBreadcrumbBuffer, getReporterToken, getDeviceFingerprintHash, MAX_SCREENSHOT_DATA_URL_BYTES, captureEnvironment, getSessionId, newUuid, DEFAULT_API_ENDPOINT, MUSHI_RADIUS, MUSHI_SPACING, isLikelyGenericFavicon, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INTERNAL_HEADER, parseIdentityToken, normaliseThrown,
|
|
1
|
+
import { mushiPalette, resolveWidgetAccent, MUSHI_REPORTER_STATUS, MUSHI_GEOMETRY, MUSHI_Z, MUSHI_MOTION, MUSHI_TYPE, MUSHI_BANNER_BRAND_BORDER, MUSHI_BANNER_NEON, MUSHI_INVERSE, MUSHI_ON_ACCENT, MUSHI_ACCENT_SHADOW, MUSHI_TIER_COLORS, readPageFaviconHref, resolveEnvConfig, createLogger, noopLogger, createApiClient, createPreFilter, createOfflineQueue, createRateLimiter, createPiiScrubber, createBreadcrumbBuffer, getReporterToken, getDeviceFingerprintHash, MAX_SCREENSHOT_DATA_URL_BYTES, captureEnvironment, getSessionId, newUuid, DEFAULT_API_ENDPOINT, MUSHI_RADIUS, MUSHI_SPACING, isLikelyGenericFavicon, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INTERNAL_HEADER, MUSHI_COLORS_LIGHT, parseIdentityToken, normaliseThrown, resolveProjectDomain, projectInitials, projectFaviconUrlCandidates, sha256Hex } 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) {
|
|
@@ -2551,7 +2551,7 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
2551
2551
|
|
|
2552
2552
|
// src/version.ts
|
|
2553
2553
|
var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
|
|
2554
|
-
var MUSHI_SDK_VERSION = "1.
|
|
2554
|
+
var MUSHI_SDK_VERSION = "1.22.0" ;
|
|
2555
2555
|
var CATEGORY_ICONS = {
|
|
2556
2556
|
bug: "\u26A0\uFE0F",
|
|
2557
2557
|
slow: "\u{1F40C}",
|
|
@@ -3667,6 +3667,8 @@ var MushiWidget = class _MushiWidget {
|
|
|
3667
3667
|
return this.host.isConnected;
|
|
3668
3668
|
}
|
|
3669
3669
|
updateConfig(config = {}) {
|
|
3670
|
+
const prevTrigger = this.config.trigger;
|
|
3671
|
+
const prevBannerConfig = JSON.stringify(this.config.bannerConfig ?? null);
|
|
3670
3672
|
this.config = {
|
|
3671
3673
|
...this.config,
|
|
3672
3674
|
...config.position ? { position: config.position } : {},
|
|
@@ -3704,6 +3706,11 @@ var MushiWidget = class _MushiWidget {
|
|
|
3704
3706
|
...config.categories !== void 0 ? { categories: config.categories } : {}
|
|
3705
3707
|
};
|
|
3706
3708
|
this.locale = getLocale(this.config.locale === "auto" ? void 0 : this.config.locale);
|
|
3709
|
+
const triggerBecameBanner = this.config.trigger === "banner" && prevTrigger !== "banner";
|
|
3710
|
+
const bannerConfigChanged = JSON.stringify(this.config.bannerConfig ?? null) !== prevBannerConfig;
|
|
3711
|
+
if (triggerBecameBanner || bannerConfigChanged) {
|
|
3712
|
+
this.bannerDismissed = false;
|
|
3713
|
+
}
|
|
3707
3714
|
if (this.host.isConnected) this.syncHostChromeState();
|
|
3708
3715
|
this.syncAttachedLaunchers();
|
|
3709
3716
|
this.syncSmartHide();
|
|
@@ -7412,6 +7419,9 @@ var Mushi = class {
|
|
|
7412
7419
|
createLogger({ scope: "mushi", level: "warn", format: "pretty" }).warn("Already initialized \u2014 call destroy() first to reinitialize");
|
|
7413
7420
|
return instance;
|
|
7414
7421
|
}
|
|
7422
|
+
if (typeof document === "undefined" || typeof window === "undefined") {
|
|
7423
|
+
return createNoopInstance();
|
|
7424
|
+
}
|
|
7415
7425
|
const resolved = { ...resolveEnvConfig(), ...config };
|
|
7416
7426
|
if (!resolved.projectId) {
|
|
7417
7427
|
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");
|
|
@@ -7448,6 +7458,9 @@ function createInstance(config) {
|
|
|
7448
7458
|
projectId: bootstrapConfig.projectId,
|
|
7449
7459
|
apiKey: bootstrapConfig.apiKey,
|
|
7450
7460
|
...bootstrapConfig.apiEndpoint ? { apiEndpoint: bootstrapConfig.apiEndpoint } : {},
|
|
7461
|
+
...typeof bootstrapConfig.timeout === "number" ? { timeout: bootstrapConfig.timeout } : {},
|
|
7462
|
+
...typeof bootstrapConfig.maxRetries === "number" ? { maxRetries: bootstrapConfig.maxRetries } : {},
|
|
7463
|
+
...bootstrapConfig.circuitBreaker ? { circuitBreaker: bootstrapConfig.circuitBreaker } : {},
|
|
7451
7464
|
getUserToken: () => userToken,
|
|
7452
7465
|
sdkPackage: MUSHI_SDK_PACKAGE,
|
|
7453
7466
|
sdkVersion: MUSHI_SDK_VERSION
|
|
@@ -7642,6 +7655,7 @@ function createInstance(config) {
|
|
|
7642
7655
|
let reporterPollTimer = null;
|
|
7643
7656
|
let reporterPollVisibleHandler = null;
|
|
7644
7657
|
let userInfo = null;
|
|
7658
|
+
let lastIdentifySig = null;
|
|
7645
7659
|
const customMetadata = {};
|
|
7646
7660
|
const stickyTags = {};
|
|
7647
7661
|
const breadcrumbs = createBreadcrumbBuffer({ max: 50 });
|
|
@@ -7714,7 +7728,7 @@ function createInstance(config) {
|
|
|
7714
7728
|
screenshotCaptureInFlight = true;
|
|
7715
7729
|
try {
|
|
7716
7730
|
const result = await provider();
|
|
7717
|
-
|
|
7731
|
+
if (result) return result;
|
|
7718
7732
|
} catch (err) {
|
|
7719
7733
|
log.warn("screenshotProvider threw, falling back to built-in capturer", {
|
|
7720
7734
|
error: err instanceof Error ? err.message : String(err)
|
|
@@ -7983,6 +7997,10 @@ function createInstance(config) {
|
|
|
7983
7997
|
proactiveTriggers = setupProactiveTriggers(
|
|
7984
7998
|
{
|
|
7985
7999
|
onTrigger: (type, context) => {
|
|
8000
|
+
if (typeof navigator !== "undefined" && !navigator.onLine) {
|
|
8001
|
+
log.debug("Proactive trigger suppressed: offline", { type });
|
|
8002
|
+
return;
|
|
8003
|
+
}
|
|
7986
8004
|
if (!proactiveManager.shouldShow(type)) {
|
|
7987
8005
|
log.debug("Proactive trigger suppressed by fatigue prevention", { type });
|
|
7988
8006
|
return;
|
|
@@ -8497,6 +8515,9 @@ function createInstance(config) {
|
|
|
8497
8515
|
});
|
|
8498
8516
|
},
|
|
8499
8517
|
identify(userId, traits) {
|
|
8518
|
+
const sig = `${userId}::${traits ? JSON.stringify(traits) : ""}`;
|
|
8519
|
+
if (sig === lastIdentifySig) return;
|
|
8520
|
+
lastIdentifySig = sig;
|
|
8500
8521
|
userInfo = { id: userId, ...traits?.email ? { email: traits.email } : {}, ...traits?.name ? { name: traits.name } : {} };
|
|
8501
8522
|
widget.setIdentifiedUser(
|
|
8502
8523
|
userInfo.name || userInfo.email ? { name: userInfo.name, email: userInfo.email } : null
|
|
@@ -8525,6 +8546,10 @@ function createInstance(config) {
|
|
|
8525
8546
|
if (userToken) {
|
|
8526
8547
|
const claims = parseIdentityToken(userToken);
|
|
8527
8548
|
if (claims?.sub) {
|
|
8549
|
+
if (userInfo?.id === claims.sub) {
|
|
8550
|
+
breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken() refreshed" });
|
|
8551
|
+
return;
|
|
8552
|
+
}
|
|
8528
8553
|
userInfo = {
|
|
8529
8554
|
id: claims.sub,
|
|
8530
8555
|
...claims.email ? { email: claims.email } : {},
|
|
@@ -8541,6 +8566,7 @@ function createInstance(config) {
|
|
|
8541
8566
|
breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken()" });
|
|
8542
8567
|
} else {
|
|
8543
8568
|
userInfo = null;
|
|
8569
|
+
lastIdentifySig = null;
|
|
8544
8570
|
widget.setIdentifiedUser(null);
|
|
8545
8571
|
breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken(null)" });
|
|
8546
8572
|
}
|
|
@@ -8668,7 +8694,55 @@ function createInstance(config) {
|
|
|
8668
8694
|
}
|
|
8669
8695
|
}
|
|
8670
8696
|
}
|
|
8671
|
-
|
|
8697
|
+
const PUBLIC_API_FALLBACKS = {
|
|
8698
|
+
on: () => {
|
|
8699
|
+
},
|
|
8700
|
+
// returns a no-op unsubscribe
|
|
8701
|
+
isOpen: false,
|
|
8702
|
+
getBreadcrumbs: [],
|
|
8703
|
+
captureEvent: null,
|
|
8704
|
+
captureException: null,
|
|
8705
|
+
getReputation: null,
|
|
8706
|
+
getTier: null,
|
|
8707
|
+
listMyReports: [],
|
|
8708
|
+
listMyComments: [],
|
|
8709
|
+
getHallOfFame: [],
|
|
8710
|
+
replyToReport: null,
|
|
8711
|
+
submitFeedbackSignal: null,
|
|
8712
|
+
reopenReport: null
|
|
8713
|
+
};
|
|
8714
|
+
const noteSdkError = (method, err) => {
|
|
8715
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
8716
|
+
log.debug(`Mushi.${method}() failed (swallowed)`, { error: message });
|
|
8717
|
+
try {
|
|
8718
|
+
breadcrumbs.add({ category: "custom", level: "warning", message: `mushi.${method}() threw`, data: { error: message } });
|
|
8719
|
+
} catch {
|
|
8720
|
+
}
|
|
8721
|
+
};
|
|
8722
|
+
const isolatePublicApi = (raw) => new Proxy(raw, {
|
|
8723
|
+
get(target, prop, receiver) {
|
|
8724
|
+
const value = Reflect.get(target, prop, receiver);
|
|
8725
|
+
if (typeof value !== "function") return value;
|
|
8726
|
+
const method = String(prop);
|
|
8727
|
+
const resolveFallback = () => method === "diagnose" ? diagnoseWithoutInstance() : method in PUBLIC_API_FALLBACKS ? PUBLIC_API_FALLBACKS[method] : void 0;
|
|
8728
|
+
return (...args) => {
|
|
8729
|
+
try {
|
|
8730
|
+
const result = value.apply(target, args);
|
|
8731
|
+
if (result && typeof result.then === "function") {
|
|
8732
|
+
return result.catch((err) => {
|
|
8733
|
+
noteSdkError(method, err);
|
|
8734
|
+
return resolveFallback();
|
|
8735
|
+
});
|
|
8736
|
+
}
|
|
8737
|
+
return result;
|
|
8738
|
+
} catch (err) {
|
|
8739
|
+
noteSdkError(method, err);
|
|
8740
|
+
return resolveFallback();
|
|
8741
|
+
}
|
|
8742
|
+
};
|
|
8743
|
+
}
|
|
8744
|
+
});
|
|
8745
|
+
return isolatePublicApi(sdk);
|
|
8672
8746
|
}
|
|
8673
8747
|
function mergeRuntimeConfig(config, runtime) {
|
|
8674
8748
|
const nativeTrigger = runtime.native?.triggerMode;
|