@mushi-mushi/web 1.21.0 → 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 +80 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +81 -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();
|
|
@@ -5574,7 +5581,10 @@ var routeObserver = null;
|
|
|
5574
5581
|
var clickHandler = null;
|
|
5575
5582
|
var origPushState = null;
|
|
5576
5583
|
var lastRoute = "";
|
|
5584
|
+
var listenersInstalled = false;
|
|
5577
5585
|
function installActivityListeners(projectId) {
|
|
5586
|
+
if (listenersInstalled) return;
|
|
5587
|
+
listenersInstalled = true;
|
|
5578
5588
|
const emitRoute = () => {
|
|
5579
5589
|
const route = location.pathname;
|
|
5580
5590
|
if (route === lastRoute) return;
|
|
@@ -7409,6 +7419,9 @@ var Mushi = class {
|
|
|
7409
7419
|
createLogger({ scope: "mushi", level: "warn", format: "pretty" }).warn("Already initialized \u2014 call destroy() first to reinitialize");
|
|
7410
7420
|
return instance;
|
|
7411
7421
|
}
|
|
7422
|
+
if (typeof document === "undefined" || typeof window === "undefined") {
|
|
7423
|
+
return createNoopInstance();
|
|
7424
|
+
}
|
|
7412
7425
|
const resolved = { ...resolveEnvConfig(), ...config };
|
|
7413
7426
|
if (!resolved.projectId) {
|
|
7414
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");
|
|
@@ -7445,6 +7458,9 @@ function createInstance(config) {
|
|
|
7445
7458
|
projectId: bootstrapConfig.projectId,
|
|
7446
7459
|
apiKey: bootstrapConfig.apiKey,
|
|
7447
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 } : {},
|
|
7448
7464
|
getUserToken: () => userToken,
|
|
7449
7465
|
sdkPackage: MUSHI_SDK_PACKAGE,
|
|
7450
7466
|
sdkVersion: MUSHI_SDK_VERSION
|
|
@@ -7639,6 +7655,7 @@ function createInstance(config) {
|
|
|
7639
7655
|
let reporterPollTimer = null;
|
|
7640
7656
|
let reporterPollVisibleHandler = null;
|
|
7641
7657
|
let userInfo = null;
|
|
7658
|
+
let lastIdentifySig = null;
|
|
7642
7659
|
const customMetadata = {};
|
|
7643
7660
|
const stickyTags = {};
|
|
7644
7661
|
const breadcrumbs = createBreadcrumbBuffer({ max: 50 });
|
|
@@ -7711,7 +7728,7 @@ function createInstance(config) {
|
|
|
7711
7728
|
screenshotCaptureInFlight = true;
|
|
7712
7729
|
try {
|
|
7713
7730
|
const result = await provider();
|
|
7714
|
-
|
|
7731
|
+
if (result) return result;
|
|
7715
7732
|
} catch (err) {
|
|
7716
7733
|
log.warn("screenshotProvider threw, falling back to built-in capturer", {
|
|
7717
7734
|
error: err instanceof Error ? err.message : String(err)
|
|
@@ -7980,6 +7997,10 @@ function createInstance(config) {
|
|
|
7980
7997
|
proactiveTriggers = setupProactiveTriggers(
|
|
7981
7998
|
{
|
|
7982
7999
|
onTrigger: (type, context) => {
|
|
8000
|
+
if (typeof navigator !== "undefined" && !navigator.onLine) {
|
|
8001
|
+
log.debug("Proactive trigger suppressed: offline", { type });
|
|
8002
|
+
return;
|
|
8003
|
+
}
|
|
7983
8004
|
if (!proactiveManager.shouldShow(type)) {
|
|
7984
8005
|
log.debug("Proactive trigger suppressed by fatigue prevention", { type });
|
|
7985
8006
|
return;
|
|
@@ -8494,6 +8515,9 @@ function createInstance(config) {
|
|
|
8494
8515
|
});
|
|
8495
8516
|
},
|
|
8496
8517
|
identify(userId, traits) {
|
|
8518
|
+
const sig = `${userId}::${traits ? JSON.stringify(traits) : ""}`;
|
|
8519
|
+
if (sig === lastIdentifySig) return;
|
|
8520
|
+
lastIdentifySig = sig;
|
|
8497
8521
|
userInfo = { id: userId, ...traits?.email ? { email: traits.email } : {}, ...traits?.name ? { name: traits.name } : {} };
|
|
8498
8522
|
widget.setIdentifiedUser(
|
|
8499
8523
|
userInfo.name || userInfo.email ? { name: userInfo.name, email: userInfo.email } : null
|
|
@@ -8522,6 +8546,10 @@ function createInstance(config) {
|
|
|
8522
8546
|
if (userToken) {
|
|
8523
8547
|
const claims = parseIdentityToken(userToken);
|
|
8524
8548
|
if (claims?.sub) {
|
|
8549
|
+
if (userInfo?.id === claims.sub) {
|
|
8550
|
+
breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken() refreshed" });
|
|
8551
|
+
return;
|
|
8552
|
+
}
|
|
8525
8553
|
userInfo = {
|
|
8526
8554
|
id: claims.sub,
|
|
8527
8555
|
...claims.email ? { email: claims.email } : {},
|
|
@@ -8538,6 +8566,7 @@ function createInstance(config) {
|
|
|
8538
8566
|
breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken()" });
|
|
8539
8567
|
} else {
|
|
8540
8568
|
userInfo = null;
|
|
8569
|
+
lastIdentifySig = null;
|
|
8541
8570
|
widget.setIdentifiedUser(null);
|
|
8542
8571
|
breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken(null)" });
|
|
8543
8572
|
}
|
|
@@ -8665,7 +8694,55 @@ function createInstance(config) {
|
|
|
8665
8694
|
}
|
|
8666
8695
|
}
|
|
8667
8696
|
}
|
|
8668
|
-
|
|
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);
|
|
8669
8746
|
}
|
|
8670
8747
|
function mergeRuntimeConfig(config, runtime) {
|
|
8671
8748
|
const nativeTrigger = runtime.native?.triggerMode;
|