@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.cjs CHANGED
@@ -77,7 +77,9 @@ var en = {
77
77
  visual: "Layout, styling, or display problem",
78
78
  confusing: "Hard to understand or navigate",
79
79
  other: "Something else"
80
- }
80
+ },
81
+ moreCategoriesLabel: "More issue types",
82
+ moreCategoriesCount: "{n} more"
81
83
  },
82
84
  step2: {
83
85
  heading: "What happened?",
@@ -214,7 +216,15 @@ var en = {
214
216
  label: "Feature request",
215
217
  description: "Suggest a change"
216
218
  },
217
- poweredBy: "Powered by Mushi v{version}"
219
+ betaStrip: {
220
+ defaultMessage: "{appName} is in early development",
221
+ contactHint: "Reports go to {email} \xB7 reviewed by the team",
222
+ ariaLabel: "Beta status"
223
+ },
224
+ changelog: {
225
+ whatsNew: "What's new in {version}"
226
+ },
227
+ poweredBy: "Bug reports by Mushi"
218
228
  }
219
229
  };
220
230
 
@@ -257,7 +267,9 @@ var ja = {
257
267
  visual: "\u30EC\u30A4\u30A2\u30A6\u30C8\u3001\u30C7\u30B6\u30A4\u30F3\u3001\u8868\u793A\u306E\u554F\u984C",
258
268
  confusing: "\u7406\u89E3\u3057\u306B\u304F\u3044\u3001\u64CD\u4F5C\u304C\u308F\u304B\u308A\u306B\u304F\u3044",
259
269
  other: "\u305D\u306E\u4ED6\u306E\u554F\u984C"
260
- }
270
+ },
271
+ moreCategoriesLabel: "\u305D\u306E\u4ED6\u306E\u554F\u984C\u306E\u7A2E\u985E",
272
+ moreCategoriesCount: "\u4ED6{n}\u4EF6"
261
273
  },
262
274
  step2: {
263
275
  heading: "\u4F55\u304C\u8D77\u304D\u307E\u3057\u305F\u304B\uFF1F",
@@ -394,7 +406,15 @@ var ja = {
394
406
  label: "\u6A5F\u80FD\u30EA\u30AF\u30A8\u30B9\u30C8",
395
407
  description: "\u5909\u66F4\u3092\u63D0\u6848"
396
408
  },
397
- poweredBy: "Mushi v{version}"
409
+ betaStrip: {
410
+ defaultMessage: "{appName}\u306F\u958B\u767A\u521D\u671F\u6BB5\u968E\u3067\u3059",
411
+ contactHint: "\u30EC\u30DD\u30FC\u30C8\u306F {email} \u306B\u5C4A\u304D\u3001\u30C1\u30FC\u30E0\u304C\u78BA\u8A8D\u3057\u307E\u3059",
412
+ ariaLabel: "\u30D9\u30FC\u30BF\u7248\u306E\u304A\u77E5\u3089\u305B"
413
+ },
414
+ changelog: {
415
+ whatsNew: "{version} \u306E\u65B0\u6A5F\u80FD"
416
+ },
417
+ poweredBy: "\u30D0\u30B0\u5831\u544A\u306F Mushi \u3067"
398
418
  }
399
419
  };
400
420
 
@@ -437,7 +457,9 @@ var th = {
437
457
  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",
438
458
  confusing: "\u0E40\u0E02\u0E49\u0E32\u0E43\u0E08\u0E22\u0E32\u0E01\u0E2B\u0E23\u0E37\u0E2D\u0E19\u0E33\u0E17\u0E32\u0E07\u0E22\u0E32\u0E01",
439
459
  other: "\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E2D\u0E37\u0E48\u0E19"
440
- }
460
+ },
461
+ moreCategoriesLabel: "\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E1B\u0E31\u0E0D\u0E2B\u0E32\u0E2D\u0E37\u0E48\u0E19 \u0E46",
462
+ moreCategoriesCount: "\u0E2D\u0E35\u0E01 {n} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"
441
463
  },
442
464
  step2: {
443
465
  heading: "\u0E40\u0E01\u0E34\u0E14\u0E2D\u0E30\u0E44\u0E23\u0E02\u0E36\u0E49\u0E19?",
@@ -574,7 +596,15 @@ var th = {
574
596
  label: "\u0E02\u0E2D\u0E1F\u0E35\u0E40\u0E08\u0E2D\u0E23\u0E4C",
575
597
  description: "\u0E40\u0E2A\u0E19\u0E2D\u0E01\u0E32\u0E23\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E41\u0E1B\u0E25\u0E07"
576
598
  },
577
- poweredBy: "Powered by Mushi v{version}"
599
+ betaStrip: {
600
+ 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",
601
+ 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",
602
+ ariaLabel: "\u0E2A\u0E16\u0E32\u0E19\u0E30\u0E40\u0E1A\u0E15\u0E49\u0E32"
603
+ },
604
+ changelog: {
605
+ whatsNew: "\u0E21\u0E35\u0E2D\u0E30\u0E44\u0E23\u0E43\u0E2B\u0E21\u0E48\u0E43\u0E19 {version}"
606
+ },
607
+ poweredBy: "\u0E23\u0E32\u0E22\u0E07\u0E32\u0E19\u0E1A\u0E31\u0E4A\u0E01\u0E42\u0E14\u0E22 Mushi"
578
608
  }
579
609
  };
580
610
 
@@ -617,7 +647,9 @@ var es = {
617
647
  visual: "Problema de dise\xF1o, estilo o visualizaci\xF3n",
618
648
  confusing: "Dif\xEDcil de entender o navegar",
619
649
  other: "Otro problema"
620
- }
650
+ },
651
+ moreCategoriesLabel: "M\xE1s tipos de problemas",
652
+ moreCategoriesCount: "{n} m\xE1s"
621
653
  },
622
654
  step2: {
623
655
  heading: "\xBFQu\xE9 pas\xF3?",
@@ -754,7 +786,15 @@ var es = {
754
786
  label: "Solicitud de funci\xF3n",
755
787
  description: "Sugerir un cambio"
756
788
  },
757
- poweredBy: "Con tecnolog\xEDa de Mushi v{version}"
789
+ betaStrip: {
790
+ defaultMessage: "{appName} est\xE1 en desarrollo temprano",
791
+ contactHint: "Los reportes van a {email} \xB7 revisados por el equipo",
792
+ ariaLabel: "Estado beta"
793
+ },
794
+ changelog: {
795
+ whatsNew: "Novedades de {version}"
796
+ },
797
+ poweredBy: "Reportes de errores con Mushi"
758
798
  }
759
799
  };
760
800
 
@@ -1825,6 +1865,19 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
1825
1865
  text-align: center;
1826
1866
  text-transform: uppercase;
1827
1867
  }
1868
+ .mushi-brand-link {
1869
+ color: inherit;
1870
+ text-decoration: none;
1871
+ text-underline-offset: 3px;
1872
+ }
1873
+ .mushi-brand-link:hover { color: ${inkMuted}; text-decoration: underline; }
1874
+ .mushi-brand-link:focus-visible {
1875
+ outline: 2px solid ${widgetAccent};
1876
+ outline-offset: 2px;
1877
+ border-radius: 2px;
1878
+ color: ${widgetAccent};
1879
+ text-decoration: underline;
1880
+ }
1828
1881
 
1829
1882
  .mushi-step-indicator {
1830
1883
  display: flex;
@@ -2675,7 +2728,7 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
2675
2728
 
2676
2729
  // src/version.ts
2677
2730
  var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
2678
- var MUSHI_SDK_VERSION = "1.27.0" ;
2731
+ var MUSHI_SDK_VERSION = "1.29.0" ;
2679
2732
  var ASSISTANT_SESSION_STORAGE_KEY = "mushi-assistant-session-v1";
2680
2733
  function loadAssistantSession() {
2681
2734
  try {
@@ -2833,6 +2886,12 @@ function formatRelativeTime(iso) {
2833
2886
  function pad2(n) {
2834
2887
  return n < 10 ? `0${n}` : String(n);
2835
2888
  }
2889
+ var BRAND_FOOTER_URL = "https://kensaur.us/mushi-mushi/";
2890
+ var BRAND_FOOTER_UTM = "utm_source=widget&utm_medium=powered-by";
2891
+ function buildBrandFooterHref(ref) {
2892
+ const base = `${BRAND_FOOTER_URL}?${BRAND_FOOTER_UTM}`;
2893
+ return ref && /^[0-9a-f]{6,64}$/.test(ref) ? `${base}&ref=${ref}` : base;
2894
+ }
2836
2895
  var TOTAL_STEPS = 3;
2837
2896
  var STEP_NUMBER = {
2838
2897
  category: 1,
@@ -2979,8 +3038,9 @@ function renderOutdatedBanner(ctx) {
2979
3038
  `;
2980
3039
  }
2981
3040
  function renderBrandFooter(ctx) {
2982
- if (ctx.config.brandFooter === false) return "";
2983
- return `<div class="mushi-brand-footer">${escapeHtml(ctx.locale.flows.poweredBy.replace("{version}", ctx.sdkVersion))}</div>`;
3041
+ if (ctx.config.brandFooter !== true) return "";
3042
+ const href = buildBrandFooterHref(ctx.brandRef);
3043
+ 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>`;
2984
3044
  }
2985
3045
  function renderHeader(ctx, opts) {
2986
3046
  const t = ctx.locale;
@@ -3103,8 +3163,8 @@ function renderCategoryStep(ctx) {
3103
3163
  const primaryCategories = primaryEntries.map(renderEntry).join("");
3104
3164
  const secondaryCategories = secondaryEntries.map(renderEntry).join("");
3105
3165
  const secondaryHtml = hasMore ? ctx.showAllCategories ? `<div class="mushi-categories-expanded">${secondaryCategories}</div>` : `<button type="button" class="mushi-more-toggle" data-action="show-all-categories">
3106
- <span class="mushi-more-toggle-text">More issue types</span>
3107
- <span class="mushi-more-toggle-count">${secondaryEntries.length} more</span>
3166
+ <span class="mushi-more-toggle-text">${escapeHtml(t.step1.moreCategoriesLabel)}</span>
3167
+ <span class="mushi-more-toggle-count">${escapeHtml(t.step1.moreCategoriesCount.replace("{n}", String(secondaryEntries.length)))}</span>
3108
3168
  <span class="mushi-more-toggle-arrow" aria-hidden="true">\u2192</span>
3109
3169
  </button>` : "";
3110
3170
  return `
@@ -3147,7 +3207,10 @@ function renderBetaChangelog(ctx) {
3147
3207
  if (!entries?.length) return "";
3148
3208
  const latest = entries[0];
3149
3209
  const items = latest.items.map((item) => `<li>\u2022 ${escapeHtml(item)}</li>`).join("");
3150
- const label = latest.date ? `What\u2019s new in ${escapeHtml(latest.version)} \xB7 ${escapeHtml(latest.date)}` : `What\u2019s new in ${escapeHtml(latest.version)}`;
3210
+ const whatsNew = escapeHtml(
3211
+ ctx.locale.flows.changelog.whatsNew.replace("{version}", latest.version)
3212
+ );
3213
+ const label = latest.date ? `${whatsNew} \xB7 ${escapeHtml(latest.date)}` : whatsNew;
3151
3214
  return `
3152
3215
  <details class="mushi-changelog">
3153
3216
  <summary class="mushi-changelog-summary">${label}</summary>
@@ -3157,17 +3220,18 @@ function renderBetaChangelog(ctx) {
3157
3220
  }
3158
3221
  function renderBetaStrip(ctx) {
3159
3222
  const beta = ctx.config.betaMode;
3223
+ const strip = ctx.locale.flows.betaStrip;
3160
3224
  const appName = escapeHtml(beta.appName ?? "This app");
3161
- const message = beta.message ? escapeHtml(beta.message) : `${appName} is in early development`;
3225
+ const message = beta.message ? escapeHtml(beta.message) : escapeHtml(strip.defaultMessage).replace("{appName}", appName);
3162
3226
  const email = beta.contactEmail ? escapeHtml(beta.contactEmail) : null;
3163
3227
  const perks = beta.perks ?? [];
3164
3228
  return `
3165
- <div class="mushi-beta-strip" role="note" aria-label="Beta status">
3229
+ <div class="mushi-beta-strip" role="note" aria-label="${escapeHtml(strip.ariaLabel)}">
3166
3230
  <div class="mushi-beta-strip-row">
3167
3231
  <span class="mushi-beta-tag" aria-hidden="true">BETA</span>
3168
3232
  <span class="mushi-beta-msg">${message}</span>
3169
3233
  </div>
3170
- ${email ? `<div class="mushi-beta-contact-hint">Reports go to ${email} \xB7 reviewed by the team</div>` : ""}
3234
+ ${email ? `<div class="mushi-beta-contact-hint">${escapeHtml(strip.contactHint).replace("{email}", email)}</div>` : ""}
3171
3235
  ${perks.length > 0 ? `
3172
3236
  <ul class="mushi-beta-perks" aria-label="Beta tester perks">
3173
3237
  ${perks.map((p) => `<li>\u2713 ${escapeHtml(p)}</li>`).join("")}
@@ -3813,6 +3877,9 @@ var MushiWidget = class _MushiWidget {
3813
3877
  nudgeEl = null;
3814
3878
  nudgeTimer = null;
3815
3879
  sdkFreshness = null;
3880
+ /** Brand-footer ref (SDK sets it once hashed) + once-per-instance impression latch. */
3881
+ brandRef = null;
3882
+ brandImpressionSent = false;
3816
3883
  reporterReports = [];
3817
3884
  featureBoard = [];
3818
3885
  reporterComments = [];
@@ -4321,6 +4388,11 @@ var MushiWidget = class _MushiWidget {
4321
4388
  this.sdkFreshness = info;
4322
4389
  if (this.isOpen) this.render();
4323
4390
  }
4391
+ setBrandRef(ref) {
4392
+ if (this.brandRef === ref) return;
4393
+ this.brandRef = ref;
4394
+ if (this.isOpen) this.render();
4395
+ }
4324
4396
  setRewardsState(state) {
4325
4397
  this.rewardsState = state;
4326
4398
  if (this.isOpen) this.render();
@@ -4870,6 +4942,10 @@ var MushiWidget = class _MushiWidget {
4870
4942
  panel.innerHTML = `${renderOutdatedBanner(ctx)}${renderStep(ctx)}${renderBrandFooter(ctx)}`;
4871
4943
  this.shadow.appendChild(panel);
4872
4944
  this.attachHandlers(panel);
4945
+ if (!this.brandImpressionSent && this.config.brandFooter === true) {
4946
+ this.brandImpressionSent = true;
4947
+ this.callbacks.onBrandFooterImpression?.();
4948
+ }
4873
4949
  this.trapFocus(panel);
4874
4950
  this.restoreFormDrafts(panel);
4875
4951
  this.attachViewportHandlers(panel);
@@ -5206,13 +5282,17 @@ var MushiWidget = class _MushiWidget {
5206
5282
  assistantError: this.assistantError,
5207
5283
  showAllCategories: this.showAllCategories,
5208
5284
  showMoreNav: this.showMoreNav,
5209
- pageFaviconHref: core.readPageFaviconHref()
5285
+ pageFaviconHref: core.readPageFaviconHref(),
5286
+ brandRef: this.brandRef
5210
5287
  };
5211
5288
  }
5212
5289
  attachHandlers(panel) {
5213
5290
  const t = this.locale;
5214
5291
  bindFaviconFallbacks(panel);
5215
5292
  panel.querySelector('[data-action="close"]')?.addEventListener("click", () => this.close());
5293
+ panel.querySelector('[data-action="brand-footer"]')?.addEventListener("click", () => {
5294
+ this.callbacks.onBrandFooterClick?.();
5295
+ });
5216
5296
  panel.querySelector('[data-action="back"]')?.addEventListener("click", () => {
5217
5297
  if (this.step === "intent") {
5218
5298
  this.step = "category";
@@ -5798,7 +5878,8 @@ function mergeRuntimeCapture(host, runtime) {
5798
5878
  }
5799
5879
  return merged;
5800
5880
  }
5801
- function mergeRuntimeConfig(config, runtime) {
5881
+ var HOST_WINS_WIDGET_KEYS = ["brandFooter"];
5882
+ function mergeRuntimeConfig(config, runtime, host = config) {
5802
5883
  const nativeTrigger = runtime.native?.triggerMode;
5803
5884
  const runtimeLauncher = runtime.widget?.launcher;
5804
5885
  const hostTrigger = config.widget?.trigger;
@@ -5827,7 +5908,11 @@ function mergeRuntimeConfig(config, runtime) {
5827
5908
  if (runtime.widget) {
5828
5909
  for (const [key, value] of Object.entries(runtime.widget)) {
5829
5910
  if (key === "trigger" || key === "launcher") continue;
5830
- if (value !== void 0 && value !== null) definedRuntimeWidget[key] = value;
5911
+ if (value === void 0 || value === null) continue;
5912
+ if (HOST_WINS_WIDGET_KEYS.includes(key) && host.widget?.[key] !== void 0) {
5913
+ continue;
5914
+ }
5915
+ definedRuntimeWidget[key] = value;
5831
5916
  }
5832
5917
  }
5833
5918
  return {
@@ -6438,8 +6523,7 @@ function createNetworkCapture(options = {}) {
6438
6523
  const originalXhrSend = OriginalXHR ? XMLHttpRequest.prototype.send : null;
6439
6524
  const originalXhrSetRequestHeader = OriginalXHR ? XMLHttpRequest.prototype.setRequestHeader : null;
6440
6525
  let activeOptions = options;
6441
- let fetchWrapper;
6442
- globalThis.fetch = fetchWrapper = async function mushiFetchInterceptor(input, init) {
6526
+ const fetchWrapper = async function mushiFetchInterceptor(input, init) {
6443
6527
  const startTime = Date.now();
6444
6528
  const method = init?.method?.toUpperCase() ?? "GET";
6445
6529
  const url = getRequestUrl(input);
@@ -6497,6 +6581,7 @@ function createNetworkCapture(options = {}) {
6497
6581
  }
6498
6582
  }
6499
6583
  };
6584
+ globalThis.fetch = fetchWrapper;
6500
6585
  const xhrStateMap = typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : null;
6501
6586
  if (OriginalXHR && originalXhrOpen && originalXhrSend && originalXhrSetRequestHeader && xhrStateMap) {
6502
6587
  const _originalOpen = originalXhrOpen;
@@ -7495,8 +7580,6 @@ function createDiscoveryCapture(opts) {
7495
7580
  }
7496
7581
  };
7497
7582
  }
7498
-
7499
- // src/capture/replay.ts
7500
7583
  var DEFAULT_MAX_MS = 3e4;
7501
7584
  var MAX_EVENTS = 400;
7502
7585
  var RRWEB_META = 4;
@@ -7554,15 +7637,33 @@ function createLiteReplay(maxMs) {
7554
7637
  }
7555
7638
  };
7556
7639
  }
7640
+ var DEFAULT_REDACT_SELECTORS2 = ['input[type="password"]', "[data-mushi-redact]"];
7557
7641
  var rrwebModule = null;
7558
- async function loadRrweb() {
7642
+ var warnedMissingRrweb = false;
7643
+ function asRrweb(mod) {
7644
+ if (!mod || typeof mod !== "object") return null;
7645
+ const direct = mod;
7646
+ if (typeof direct.record === "function") return direct;
7647
+ if (direct.default && typeof direct.default.record === "function") return direct.default;
7648
+ return null;
7649
+ }
7650
+ async function loadRrweb(loader) {
7651
+ if (rrwebModule) return rrwebModule;
7652
+ if (typeof loader === "function") {
7653
+ try {
7654
+ rrwebModule = asRrweb(await loader());
7655
+ if (rrwebModule) return rrwebModule;
7656
+ } catch {
7657
+ }
7658
+ }
7659
+ rrwebModule = asRrweb(globalThis.rrweb);
7559
7660
  if (rrwebModule) return rrwebModule;
7560
7661
  try {
7561
7662
  const specifier = "rrweb";
7562
- rrwebModule = await import(
7663
+ rrwebModule = asRrweb(await import(
7563
7664
  /* @vite-ignore */
7564
7665
  specifier
7565
- );
7666
+ ));
7566
7667
  return rrwebModule;
7567
7668
  } catch {
7568
7669
  return null;
@@ -7570,15 +7671,22 @@ async function loadRrweb() {
7570
7671
  }
7571
7672
  async function createReplayCapture(opts) {
7572
7673
  const maxMs = opts.maxDurationMs ?? DEFAULT_MAX_MS;
7573
- const rrweb = await loadRrweb();
7674
+ if (opts.mode === "lite") return createLiteReplay(maxMs);
7675
+ const rrweb = await loadRrweb(opts.loadRrweb);
7574
7676
  if (!rrweb?.record) {
7677
+ if (!warnedMissingRrweb) {
7678
+ warnedMissingRrweb = true;
7679
+ core.createLogger({ scope: "mushi" }).warn(
7680
+ "capture.replay is 'rrweb' but rrweb could not be loaded, so replay is recording clicks only. Install rrweb and pass capture: { rrweb: () => import('rrweb') }."
7681
+ );
7682
+ }
7575
7683
  return createLiteReplay(maxMs);
7576
7684
  }
7577
7685
  const record = rrweb.record;
7578
7686
  const events = [];
7579
7687
  let stopFn = null;
7580
7688
  let recording = false;
7581
- const maskSelectors = ['input[type="password"]', ...opts.redactSelectors ?? []];
7689
+ const redactSelectors = [.../* @__PURE__ */ new Set([...DEFAULT_REDACT_SELECTORS2, ...opts.redactSelectors ?? []])];
7582
7690
  const stop = () => {
7583
7691
  stopFn?.();
7584
7692
  stopFn = null;
@@ -7594,13 +7702,8 @@ async function createReplayCapture(opts) {
7594
7702
  trimReplayBuffer(events, maxMs, MAX_EVENTS);
7595
7703
  },
7596
7704
  maskAllInputs: true,
7597
- // Mask rendered DOM text too — without this, rrweb records every
7598
- // visible label (emails, names) as plaintext. Hosts that need richer
7599
- // capture can opt out via their own rrweb integration.
7600
- maskAllText: true,
7601
- maskTextSelector: maskSelectors.join(","),
7602
- // Re-emit a full snapshot roughly once per retained window so trimming
7603
- // never leaves incrementals without a base snapshot.
7705
+ maskTextSelector: "*",
7706
+ blockSelector: redactSelectors.join(","),
7604
7707
  checkoutEveryNms: maxMs,
7605
7708
  sampling: { mousemove: false, mouseInteraction: true, scroll: 150, media: 800 }
7606
7709
  }) ?? null;
@@ -7955,8 +8058,6 @@ function tagSentryScope(reportId, options = {}) {
7955
8058
  } catch {
7956
8059
  }
7957
8060
  }
7958
-
7959
- // src/proactive-triggers.ts
7960
8061
  var DEFAULT_EXCLUDE_ROUTES = [
7961
8062
  "/login",
7962
8063
  "/logout",
@@ -8099,6 +8200,15 @@ function setupProactiveTriggers(callbacks, config = {}) {
8099
8200
  }
8100
8201
  if (config.errorBoundary) {
8101
8202
  let handleError2 = function(event) {
8203
+ if (core.shouldDropCapturedError({
8204
+ message: event.message,
8205
+ filename: event.filename,
8206
+ ignoreErrors: config.ignoreErrors,
8207
+ denyUrls: config.denyUrls,
8208
+ allowUrls: config.allowUrls
8209
+ })) {
8210
+ return;
8211
+ }
8102
8212
  callbacks.onTrigger("error_boundary", {
8103
8213
  message: event.message,
8104
8214
  filename: event.filename,
@@ -8106,8 +8216,17 @@ function setupProactiveTriggers(callbacks, config = {}) {
8106
8216
  colno: event.colno
8107
8217
  });
8108
8218
  }, handleUnhandledRejection2 = function(event) {
8219
+ const message = event.reason instanceof Error ? event.reason.message : String(event.reason);
8220
+ if (core.shouldDropCapturedError({
8221
+ message,
8222
+ ignoreErrors: config.ignoreErrors,
8223
+ denyUrls: config.denyUrls,
8224
+ allowUrls: config.allowUrls
8225
+ })) {
8226
+ return;
8227
+ }
8109
8228
  callbacks.onTrigger("error_boundary", {
8110
- message: event.reason instanceof Error ? event.reason.message : String(event.reason),
8229
+ message,
8111
8230
  type: "unhandled_rejection"
8112
8231
  });
8113
8232
  };
@@ -8270,21 +8389,47 @@ function createInstance(config) {
8270
8389
  ...typeof bootstrapConfig.timeout === "number" ? { timeout: bootstrapConfig.timeout } : {},
8271
8390
  ...typeof bootstrapConfig.maxRetries === "number" ? { maxRetries: bootstrapConfig.maxRetries } : {},
8272
8391
  ...bootstrapConfig.circuitBreaker ? { circuitBreaker: bootstrapConfig.circuitBreaker } : {},
8392
+ ...bootstrapConfig.tunnel ? { tunnel: bootstrapConfig.tunnel } : {},
8273
8393
  getUserToken: () => userToken,
8274
8394
  sdkPackage: MUSHI_SDK_PACKAGE,
8275
8395
  sdkVersion: MUSHI_SDK_VERSION
8276
8396
  });
8277
- if (bootstrapConfig["trackSessions"] !== false) {
8397
+ let unsubPageViewHistory = null;
8398
+ if (bootstrapConfig.trackSessions !== false) {
8278
8399
  core.initSessionTracker({
8279
8400
  client: apiClient2,
8280
8401
  sdkVersion: MUSHI_SDK_VERSION,
8281
- reporterTokenHash: core.getReporterToken(bootstrapConfig.projectId) ?? null
8402
+ reporterToken: core.getReporterToken(bootstrapConfig.projectId) ?? null,
8403
+ projectId: bootstrapConfig.projectId,
8404
+ analytics: bootstrapConfig.analytics,
8405
+ // This package owns the history patch (history-patch.ts):
8406
+ // installAutoBreadcrumbs() captures History.prototype.pushState (the
8407
+ // native) and assigns its own wrapper to history.pushState, which
8408
+ // silently discarded core's page-view wrapper — so no SPA page view
8409
+ // was ever recorded from this SDK. Report views through the shared
8410
+ // patch instead of stacking a second wrapper.
8411
+ patchHistory: false
8282
8412
  });
8413
+ try {
8414
+ unsubPageViewHistory = subscribeHistory({
8415
+ onPush: () => core.trackPageView(),
8416
+ onPop: () => core.trackPageView()
8417
+ });
8418
+ } catch {
8419
+ }
8283
8420
  }
8284
8421
  const preFilter = core.createPreFilter(bootstrapConfig.preFilter);
8285
8422
  const offlineQueue = core.createOfflineQueue(bootstrapConfig.offline);
8286
8423
  const rateLimiter = core.createRateLimiter({ maxBurst: 10, refillRate: 1, refillIntervalMs: 5e3 });
8287
8424
  const piiScrubber = core.createPiiScrubber();
8425
+ core.initEventTracker({
8426
+ client: apiClient2,
8427
+ projectId: bootstrapConfig.projectId,
8428
+ sdkVersion: MUSHI_SDK_VERSION,
8429
+ config: bootstrapConfig.analytics,
8430
+ scrub: (s) => piiScrubber.scrub(s),
8431
+ getSessionId: core.getSessionId
8432
+ });
8288
8433
  function scrubBreadcrumbsForWire(crumbs) {
8289
8434
  return crumbs.map((c) => {
8290
8435
  const next = { ...c };
@@ -8459,9 +8604,13 @@ function createInstance(config) {
8459
8604
  const replayMode = activeConfig.capture?.replay ?? "off";
8460
8605
  const replaySampleRate = activeConfig.replaySampleRate ?? 1;
8461
8606
  const replaySampled = replaySampleRate >= 1 || Math.random() < replaySampleRate;
8462
- if ((replayMode === "rrweb" || replayMode === "lite") && replaySampled) {
8607
+ const onErrorReplayRate = activeConfig.replaysOnErrorSampleRate ?? 0;
8608
+ const replayOnErrorSampled = !replaySampled && onErrorReplayRate > 0 && Math.random() < onErrorReplayRate;
8609
+ if ((replayMode === "rrweb" || replayMode === "lite") && (replaySampled || replayOnErrorSampled)) {
8463
8610
  const generation = ++replayGeneration;
8464
8611
  void createReplayCapture({
8612
+ mode: replayMode,
8613
+ loadRrweb: bootstrapConfig.capture?.rrweb,
8465
8614
  redactSelectors: activeConfig.privacy?.redactSelectors
8466
8615
  }).then((cap) => {
8467
8616
  if (generation !== replayGeneration) {
@@ -8601,6 +8750,7 @@ function createInstance(config) {
8601
8750
  widget.setScreenshotAttached(pendingScreenshot !== null);
8602
8751
  widget.setScreenshotPreview(pendingScreenshot);
8603
8752
  }
8753
+ const brandRefReady = core.sha256Hex(projectId).then((hex) => hex.slice(0, 12)).catch(() => null);
8604
8754
  widget = new MushiWidget(bootstrapConfig.widget, {
8605
8755
  onSubmit: async ({ category, userCategory, description, intent }) => {
8606
8756
  log.info("Report submitted", { category, userCategory, intent });
@@ -8615,6 +8765,18 @@ function createInstance(config) {
8615
8765
  replayCap?.start();
8616
8766
  emit("widget:opened");
8617
8767
  },
8768
+ // Growth loop (plan-gtm C §5); the tracker already honours DNT/consent/enabled.
8769
+ onBrandFooterImpression: () => {
8770
+ void brandRefReady.then((ref) => {
8771
+ core.trackEvent("loop_impression", { placement: "widget" }, ref ? { reserved: { $ref: ref } } : void 0);
8772
+ });
8773
+ },
8774
+ onBrandFooterClick: () => {
8775
+ void brandRefReady.then((ref) => {
8776
+ core.trackEvent("loop_click", { placement: "widget" }, ref ? { reserved: { $ref: ref } } : void 0);
8777
+ return core.flushEvents();
8778
+ });
8779
+ },
8618
8780
  onClose: () => {
8619
8781
  log.debug("Widget closed");
8620
8782
  if (pendingProactiveTrigger) {
@@ -8833,6 +8995,7 @@ function createInstance(config) {
8833
8995
  return res.ok ? res.data ?? null : null;
8834
8996
  }
8835
8997
  }, MUSHI_SDK_VERSION);
8998
+ void brandRefReady.then((ref) => widget.setBrandRef(ref));
8836
8999
  syncCaptureModules();
8837
9000
  if (typeof document !== "undefined") {
8838
9001
  if (document.readyState === "loading") {
@@ -8878,6 +9041,9 @@ function createInstance(config) {
8878
9041
  apiCascade: proactiveCfg?.apiCascade,
8879
9042
  apiEndpoint: resolveApiEndpoint(activeConfig),
8880
9043
  errorBoundary: proactiveCfg?.errorBoundary,
9044
+ ignoreErrors: activeConfig.ignoreErrors,
9045
+ denyUrls: activeConfig.denyUrls,
9046
+ allowUrls: activeConfig.allowUrls,
8881
9047
  pageDwell: proactiveCfg?.pageDwell,
8882
9048
  firstSession: proactiveCfg?.firstSession,
8883
9049
  projectId: bootstrapConfig.projectId
@@ -8908,7 +9074,7 @@ function createInstance(config) {
8908
9074
  log.debug("Runtime SDK config disabled; using bootstrap config", { version: runtime.version });
8909
9075
  return;
8910
9076
  }
8911
- activeConfig = mergeRuntimeConfig(activeConfig, runtime);
9077
+ activeConfig = mergeRuntimeConfig(activeConfig, runtime, bootstrapConfig);
8912
9078
  syncCaptureModules();
8913
9079
  if (runtime.widget) widget.updateConfig(activeConfig.widget);
8914
9080
  if (reporterNotificationsEnabled) startReporterInboxPolling();
@@ -9276,6 +9442,7 @@ function createInstance(config) {
9276
9442
  destroy() {
9277
9443
  proactiveTriggers?.destroy();
9278
9444
  proactiveManager?.reset();
9445
+ core.destroyEventTracker();
9279
9446
  widget.destroy();
9280
9447
  consoleCap?.destroy();
9281
9448
  networkCap?.destroy();
@@ -9292,6 +9459,8 @@ function createInstance(config) {
9292
9459
  replayCap = null;
9293
9460
  offlineQueue.stopAutoSync();
9294
9461
  stopReporterInboxPolling();
9462
+ unsubPageViewHistory?.();
9463
+ unsubPageViewHistory = null;
9295
9464
  core.destroySessionTracker();
9296
9465
  breadcrumbs.clear();
9297
9466
  listeners.clear();
@@ -9385,6 +9554,16 @@ function createInstance(config) {
9385
9554
  },
9386
9555
  async captureException(error, options) {
9387
9556
  const normalised = core.normaliseThrown(error);
9557
+ const filename = typeof options?.metadata?.filename === "string" ? options.metadata.filename : void 0;
9558
+ if (core.shouldDropCapturedError({
9559
+ message: normalised.message,
9560
+ filename,
9561
+ ignoreErrors: activeConfig.ignoreErrors,
9562
+ denyUrls: activeConfig.denyUrls,
9563
+ allowUrls: activeConfig.allowUrls
9564
+ })) {
9565
+ return null;
9566
+ }
9388
9567
  breadcrumbs.add({
9389
9568
  category: "lifecycle",
9390
9569
  level: "error",
@@ -9428,6 +9607,7 @@ function createInstance(config) {
9428
9607
  level: "info",
9429
9608
  message: `Mushi.identify(${userId})`
9430
9609
  });
9610
+ core.updateEventIdentity(userId, traits ?? null);
9431
9611
  wireRewardsForIdentifiedUser(
9432
9612
  userId,
9433
9613
  traits ? {
@@ -9520,6 +9700,16 @@ function createInstance(config) {
9520
9700
  if (!activeConfig.rewards?.enabled) return;
9521
9701
  enqueue({ action, metadata });
9522
9702
  },
9703
+ // ─── Product analytics (Users & Funnels) ──────────────────────────
9704
+ track(event, properties) {
9705
+ return core.trackEvent(event, properties);
9706
+ },
9707
+ setConsent(state) {
9708
+ core.setEventConsent(state);
9709
+ },
9710
+ getAnonymousId() {
9711
+ return core.getEventAnonymousId();
9712
+ },
9523
9713
  pulseTrigger() {
9524
9714
  widget.pulseTrigger?.();
9525
9715
  },
@@ -9578,6 +9768,8 @@ function createInstance(config) {
9578
9768
  localStorage.setItem(SENTINEL_KEY, "clean");
9579
9769
  } catch {
9580
9770
  }
9771
+ core.markPageUnloading();
9772
+ core.flushLastOutboundOnUnload();
9581
9773
  });
9582
9774
  } catch {
9583
9775
  }
@@ -9828,6 +10020,10 @@ function createNoopInstance() {
9828
10020
  getTier: async () => null,
9829
10021
  recordActivity: () => {
9830
10022
  },
10023
+ track: () => false,
10024
+ setConsent: () => {
10025
+ },
10026
+ getAnonymousId: () => null,
9831
10027
  pulseTrigger: () => {
9832
10028
  },
9833
10029
  listMyReports: async () => [],