@mushi-mushi/web 1.7.8 → 1.9.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.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiWidgetConfig, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiConsoleEntry, MushiNetworkEntry, MushiUrlMatcher, MushiPrivacyConfig, MushiPerformanceMetrics, MushiSelectedElement, MushiTimelineEntry, MushiApiCascadeConfig } from '@mushi-mushi/core';
1
+ import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiWidgetConfig, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiConsoleEntry, MushiNetworkEntry, MushiUrlMatcher, MushiTracePropagationConfig, MushiPrivacyConfig, MushiPerformanceMetrics, MushiSelectedElement, MushiTimelineEntry, MushiApiCascadeConfig } from '@mushi-mushi/core';
2
2
  export { MushiApiCascadeConfig, MushiConfig, MushiConsoleEntry, MushiDiagnosticsResult, MushiEnvironment, MushiEventHandler, MushiEventType, MushiNetworkEntry, MushiPerformanceMetrics, MushiReport, MushiReportCategory, MushiSDKInstance, MushiTimelineEntry, MushiTimelineKind, MushiUrlMatcher, MushiWidgetConfig } from '@mushi-mushi/core';
3
3
 
4
4
  declare class Mushi {
@@ -349,6 +349,8 @@ interface NetworkCapture {
349
349
  interface NetworkCaptureOptions {
350
350
  apiEndpoint?: string;
351
351
  ignoreUrls?: MushiUrlMatcher[];
352
+ tracePropagation?: MushiTracePropagationConfig;
353
+ sessionId?: string;
352
354
  }
353
355
  declare function createNetworkCapture(options?: NetworkCaptureOptions): NetworkCapture;
354
356
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiWidgetConfig, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiConsoleEntry, MushiNetworkEntry, MushiUrlMatcher, MushiPrivacyConfig, MushiPerformanceMetrics, MushiSelectedElement, MushiTimelineEntry, MushiApiCascadeConfig } from '@mushi-mushi/core';
1
+ import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiWidgetConfig, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiConsoleEntry, MushiNetworkEntry, MushiUrlMatcher, MushiTracePropagationConfig, MushiPrivacyConfig, MushiPerformanceMetrics, MushiSelectedElement, MushiTimelineEntry, MushiApiCascadeConfig } from '@mushi-mushi/core';
2
2
  export { MushiApiCascadeConfig, MushiConfig, MushiConsoleEntry, MushiDiagnosticsResult, MushiEnvironment, MushiEventHandler, MushiEventType, MushiNetworkEntry, MushiPerformanceMetrics, MushiReport, MushiReportCategory, MushiSDKInstance, MushiTimelineEntry, MushiTimelineKind, MushiUrlMatcher, MushiWidgetConfig } from '@mushi-mushi/core';
3
3
 
4
4
  declare class Mushi {
@@ -349,6 +349,8 @@ interface NetworkCapture {
349
349
  interface NetworkCaptureOptions {
350
350
  apiEndpoint?: string;
351
351
  ignoreUrls?: MushiUrlMatcher[];
352
+ tracePropagation?: MushiTracePropagationConfig;
353
+ sessionId?: string;
352
354
  }
353
355
  declare function createNetworkCapture(options?: NetworkCaptureOptions): NetworkCapture;
354
356
 
package/dist/index.js CHANGED
@@ -1510,6 +1510,106 @@ function getWidgetStyles(theme) {
1510
1510
  text-overflow: ellipsis;
1511
1511
  }
1512
1512
 
1513
+ /* Rich layout \u2014 pill + message + flat text actions (admin BetaBanner parity) */
1514
+ .mushi-banner--rich {
1515
+ justify-content: space-between;
1516
+ gap: 12px;
1517
+ min-height: 36px;
1518
+ height: auto;
1519
+ padding: 4px 12px 4px 16px;
1520
+ white-space: normal;
1521
+ }
1522
+ .mushi-banner-body {
1523
+ display: flex;
1524
+ align-items: center;
1525
+ gap: 8px;
1526
+ flex: 1;
1527
+ min-width: 0;
1528
+ overflow: hidden;
1529
+ }
1530
+ .mushi-banner-pill {
1531
+ display: inline-flex;
1532
+ flex-shrink: 0;
1533
+ align-items: center;
1534
+ padding: 1px 6px;
1535
+ border-radius: 3px;
1536
+ border: 1px solid currentColor;
1537
+ font-size: 10px;
1538
+ font-weight: 700;
1539
+ letter-spacing: 0.18em;
1540
+ text-transform: uppercase;
1541
+ opacity: 0.92;
1542
+ }
1543
+ .mushi-banner.neon .mushi-banner-pill {
1544
+ border-color: rgba(10,26,10,0.45);
1545
+ background: rgba(10,26,10,0.12);
1546
+ }
1547
+ .mushi-banner.brand .mushi-banner-pill {
1548
+ border-color: rgba(255,255,255,0.45);
1549
+ background: rgba(255,255,255,0.14);
1550
+ }
1551
+ .mushi-banner.subtle .mushi-banner-pill {
1552
+ border-color: ${ruleStrong};
1553
+ background: ${isDark ? "rgba(242,235,221,0.08)" : "rgba(14,13,11,0.06)"};
1554
+ }
1555
+ .mushi-banner-message {
1556
+ min-width: 0;
1557
+ overflow: hidden;
1558
+ text-overflow: ellipsis;
1559
+ white-space: nowrap;
1560
+ font-size: 11.5px;
1561
+ font-weight: 500;
1562
+ line-height: 1.3;
1563
+ opacity: 0.9;
1564
+ }
1565
+ .mushi-banner-actions {
1566
+ display: inline-flex;
1567
+ align-items: center;
1568
+ gap: 0;
1569
+ /* Shrinkable + swipe-scrollable so a long action row can never push
1570
+ past the viewport edge (dismiss sits outside this nav). */
1571
+ flex-shrink: 1;
1572
+ min-width: 0;
1573
+ overflow-x: auto;
1574
+ scrollbar-width: none;
1575
+ font-size: 11px;
1576
+ }
1577
+ .mushi-banner-actions::-webkit-scrollbar { display: none; }
1578
+ @media (max-width: 480px) {
1579
+ /* Phones: keep only the primary bug CTA (+ dismiss outside the nav). */
1580
+ .mushi-banner-actions .mushi-banner-extra { display: none; }
1581
+ }
1582
+ .mushi-banner-link {
1583
+ display: inline-flex;
1584
+ align-items: center;
1585
+ padding: 2px 8px;
1586
+ border: none;
1587
+ background: transparent;
1588
+ color: inherit;
1589
+ cursor: pointer;
1590
+ font: inherit;
1591
+ letter-spacing: inherit;
1592
+ text-decoration: none;
1593
+ opacity: 0.88;
1594
+ transition: opacity 0.15s ease;
1595
+ flex-shrink: 0;
1596
+ }
1597
+ .mushi-banner-link:hover { opacity: 1; }
1598
+ .mushi-banner-link:focus-visible {
1599
+ outline: 2px solid ${widgetAccent};
1600
+ outline-offset: 2px;
1601
+ border-radius: 2px;
1602
+ }
1603
+ .mushi-banner-divider {
1604
+ opacity: 0.28;
1605
+ padding: 0 1px;
1606
+ user-select: none;
1607
+ flex-shrink: 0;
1608
+ }
1609
+ .mushi-banner--rich .mushi-banner-dismiss {
1610
+ margin-left: 4px;
1611
+ }
1612
+
1513
1613
  .mushi-banner-btn {
1514
1614
  display: inline-flex;
1515
1615
  align-items: center;
@@ -1752,7 +1852,12 @@ var MushiWidget = class _MushiWidget {
1752
1852
  ...config.responseSlaLabel !== void 0 ? { responseSlaLabel: config.responseSlaLabel } : {},
1753
1853
  ...config.featureRequestCard !== void 0 ? { featureRequestCard: config.featureRequestCard } : {},
1754
1854
  ...config.featureRequestLabel !== void 0 ? { featureRequestLabel: config.featureRequestLabel } : {},
1755
- ...config.featureRequestDescription !== void 0 ? { featureRequestDescription: config.featureRequestDescription } : {}
1855
+ ...config.featureRequestDescription !== void 0 ? { featureRequestDescription: config.featureRequestDescription } : {},
1856
+ // Runtime/dashboard config delivers bannerMessage/bannerLabel via
1857
+ // mergeRuntimeConfig → bannerConfig. The widget is constructed before
1858
+ // that fetch resolves, so this pass-through is what makes server-driven
1859
+ // banner copy actually render.
1860
+ ...config.bannerConfig !== void 0 ? { bannerConfig: config.bannerConfig } : {}
1756
1861
  };
1757
1862
  this.locale = getLocale(this.config.locale === "auto" ? void 0 : this.config.locale);
1758
1863
  if (this.host.isConnected) this.syncHostChromeState();
@@ -2137,18 +2242,16 @@ var MushiWidget = class _MushiWidget {
2137
2242
  const bc = this.config.bannerConfig ?? {};
2138
2243
  const variant = bc.variant ?? "brand";
2139
2244
  const position = bc.position ?? "top";
2245
+ const message = bc.message?.trim() ?? "";
2246
+ const richLayout = message.length > 0;
2140
2247
  const bugLabel = bc.bugCta ?? "\u{1F41B} Report a bug";
2141
2248
  const showFeat = bc.featureCta !== false;
2142
2249
  const featLabel = bc.featureCtaLabel ?? "\u2728 Request feature";
2143
2250
  const zIdx = bc.zIndex ?? (this.config.zIndex ?? 99999) - 1;
2144
2251
  const banner = document.createElement("div");
2145
- banner.className = `mushi-banner ${variant} ${position}`;
2252
+ banner.className = `mushi-banner ${variant} ${position}${richLayout ? " mushi-banner--rich" : ""}`;
2146
2253
  banner.style.setProperty("--mushi-banner-z", String(zIdx));
2147
2254
  banner.setAttribute("role", "banner");
2148
- const bugBtn = document.createElement("button");
2149
- bugBtn.className = "mushi-banner-btn";
2150
- bugBtn.textContent = bugLabel;
2151
- bugBtn.addEventListener("click", () => this.open());
2152
2255
  const dismissBtn = document.createElement("button");
2153
2256
  dismissBtn.className = "mushi-banner-dismiss";
2154
2257
  dismissBtn.textContent = "\u2715";
@@ -2158,15 +2261,81 @@ var MushiWidget = class _MushiWidget {
2158
2261
  this.removeBodyNudge();
2159
2262
  this.render();
2160
2263
  });
2161
- banner.appendChild(bugBtn);
2162
- if (showFeat) {
2163
- const featBtn = document.createElement("button");
2164
- featBtn.className = "mushi-banner-btn";
2165
- featBtn.textContent = featLabel;
2166
- featBtn.addEventListener("click", () => this.open({ featureRequest: true }));
2167
- banner.appendChild(featBtn);
2168
- }
2169
- banner.appendChild(dismissBtn);
2264
+ if (richLayout) {
2265
+ const body = document.createElement("div");
2266
+ body.className = "mushi-banner-body";
2267
+ const labelText = bc.label === false ? null : bc.label ?? "Beta";
2268
+ if (labelText) {
2269
+ const pill = document.createElement("span");
2270
+ pill.className = "mushi-banner-pill";
2271
+ pill.textContent = labelText;
2272
+ body.appendChild(pill);
2273
+ }
2274
+ const msg = document.createElement("span");
2275
+ msg.className = "mushi-banner-message";
2276
+ msg.textContent = message;
2277
+ body.appendChild(msg);
2278
+ banner.appendChild(body);
2279
+ const nav = document.createElement("nav");
2280
+ nav.className = "mushi-banner-actions";
2281
+ nav.setAttribute("aria-label", "Feedback banner actions");
2282
+ const appendDivider = (extra = false) => {
2283
+ const sep = document.createElement("span");
2284
+ sep.className = `mushi-banner-divider${extra ? " mushi-banner-extra" : ""}`;
2285
+ sep.setAttribute("aria-hidden", "true");
2286
+ sep.textContent = "|";
2287
+ nav.appendChild(sep);
2288
+ };
2289
+ const appendAction = (label, onClick, extra = false) => {
2290
+ const btn = document.createElement("button");
2291
+ btn.type = "button";
2292
+ btn.className = `mushi-banner-link${extra ? " mushi-banner-extra" : ""}`;
2293
+ btn.textContent = label;
2294
+ btn.addEventListener("click", onClick);
2295
+ nav.appendChild(btn);
2296
+ };
2297
+ appendAction(bugLabel, () => this.open());
2298
+ if (showFeat) {
2299
+ appendDivider(true);
2300
+ appendAction(featLabel, () => this.open({ featureRequest: true }), true);
2301
+ }
2302
+ for (const link of bc.links ?? []) {
2303
+ const linkLabel = link.label?.trim();
2304
+ if (!linkLabel) continue;
2305
+ const href = link.href && (/^https?:\/\//i.test(link.href) || link.href.startsWith("/")) ? link.href : void 0;
2306
+ appendDivider(true);
2307
+ if (href) {
2308
+ const anchor = document.createElement("a");
2309
+ anchor.className = "mushi-banner-link mushi-banner-extra";
2310
+ anchor.href = href;
2311
+ anchor.textContent = linkLabel;
2312
+ anchor.target = "_blank";
2313
+ anchor.rel = "noopener noreferrer";
2314
+ nav.appendChild(anchor);
2315
+ } else {
2316
+ appendAction(linkLabel, () => {
2317
+ if (link.featureRequest) this.open({ featureRequest: true });
2318
+ else this.open();
2319
+ }, true);
2320
+ }
2321
+ }
2322
+ banner.appendChild(nav);
2323
+ banner.appendChild(dismissBtn);
2324
+ } else {
2325
+ const bugBtn = document.createElement("button");
2326
+ bugBtn.className = "mushi-banner-btn";
2327
+ bugBtn.textContent = bugLabel;
2328
+ bugBtn.addEventListener("click", () => this.open());
2329
+ banner.appendChild(bugBtn);
2330
+ if (showFeat) {
2331
+ const featBtn = document.createElement("button");
2332
+ featBtn.className = "mushi-banner-btn";
2333
+ featBtn.textContent = featLabel;
2334
+ featBtn.addEventListener("click", () => this.open({ featureRequest: true }));
2335
+ banner.appendChild(featBtn);
2336
+ }
2337
+ banner.appendChild(dismissBtn);
2338
+ }
2170
2339
  this.shadow.appendChild(banner);
2171
2340
  this.applyBodyNudge(position);
2172
2341
  }
@@ -3558,6 +3727,29 @@ function readHeader(headers, name) {
3558
3727
 
3559
3728
  // src/capture/network.ts
3560
3729
  var MAX_ENTRIES2 = 30;
3730
+ var TRACEPARENT_VERSION = "00";
3731
+ function generateTraceparent() {
3732
+ const traceBytes = crypto.getRandomValues(new Uint8Array(16));
3733
+ const spanBytes = crypto.getRandomValues(new Uint8Array(8));
3734
+ const toHex = (bytes) => Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
3735
+ const traceId = toHex(traceBytes);
3736
+ const spanId = toHex(spanBytes);
3737
+ return {
3738
+ traceparent: `${TRACEPARENT_VERSION}-${traceId}-${spanId}-01`,
3739
+ traceId,
3740
+ spanId
3741
+ };
3742
+ }
3743
+ function matchesCorsUrls(url, corsUrls) {
3744
+ for (const pattern of corsUrls) {
3745
+ if (typeof pattern === "string") {
3746
+ if (url.includes(pattern)) return true;
3747
+ } else {
3748
+ if (pattern.test(url)) return true;
3749
+ }
3750
+ }
3751
+ return false;
3752
+ }
3561
3753
  function createNetworkCapture(options = {}) {
3562
3754
  const entries = [];
3563
3755
  const originalFetch = globalThis.fetch;
@@ -3568,15 +3760,29 @@ function createNetworkCapture(options = {}) {
3568
3760
  const url = getRequestUrl(input);
3569
3761
  const internalKind = getInternalRequestKind(input, init);
3570
3762
  const shouldRecord = !internalKind && !shouldIgnoreMushiUrl(url, activeOptions);
3763
+ let traceId;
3764
+ let patchedInit = init;
3765
+ const tp = activeOptions.tracePropagation;
3766
+ if (shouldRecord && tp?.enabled && tp.corsUrls?.length && matchesCorsUrls(url, tp.corsUrls)) {
3767
+ const { traceparent, traceId: tid } = generateTraceparent();
3768
+ traceId = tid;
3769
+ const existingHeaders = init?.headers ? new Headers(init.headers) : new Headers();
3770
+ existingHeaders.set("traceparent", traceparent);
3771
+ if (activeOptions.sessionId) {
3772
+ existingHeaders.set("x-mushi-session", activeOptions.sessionId);
3773
+ }
3774
+ patchedInit = { ...init, headers: existingHeaders };
3775
+ }
3571
3776
  try {
3572
- const response = await originalFetch.call(globalThis, input, init);
3777
+ const response = await originalFetch.call(globalThis, input, patchedInit);
3573
3778
  if (shouldRecord) {
3574
3779
  addEntry({
3575
3780
  method,
3576
3781
  url: truncateUrl(url),
3577
3782
  status: response.status,
3578
3783
  duration: Date.now() - startTime,
3579
- timestamp: startTime
3784
+ timestamp: startTime,
3785
+ ...traceId ? { traceId } : {}
3580
3786
  });
3581
3787
  }
3582
3788
  return response;
@@ -3588,7 +3794,8 @@ function createNetworkCapture(options = {}) {
3588
3794
  status: 0,
3589
3795
  duration: Date.now() - startTime,
3590
3796
  timestamp: startTime,
3591
- error: error instanceof Error ? error.message : "Network error"
3797
+ error: error instanceof Error ? error.message : "Network error",
3798
+ ...traceId ? { traceId } : {}
3592
3799
  });
3593
3800
  }
3594
3801
  throw error;
@@ -4821,7 +5028,7 @@ function createProactiveManager(config = {}) {
4821
5028
 
4822
5029
  // src/version.ts
4823
5030
  var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
4824
- var MUSHI_SDK_VERSION = "1.7.7" ;
5031
+ var MUSHI_SDK_VERSION = "1.9.0" ;
4825
5032
 
4826
5033
  // src/mushi.ts
4827
5034
  var instance = null;
@@ -4911,7 +5118,9 @@ function createInstance(config) {
4911
5118
  if (activeConfig.capture?.network !== false) {
4912
5119
  const networkOptions = {
4913
5120
  apiEndpoint: resolveApiEndpoint(activeConfig),
4914
- ignoreUrls: activeConfig.capture?.ignoreUrls
5121
+ ignoreUrls: activeConfig.capture?.ignoreUrls,
5122
+ tracePropagation: activeConfig.capture?.tracePropagation,
5123
+ sessionId: getSessionId()
4915
5124
  };
4916
5125
  if (networkCap) {
4917
5126
  networkCap.updateOptions(networkOptions);
@@ -5002,8 +5211,10 @@ function createInstance(config) {
5002
5211
  });
5003
5212
  let detachAutoBreadcrumbs = null;
5004
5213
  detachAutoBreadcrumbs = installAutoBreadcrumbs(breadcrumbs);
5214
+ let screenshotCaptureInFlight = false;
5005
5215
  async function takeScreenshotWithoutChrome() {
5006
- if (!screenshotCap) return null;
5216
+ if (!screenshotCap || screenshotCaptureInFlight) return null;
5217
+ screenshotCaptureInFlight = true;
5007
5218
  const panelWasVisible = widget.getIsOpen();
5008
5219
  if (panelWasVisible) widget.hidePanel();
5009
5220
  const host = document.getElementById("mushi-mushi-widget");
@@ -5015,6 +5226,7 @@ function createInstance(config) {
5015
5226
  try {
5016
5227
  return await screenshotCap.take();
5017
5228
  } finally {
5229
+ screenshotCaptureInFlight = false;
5018
5230
  if (host) host.style.visibility = prevVisibility;
5019
5231
  if (panelWasVisible) widget.showPanel();
5020
5232
  }
@@ -5688,14 +5900,21 @@ function mergeRuntimeConfig(config, runtime) {
5688
5900
  const nativeTrigger = runtime.native?.triggerMode;
5689
5901
  const runtimeLauncher = runtime.widget?.launcher;
5690
5902
  const widgetTrigger = runtimeLauncher ?? runtime.widget?.trigger ?? (nativeTrigger === "none" || nativeTrigger === "shake" ? "manual" : void 0);
5691
- const runtimeBannerVariant = runtime.widget?.bannerVariant;
5692
- const runtimeBannerPosition = runtime.widget?.bannerPosition;
5693
- const runtimeBannerBugCta = runtime.widget?.bannerBugCta;
5694
- const runtimeBannerFeatureCta = runtime.widget?.bannerFeatureCta;
5695
- const derivedBannerConfig = runtimeBannerVariant || runtimeBannerPosition || runtimeBannerBugCta != null || runtimeBannerFeatureCta != null ? {
5903
+ const runtimeWidget = runtime.widget;
5904
+ const runtimeBannerVariant = runtimeWidget?.bannerVariant;
5905
+ const runtimeBannerPosition = runtimeWidget?.bannerPosition;
5906
+ const runtimeBannerMessage = runtimeWidget?.bannerMessage;
5907
+ const runtimeBannerLabel = runtimeWidget?.bannerLabel;
5908
+ const runtimeBannerBugCta = runtimeWidget?.bannerBugCta;
5909
+ const runtimeBannerFeatureCta = runtimeWidget?.bannerFeatureCta;
5910
+ const derivedBannerConfig = runtimeBannerVariant || runtimeBannerPosition || runtimeBannerMessage != null || runtimeBannerLabel != null || runtimeBannerBugCta != null || runtimeBannerFeatureCta != null ? {
5696
5911
  ...config.widget?.bannerConfig ?? {},
5697
5912
  ...runtimeBannerVariant ? { variant: runtimeBannerVariant } : {},
5698
5913
  ...runtimeBannerPosition ? { position: runtimeBannerPosition } : {},
5914
+ ...runtimeBannerMessage != null ? { message: runtimeBannerMessage } : {},
5915
+ // Dashboard sends an empty string to hide the pill (the runtime
5916
+ // payload has no way to express the local-config `label: false`).
5917
+ ...runtimeBannerLabel != null ? { label: runtimeBannerLabel === "" ? false : runtimeBannerLabel } : {},
5699
5918
  ...runtimeBannerBugCta != null ? { bugCta: runtimeBannerBugCta ?? void 0 } : {},
5700
5919
  ...runtimeBannerFeatureCta != null ? { featureCta: runtimeBannerFeatureCta } : {}
5701
5920
  } : void 0;