@mushi-mushi/core 1.21.0 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -2,6 +2,22 @@ interface MushiConfig {
2
2
  projectId: string;
3
3
  apiKey: string;
4
4
  apiEndpoint?: string;
5
+ /** Per-request timeout in ms (default 10000). Raise on slow mobile networks. */
6
+ timeout?: number;
7
+ /** Max retries for transient (network / 5xx) failures (default 2). */
8
+ maxRetries?: number;
9
+ /**
10
+ * Endpoint circuit breaker. After `threshold` consecutive unreachable
11
+ * failures the client fast-fails for `cooldownMs` (then half-opens) instead
12
+ * of hammering a down endpoint; fast-failed reports still hit the offline
13
+ * queue. Set `enabled: false` to opt out. Defaults: enabled, threshold 4,
14
+ * cooldown 30000ms.
15
+ */
16
+ circuitBreaker?: {
17
+ enabled?: boolean;
18
+ threshold?: number;
19
+ cooldownMs?: number;
20
+ };
5
21
  /** Opinionated defaults for common environments. Explicit config wins. */
6
22
  preset?: MushiPreset;
7
23
  /**
@@ -858,6 +874,16 @@ interface MushiEnvironment {
858
874
  */
859
875
  route?: string;
860
876
  nearestTestid?: string;
877
+ /**
878
+ * Native-shell detection (best-effort, present only when a native bridge is
879
+ * detected). Lets triage distinguish a Capacitor/Cordova/React-Native WebView
880
+ * report from a plain browser one, and lets the SDK gate DOM-only behaviour.
881
+ */
882
+ native?: {
883
+ capacitor?: boolean;
884
+ cordova?: boolean;
885
+ reactNative?: boolean;
886
+ };
861
887
  /**
862
888
  * SDK boost (2026-05-07): richer per-report context so the Triage LLM
863
889
  * and the admin /reports detail drawer have something to reason about
@@ -1615,6 +1641,19 @@ interface ApiClientOptions {
1615
1641
  apiEndpoint?: string;
1616
1642
  timeout?: number;
1617
1643
  maxRetries?: number;
1644
+ /**
1645
+ * Circuit breaker for the endpoint. After `threshold` consecutive
1646
+ * unreachable failures (network errors / exhausted 5xx) the client
1647
+ * fast-fails for `cooldownMs` instead of hammering a down endpoint, then
1648
+ * half-opens (one trial request). Fast-failed requests return a transient
1649
+ * error so the offline queue still captures the report. Set
1650
+ * `enabled: false` to opt out. Defaults: enabled, threshold 4, cooldown 30s.
1651
+ */
1652
+ circuitBreaker?: {
1653
+ enabled?: boolean;
1654
+ threshold?: number;
1655
+ cooldownMs?: number;
1656
+ };
1618
1657
  /** When set, sent on every request so heartbeats record the running SDK version. */
1619
1658
  sdkPackage?: string;
1620
1659
  sdkVersion?: string;
@@ -1629,6 +1668,8 @@ declare const DEFAULT_API_ENDPOINT = "https://dxptnwrhwsqckaftyymj.supabase.co/f
1629
1668
  declare const MUSHI_INTERNAL_HEADER = "X-Mushi-Internal";
1630
1669
  declare const MUSHI_INTERNAL_INIT_MARKER = "__mushiInternal";
1631
1670
  type MushiInternalRequestKind = 'sdk-config' | 'report-submit' | 'report-status' | 'reporter-poll' | 'diagnose' | 'discovery' | 'community';
1671
+ declare const DEFAULT_TIMEOUT = 10000;
1672
+ declare const DEFAULT_MAX_RETRIES = 2;
1632
1673
  declare function createApiClient(options: ApiClientOptions): MushiApiClient;
1633
1674
 
1634
1675
  /**
@@ -2344,4 +2385,4 @@ declare function projectInitialsThemeIndex(projectId: string): number;
2344
2385
  */
2345
2386
  declare function readPageFaviconHref(): string | null;
2346
2387
 
2347
- export { type ApiClientOptions, type BreadcrumbBuffer, type BreadcrumbBufferOptions, DEFAULT_API_ENDPOINT, type LogEntry, type LogFormat, type LogLevel, type Logger, type LoggerOptions, MAX_REPORT_PAYLOAD_BYTES, MAX_SCREENSHOT_DATA_URL_BYTES, MUSHI_ACCENT_SHADOW, MUSHI_BANNER_BRAND_BORDER, MUSHI_BANNER_NEON, MUSHI_COLORS_DARK, MUSHI_COLORS_LIGHT, MUSHI_COPY, MUSHI_GEOMETRY, MUSHI_IDENTITY_TOKEN_PREFIX, MUSHI_INTERNAL_HEADER, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INVERSE, MUSHI_MOTION, MUSHI_ON_ACCENT, MUSHI_PROJECT_HEADER, MUSHI_RADIUS, MUSHI_REPORTER_STATUS, MUSHI_SDK_PACKAGE_HEADER, MUSHI_SDK_VERSION_HEADER, MUSHI_SPACING, MUSHI_TIER_COLORS, MUSHI_TYPE, MUSHI_USER_TOKEN_HEADER, MUSHI_Z, type MushiActivityEvent, type MushiApiCascadeConfig, type MushiApiClient, type MushiApiResponse, type MushiAssistantConfig, type MushiAssistantReply, type MushiAssistantStep, type MushiBannerConfig, type MushiBannerLink, type MushiBetaChangelogEntry, type MushiBetaModeConfig, type MushiBreadcrumb, type MushiCaptureConfig, type MushiCaptureEventInput, type MushiCaptureExceptionOptions, type MushiColorPalette, type MushiConfig, type MushiConsoleEntry, type MushiCooldownConfig, type MushiCrossAppReport, type MushiCustomCategory, type MushiDiagnosticsResult, type MushiDiscoverInventoryConfig, type MushiDiscoveryEventPayload, type MushiEnvironment, type MushiEventHandler, type MushiEventType, type MushiHallOfFameEntry, type MushiIdentityClaims, type MushiIntegrationsConfig, type MushiInternalRequestKind, type MushiLeaderboardEntry, type MushiNetworkEntry, type MushiOfflineConfig, type MushiOnDeviceClassifier, type MushiOnDeviceClassifierInput, type MushiOnDeviceClassifierResult, type MushiPageContext, type MushiPerformanceMetrics, type MushiPreFilterConfig, type MushiPreset, type MushiPrivacyConfig, type MushiProactiveConfig, type MushiRegion, type MushiReport, type MushiReportBuilder, type MushiReportCategory, type MushiReportStatus, type MushiReporterComment, type MushiReporterReport, type MushiReputationResult, type MushiRewardsConfig, type MushiRuntimeSdkConfig, type MushiSDKInstance, type MushiSdkVersionInfo, type MushiSelectedElement, type MushiSentryConfig, type MushiSentryContext, type MushiTesterReputation, type MushiThemeMode, type MushiTierResult, type MushiTimelineEntry, type MushiTimelineKind, type MushiTokenSnapshot, type MushiTracePropagationConfig, type MushiUrlMatcher, type MushiWidgetAnchor, type MushiWidgetConfig, type NormalisedException, type OfflineQueue, type PayloadGuardResult, type PiiScrubberConfig, type PreFilterResult, type ProjectFaviconSource, REGION_ENDPOINTS, type RateLimiter, type RateLimiterConfig, type ResolvedEnvConfig, buildIdentityClaims, buildSdkIngestHeaders, captureEnvironment, checkReportPayloadSize, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, estimateJsonBytes, faviconUrlCandidates, formatBytes, getDeviceFingerprintHash, getReporterToken, getSessionId, githubRepoDomainHint, hmacSha256Hex, isLikelyGenericFavicon, isUntrustedFaviconUrl, mushiPalette, mushiTokens, newUuid, noopLogger, normaliseThrown, originToDomain, parseIdentityToken, projectFaviconUrlCandidates, projectInitials, projectInitialsThemeIndex, readPageFaviconHref, resolveEnvConfig, resolveProjectDomain, resolveProjectFaviconDomains, resolveRegionEndpoint, resolveWidgetAccent, safeWidgetHex, scrubPii, sha256Hex };
2388
+ export { type ApiClientOptions, type BreadcrumbBuffer, type BreadcrumbBufferOptions, DEFAULT_API_ENDPOINT, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, type LogEntry, type LogFormat, type LogLevel, type Logger, type LoggerOptions, MAX_REPORT_PAYLOAD_BYTES, MAX_SCREENSHOT_DATA_URL_BYTES, MUSHI_ACCENT_SHADOW, MUSHI_BANNER_BRAND_BORDER, MUSHI_BANNER_NEON, MUSHI_COLORS_DARK, MUSHI_COLORS_LIGHT, MUSHI_COPY, MUSHI_GEOMETRY, MUSHI_IDENTITY_TOKEN_PREFIX, MUSHI_INTERNAL_HEADER, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INVERSE, MUSHI_MOTION, MUSHI_ON_ACCENT, MUSHI_PROJECT_HEADER, MUSHI_RADIUS, MUSHI_REPORTER_STATUS, MUSHI_SDK_PACKAGE_HEADER, MUSHI_SDK_VERSION_HEADER, MUSHI_SPACING, MUSHI_TIER_COLORS, MUSHI_TYPE, MUSHI_USER_TOKEN_HEADER, MUSHI_Z, type MushiActivityEvent, type MushiApiCascadeConfig, type MushiApiClient, type MushiApiResponse, type MushiAssistantConfig, type MushiAssistantReply, type MushiAssistantStep, type MushiBannerConfig, type MushiBannerLink, type MushiBetaChangelogEntry, type MushiBetaModeConfig, type MushiBreadcrumb, type MushiCaptureConfig, type MushiCaptureEventInput, type MushiCaptureExceptionOptions, type MushiColorPalette, type MushiConfig, type MushiConsoleEntry, type MushiCooldownConfig, type MushiCrossAppReport, type MushiCustomCategory, type MushiDiagnosticsResult, type MushiDiscoverInventoryConfig, type MushiDiscoveryEventPayload, type MushiEnvironment, type MushiEventHandler, type MushiEventType, type MushiHallOfFameEntry, type MushiIdentityClaims, type MushiIntegrationsConfig, type MushiInternalRequestKind, type MushiLeaderboardEntry, type MushiNetworkEntry, type MushiOfflineConfig, type MushiOnDeviceClassifier, type MushiOnDeviceClassifierInput, type MushiOnDeviceClassifierResult, type MushiPageContext, type MushiPerformanceMetrics, type MushiPreFilterConfig, type MushiPreset, type MushiPrivacyConfig, type MushiProactiveConfig, type MushiRegion, type MushiReport, type MushiReportBuilder, type MushiReportCategory, type MushiReportStatus, type MushiReporterComment, type MushiReporterReport, type MushiReputationResult, type MushiRewardsConfig, type MushiRuntimeSdkConfig, type MushiSDKInstance, type MushiSdkVersionInfo, type MushiSelectedElement, type MushiSentryConfig, type MushiSentryContext, type MushiTesterReputation, type MushiThemeMode, type MushiTierResult, type MushiTimelineEntry, type MushiTimelineKind, type MushiTokenSnapshot, type MushiTracePropagationConfig, type MushiUrlMatcher, type MushiWidgetAnchor, type MushiWidgetConfig, type NormalisedException, type OfflineQueue, type PayloadGuardResult, type PiiScrubberConfig, type PreFilterResult, type ProjectFaviconSource, REGION_ENDPOINTS, type RateLimiter, type RateLimiterConfig, type ResolvedEnvConfig, buildIdentityClaims, buildSdkIngestHeaders, captureEnvironment, checkReportPayloadSize, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, estimateJsonBytes, faviconUrlCandidates, formatBytes, getDeviceFingerprintHash, getReporterToken, getSessionId, githubRepoDomainHint, hmacSha256Hex, isLikelyGenericFavicon, isUntrustedFaviconUrl, mushiPalette, mushiTokens, newUuid, noopLogger, normaliseThrown, originToDomain, parseIdentityToken, projectFaviconUrlCandidates, projectInitials, projectInitialsThemeIndex, readPageFaviconHref, resolveEnvConfig, resolveProjectDomain, resolveProjectFaviconDomains, resolveRegionEndpoint, resolveWidgetAccent, safeWidgetHex, scrubPii, sha256Hex };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,22 @@ interface MushiConfig {
2
2
  projectId: string;
3
3
  apiKey: string;
4
4
  apiEndpoint?: string;
5
+ /** Per-request timeout in ms (default 10000). Raise on slow mobile networks. */
6
+ timeout?: number;
7
+ /** Max retries for transient (network / 5xx) failures (default 2). */
8
+ maxRetries?: number;
9
+ /**
10
+ * Endpoint circuit breaker. After `threshold` consecutive unreachable
11
+ * failures the client fast-fails for `cooldownMs` (then half-opens) instead
12
+ * of hammering a down endpoint; fast-failed reports still hit the offline
13
+ * queue. Set `enabled: false` to opt out. Defaults: enabled, threshold 4,
14
+ * cooldown 30000ms.
15
+ */
16
+ circuitBreaker?: {
17
+ enabled?: boolean;
18
+ threshold?: number;
19
+ cooldownMs?: number;
20
+ };
5
21
  /** Opinionated defaults for common environments. Explicit config wins. */
6
22
  preset?: MushiPreset;
7
23
  /**
@@ -858,6 +874,16 @@ interface MushiEnvironment {
858
874
  */
859
875
  route?: string;
860
876
  nearestTestid?: string;
877
+ /**
878
+ * Native-shell detection (best-effort, present only when a native bridge is
879
+ * detected). Lets triage distinguish a Capacitor/Cordova/React-Native WebView
880
+ * report from a plain browser one, and lets the SDK gate DOM-only behaviour.
881
+ */
882
+ native?: {
883
+ capacitor?: boolean;
884
+ cordova?: boolean;
885
+ reactNative?: boolean;
886
+ };
861
887
  /**
862
888
  * SDK boost (2026-05-07): richer per-report context so the Triage LLM
863
889
  * and the admin /reports detail drawer have something to reason about
@@ -1615,6 +1641,19 @@ interface ApiClientOptions {
1615
1641
  apiEndpoint?: string;
1616
1642
  timeout?: number;
1617
1643
  maxRetries?: number;
1644
+ /**
1645
+ * Circuit breaker for the endpoint. After `threshold` consecutive
1646
+ * unreachable failures (network errors / exhausted 5xx) the client
1647
+ * fast-fails for `cooldownMs` instead of hammering a down endpoint, then
1648
+ * half-opens (one trial request). Fast-failed requests return a transient
1649
+ * error so the offline queue still captures the report. Set
1650
+ * `enabled: false` to opt out. Defaults: enabled, threshold 4, cooldown 30s.
1651
+ */
1652
+ circuitBreaker?: {
1653
+ enabled?: boolean;
1654
+ threshold?: number;
1655
+ cooldownMs?: number;
1656
+ };
1618
1657
  /** When set, sent on every request so heartbeats record the running SDK version. */
1619
1658
  sdkPackage?: string;
1620
1659
  sdkVersion?: string;
@@ -1629,6 +1668,8 @@ declare const DEFAULT_API_ENDPOINT = "https://dxptnwrhwsqckaftyymj.supabase.co/f
1629
1668
  declare const MUSHI_INTERNAL_HEADER = "X-Mushi-Internal";
1630
1669
  declare const MUSHI_INTERNAL_INIT_MARKER = "__mushiInternal";
1631
1670
  type MushiInternalRequestKind = 'sdk-config' | 'report-submit' | 'report-status' | 'reporter-poll' | 'diagnose' | 'discovery' | 'community';
1671
+ declare const DEFAULT_TIMEOUT = 10000;
1672
+ declare const DEFAULT_MAX_RETRIES = 2;
1632
1673
  declare function createApiClient(options: ApiClientOptions): MushiApiClient;
1633
1674
 
1634
1675
  /**
@@ -2344,4 +2385,4 @@ declare function projectInitialsThemeIndex(projectId: string): number;
2344
2385
  */
2345
2386
  declare function readPageFaviconHref(): string | null;
2346
2387
 
2347
- export { type ApiClientOptions, type BreadcrumbBuffer, type BreadcrumbBufferOptions, DEFAULT_API_ENDPOINT, type LogEntry, type LogFormat, type LogLevel, type Logger, type LoggerOptions, MAX_REPORT_PAYLOAD_BYTES, MAX_SCREENSHOT_DATA_URL_BYTES, MUSHI_ACCENT_SHADOW, MUSHI_BANNER_BRAND_BORDER, MUSHI_BANNER_NEON, MUSHI_COLORS_DARK, MUSHI_COLORS_LIGHT, MUSHI_COPY, MUSHI_GEOMETRY, MUSHI_IDENTITY_TOKEN_PREFIX, MUSHI_INTERNAL_HEADER, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INVERSE, MUSHI_MOTION, MUSHI_ON_ACCENT, MUSHI_PROJECT_HEADER, MUSHI_RADIUS, MUSHI_REPORTER_STATUS, MUSHI_SDK_PACKAGE_HEADER, MUSHI_SDK_VERSION_HEADER, MUSHI_SPACING, MUSHI_TIER_COLORS, MUSHI_TYPE, MUSHI_USER_TOKEN_HEADER, MUSHI_Z, type MushiActivityEvent, type MushiApiCascadeConfig, type MushiApiClient, type MushiApiResponse, type MushiAssistantConfig, type MushiAssistantReply, type MushiAssistantStep, type MushiBannerConfig, type MushiBannerLink, type MushiBetaChangelogEntry, type MushiBetaModeConfig, type MushiBreadcrumb, type MushiCaptureConfig, type MushiCaptureEventInput, type MushiCaptureExceptionOptions, type MushiColorPalette, type MushiConfig, type MushiConsoleEntry, type MushiCooldownConfig, type MushiCrossAppReport, type MushiCustomCategory, type MushiDiagnosticsResult, type MushiDiscoverInventoryConfig, type MushiDiscoveryEventPayload, type MushiEnvironment, type MushiEventHandler, type MushiEventType, type MushiHallOfFameEntry, type MushiIdentityClaims, type MushiIntegrationsConfig, type MushiInternalRequestKind, type MushiLeaderboardEntry, type MushiNetworkEntry, type MushiOfflineConfig, type MushiOnDeviceClassifier, type MushiOnDeviceClassifierInput, type MushiOnDeviceClassifierResult, type MushiPageContext, type MushiPerformanceMetrics, type MushiPreFilterConfig, type MushiPreset, type MushiPrivacyConfig, type MushiProactiveConfig, type MushiRegion, type MushiReport, type MushiReportBuilder, type MushiReportCategory, type MushiReportStatus, type MushiReporterComment, type MushiReporterReport, type MushiReputationResult, type MushiRewardsConfig, type MushiRuntimeSdkConfig, type MushiSDKInstance, type MushiSdkVersionInfo, type MushiSelectedElement, type MushiSentryConfig, type MushiSentryContext, type MushiTesterReputation, type MushiThemeMode, type MushiTierResult, type MushiTimelineEntry, type MushiTimelineKind, type MushiTokenSnapshot, type MushiTracePropagationConfig, type MushiUrlMatcher, type MushiWidgetAnchor, type MushiWidgetConfig, type NormalisedException, type OfflineQueue, type PayloadGuardResult, type PiiScrubberConfig, type PreFilterResult, type ProjectFaviconSource, REGION_ENDPOINTS, type RateLimiter, type RateLimiterConfig, type ResolvedEnvConfig, buildIdentityClaims, buildSdkIngestHeaders, captureEnvironment, checkReportPayloadSize, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, estimateJsonBytes, faviconUrlCandidates, formatBytes, getDeviceFingerprintHash, getReporterToken, getSessionId, githubRepoDomainHint, hmacSha256Hex, isLikelyGenericFavicon, isUntrustedFaviconUrl, mushiPalette, mushiTokens, newUuid, noopLogger, normaliseThrown, originToDomain, parseIdentityToken, projectFaviconUrlCandidates, projectInitials, projectInitialsThemeIndex, readPageFaviconHref, resolveEnvConfig, resolveProjectDomain, resolveProjectFaviconDomains, resolveRegionEndpoint, resolveWidgetAccent, safeWidgetHex, scrubPii, sha256Hex };
2388
+ export { type ApiClientOptions, type BreadcrumbBuffer, type BreadcrumbBufferOptions, DEFAULT_API_ENDPOINT, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, type LogEntry, type LogFormat, type LogLevel, type Logger, type LoggerOptions, MAX_REPORT_PAYLOAD_BYTES, MAX_SCREENSHOT_DATA_URL_BYTES, MUSHI_ACCENT_SHADOW, MUSHI_BANNER_BRAND_BORDER, MUSHI_BANNER_NEON, MUSHI_COLORS_DARK, MUSHI_COLORS_LIGHT, MUSHI_COPY, MUSHI_GEOMETRY, MUSHI_IDENTITY_TOKEN_PREFIX, MUSHI_INTERNAL_HEADER, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INVERSE, MUSHI_MOTION, MUSHI_ON_ACCENT, MUSHI_PROJECT_HEADER, MUSHI_RADIUS, MUSHI_REPORTER_STATUS, MUSHI_SDK_PACKAGE_HEADER, MUSHI_SDK_VERSION_HEADER, MUSHI_SPACING, MUSHI_TIER_COLORS, MUSHI_TYPE, MUSHI_USER_TOKEN_HEADER, MUSHI_Z, type MushiActivityEvent, type MushiApiCascadeConfig, type MushiApiClient, type MushiApiResponse, type MushiAssistantConfig, type MushiAssistantReply, type MushiAssistantStep, type MushiBannerConfig, type MushiBannerLink, type MushiBetaChangelogEntry, type MushiBetaModeConfig, type MushiBreadcrumb, type MushiCaptureConfig, type MushiCaptureEventInput, type MushiCaptureExceptionOptions, type MushiColorPalette, type MushiConfig, type MushiConsoleEntry, type MushiCooldownConfig, type MushiCrossAppReport, type MushiCustomCategory, type MushiDiagnosticsResult, type MushiDiscoverInventoryConfig, type MushiDiscoveryEventPayload, type MushiEnvironment, type MushiEventHandler, type MushiEventType, type MushiHallOfFameEntry, type MushiIdentityClaims, type MushiIntegrationsConfig, type MushiInternalRequestKind, type MushiLeaderboardEntry, type MushiNetworkEntry, type MushiOfflineConfig, type MushiOnDeviceClassifier, type MushiOnDeviceClassifierInput, type MushiOnDeviceClassifierResult, type MushiPageContext, type MushiPerformanceMetrics, type MushiPreFilterConfig, type MushiPreset, type MushiPrivacyConfig, type MushiProactiveConfig, type MushiRegion, type MushiReport, type MushiReportBuilder, type MushiReportCategory, type MushiReportStatus, type MushiReporterComment, type MushiReporterReport, type MushiReputationResult, type MushiRewardsConfig, type MushiRuntimeSdkConfig, type MushiSDKInstance, type MushiSdkVersionInfo, type MushiSelectedElement, type MushiSentryConfig, type MushiSentryContext, type MushiTesterReputation, type MushiThemeMode, type MushiTierResult, type MushiTimelineEntry, type MushiTimelineKind, type MushiTokenSnapshot, type MushiTracePropagationConfig, type MushiUrlMatcher, type MushiWidgetAnchor, type MushiWidgetConfig, type NormalisedException, type OfflineQueue, type PayloadGuardResult, type PiiScrubberConfig, type PreFilterResult, type ProjectFaviconSource, REGION_ENDPOINTS, type RateLimiter, type RateLimiterConfig, type ResolvedEnvConfig, buildIdentityClaims, buildSdkIngestHeaders, captureEnvironment, checkReportPayloadSize, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, estimateJsonBytes, faviconUrlCandidates, formatBytes, getDeviceFingerprintHash, getReporterToken, getSessionId, githubRepoDomainHint, hmacSha256Hex, isLikelyGenericFavicon, isUntrustedFaviconUrl, mushiPalette, mushiTokens, newUuid, noopLogger, normaliseThrown, originToDomain, parseIdentityToken, projectFaviconUrlCandidates, projectInitials, projectInitialsThemeIndex, readPageFaviconHref, resolveEnvConfig, resolveProjectDomain, resolveProjectFaviconDomains, resolveRegionEndpoint, resolveWidgetAccent, safeWidgetHex, scrubPii, sha256Hex };
package/dist/index.js CHANGED
@@ -104,6 +104,8 @@ var MUSHI_INTERNAL_HEADER = "X-Mushi-Internal";
104
104
  var MUSHI_INTERNAL_INIT_MARKER = "__mushiInternal";
105
105
  var DEFAULT_TIMEOUT = 1e4;
106
106
  var DEFAULT_MAX_RETRIES = 2;
107
+ var DEFAULT_CIRCUIT_THRESHOLD = 4;
108
+ var DEFAULT_CIRCUIT_COOLDOWN_MS = 3e4;
107
109
  function createApiClient(options) {
108
110
  const {
109
111
  projectId,
@@ -113,10 +115,29 @@ function createApiClient(options) {
113
115
  maxRetries = DEFAULT_MAX_RETRIES,
114
116
  getUserToken,
115
117
  sdkPackage,
116
- sdkVersion
118
+ sdkVersion,
119
+ circuitBreaker
117
120
  } = options;
118
121
  let baseUrl = apiEndpoint.replace(/\/$/, "");
122
+ const cbEnabled = circuitBreaker?.enabled !== false;
123
+ const cbThreshold = Math.max(1, circuitBreaker?.threshold ?? DEFAULT_CIRCUIT_THRESHOLD);
124
+ const cbCooldownMs = Math.max(1e3, circuitBreaker?.cooldownMs ?? DEFAULT_CIRCUIT_COOLDOWN_MS);
125
+ let cbFailures = 0;
126
+ let cbOpenUntil = 0;
127
+ const cbIsOpen = () => cbEnabled && cbOpenUntil > Date.now();
128
+ const cbRecordReachable = () => {
129
+ cbFailures = 0;
130
+ cbOpenUntil = 0;
131
+ };
132
+ const cbRecordUnreachable = () => {
133
+ if (!cbEnabled) return;
134
+ cbFailures += 1;
135
+ if (cbFailures >= cbThreshold) cbOpenUntil = Date.now() + cbCooldownMs;
136
+ };
119
137
  async function request(method, path, body, retries = maxRetries, internalKind, extraHeaders) {
138
+ if (cbIsOpen()) {
139
+ return { ok: false, error: { code: "CIRCUIT_OPEN", message: "Endpoint temporarily unavailable; retrying later." } };
140
+ }
120
141
  const url = `${baseUrl}${path}`;
121
142
  const controller = new AbortController();
122
143
  const timer = setTimeout(() => controller.abort(), timeout);
@@ -163,6 +184,8 @@ function createApiClient(options) {
163
184
  await sleep(getBackoffDelay(maxRetries - retries));
164
185
  return request(method, path, body, retries - 1, internalKind, extraHeaders);
165
186
  }
187
+ if (response.status >= 500) cbRecordUnreachable();
188
+ else cbRecordReachable();
166
189
  return {
167
190
  ok: false,
168
191
  error: {
@@ -173,6 +196,7 @@ function createApiClient(options) {
173
196
  }
174
197
  const payload = await response.json();
175
198
  const data = payload && typeof payload === "object" && "ok" in payload && "data" in payload ? payload.data : payload;
199
+ cbRecordReachable();
176
200
  return { ok: true, data };
177
201
  } catch (error) {
178
202
  clearTimeout(timer);
@@ -180,6 +204,7 @@ function createApiClient(options) {
180
204
  await sleep(getBackoffDelay(maxRetries - retries));
181
205
  return request(method, path, body, retries - 1, internalKind);
182
206
  }
207
+ cbRecordUnreachable();
183
208
  return {
184
209
  ok: false,
185
210
  error: {
@@ -464,9 +489,9 @@ function isRetryable(error) {
464
489
 
465
490
  // src/region.ts
466
491
  var REGION_ENDPOINTS = {
467
- us: "https://api.us.mushimushi.dev/functions/v1/api",
468
- eu: "https://api.eu.mushimushi.dev/functions/v1/api",
469
- jp: "https://api.jp.mushimushi.dev/functions/v1/api"
492
+ us: "https://dxptnwrhwsqckaftyymj.supabase.co/functions/v1/api",
493
+ eu: "https://dxptnwrhwsqckaftyymj.supabase.co/functions/v1/api",
494
+ jp: "https://dxptnwrhwsqckaftyymj.supabase.co/functions/v1/api"
470
495
  };
471
496
  var ROUTING_CACHE_KEY = "mushi_region_v1";
472
497
  var ROUTING_CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
@@ -1212,7 +1237,8 @@ function createOfflineQueue(config = {}) {
1212
1237
  if (!enabled || !syncOnReconnect || typeof window === "undefined") return;
1213
1238
  const tryFlush = () => {
1214
1239
  if (navigator.onLine) {
1215
- flush(client).catch(() => {
1240
+ flush(client).catch((err) => {
1241
+ queueLog.warn("Offline queue auto-flush failed", { err: String(err) });
1216
1242
  });
1217
1243
  }
1218
1244
  };
@@ -1245,6 +1271,15 @@ function captureEnvironment() {
1245
1271
  const scr = typeof screen !== "undefined" ? screen : void 0;
1246
1272
  void kickOffUserAgentData(nav);
1247
1273
  const connection = nav && "connection" in nav ? nav.connection : void 0;
1274
+ const w = win;
1275
+ const isCapacitor = !!w?.Capacitor;
1276
+ const isCordova = !!w?.cordova;
1277
+ const isReactNative = nav?.product === "ReactNative" || typeof globalThis.HermesInternal !== "undefined";
1278
+ const native = isCapacitor || isCordova || isReactNative ? {
1279
+ ...isCapacitor ? { capacitor: true } : {},
1280
+ ...isCordova ? { cordova: true } : {},
1281
+ ...isReactNative ? { reactNative: true } : {}
1282
+ } : void 0;
1248
1283
  return {
1249
1284
  userAgent: nav?.userAgent ?? "unknown",
1250
1285
  platform: nav?.platform ?? "unknown",
@@ -1277,7 +1312,8 @@ function captureEnvironment() {
1277
1312
  displayMode: matchDisplayMode(win),
1278
1313
  documentTitle: doc?.title?.slice(0, 200),
1279
1314
  buildId: readBuildIdMeta(doc),
1280
- pageLoadTiming: capturePageLoadTiming(win)
1315
+ pageLoadTiming: capturePageLoadTiming(win),
1316
+ ...native ? { native } : {}
1281
1317
  };
1282
1318
  }
1283
1319
  function findNearestTestidFromActive(doc) {
@@ -1931,7 +1967,7 @@ var SLUG_DOMAIN_HINTS = {
1931
1967
  "glot-it": "glot.it",
1932
1968
  glotit: "glot.it",
1933
1969
  "solo-boss-cloud": "sbc-front.vercel.app",
1934
- "mushi-mushi": "mushimushi.dev"
1970
+ "mushi-mushi": "kensaur.us"
1935
1971
  };
1936
1972
  var SLUG_ICON_URL_HINTS = {
1937
1973
  "mushi-mushi": "https://kensaur.us/mushi-mushi/admin/favicon.svg",
@@ -2109,6 +2145,6 @@ function isSafeFaviconHref(href) {
2109
2145
  }
2110
2146
  }
2111
2147
 
2112
- export { DEFAULT_API_ENDPOINT, MAX_REPORT_PAYLOAD_BYTES, MAX_SCREENSHOT_DATA_URL_BYTES, MUSHI_ACCENT_SHADOW, MUSHI_BANNER_BRAND_BORDER, MUSHI_BANNER_NEON, MUSHI_COLORS_DARK, MUSHI_COLORS_LIGHT, MUSHI_COPY, MUSHI_GEOMETRY, MUSHI_IDENTITY_TOKEN_PREFIX, MUSHI_INTERNAL_HEADER, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INVERSE, MUSHI_MOTION, MUSHI_ON_ACCENT, MUSHI_PROJECT_HEADER, MUSHI_RADIUS, MUSHI_REPORTER_STATUS, MUSHI_SDK_PACKAGE_HEADER, MUSHI_SDK_VERSION_HEADER, MUSHI_SPACING, MUSHI_TIER_COLORS, MUSHI_TYPE, MUSHI_USER_TOKEN_HEADER, MUSHI_Z, REGION_ENDPOINTS, buildIdentityClaims, buildSdkIngestHeaders, captureEnvironment, checkReportPayloadSize, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, estimateJsonBytes, faviconUrlCandidates, formatBytes, getDeviceFingerprintHash, getReporterToken, getSessionId, githubRepoDomainHint, hmacSha256Hex, isLikelyGenericFavicon, isUntrustedFaviconUrl, mushiPalette, mushiTokens, newUuid, noopLogger, normaliseThrown, originToDomain, parseIdentityToken, projectFaviconUrlCandidates, projectInitials, projectInitialsThemeIndex, readPageFaviconHref, resolveEnvConfig, resolveProjectDomain, resolveProjectFaviconDomains, resolveRegionEndpoint, resolveWidgetAccent, safeWidgetHex, scrubPii, sha256Hex };
2148
+ export { DEFAULT_API_ENDPOINT, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, MAX_REPORT_PAYLOAD_BYTES, MAX_SCREENSHOT_DATA_URL_BYTES, MUSHI_ACCENT_SHADOW, MUSHI_BANNER_BRAND_BORDER, MUSHI_BANNER_NEON, MUSHI_COLORS_DARK, MUSHI_COLORS_LIGHT, MUSHI_COPY, MUSHI_GEOMETRY, MUSHI_IDENTITY_TOKEN_PREFIX, MUSHI_INTERNAL_HEADER, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INVERSE, MUSHI_MOTION, MUSHI_ON_ACCENT, MUSHI_PROJECT_HEADER, MUSHI_RADIUS, MUSHI_REPORTER_STATUS, MUSHI_SDK_PACKAGE_HEADER, MUSHI_SDK_VERSION_HEADER, MUSHI_SPACING, MUSHI_TIER_COLORS, MUSHI_TYPE, MUSHI_USER_TOKEN_HEADER, MUSHI_Z, REGION_ENDPOINTS, buildIdentityClaims, buildSdkIngestHeaders, captureEnvironment, checkReportPayloadSize, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, estimateJsonBytes, faviconUrlCandidates, formatBytes, getDeviceFingerprintHash, getReporterToken, getSessionId, githubRepoDomainHint, hmacSha256Hex, isLikelyGenericFavicon, isUntrustedFaviconUrl, mushiPalette, mushiTokens, newUuid, noopLogger, normaliseThrown, originToDomain, parseIdentityToken, projectFaviconUrlCandidates, projectInitials, projectInitialsThemeIndex, readPageFaviconHref, resolveEnvConfig, resolveProjectDomain, resolveProjectFaviconDomains, resolveRegionEndpoint, resolveWidgetAccent, safeWidgetHex, scrubPii, sha256Hex };
2113
2149
  //# sourceMappingURL=index.js.map
2114
2150
  //# sourceMappingURL=index.js.map