@mushi-mushi/web 1.27.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/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, getSessionId, newUuid, DEFAULT_API_ENDPOINT, MUSHI_DURATION, MUSHI_SPACING, MUSHI_RADIUS, isLikelyGenericFavicon, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INTERNAL_HEADER, MUSHI_COLORS_LIGHT, parseIdentityToken, updateSessionIdentity, normaliseThrown, destroySessionTracker, resolveProjectDomain, projectInitials, projectFaviconUrlCandidates, sha256Hex } from '@mushi-mushi/core';
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) {
@@ -75,7 +75,9 @@ var en = {
75
75
  visual: "Layout, styling, or display problem",
76
76
  confusing: "Hard to understand or navigate",
77
77
  other: "Something else"
78
- }
78
+ },
79
+ moreCategoriesLabel: "More issue types",
80
+ moreCategoriesCount: "{n} more"
79
81
  },
80
82
  step2: {
81
83
  heading: "What happened?",
@@ -212,7 +214,15 @@ var en = {
212
214
  label: "Feature request",
213
215
  description: "Suggest a change"
214
216
  },
215
- poweredBy: "Powered by Mushi v{version}"
217
+ betaStrip: {
218
+ defaultMessage: "{appName} is in early development",
219
+ contactHint: "Reports go to {email} \xB7 reviewed by the team",
220
+ ariaLabel: "Beta status"
221
+ },
222
+ changelog: {
223
+ whatsNew: "What's new in {version}"
224
+ },
225
+ poweredBy: "Bug reports by Mushi"
216
226
  }
217
227
  };
218
228
 
@@ -255,7 +265,9 @@ var ja = {
255
265
  visual: "\u30EC\u30A4\u30A2\u30A6\u30C8\u3001\u30C7\u30B6\u30A4\u30F3\u3001\u8868\u793A\u306E\u554F\u984C",
256
266
  confusing: "\u7406\u89E3\u3057\u306B\u304F\u3044\u3001\u64CD\u4F5C\u304C\u308F\u304B\u308A\u306B\u304F\u3044",
257
267
  other: "\u305D\u306E\u4ED6\u306E\u554F\u984C"
258
- }
268
+ },
269
+ moreCategoriesLabel: "\u305D\u306E\u4ED6\u306E\u554F\u984C\u306E\u7A2E\u985E",
270
+ moreCategoriesCount: "\u4ED6{n}\u4EF6"
259
271
  },
260
272
  step2: {
261
273
  heading: "\u4F55\u304C\u8D77\u304D\u307E\u3057\u305F\u304B\uFF1F",
@@ -392,7 +404,15 @@ var ja = {
392
404
  label: "\u6A5F\u80FD\u30EA\u30AF\u30A8\u30B9\u30C8",
393
405
  description: "\u5909\u66F4\u3092\u63D0\u6848"
394
406
  },
395
- poweredBy: "Mushi v{version}"
407
+ betaStrip: {
408
+ defaultMessage: "{appName}\u306F\u958B\u767A\u521D\u671F\u6BB5\u968E\u3067\u3059",
409
+ contactHint: "\u30EC\u30DD\u30FC\u30C8\u306F {email} \u306B\u5C4A\u304D\u3001\u30C1\u30FC\u30E0\u304C\u78BA\u8A8D\u3057\u307E\u3059",
410
+ ariaLabel: "\u30D9\u30FC\u30BF\u7248\u306E\u304A\u77E5\u3089\u305B"
411
+ },
412
+ changelog: {
413
+ whatsNew: "{version} \u306E\u65B0\u6A5F\u80FD"
414
+ },
415
+ poweredBy: "\u30D0\u30B0\u5831\u544A\u306F Mushi \u3067"
396
416
  }
397
417
  };
398
418
 
@@ -435,7 +455,9 @@ var th = {
435
455
  visual: "\u0E1B\u0E31\u0E0D\u0E2B\u0E32\u0E40\u0E25\u0E22\u0E4C\u0E40\u0E2D\u0E32\u0E15\u0E4C \u0E2A\u0E44\u0E15\u0E25\u0E4C \u0E2B\u0E23\u0E37\u0E2D\u0E01\u0E32\u0E23\u0E41\u0E2A\u0E14\u0E07\u0E1C\u0E25",
436
456
  confusing: "\u0E40\u0E02\u0E49\u0E32\u0E43\u0E08\u0E22\u0E32\u0E01\u0E2B\u0E23\u0E37\u0E2D\u0E19\u0E33\u0E17\u0E32\u0E07\u0E22\u0E32\u0E01",
437
457
  other: "\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E2D\u0E37\u0E48\u0E19"
438
- }
458
+ },
459
+ moreCategoriesLabel: "\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E1B\u0E31\u0E0D\u0E2B\u0E32\u0E2D\u0E37\u0E48\u0E19 \u0E46",
460
+ moreCategoriesCount: "\u0E2D\u0E35\u0E01 {n} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"
439
461
  },
440
462
  step2: {
441
463
  heading: "\u0E40\u0E01\u0E34\u0E14\u0E2D\u0E30\u0E44\u0E23\u0E02\u0E36\u0E49\u0E19?",
@@ -572,7 +594,15 @@ var th = {
572
594
  label: "\u0E02\u0E2D\u0E1F\u0E35\u0E40\u0E08\u0E2D\u0E23\u0E4C",
573
595
  description: "\u0E40\u0E2A\u0E19\u0E2D\u0E01\u0E32\u0E23\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E41\u0E1B\u0E25\u0E07"
574
596
  },
575
- poweredBy: "Powered by Mushi v{version}"
597
+ betaStrip: {
598
+ defaultMessage: "{appName} \u0E2D\u0E22\u0E39\u0E48\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E01\u0E32\u0E23\u0E1E\u0E31\u0E12\u0E19\u0E32\u0E0A\u0E48\u0E27\u0E07\u0E15\u0E49\u0E19",
599
+ contactHint: "\u0E23\u0E32\u0E22\u0E07\u0E32\u0E19\u0E08\u0E30\u0E2A\u0E48\u0E07\u0E44\u0E1B\u0E17\u0E35\u0E48 {email} \xB7 \u0E17\u0E35\u0E21\u0E07\u0E32\u0E19\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E17\u0E38\u0E01\u0E09\u0E1A\u0E31\u0E1A",
600
+ ariaLabel: "\u0E2A\u0E16\u0E32\u0E19\u0E30\u0E40\u0E1A\u0E15\u0E49\u0E32"
601
+ },
602
+ changelog: {
603
+ whatsNew: "\u0E21\u0E35\u0E2D\u0E30\u0E44\u0E23\u0E43\u0E2B\u0E21\u0E48\u0E43\u0E19 {version}"
604
+ },
605
+ poweredBy: "\u0E23\u0E32\u0E22\u0E07\u0E32\u0E19\u0E1A\u0E31\u0E4A\u0E01\u0E42\u0E14\u0E22 Mushi"
576
606
  }
577
607
  };
578
608
 
@@ -615,7 +645,9 @@ var es = {
615
645
  visual: "Problema de dise\xF1o, estilo o visualizaci\xF3n",
616
646
  confusing: "Dif\xEDcil de entender o navegar",
617
647
  other: "Otro problema"
618
- }
648
+ },
649
+ moreCategoriesLabel: "M\xE1s tipos de problemas",
650
+ moreCategoriesCount: "{n} m\xE1s"
619
651
  },
620
652
  step2: {
621
653
  heading: "\xBFQu\xE9 pas\xF3?",
@@ -752,7 +784,15 @@ var es = {
752
784
  label: "Solicitud de funci\xF3n",
753
785
  description: "Sugerir un cambio"
754
786
  },
755
- poweredBy: "Con tecnolog\xEDa de Mushi v{version}"
787
+ betaStrip: {
788
+ defaultMessage: "{appName} est\xE1 en desarrollo temprano",
789
+ contactHint: "Los reportes van a {email} \xB7 revisados por el equipo",
790
+ ariaLabel: "Estado beta"
791
+ },
792
+ changelog: {
793
+ whatsNew: "Novedades de {version}"
794
+ },
795
+ poweredBy: "Reportes de errores con Mushi"
756
796
  }
757
797
  };
758
798
 
@@ -1823,6 +1863,19 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
1823
1863
  text-align: center;
1824
1864
  text-transform: uppercase;
1825
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
+ }
1826
1879
 
1827
1880
  .mushi-step-indicator {
1828
1881
  display: flex;
@@ -2673,7 +2726,7 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
2673
2726
 
2674
2727
  // src/version.ts
2675
2728
  var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
2676
- var MUSHI_SDK_VERSION = "1.27.0" ;
2729
+ var MUSHI_SDK_VERSION = "1.29.0" ;
2677
2730
  var ASSISTANT_SESSION_STORAGE_KEY = "mushi-assistant-session-v1";
2678
2731
  function loadAssistantSession() {
2679
2732
  try {
@@ -2831,6 +2884,12 @@ function formatRelativeTime(iso) {
2831
2884
  function pad2(n) {
2832
2885
  return n < 10 ? `0${n}` : String(n);
2833
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
+ }
2834
2893
  var TOTAL_STEPS = 3;
2835
2894
  var STEP_NUMBER = {
2836
2895
  category: 1,
@@ -2977,8 +3036,9 @@ function renderOutdatedBanner(ctx) {
2977
3036
  `;
2978
3037
  }
2979
3038
  function renderBrandFooter(ctx) {
2980
- if (ctx.config.brandFooter === false) return "";
2981
- return `<div class="mushi-brand-footer">${escapeHtml(ctx.locale.flows.poweredBy.replace("{version}", ctx.sdkVersion))}</div>`;
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>`;
2982
3042
  }
2983
3043
  function renderHeader(ctx, opts) {
2984
3044
  const t = ctx.locale;
@@ -3101,8 +3161,8 @@ function renderCategoryStep(ctx) {
3101
3161
  const primaryCategories = primaryEntries.map(renderEntry).join("");
3102
3162
  const secondaryCategories = secondaryEntries.map(renderEntry).join("");
3103
3163
  const secondaryHtml = hasMore ? ctx.showAllCategories ? `<div class="mushi-categories-expanded">${secondaryCategories}</div>` : `<button type="button" class="mushi-more-toggle" data-action="show-all-categories">
3104
- <span class="mushi-more-toggle-text">More issue types</span>
3105
- <span class="mushi-more-toggle-count">${secondaryEntries.length} more</span>
3164
+ <span class="mushi-more-toggle-text">${escapeHtml(t.step1.moreCategoriesLabel)}</span>
3165
+ <span class="mushi-more-toggle-count">${escapeHtml(t.step1.moreCategoriesCount.replace("{n}", String(secondaryEntries.length)))}</span>
3106
3166
  <span class="mushi-more-toggle-arrow" aria-hidden="true">\u2192</span>
3107
3167
  </button>` : "";
3108
3168
  return `
@@ -3145,7 +3205,10 @@ function renderBetaChangelog(ctx) {
3145
3205
  if (!entries?.length) return "";
3146
3206
  const latest = entries[0];
3147
3207
  const items = latest.items.map((item) => `<li>\u2022 ${escapeHtml(item)}</li>`).join("");
3148
- const label = latest.date ? `What\u2019s new in ${escapeHtml(latest.version)} \xB7 ${escapeHtml(latest.date)}` : `What\u2019s new in ${escapeHtml(latest.version)}`;
3208
+ const whatsNew = escapeHtml(
3209
+ ctx.locale.flows.changelog.whatsNew.replace("{version}", latest.version)
3210
+ );
3211
+ const label = latest.date ? `${whatsNew} \xB7 ${escapeHtml(latest.date)}` : whatsNew;
3149
3212
  return `
3150
3213
  <details class="mushi-changelog">
3151
3214
  <summary class="mushi-changelog-summary">${label}</summary>
@@ -3155,17 +3218,18 @@ function renderBetaChangelog(ctx) {
3155
3218
  }
3156
3219
  function renderBetaStrip(ctx) {
3157
3220
  const beta = ctx.config.betaMode;
3221
+ const strip = ctx.locale.flows.betaStrip;
3158
3222
  const appName = escapeHtml(beta.appName ?? "This app");
3159
- const message = beta.message ? escapeHtml(beta.message) : `${appName} is in early development`;
3223
+ const message = beta.message ? escapeHtml(beta.message) : escapeHtml(strip.defaultMessage).replace("{appName}", appName);
3160
3224
  const email = beta.contactEmail ? escapeHtml(beta.contactEmail) : null;
3161
3225
  const perks = beta.perks ?? [];
3162
3226
  return `
3163
- <div class="mushi-beta-strip" role="note" aria-label="Beta status">
3227
+ <div class="mushi-beta-strip" role="note" aria-label="${escapeHtml(strip.ariaLabel)}">
3164
3228
  <div class="mushi-beta-strip-row">
3165
3229
  <span class="mushi-beta-tag" aria-hidden="true">BETA</span>
3166
3230
  <span class="mushi-beta-msg">${message}</span>
3167
3231
  </div>
3168
- ${email ? `<div class="mushi-beta-contact-hint">Reports go to ${email} \xB7 reviewed by the team</div>` : ""}
3232
+ ${email ? `<div class="mushi-beta-contact-hint">${escapeHtml(strip.contactHint).replace("{email}", email)}</div>` : ""}
3169
3233
  ${perks.length > 0 ? `
3170
3234
  <ul class="mushi-beta-perks" aria-label="Beta tester perks">
3171
3235
  ${perks.map((p) => `<li>\u2713 ${escapeHtml(p)}</li>`).join("")}
@@ -3811,6 +3875,9 @@ var MushiWidget = class _MushiWidget {
3811
3875
  nudgeEl = null;
3812
3876
  nudgeTimer = null;
3813
3877
  sdkFreshness = null;
3878
+ /** Brand-footer ref (SDK sets it once hashed) + once-per-instance impression latch. */
3879
+ brandRef = null;
3880
+ brandImpressionSent = false;
3814
3881
  reporterReports = [];
3815
3882
  featureBoard = [];
3816
3883
  reporterComments = [];
@@ -4319,6 +4386,11 @@ var MushiWidget = class _MushiWidget {
4319
4386
  this.sdkFreshness = info;
4320
4387
  if (this.isOpen) this.render();
4321
4388
  }
4389
+ setBrandRef(ref) {
4390
+ if (this.brandRef === ref) return;
4391
+ this.brandRef = ref;
4392
+ if (this.isOpen) this.render();
4393
+ }
4322
4394
  setRewardsState(state) {
4323
4395
  this.rewardsState = state;
4324
4396
  if (this.isOpen) this.render();
@@ -4868,6 +4940,10 @@ var MushiWidget = class _MushiWidget {
4868
4940
  panel.innerHTML = `${renderOutdatedBanner(ctx)}${renderStep(ctx)}${renderBrandFooter(ctx)}`;
4869
4941
  this.shadow.appendChild(panel);
4870
4942
  this.attachHandlers(panel);
4943
+ if (!this.brandImpressionSent && this.config.brandFooter === true) {
4944
+ this.brandImpressionSent = true;
4945
+ this.callbacks.onBrandFooterImpression?.();
4946
+ }
4871
4947
  this.trapFocus(panel);
4872
4948
  this.restoreFormDrafts(panel);
4873
4949
  this.attachViewportHandlers(panel);
@@ -5204,13 +5280,17 @@ var MushiWidget = class _MushiWidget {
5204
5280
  assistantError: this.assistantError,
5205
5281
  showAllCategories: this.showAllCategories,
5206
5282
  showMoreNav: this.showMoreNav,
5207
- pageFaviconHref: readPageFaviconHref()
5283
+ pageFaviconHref: readPageFaviconHref(),
5284
+ brandRef: this.brandRef
5208
5285
  };
5209
5286
  }
5210
5287
  attachHandlers(panel) {
5211
5288
  const t = this.locale;
5212
5289
  bindFaviconFallbacks(panel);
5213
5290
  panel.querySelector('[data-action="close"]')?.addEventListener("click", () => this.close());
5291
+ panel.querySelector('[data-action="brand-footer"]')?.addEventListener("click", () => {
5292
+ this.callbacks.onBrandFooterClick?.();
5293
+ });
5214
5294
  panel.querySelector('[data-action="back"]')?.addEventListener("click", () => {
5215
5295
  if (this.step === "intent") {
5216
5296
  this.step = "category";
@@ -5796,7 +5876,8 @@ function mergeRuntimeCapture(host, runtime) {
5796
5876
  }
5797
5877
  return merged;
5798
5878
  }
5799
- function mergeRuntimeConfig(config, runtime) {
5879
+ var HOST_WINS_WIDGET_KEYS = ["brandFooter"];
5880
+ function mergeRuntimeConfig(config, runtime, host = config) {
5800
5881
  const nativeTrigger = runtime.native?.triggerMode;
5801
5882
  const runtimeLauncher = runtime.widget?.launcher;
5802
5883
  const hostTrigger = config.widget?.trigger;
@@ -5825,7 +5906,11 @@ function mergeRuntimeConfig(config, runtime) {
5825
5906
  if (runtime.widget) {
5826
5907
  for (const [key, value] of Object.entries(runtime.widget)) {
5827
5908
  if (key === "trigger" || key === "launcher") continue;
5828
- if (value !== void 0 && value !== null) definedRuntimeWidget[key] = 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;
5829
5914
  }
5830
5915
  }
5831
5916
  return {
@@ -6436,8 +6521,7 @@ function createNetworkCapture(options = {}) {
6436
6521
  const originalXhrSend = OriginalXHR ? XMLHttpRequest.prototype.send : null;
6437
6522
  const originalXhrSetRequestHeader = OriginalXHR ? XMLHttpRequest.prototype.setRequestHeader : null;
6438
6523
  let activeOptions = options;
6439
- let fetchWrapper;
6440
- globalThis.fetch = fetchWrapper = async function mushiFetchInterceptor(input, init) {
6524
+ const fetchWrapper = async function mushiFetchInterceptor(input, init) {
6441
6525
  const startTime = Date.now();
6442
6526
  const method = init?.method?.toUpperCase() ?? "GET";
6443
6527
  const url = getRequestUrl(input);
@@ -6495,6 +6579,7 @@ function createNetworkCapture(options = {}) {
6495
6579
  }
6496
6580
  }
6497
6581
  };
6582
+ globalThis.fetch = fetchWrapper;
6498
6583
  const xhrStateMap = typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : null;
6499
6584
  if (OriginalXHR && originalXhrOpen && originalXhrSend && originalXhrSetRequestHeader && xhrStateMap) {
6500
6585
  const _originalOpen = originalXhrOpen;
@@ -7493,8 +7578,6 @@ function createDiscoveryCapture(opts) {
7493
7578
  }
7494
7579
  };
7495
7580
  }
7496
-
7497
- // src/capture/replay.ts
7498
7581
  var DEFAULT_MAX_MS = 3e4;
7499
7582
  var MAX_EVENTS = 400;
7500
7583
  var RRWEB_META = 4;
@@ -7552,15 +7635,33 @@ function createLiteReplay(maxMs) {
7552
7635
  }
7553
7636
  };
7554
7637
  }
7638
+ var DEFAULT_REDACT_SELECTORS2 = ['input[type="password"]', "[data-mushi-redact]"];
7555
7639
  var rrwebModule = null;
7556
- async function loadRrweb() {
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);
7557
7658
  if (rrwebModule) return rrwebModule;
7558
7659
  try {
7559
7660
  const specifier = "rrweb";
7560
- rrwebModule = await import(
7661
+ rrwebModule = asRrweb(await import(
7561
7662
  /* @vite-ignore */
7562
7663
  specifier
7563
- );
7664
+ ));
7564
7665
  return rrwebModule;
7565
7666
  } catch {
7566
7667
  return null;
@@ -7568,15 +7669,22 @@ async function loadRrweb() {
7568
7669
  }
7569
7670
  async function createReplayCapture(opts) {
7570
7671
  const maxMs = opts.maxDurationMs ?? DEFAULT_MAX_MS;
7571
- const rrweb = await loadRrweb();
7672
+ if (opts.mode === "lite") return createLiteReplay(maxMs);
7673
+ const rrweb = await loadRrweb(opts.loadRrweb);
7572
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
+ }
7573
7681
  return createLiteReplay(maxMs);
7574
7682
  }
7575
7683
  const record = rrweb.record;
7576
7684
  const events = [];
7577
7685
  let stopFn = null;
7578
7686
  let recording = false;
7579
- const maskSelectors = ['input[type="password"]', ...opts.redactSelectors ?? []];
7687
+ const redactSelectors = [.../* @__PURE__ */ new Set([...DEFAULT_REDACT_SELECTORS2, ...opts.redactSelectors ?? []])];
7580
7688
  const stop = () => {
7581
7689
  stopFn?.();
7582
7690
  stopFn = null;
@@ -7592,13 +7700,8 @@ async function createReplayCapture(opts) {
7592
7700
  trimReplayBuffer(events, maxMs, MAX_EVENTS);
7593
7701
  },
7594
7702
  maskAllInputs: true,
7595
- // Mask rendered DOM text too — without this, rrweb records every
7596
- // visible label (emails, names) as plaintext. Hosts that need richer
7597
- // capture can opt out via their own rrweb integration.
7598
- maskAllText: true,
7599
- maskTextSelector: maskSelectors.join(","),
7600
- // Re-emit a full snapshot roughly once per retained window so trimming
7601
- // never leaves incrementals without a base snapshot.
7703
+ maskTextSelector: "*",
7704
+ blockSelector: redactSelectors.join(","),
7602
7705
  checkoutEveryNms: maxMs,
7603
7706
  sampling: { mousemove: false, mouseInteraction: true, scroll: 150, media: 800 }
7604
7707
  }) ?? null;
@@ -7953,8 +8056,6 @@ function tagSentryScope(reportId, options = {}) {
7953
8056
  } catch {
7954
8057
  }
7955
8058
  }
7956
-
7957
- // src/proactive-triggers.ts
7958
8059
  var DEFAULT_EXCLUDE_ROUTES = [
7959
8060
  "/login",
7960
8061
  "/logout",
@@ -8097,6 +8198,15 @@ function setupProactiveTriggers(callbacks, config = {}) {
8097
8198
  }
8098
8199
  if (config.errorBoundary) {
8099
8200
  let handleError2 = function(event) {
8201
+ if (shouldDropCapturedError({
8202
+ message: event.message,
8203
+ filename: event.filename,
8204
+ ignoreErrors: config.ignoreErrors,
8205
+ denyUrls: config.denyUrls,
8206
+ allowUrls: config.allowUrls
8207
+ })) {
8208
+ return;
8209
+ }
8100
8210
  callbacks.onTrigger("error_boundary", {
8101
8211
  message: event.message,
8102
8212
  filename: event.filename,
@@ -8104,8 +8214,17 @@ function setupProactiveTriggers(callbacks, config = {}) {
8104
8214
  colno: event.colno
8105
8215
  });
8106
8216
  }, handleUnhandledRejection2 = function(event) {
8217
+ const message = event.reason instanceof Error ? event.reason.message : String(event.reason);
8218
+ if (shouldDropCapturedError({
8219
+ message,
8220
+ ignoreErrors: config.ignoreErrors,
8221
+ denyUrls: config.denyUrls,
8222
+ allowUrls: config.allowUrls
8223
+ })) {
8224
+ return;
8225
+ }
8107
8226
  callbacks.onTrigger("error_boundary", {
8108
- message: event.reason instanceof Error ? event.reason.message : String(event.reason),
8227
+ message,
8109
8228
  type: "unhandled_rejection"
8110
8229
  });
8111
8230
  };
@@ -8268,21 +8387,47 @@ function createInstance(config) {
8268
8387
  ...typeof bootstrapConfig.timeout === "number" ? { timeout: bootstrapConfig.timeout } : {},
8269
8388
  ...typeof bootstrapConfig.maxRetries === "number" ? { maxRetries: bootstrapConfig.maxRetries } : {},
8270
8389
  ...bootstrapConfig.circuitBreaker ? { circuitBreaker: bootstrapConfig.circuitBreaker } : {},
8390
+ ...bootstrapConfig.tunnel ? { tunnel: bootstrapConfig.tunnel } : {},
8271
8391
  getUserToken: () => userToken,
8272
8392
  sdkPackage: MUSHI_SDK_PACKAGE,
8273
8393
  sdkVersion: MUSHI_SDK_VERSION
8274
8394
  });
8275
- if (bootstrapConfig["trackSessions"] !== false) {
8395
+ let unsubPageViewHistory = null;
8396
+ if (bootstrapConfig.trackSessions !== false) {
8276
8397
  initSessionTracker({
8277
8398
  client: apiClient2,
8278
8399
  sdkVersion: MUSHI_SDK_VERSION,
8279
- reporterTokenHash: getReporterToken(bootstrapConfig.projectId) ?? null
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
8280
8410
  });
8411
+ try {
8412
+ unsubPageViewHistory = subscribeHistory({
8413
+ onPush: () => trackPageView(),
8414
+ onPop: () => trackPageView()
8415
+ });
8416
+ } catch {
8417
+ }
8281
8418
  }
8282
8419
  const preFilter = createPreFilter(bootstrapConfig.preFilter);
8283
8420
  const offlineQueue = createOfflineQueue(bootstrapConfig.offline);
8284
8421
  const rateLimiter = createRateLimiter({ maxBurst: 10, refillRate: 1, refillIntervalMs: 5e3 });
8285
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
+ });
8286
8431
  function scrubBreadcrumbsForWire(crumbs) {
8287
8432
  return crumbs.map((c) => {
8288
8433
  const next = { ...c };
@@ -8457,9 +8602,13 @@ function createInstance(config) {
8457
8602
  const replayMode = activeConfig.capture?.replay ?? "off";
8458
8603
  const replaySampleRate = activeConfig.replaySampleRate ?? 1;
8459
8604
  const replaySampled = replaySampleRate >= 1 || Math.random() < replaySampleRate;
8460
- if ((replayMode === "rrweb" || replayMode === "lite") && replaySampled) {
8605
+ const onErrorReplayRate = activeConfig.replaysOnErrorSampleRate ?? 0;
8606
+ const replayOnErrorSampled = !replaySampled && onErrorReplayRate > 0 && Math.random() < onErrorReplayRate;
8607
+ if ((replayMode === "rrweb" || replayMode === "lite") && (replaySampled || replayOnErrorSampled)) {
8461
8608
  const generation = ++replayGeneration;
8462
8609
  void createReplayCapture({
8610
+ mode: replayMode,
8611
+ loadRrweb: bootstrapConfig.capture?.rrweb,
8463
8612
  redactSelectors: activeConfig.privacy?.redactSelectors
8464
8613
  }).then((cap) => {
8465
8614
  if (generation !== replayGeneration) {
@@ -8599,6 +8748,7 @@ function createInstance(config) {
8599
8748
  widget.setScreenshotAttached(pendingScreenshot !== null);
8600
8749
  widget.setScreenshotPreview(pendingScreenshot);
8601
8750
  }
8751
+ const brandRefReady = sha256Hex(projectId).then((hex) => hex.slice(0, 12)).catch(() => null);
8602
8752
  widget = new MushiWidget(bootstrapConfig.widget, {
8603
8753
  onSubmit: async ({ category, userCategory, description, intent }) => {
8604
8754
  log.info("Report submitted", { category, userCategory, intent });
@@ -8613,6 +8763,18 @@ function createInstance(config) {
8613
8763
  replayCap?.start();
8614
8764
  emit("widget:opened");
8615
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
+ },
8616
8778
  onClose: () => {
8617
8779
  log.debug("Widget closed");
8618
8780
  if (pendingProactiveTrigger) {
@@ -8831,6 +8993,7 @@ function createInstance(config) {
8831
8993
  return res.ok ? res.data ?? null : null;
8832
8994
  }
8833
8995
  }, MUSHI_SDK_VERSION);
8996
+ void brandRefReady.then((ref) => widget.setBrandRef(ref));
8834
8997
  syncCaptureModules();
8835
8998
  if (typeof document !== "undefined") {
8836
8999
  if (document.readyState === "loading") {
@@ -8876,6 +9039,9 @@ function createInstance(config) {
8876
9039
  apiCascade: proactiveCfg?.apiCascade,
8877
9040
  apiEndpoint: resolveApiEndpoint(activeConfig),
8878
9041
  errorBoundary: proactiveCfg?.errorBoundary,
9042
+ ignoreErrors: activeConfig.ignoreErrors,
9043
+ denyUrls: activeConfig.denyUrls,
9044
+ allowUrls: activeConfig.allowUrls,
8879
9045
  pageDwell: proactiveCfg?.pageDwell,
8880
9046
  firstSession: proactiveCfg?.firstSession,
8881
9047
  projectId: bootstrapConfig.projectId
@@ -8906,7 +9072,7 @@ function createInstance(config) {
8906
9072
  log.debug("Runtime SDK config disabled; using bootstrap config", { version: runtime.version });
8907
9073
  return;
8908
9074
  }
8909
- activeConfig = mergeRuntimeConfig(activeConfig, runtime);
9075
+ activeConfig = mergeRuntimeConfig(activeConfig, runtime, bootstrapConfig);
8910
9076
  syncCaptureModules();
8911
9077
  if (runtime.widget) widget.updateConfig(activeConfig.widget);
8912
9078
  if (reporterNotificationsEnabled) startReporterInboxPolling();
@@ -9274,6 +9440,7 @@ function createInstance(config) {
9274
9440
  destroy() {
9275
9441
  proactiveTriggers?.destroy();
9276
9442
  proactiveManager?.reset();
9443
+ destroyEventTracker();
9277
9444
  widget.destroy();
9278
9445
  consoleCap?.destroy();
9279
9446
  networkCap?.destroy();
@@ -9290,6 +9457,8 @@ function createInstance(config) {
9290
9457
  replayCap = null;
9291
9458
  offlineQueue.stopAutoSync();
9292
9459
  stopReporterInboxPolling();
9460
+ unsubPageViewHistory?.();
9461
+ unsubPageViewHistory = null;
9293
9462
  destroySessionTracker();
9294
9463
  breadcrumbs.clear();
9295
9464
  listeners.clear();
@@ -9383,6 +9552,16 @@ function createInstance(config) {
9383
9552
  },
9384
9553
  async captureException(error, options) {
9385
9554
  const normalised = normaliseThrown(error);
9555
+ const filename = typeof options?.metadata?.filename === "string" ? options.metadata.filename : void 0;
9556
+ if (shouldDropCapturedError({
9557
+ message: normalised.message,
9558
+ filename,
9559
+ ignoreErrors: activeConfig.ignoreErrors,
9560
+ denyUrls: activeConfig.denyUrls,
9561
+ allowUrls: activeConfig.allowUrls
9562
+ })) {
9563
+ return null;
9564
+ }
9386
9565
  breadcrumbs.add({
9387
9566
  category: "lifecycle",
9388
9567
  level: "error",
@@ -9426,6 +9605,7 @@ function createInstance(config) {
9426
9605
  level: "info",
9427
9606
  message: `Mushi.identify(${userId})`
9428
9607
  });
9608
+ updateEventIdentity(userId, traits ?? null);
9429
9609
  wireRewardsForIdentifiedUser(
9430
9610
  userId,
9431
9611
  traits ? {
@@ -9518,6 +9698,16 @@ function createInstance(config) {
9518
9698
  if (!activeConfig.rewards?.enabled) return;
9519
9699
  enqueue({ action, metadata });
9520
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
+ },
9521
9711
  pulseTrigger() {
9522
9712
  widget.pulseTrigger?.();
9523
9713
  },
@@ -9576,6 +9766,8 @@ function createInstance(config) {
9576
9766
  localStorage.setItem(SENTINEL_KEY, "clean");
9577
9767
  } catch {
9578
9768
  }
9769
+ markPageUnloading();
9770
+ flushLastOutboundOnUnload();
9579
9771
  });
9580
9772
  } catch {
9581
9773
  }
@@ -9826,6 +10018,10 @@ function createNoopInstance() {
9826
10018
  getTier: async () => null,
9827
10019
  recordActivity: () => {
9828
10020
  },
10021
+ track: () => false,
10022
+ setConsent: () => {
10023
+ },
10024
+ getAnonymousId: () => null,
9829
10025
  pulseTrigger: () => {
9830
10026
  },
9831
10027
  listMyReports: async () => [],