@mushi-mushi/web 1.28.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 +35 -6
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.d.cts +2 -2
- package/dist/headless.d.ts +2 -2
- package/dist/headless.js.map +1 -1
- package/dist/i18n/index.cjs +4 -4
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +1 -0
- package/dist/i18n/index.d.ts +1 -0
- package/dist/i18n/index.js +4 -4
- package/dist/i18n/index.js.map +1 -1
- package/dist/index.cjs +145 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +146 -28
- package/dist/index.js.map +1 -1
- package/dist/mushi.loader.global.js +410 -398
- package/dist/test-utils.cjs.map +1 -1
- package/dist/test-utils.js.map +1 -1
- package/package.json +74 -32
- package/CODE_OF_CONDUCT.md +0 -51
- package/CONTRIBUTING.md +0 -226
- package/SECURITY.md +0 -359
- package/dist/mushi.loader.global.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -92,6 +92,9 @@ interface WidgetCallbacks {
|
|
|
92
92
|
}): void | Promise<WidgetSubmitOutcome | void>;
|
|
93
93
|
onOpen(): void;
|
|
94
94
|
onClose(): void;
|
|
95
|
+
/** "Bug reports by Mushi" mark: impression once per widget instance, click per activation → loop_* events. */
|
|
96
|
+
onBrandFooterImpression?(): void;
|
|
97
|
+
onBrandFooterClick?(): void;
|
|
95
98
|
onScreenshotRequest(): void;
|
|
96
99
|
onScreenshotRemove?(): void;
|
|
97
100
|
/** Optional markup pass (highlight / blur / arrow) before submit. */
|
|
@@ -202,6 +205,9 @@ declare class MushiWidget {
|
|
|
202
205
|
private nudgeEl;
|
|
203
206
|
private nudgeTimer;
|
|
204
207
|
private sdkFreshness;
|
|
208
|
+
/** Brand-footer ref (SDK sets it once hashed) + once-per-instance impression latch. */
|
|
209
|
+
private brandRef;
|
|
210
|
+
private brandImpressionSent;
|
|
205
211
|
private reporterReports;
|
|
206
212
|
private featureBoard;
|
|
207
213
|
private reporterComments;
|
|
@@ -352,6 +358,7 @@ declare class MushiWidget {
|
|
|
352
358
|
deprecated: boolean;
|
|
353
359
|
message?: string | null;
|
|
354
360
|
}): void;
|
|
361
|
+
setBrandRef(ref: string | null): void;
|
|
355
362
|
setRewardsState(state: WidgetRewardsState | null): void;
|
|
356
363
|
setLeaderboard(entries: Array<{
|
|
357
364
|
display_name: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -92,6 +92,9 @@ interface WidgetCallbacks {
|
|
|
92
92
|
}): void | Promise<WidgetSubmitOutcome | void>;
|
|
93
93
|
onOpen(): void;
|
|
94
94
|
onClose(): void;
|
|
95
|
+
/** "Bug reports by Mushi" mark: impression once per widget instance, click per activation → loop_* events. */
|
|
96
|
+
onBrandFooterImpression?(): void;
|
|
97
|
+
onBrandFooterClick?(): void;
|
|
95
98
|
onScreenshotRequest(): void;
|
|
96
99
|
onScreenshotRemove?(): void;
|
|
97
100
|
/** Optional markup pass (highlight / blur / arrow) before submit. */
|
|
@@ -202,6 +205,9 @@ declare class MushiWidget {
|
|
|
202
205
|
private nudgeEl;
|
|
203
206
|
private nudgeTimer;
|
|
204
207
|
private sdkFreshness;
|
|
208
|
+
/** Brand-footer ref (SDK sets it once hashed) + once-per-instance impression latch. */
|
|
209
|
+
private brandRef;
|
|
210
|
+
private brandImpressionSent;
|
|
205
211
|
private reporterReports;
|
|
206
212
|
private featureBoard;
|
|
207
213
|
private reporterComments;
|
|
@@ -352,6 +358,7 @@ declare class MushiWidget {
|
|
|
352
358
|
deprecated: boolean;
|
|
353
359
|
message?: string | null;
|
|
354
360
|
}): void;
|
|
361
|
+
setBrandRef(ref: string | null): void;
|
|
355
362
|
setRewardsState(state: WidgetRewardsState | null): void;
|
|
356
363
|
setLeaderboard(entries: Array<{
|
|
357
364
|
display_name: string;
|
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, scrubUrl, resolveEnvConfig, diagnoseEnvConfig, validateConfig, expandPreset, createLogger, noopLogger, createApiClient, initSessionTracker, getReporterToken, createPreFilter, createOfflineQueue, createRateLimiter, createPiiScrubber, createBreadcrumbBuffer, getDeviceFingerprintHash, MAX_SCREENSHOT_DATA_URL_BYTES, captureEnvironment,
|
|
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, scrubUrl, resolveEnvConfig, diagnoseEnvConfig, validateConfig, expandPreset, createLogger, noopLogger, createApiClient, initSessionTracker, getReporterToken, trackPageView, createPreFilter, createOfflineQueue, createRateLimiter, createPiiScrubber, initEventTracker, getSessionId, createBreadcrumbBuffer, sha256Hex, trackEvent, flushEvents, getDeviceFingerprintHash, MAX_SCREENSHOT_DATA_URL_BYTES, captureEnvironment, newUuid, markPageUnloading, flushLastOutboundOnUnload, DEFAULT_API_ENDPOINT, shouldDropCapturedError, MUSHI_DURATION, MUSHI_SPACING, MUSHI_RADIUS, isLikelyGenericFavicon, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INTERNAL_HEADER, MUSHI_COLORS_LIGHT, getEventAnonymousId, setEventConsent, parseIdentityToken, updateSessionIdentity, updateEventIdentity, normaliseThrown, destroyEventTracker, destroySessionTracker, resolveProjectDomain, projectInitials, projectFaviconUrlCandidates } 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) {
|
|
@@ -222,7 +222,7 @@ var en = {
|
|
|
222
222
|
changelog: {
|
|
223
223
|
whatsNew: "What's new in {version}"
|
|
224
224
|
},
|
|
225
|
-
poweredBy: "
|
|
225
|
+
poweredBy: "Bug reports by Mushi"
|
|
226
226
|
}
|
|
227
227
|
};
|
|
228
228
|
|
|
@@ -412,7 +412,7 @@ var ja = {
|
|
|
412
412
|
changelog: {
|
|
413
413
|
whatsNew: "{version} \u306E\u65B0\u6A5F\u80FD"
|
|
414
414
|
},
|
|
415
|
-
poweredBy: "Mushi
|
|
415
|
+
poweredBy: "\u30D0\u30B0\u5831\u544A\u306F Mushi \u3067"
|
|
416
416
|
}
|
|
417
417
|
};
|
|
418
418
|
|
|
@@ -602,7 +602,7 @@ var th = {
|
|
|
602
602
|
changelog: {
|
|
603
603
|
whatsNew: "\u0E21\u0E35\u0E2D\u0E30\u0E44\u0E23\u0E43\u0E2B\u0E21\u0E48\u0E43\u0E19 {version}"
|
|
604
604
|
},
|
|
605
|
-
poweredBy: "
|
|
605
|
+
poweredBy: "\u0E23\u0E32\u0E22\u0E07\u0E32\u0E19\u0E1A\u0E31\u0E4A\u0E01\u0E42\u0E14\u0E22 Mushi"
|
|
606
606
|
}
|
|
607
607
|
};
|
|
608
608
|
|
|
@@ -792,7 +792,7 @@ var es = {
|
|
|
792
792
|
changelog: {
|
|
793
793
|
whatsNew: "Novedades de {version}"
|
|
794
794
|
},
|
|
795
|
-
poweredBy: "
|
|
795
|
+
poweredBy: "Reportes de errores con Mushi"
|
|
796
796
|
}
|
|
797
797
|
};
|
|
798
798
|
|
|
@@ -1863,6 +1863,19 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1863
1863
|
text-align: center;
|
|
1864
1864
|
text-transform: uppercase;
|
|
1865
1865
|
}
|
|
1866
|
+
.mushi-brand-link {
|
|
1867
|
+
color: inherit;
|
|
1868
|
+
text-decoration: none;
|
|
1869
|
+
text-underline-offset: 3px;
|
|
1870
|
+
}
|
|
1871
|
+
.mushi-brand-link:hover { color: ${inkMuted}; text-decoration: underline; }
|
|
1872
|
+
.mushi-brand-link:focus-visible {
|
|
1873
|
+
outline: 2px solid ${widgetAccent};
|
|
1874
|
+
outline-offset: 2px;
|
|
1875
|
+
border-radius: 2px;
|
|
1876
|
+
color: ${widgetAccent};
|
|
1877
|
+
text-decoration: underline;
|
|
1878
|
+
}
|
|
1866
1879
|
|
|
1867
1880
|
.mushi-step-indicator {
|
|
1868
1881
|
display: flex;
|
|
@@ -2713,7 +2726,7 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
2713
2726
|
|
|
2714
2727
|
// src/version.ts
|
|
2715
2728
|
var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
|
|
2716
|
-
var MUSHI_SDK_VERSION = "1.
|
|
2729
|
+
var MUSHI_SDK_VERSION = "1.29.0" ;
|
|
2717
2730
|
var ASSISTANT_SESSION_STORAGE_KEY = "mushi-assistant-session-v1";
|
|
2718
2731
|
function loadAssistantSession() {
|
|
2719
2732
|
try {
|
|
@@ -2871,6 +2884,12 @@ function formatRelativeTime(iso) {
|
|
|
2871
2884
|
function pad2(n) {
|
|
2872
2885
|
return n < 10 ? `0${n}` : String(n);
|
|
2873
2886
|
}
|
|
2887
|
+
var BRAND_FOOTER_URL = "https://kensaur.us/mushi-mushi/";
|
|
2888
|
+
var BRAND_FOOTER_UTM = "utm_source=widget&utm_medium=powered-by";
|
|
2889
|
+
function buildBrandFooterHref(ref) {
|
|
2890
|
+
const base = `${BRAND_FOOTER_URL}?${BRAND_FOOTER_UTM}`;
|
|
2891
|
+
return ref && /^[0-9a-f]{6,64}$/.test(ref) ? `${base}&ref=${ref}` : base;
|
|
2892
|
+
}
|
|
2874
2893
|
var TOTAL_STEPS = 3;
|
|
2875
2894
|
var STEP_NUMBER = {
|
|
2876
2895
|
category: 1,
|
|
@@ -3017,8 +3036,9 @@ function renderOutdatedBanner(ctx) {
|
|
|
3017
3036
|
`;
|
|
3018
3037
|
}
|
|
3019
3038
|
function renderBrandFooter(ctx) {
|
|
3020
|
-
if (ctx.config.brandFooter
|
|
3021
|
-
|
|
3039
|
+
if (ctx.config.brandFooter !== true) return "";
|
|
3040
|
+
const href = buildBrandFooterHref(ctx.brandRef);
|
|
3041
|
+
return `<div class="mushi-brand-footer"><a class="mushi-brand-link" href="${escapeHtml(href)}" target="_blank" rel="noopener noreferrer" data-action="brand-footer">${escapeHtml(ctx.locale.flows.poweredBy)}<span aria-hidden="true"> \u2197</span></a></div>`;
|
|
3022
3042
|
}
|
|
3023
3043
|
function renderHeader(ctx, opts) {
|
|
3024
3044
|
const t = ctx.locale;
|
|
@@ -3855,6 +3875,9 @@ var MushiWidget = class _MushiWidget {
|
|
|
3855
3875
|
nudgeEl = null;
|
|
3856
3876
|
nudgeTimer = null;
|
|
3857
3877
|
sdkFreshness = null;
|
|
3878
|
+
/** Brand-footer ref (SDK sets it once hashed) + once-per-instance impression latch. */
|
|
3879
|
+
brandRef = null;
|
|
3880
|
+
brandImpressionSent = false;
|
|
3858
3881
|
reporterReports = [];
|
|
3859
3882
|
featureBoard = [];
|
|
3860
3883
|
reporterComments = [];
|
|
@@ -4363,6 +4386,11 @@ var MushiWidget = class _MushiWidget {
|
|
|
4363
4386
|
this.sdkFreshness = info;
|
|
4364
4387
|
if (this.isOpen) this.render();
|
|
4365
4388
|
}
|
|
4389
|
+
setBrandRef(ref) {
|
|
4390
|
+
if (this.brandRef === ref) return;
|
|
4391
|
+
this.brandRef = ref;
|
|
4392
|
+
if (this.isOpen) this.render();
|
|
4393
|
+
}
|
|
4366
4394
|
setRewardsState(state) {
|
|
4367
4395
|
this.rewardsState = state;
|
|
4368
4396
|
if (this.isOpen) this.render();
|
|
@@ -4912,6 +4940,10 @@ var MushiWidget = class _MushiWidget {
|
|
|
4912
4940
|
panel.innerHTML = `${renderOutdatedBanner(ctx)}${renderStep(ctx)}${renderBrandFooter(ctx)}`;
|
|
4913
4941
|
this.shadow.appendChild(panel);
|
|
4914
4942
|
this.attachHandlers(panel);
|
|
4943
|
+
if (!this.brandImpressionSent && this.config.brandFooter === true) {
|
|
4944
|
+
this.brandImpressionSent = true;
|
|
4945
|
+
this.callbacks.onBrandFooterImpression?.();
|
|
4946
|
+
}
|
|
4915
4947
|
this.trapFocus(panel);
|
|
4916
4948
|
this.restoreFormDrafts(panel);
|
|
4917
4949
|
this.attachViewportHandlers(panel);
|
|
@@ -5248,13 +5280,17 @@ var MushiWidget = class _MushiWidget {
|
|
|
5248
5280
|
assistantError: this.assistantError,
|
|
5249
5281
|
showAllCategories: this.showAllCategories,
|
|
5250
5282
|
showMoreNav: this.showMoreNav,
|
|
5251
|
-
pageFaviconHref: readPageFaviconHref()
|
|
5283
|
+
pageFaviconHref: readPageFaviconHref(),
|
|
5284
|
+
brandRef: this.brandRef
|
|
5252
5285
|
};
|
|
5253
5286
|
}
|
|
5254
5287
|
attachHandlers(panel) {
|
|
5255
5288
|
const t = this.locale;
|
|
5256
5289
|
bindFaviconFallbacks(panel);
|
|
5257
5290
|
panel.querySelector('[data-action="close"]')?.addEventListener("click", () => this.close());
|
|
5291
|
+
panel.querySelector('[data-action="brand-footer"]')?.addEventListener("click", () => {
|
|
5292
|
+
this.callbacks.onBrandFooterClick?.();
|
|
5293
|
+
});
|
|
5258
5294
|
panel.querySelector('[data-action="back"]')?.addEventListener("click", () => {
|
|
5259
5295
|
if (this.step === "intent") {
|
|
5260
5296
|
this.step = "category";
|
|
@@ -5840,7 +5876,8 @@ function mergeRuntimeCapture(host, runtime) {
|
|
|
5840
5876
|
}
|
|
5841
5877
|
return merged;
|
|
5842
5878
|
}
|
|
5843
|
-
|
|
5879
|
+
var HOST_WINS_WIDGET_KEYS = ["brandFooter"];
|
|
5880
|
+
function mergeRuntimeConfig(config, runtime, host = config) {
|
|
5844
5881
|
const nativeTrigger = runtime.native?.triggerMode;
|
|
5845
5882
|
const runtimeLauncher = runtime.widget?.launcher;
|
|
5846
5883
|
const hostTrigger = config.widget?.trigger;
|
|
@@ -5869,7 +5906,11 @@ function mergeRuntimeConfig(config, runtime) {
|
|
|
5869
5906
|
if (runtime.widget) {
|
|
5870
5907
|
for (const [key, value] of Object.entries(runtime.widget)) {
|
|
5871
5908
|
if (key === "trigger" || key === "launcher") continue;
|
|
5872
|
-
if (value
|
|
5909
|
+
if (value === void 0 || value === null) continue;
|
|
5910
|
+
if (HOST_WINS_WIDGET_KEYS.includes(key) && host.widget?.[key] !== void 0) {
|
|
5911
|
+
continue;
|
|
5912
|
+
}
|
|
5913
|
+
definedRuntimeWidget[key] = value;
|
|
5873
5914
|
}
|
|
5874
5915
|
}
|
|
5875
5916
|
return {
|
|
@@ -7537,8 +7578,6 @@ function createDiscoveryCapture(opts) {
|
|
|
7537
7578
|
}
|
|
7538
7579
|
};
|
|
7539
7580
|
}
|
|
7540
|
-
|
|
7541
|
-
// src/capture/replay.ts
|
|
7542
7581
|
var DEFAULT_MAX_MS = 3e4;
|
|
7543
7582
|
var MAX_EVENTS = 400;
|
|
7544
7583
|
var RRWEB_META = 4;
|
|
@@ -7596,15 +7635,33 @@ function createLiteReplay(maxMs) {
|
|
|
7596
7635
|
}
|
|
7597
7636
|
};
|
|
7598
7637
|
}
|
|
7638
|
+
var DEFAULT_REDACT_SELECTORS2 = ['input[type="password"]', "[data-mushi-redact]"];
|
|
7599
7639
|
var rrwebModule = null;
|
|
7600
|
-
|
|
7640
|
+
var warnedMissingRrweb = false;
|
|
7641
|
+
function asRrweb(mod) {
|
|
7642
|
+
if (!mod || typeof mod !== "object") return null;
|
|
7643
|
+
const direct = mod;
|
|
7644
|
+
if (typeof direct.record === "function") return direct;
|
|
7645
|
+
if (direct.default && typeof direct.default.record === "function") return direct.default;
|
|
7646
|
+
return null;
|
|
7647
|
+
}
|
|
7648
|
+
async function loadRrweb(loader) {
|
|
7649
|
+
if (rrwebModule) return rrwebModule;
|
|
7650
|
+
if (typeof loader === "function") {
|
|
7651
|
+
try {
|
|
7652
|
+
rrwebModule = asRrweb(await loader());
|
|
7653
|
+
if (rrwebModule) return rrwebModule;
|
|
7654
|
+
} catch {
|
|
7655
|
+
}
|
|
7656
|
+
}
|
|
7657
|
+
rrwebModule = asRrweb(globalThis.rrweb);
|
|
7601
7658
|
if (rrwebModule) return rrwebModule;
|
|
7602
7659
|
try {
|
|
7603
7660
|
const specifier = "rrweb";
|
|
7604
|
-
rrwebModule = await import(
|
|
7661
|
+
rrwebModule = asRrweb(await import(
|
|
7605
7662
|
/* @vite-ignore */
|
|
7606
7663
|
specifier
|
|
7607
|
-
);
|
|
7664
|
+
));
|
|
7608
7665
|
return rrwebModule;
|
|
7609
7666
|
} catch {
|
|
7610
7667
|
return null;
|
|
@@ -7612,15 +7669,22 @@ async function loadRrweb() {
|
|
|
7612
7669
|
}
|
|
7613
7670
|
async function createReplayCapture(opts) {
|
|
7614
7671
|
const maxMs = opts.maxDurationMs ?? DEFAULT_MAX_MS;
|
|
7615
|
-
|
|
7672
|
+
if (opts.mode === "lite") return createLiteReplay(maxMs);
|
|
7673
|
+
const rrweb = await loadRrweb(opts.loadRrweb);
|
|
7616
7674
|
if (!rrweb?.record) {
|
|
7675
|
+
if (!warnedMissingRrweb) {
|
|
7676
|
+
warnedMissingRrweb = true;
|
|
7677
|
+
createLogger({ scope: "mushi" }).warn(
|
|
7678
|
+
"capture.replay is 'rrweb' but rrweb could not be loaded, so replay is recording clicks only. Install rrweb and pass capture: { rrweb: () => import('rrweb') }."
|
|
7679
|
+
);
|
|
7680
|
+
}
|
|
7617
7681
|
return createLiteReplay(maxMs);
|
|
7618
7682
|
}
|
|
7619
7683
|
const record = rrweb.record;
|
|
7620
7684
|
const events = [];
|
|
7621
7685
|
let stopFn = null;
|
|
7622
7686
|
let recording = false;
|
|
7623
|
-
const
|
|
7687
|
+
const redactSelectors = [.../* @__PURE__ */ new Set([...DEFAULT_REDACT_SELECTORS2, ...opts.redactSelectors ?? []])];
|
|
7624
7688
|
const stop = () => {
|
|
7625
7689
|
stopFn?.();
|
|
7626
7690
|
stopFn = null;
|
|
@@ -7636,13 +7700,8 @@ async function createReplayCapture(opts) {
|
|
|
7636
7700
|
trimReplayBuffer(events, maxMs, MAX_EVENTS);
|
|
7637
7701
|
},
|
|
7638
7702
|
maskAllInputs: true,
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
// capture can opt out via their own rrweb integration.
|
|
7642
|
-
maskAllText: true,
|
|
7643
|
-
maskTextSelector: maskSelectors.join(","),
|
|
7644
|
-
// Re-emit a full snapshot roughly once per retained window so trimming
|
|
7645
|
-
// never leaves incrementals without a base snapshot.
|
|
7703
|
+
maskTextSelector: "*",
|
|
7704
|
+
blockSelector: redactSelectors.join(","),
|
|
7646
7705
|
checkoutEveryNms: maxMs,
|
|
7647
7706
|
sampling: { mousemove: false, mouseInteraction: true, scroll: 150, media: 800 }
|
|
7648
7707
|
}) ?? null;
|
|
@@ -8333,17 +8392,42 @@ function createInstance(config) {
|
|
|
8333
8392
|
sdkPackage: MUSHI_SDK_PACKAGE,
|
|
8334
8393
|
sdkVersion: MUSHI_SDK_VERSION
|
|
8335
8394
|
});
|
|
8336
|
-
|
|
8395
|
+
let unsubPageViewHistory = null;
|
|
8396
|
+
if (bootstrapConfig.trackSessions !== false) {
|
|
8337
8397
|
initSessionTracker({
|
|
8338
8398
|
client: apiClient2,
|
|
8339
8399
|
sdkVersion: MUSHI_SDK_VERSION,
|
|
8340
|
-
|
|
8400
|
+
reporterToken: getReporterToken(bootstrapConfig.projectId) ?? null,
|
|
8401
|
+
projectId: bootstrapConfig.projectId,
|
|
8402
|
+
analytics: bootstrapConfig.analytics,
|
|
8403
|
+
// This package owns the history patch (history-patch.ts):
|
|
8404
|
+
// installAutoBreadcrumbs() captures History.prototype.pushState (the
|
|
8405
|
+
// native) and assigns its own wrapper to history.pushState, which
|
|
8406
|
+
// silently discarded core's page-view wrapper — so no SPA page view
|
|
8407
|
+
// was ever recorded from this SDK. Report views through the shared
|
|
8408
|
+
// patch instead of stacking a second wrapper.
|
|
8409
|
+
patchHistory: false
|
|
8341
8410
|
});
|
|
8411
|
+
try {
|
|
8412
|
+
unsubPageViewHistory = subscribeHistory({
|
|
8413
|
+
onPush: () => trackPageView(),
|
|
8414
|
+
onPop: () => trackPageView()
|
|
8415
|
+
});
|
|
8416
|
+
} catch {
|
|
8417
|
+
}
|
|
8342
8418
|
}
|
|
8343
8419
|
const preFilter = createPreFilter(bootstrapConfig.preFilter);
|
|
8344
8420
|
const offlineQueue = createOfflineQueue(bootstrapConfig.offline);
|
|
8345
8421
|
const rateLimiter = createRateLimiter({ maxBurst: 10, refillRate: 1, refillIntervalMs: 5e3 });
|
|
8346
8422
|
const piiScrubber = createPiiScrubber();
|
|
8423
|
+
initEventTracker({
|
|
8424
|
+
client: apiClient2,
|
|
8425
|
+
projectId: bootstrapConfig.projectId,
|
|
8426
|
+
sdkVersion: MUSHI_SDK_VERSION,
|
|
8427
|
+
config: bootstrapConfig.analytics,
|
|
8428
|
+
scrub: (s) => piiScrubber.scrub(s),
|
|
8429
|
+
getSessionId
|
|
8430
|
+
});
|
|
8347
8431
|
function scrubBreadcrumbsForWire(crumbs) {
|
|
8348
8432
|
return crumbs.map((c) => {
|
|
8349
8433
|
const next = { ...c };
|
|
@@ -8523,6 +8607,8 @@ function createInstance(config) {
|
|
|
8523
8607
|
if ((replayMode === "rrweb" || replayMode === "lite") && (replaySampled || replayOnErrorSampled)) {
|
|
8524
8608
|
const generation = ++replayGeneration;
|
|
8525
8609
|
void createReplayCapture({
|
|
8610
|
+
mode: replayMode,
|
|
8611
|
+
loadRrweb: bootstrapConfig.capture?.rrweb,
|
|
8526
8612
|
redactSelectors: activeConfig.privacy?.redactSelectors
|
|
8527
8613
|
}).then((cap) => {
|
|
8528
8614
|
if (generation !== replayGeneration) {
|
|
@@ -8662,6 +8748,7 @@ function createInstance(config) {
|
|
|
8662
8748
|
widget.setScreenshotAttached(pendingScreenshot !== null);
|
|
8663
8749
|
widget.setScreenshotPreview(pendingScreenshot);
|
|
8664
8750
|
}
|
|
8751
|
+
const brandRefReady = sha256Hex(projectId).then((hex) => hex.slice(0, 12)).catch(() => null);
|
|
8665
8752
|
widget = new MushiWidget(bootstrapConfig.widget, {
|
|
8666
8753
|
onSubmit: async ({ category, userCategory, description, intent }) => {
|
|
8667
8754
|
log.info("Report submitted", { category, userCategory, intent });
|
|
@@ -8676,6 +8763,18 @@ function createInstance(config) {
|
|
|
8676
8763
|
replayCap?.start();
|
|
8677
8764
|
emit("widget:opened");
|
|
8678
8765
|
},
|
|
8766
|
+
// Growth loop (plan-gtm C §5); the tracker already honours DNT/consent/enabled.
|
|
8767
|
+
onBrandFooterImpression: () => {
|
|
8768
|
+
void brandRefReady.then((ref) => {
|
|
8769
|
+
trackEvent("loop_impression", { placement: "widget" }, ref ? { reserved: { $ref: ref } } : void 0);
|
|
8770
|
+
});
|
|
8771
|
+
},
|
|
8772
|
+
onBrandFooterClick: () => {
|
|
8773
|
+
void brandRefReady.then((ref) => {
|
|
8774
|
+
trackEvent("loop_click", { placement: "widget" }, ref ? { reserved: { $ref: ref } } : void 0);
|
|
8775
|
+
return flushEvents();
|
|
8776
|
+
});
|
|
8777
|
+
},
|
|
8679
8778
|
onClose: () => {
|
|
8680
8779
|
log.debug("Widget closed");
|
|
8681
8780
|
if (pendingProactiveTrigger) {
|
|
@@ -8894,6 +8993,7 @@ function createInstance(config) {
|
|
|
8894
8993
|
return res.ok ? res.data ?? null : null;
|
|
8895
8994
|
}
|
|
8896
8995
|
}, MUSHI_SDK_VERSION);
|
|
8996
|
+
void brandRefReady.then((ref) => widget.setBrandRef(ref));
|
|
8897
8997
|
syncCaptureModules();
|
|
8898
8998
|
if (typeof document !== "undefined") {
|
|
8899
8999
|
if (document.readyState === "loading") {
|
|
@@ -8972,7 +9072,7 @@ function createInstance(config) {
|
|
|
8972
9072
|
log.debug("Runtime SDK config disabled; using bootstrap config", { version: runtime.version });
|
|
8973
9073
|
return;
|
|
8974
9074
|
}
|
|
8975
|
-
activeConfig = mergeRuntimeConfig(activeConfig, runtime);
|
|
9075
|
+
activeConfig = mergeRuntimeConfig(activeConfig, runtime, bootstrapConfig);
|
|
8976
9076
|
syncCaptureModules();
|
|
8977
9077
|
if (runtime.widget) widget.updateConfig(activeConfig.widget);
|
|
8978
9078
|
if (reporterNotificationsEnabled) startReporterInboxPolling();
|
|
@@ -9340,6 +9440,7 @@ function createInstance(config) {
|
|
|
9340
9440
|
destroy() {
|
|
9341
9441
|
proactiveTriggers?.destroy();
|
|
9342
9442
|
proactiveManager?.reset();
|
|
9443
|
+
destroyEventTracker();
|
|
9343
9444
|
widget.destroy();
|
|
9344
9445
|
consoleCap?.destroy();
|
|
9345
9446
|
networkCap?.destroy();
|
|
@@ -9356,6 +9457,8 @@ function createInstance(config) {
|
|
|
9356
9457
|
replayCap = null;
|
|
9357
9458
|
offlineQueue.stopAutoSync();
|
|
9358
9459
|
stopReporterInboxPolling();
|
|
9460
|
+
unsubPageViewHistory?.();
|
|
9461
|
+
unsubPageViewHistory = null;
|
|
9359
9462
|
destroySessionTracker();
|
|
9360
9463
|
breadcrumbs.clear();
|
|
9361
9464
|
listeners.clear();
|
|
@@ -9502,6 +9605,7 @@ function createInstance(config) {
|
|
|
9502
9605
|
level: "info",
|
|
9503
9606
|
message: `Mushi.identify(${userId})`
|
|
9504
9607
|
});
|
|
9608
|
+
updateEventIdentity(userId, traits ?? null);
|
|
9505
9609
|
wireRewardsForIdentifiedUser(
|
|
9506
9610
|
userId,
|
|
9507
9611
|
traits ? {
|
|
@@ -9594,6 +9698,16 @@ function createInstance(config) {
|
|
|
9594
9698
|
if (!activeConfig.rewards?.enabled) return;
|
|
9595
9699
|
enqueue({ action, metadata });
|
|
9596
9700
|
},
|
|
9701
|
+
// ─── Product analytics (Users & Funnels) ──────────────────────────
|
|
9702
|
+
track(event, properties) {
|
|
9703
|
+
return trackEvent(event, properties);
|
|
9704
|
+
},
|
|
9705
|
+
setConsent(state) {
|
|
9706
|
+
setEventConsent(state);
|
|
9707
|
+
},
|
|
9708
|
+
getAnonymousId() {
|
|
9709
|
+
return getEventAnonymousId();
|
|
9710
|
+
},
|
|
9597
9711
|
pulseTrigger() {
|
|
9598
9712
|
widget.pulseTrigger?.();
|
|
9599
9713
|
},
|
|
@@ -9904,6 +10018,10 @@ function createNoopInstance() {
|
|
|
9904
10018
|
getTier: async () => null,
|
|
9905
10019
|
recordActivity: () => {
|
|
9906
10020
|
},
|
|
10021
|
+
track: () => false,
|
|
10022
|
+
setConsent: () => {
|
|
10023
|
+
},
|
|
10024
|
+
getAnonymousId: () => null,
|
|
9907
10025
|
pulseTrigger: () => {
|
|
9908
10026
|
},
|
|
9909
10027
|
listMyReports: async () => [],
|