@mushi-mushi/core 1.27.1 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/index.cjs +282 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +122 -1
- package/dist/index.d.ts +122 -1
- package/dist/index.js +269 -78
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -46,6 +46,31 @@ interface MushiConfig {
|
|
|
46
46
|
* when omitted (legacy Vercel Analytics wiring).
|
|
47
47
|
*/
|
|
48
48
|
appVersion?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Same-origin (or absolute) ingest proxy. When set, every SDK HTTP call
|
|
51
|
+
* goes here instead of `apiEndpoint` so ad blockers that drop third-party
|
|
52
|
+
* `*.supabase.co/functions` hosts cannot silently eat reports.
|
|
53
|
+
* Relative URLs resolve against the page origin — that is the recommended
|
|
54
|
+
* form (no CORS preflight; matches Sentry `tunnel`).
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* tunnel: '/api/mushi-tunnel'
|
|
58
|
+
*/
|
|
59
|
+
tunnel?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Drop automatic error reports whose message matches any string (substring)
|
|
62
|
+
* or RegExp. Never applied to user-submitted widget feedback.
|
|
63
|
+
*/
|
|
64
|
+
ignoreErrors?: Array<string | RegExp>;
|
|
65
|
+
/**
|
|
66
|
+
* Drop automatic error reports whose script URL / stack filename matches.
|
|
67
|
+
*/
|
|
68
|
+
denyUrls?: Array<string | RegExp>;
|
|
69
|
+
/**
|
|
70
|
+
* When set, drop automatic error reports unless the script URL matches
|
|
71
|
+
* at least one entry.
|
|
72
|
+
*/
|
|
73
|
+
allowUrls?: Array<string | RegExp>;
|
|
49
74
|
/**
|
|
50
75
|
* Probabilistic sampling rate for session-replay recording (rrweb/lite).
|
|
51
76
|
* Range 0–1, default 1 (record all sessions). The sampling decision is made
|
|
@@ -59,6 +84,13 @@ interface MushiConfig {
|
|
|
59
84
|
* replaySampleRate: 0.2 // record replay for ~20% of sessions
|
|
60
85
|
*/
|
|
61
86
|
replaySampleRate?: number;
|
|
87
|
+
/**
|
|
88
|
+
* When session replay was sampled out, still start the rolling buffer for
|
|
89
|
+
* this fraction of sessions (0–1, default 0) so an error/feedback report
|
|
90
|
+
* can attach replay. Keep at 0 unless you have accepted the CPU/egress
|
|
91
|
+
* cost — do not set to 1 with `capture.replay: 'rrweb'`.
|
|
92
|
+
*/
|
|
93
|
+
replaysOnErrorSampleRate?: number;
|
|
62
94
|
/**
|
|
63
95
|
* Probabilistic sampling rate for automatic (non-user-initiated) error
|
|
64
96
|
* reports. Range 0–1, default 1 (send all). User-initiated feedback reports
|
|
@@ -1711,6 +1743,8 @@ interface MushiTesterReputation {
|
|
|
1711
1743
|
total_points: number;
|
|
1712
1744
|
}
|
|
1713
1745
|
|
|
1746
|
+
/** Replay the last POST via keepalive/beacon during pagehide. */
|
|
1747
|
+
declare function flushLastOutboundOnUnload(): boolean;
|
|
1714
1748
|
/** Header carrying the signed end-user identity token (verified server-side). */
|
|
1715
1749
|
declare const MUSHI_USER_TOKEN_HEADER = "X-Mushi-User-Token";
|
|
1716
1750
|
/** Project scope header — paired with the API key on every SDK request. */
|
|
@@ -1759,14 +1793,101 @@ interface ApiClientOptions {
|
|
|
1759
1793
|
* backend can verify it and scope identity-bound features to that user.
|
|
1760
1794
|
*/
|
|
1761
1795
|
getUserToken?: () => string | null | undefined;
|
|
1796
|
+
/**
|
|
1797
|
+
* Same-origin (or absolute) proxy. When set, replaces `apiEndpoint` as the
|
|
1798
|
+
* request base so browser calls stay first-party. See `MushiConfig.tunnel`.
|
|
1799
|
+
*/
|
|
1800
|
+
tunnel?: string;
|
|
1762
1801
|
}
|
|
1763
1802
|
declare const DEFAULT_API_ENDPOINT = "https://dxptnwrhwsqckaftyymj.supabase.co/functions/v1/api";
|
|
1764
1803
|
declare const MUSHI_INTERNAL_HEADER = "X-Mushi-Internal";
|
|
1765
1804
|
declare const MUSHI_INTERNAL_INIT_MARKER = "__mushiInternal";
|
|
1766
1805
|
type MushiInternalRequestKind = 'sdk-config' | 'report-submit' | 'report-status' | 'reporter-poll' | 'diagnose' | 'discovery' | 'community';
|
|
1806
|
+
/** Resolve the HTTP base: tunnel wins so ingest stays first-party. */
|
|
1807
|
+
declare function resolveRequestBaseUrl(apiEndpoint: string | undefined, tunnel?: string): string;
|
|
1767
1808
|
declare const DEFAULT_TIMEOUT = 10000;
|
|
1768
1809
|
declare const DEFAULT_MAX_RETRIES = 2;
|
|
1769
1810
|
declare function createApiClient(options: ApiClientOptions): MushiApiClient;
|
|
1811
|
+
declare function getBackoffDelay(attempt: number): number;
|
|
1812
|
+
/**
|
|
1813
|
+
* Parse a `Retry-After` header into a delay in milliseconds. The header comes
|
|
1814
|
+
* in two shapes (RFC 9110): delta-seconds, or an HTTP-date to wait until.
|
|
1815
|
+
* Returns null when the header is absent, malformed, or negative, so the
|
|
1816
|
+
* caller falls back to its own backoff curve.
|
|
1817
|
+
*/
|
|
1818
|
+
declare function parseRetryAfter(value: string | null | undefined, now?: number): number | null;
|
|
1819
|
+
|
|
1820
|
+
/**
|
|
1821
|
+
* FILE: packages/core/src/error-filters.ts
|
|
1822
|
+
* PURPOSE: Sentry-grade drop filters for automatic error capture.
|
|
1823
|
+
*
|
|
1824
|
+
* OVERVIEW:
|
|
1825
|
+
* - ignoreErrors — drop when the error message matches a string or RegExp
|
|
1826
|
+
* - denyUrls — drop when the script URL / stack frame matches
|
|
1827
|
+
* - allowUrls — when set, drop unless the script URL matches at least one
|
|
1828
|
+
*
|
|
1829
|
+
* USAGE:
|
|
1830
|
+
* - captureException / window.onerror / unhandledrejection only
|
|
1831
|
+
* - Never applied to user-submitted widget feedback
|
|
1832
|
+
*
|
|
1833
|
+
* NOTES:
|
|
1834
|
+
* - String matchers are case-sensitive substrings (Sentry JS semantics)
|
|
1835
|
+
* - Invalid RegExp sources are treated as non-matches, not throws
|
|
1836
|
+
*/
|
|
1837
|
+
type MushiErrorFilter = string | RegExp;
|
|
1838
|
+
declare function matchesErrorFilter(value: string | undefined | null, filters: readonly MushiErrorFilter[] | undefined): boolean;
|
|
1839
|
+
declare function shouldDropCapturedError(input: {
|
|
1840
|
+
message: string;
|
|
1841
|
+
filename?: string | null;
|
|
1842
|
+
ignoreErrors?: readonly MushiErrorFilter[];
|
|
1843
|
+
denyUrls?: readonly MushiErrorFilter[];
|
|
1844
|
+
allowUrls?: readonly MushiErrorFilter[];
|
|
1845
|
+
}): boolean;
|
|
1846
|
+
|
|
1847
|
+
/**
|
|
1848
|
+
* FILE: packages/core/src/unload-transport.ts
|
|
1849
|
+
* PURPOSE: Pagehide-safe report delivery (fetch keepalive + sendBeacon).
|
|
1850
|
+
*
|
|
1851
|
+
* OVERVIEW:
|
|
1852
|
+
* - fetch({ keepalive: true }) keeps custom X-Mushi-* headers (Sentry 2024+ primary)
|
|
1853
|
+
* - sendBeacon cannot set headers, so it wraps credentials in a beacon envelope
|
|
1854
|
+
* that only the same-origin tunnel unwraps
|
|
1855
|
+
*
|
|
1856
|
+
* NOTES:
|
|
1857
|
+
* - Beacon payloads over 60 KiB are skipped (browser sendBeacon limit ~64 KiB)
|
|
1858
|
+
* - Never put the API key in the query string
|
|
1859
|
+
*/
|
|
1860
|
+
declare const MUSHI_BEACON_MAX_BYTES: number;
|
|
1861
|
+
interface MushiBeaconEnvelope {
|
|
1862
|
+
mushiBeacon: true;
|
|
1863
|
+
path: string;
|
|
1864
|
+
headers: Record<string, string>;
|
|
1865
|
+
body: unknown;
|
|
1866
|
+
}
|
|
1867
|
+
declare function isMushiBeaconEnvelope(value: unknown): value is MushiBeaconEnvelope;
|
|
1868
|
+
declare function buildBeaconEnvelope(opts: {
|
|
1869
|
+
path: string;
|
|
1870
|
+
headers: Record<string, string>;
|
|
1871
|
+
body: unknown;
|
|
1872
|
+
}): MushiBeaconEnvelope;
|
|
1873
|
+
/** True when the URL is same-origin or relative (safe for sendBeacon + tunnel). */
|
|
1874
|
+
declare function isSameOriginOrRelative(url: string, origin?: string): boolean;
|
|
1875
|
+
declare function extractTunnelPath(url: string): string;
|
|
1876
|
+
interface SendOnUnloadOptions {
|
|
1877
|
+
url: string;
|
|
1878
|
+
headers: Record<string, string>;
|
|
1879
|
+
body: string;
|
|
1880
|
+
path?: string;
|
|
1881
|
+
fetchImpl?: typeof fetch;
|
|
1882
|
+
sendBeacon?: (url: string, data: Blob) => boolean;
|
|
1883
|
+
}
|
|
1884
|
+
/**
|
|
1885
|
+
* Deliver one JSON POST during pagehide. Prefers fetch keepalive (headers).
|
|
1886
|
+
* Falls back to sendBeacon with a credential envelope on same-origin URLs.
|
|
1887
|
+
*/
|
|
1888
|
+
declare function sendOnUnload(opts: SendOnUnloadOptions): boolean;
|
|
1889
|
+
declare function markPageUnloading(): void;
|
|
1890
|
+
declare function isPageUnloading(): boolean;
|
|
1770
1891
|
|
|
1771
1892
|
/**
|
|
1772
1893
|
* C7: Data residency region resolution.
|
|
@@ -2632,4 +2753,4 @@ declare function projectInitialsThemeIndex(projectId: string): number;
|
|
|
2632
2753
|
*/
|
|
2633
2754
|
declare function readPageFaviconHref(): string | null;
|
|
2634
2755
|
|
|
2635
|
-
export { type ApiClientOptions, type BreadcrumbBuffer, type BreadcrumbBufferOptions, DEFAULT_API_ENDPOINT, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, type EnvConfigDiagnostics, type EnvNearMiss, 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_BORDER, MUSHI_COLORS_DARK, MUSHI_COLORS_LIGHT, MUSHI_CONTROL_DISABLED, MUSHI_COPY, MUSHI_DURATION, MUSHI_GEOMETRY, MUSHI_IDENTITY_TOKEN_PREFIX, MUSHI_INTERNAL_HEADER, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INVERSE, MUSHI_LETTER_SPACING, MUSHI_MOTION, MUSHI_ON_ACCENT, MUSHI_OPACITY, MUSHI_PROJECT_HEADER, MUSHI_RADIUS, MUSHI_REPORTER_STATUS, MUSHI_SDK_PACKAGE_HEADER, MUSHI_SDK_VERSION_HEADER, MUSHI_SHADOW_INK, 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 MushiSessionEventPayload, 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, type SessionTrackerOptions, buildIdentityClaims, buildSdkIngestHeaders, captureEnvironment, checkReportPayloadSize, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, destroySessionTracker, diagnoseEnvConfig, estimateJsonBytes, expandPreset, faviconUrlCandidates, formatBytes, getDeviceFingerprintHash, getReporterToken, getSessionId, githubRepoDomainHint, hmacSha256Hex, initSessionTracker, isLikelyGenericFavicon, isUntrustedFaviconUrl, mushiPalette, mushiTokens, newUuid, noopLogger, normaliseThrown, originToDomain, parseIdentityToken, projectFaviconUrlCandidates, projectInitials, projectInitialsThemeIndex, readPageFaviconHref, resolveEnvConfig, resolveProjectDomain, resolveProjectFaviconDomains, resolveRegionEndpoint, resolveWidgetAccent, safeWidgetHex, scrubPii, scrubUrl, sha256Hex, trackPageView, updateSessionIdentity, validateConfig };
|
|
2756
|
+
export { type ApiClientOptions, type BreadcrumbBuffer, type BreadcrumbBufferOptions, DEFAULT_API_ENDPOINT, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, type EnvConfigDiagnostics, type EnvNearMiss, 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_BEACON_MAX_BYTES, MUSHI_BORDER, MUSHI_COLORS_DARK, MUSHI_COLORS_LIGHT, MUSHI_CONTROL_DISABLED, MUSHI_COPY, MUSHI_DURATION, MUSHI_GEOMETRY, MUSHI_IDENTITY_TOKEN_PREFIX, MUSHI_INTERNAL_HEADER, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INVERSE, MUSHI_LETTER_SPACING, MUSHI_MOTION, MUSHI_ON_ACCENT, MUSHI_OPACITY, MUSHI_PROJECT_HEADER, MUSHI_RADIUS, MUSHI_REPORTER_STATUS, MUSHI_SDK_PACKAGE_HEADER, MUSHI_SDK_VERSION_HEADER, MUSHI_SHADOW_INK, 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 MushiBeaconEnvelope, 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 MushiErrorFilter, 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 MushiSessionEventPayload, 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, type SessionTrackerOptions, buildBeaconEnvelope, buildIdentityClaims, buildSdkIngestHeaders, captureEnvironment, checkReportPayloadSize, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, destroySessionTracker, diagnoseEnvConfig, estimateJsonBytes, expandPreset, extractTunnelPath, faviconUrlCandidates, flushLastOutboundOnUnload, formatBytes, getBackoffDelay, getDeviceFingerprintHash, getReporterToken, getSessionId, githubRepoDomainHint, hmacSha256Hex, initSessionTracker, isLikelyGenericFavicon, isMushiBeaconEnvelope, isPageUnloading, isSameOriginOrRelative, isUntrustedFaviconUrl, markPageUnloading, matchesErrorFilter, mushiPalette, mushiTokens, newUuid, noopLogger, normaliseThrown, originToDomain, parseIdentityToken, parseRetryAfter, projectFaviconUrlCandidates, projectInitials, projectInitialsThemeIndex, readPageFaviconHref, resolveEnvConfig, resolveProjectDomain, resolveProjectFaviconDomains, resolveRegionEndpoint, resolveRequestBaseUrl, resolveWidgetAccent, safeWidgetHex, scrubPii, scrubUrl, sendOnUnload, sha256Hex, shouldDropCapturedError, trackPageView, updateSessionIdentity, validateConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,31 @@ interface MushiConfig {
|
|
|
46
46
|
* when omitted (legacy Vercel Analytics wiring).
|
|
47
47
|
*/
|
|
48
48
|
appVersion?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Same-origin (or absolute) ingest proxy. When set, every SDK HTTP call
|
|
51
|
+
* goes here instead of `apiEndpoint` so ad blockers that drop third-party
|
|
52
|
+
* `*.supabase.co/functions` hosts cannot silently eat reports.
|
|
53
|
+
* Relative URLs resolve against the page origin — that is the recommended
|
|
54
|
+
* form (no CORS preflight; matches Sentry `tunnel`).
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* tunnel: '/api/mushi-tunnel'
|
|
58
|
+
*/
|
|
59
|
+
tunnel?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Drop automatic error reports whose message matches any string (substring)
|
|
62
|
+
* or RegExp. Never applied to user-submitted widget feedback.
|
|
63
|
+
*/
|
|
64
|
+
ignoreErrors?: Array<string | RegExp>;
|
|
65
|
+
/**
|
|
66
|
+
* Drop automatic error reports whose script URL / stack filename matches.
|
|
67
|
+
*/
|
|
68
|
+
denyUrls?: Array<string | RegExp>;
|
|
69
|
+
/**
|
|
70
|
+
* When set, drop automatic error reports unless the script URL matches
|
|
71
|
+
* at least one entry.
|
|
72
|
+
*/
|
|
73
|
+
allowUrls?: Array<string | RegExp>;
|
|
49
74
|
/**
|
|
50
75
|
* Probabilistic sampling rate for session-replay recording (rrweb/lite).
|
|
51
76
|
* Range 0–1, default 1 (record all sessions). The sampling decision is made
|
|
@@ -59,6 +84,13 @@ interface MushiConfig {
|
|
|
59
84
|
* replaySampleRate: 0.2 // record replay for ~20% of sessions
|
|
60
85
|
*/
|
|
61
86
|
replaySampleRate?: number;
|
|
87
|
+
/**
|
|
88
|
+
* When session replay was sampled out, still start the rolling buffer for
|
|
89
|
+
* this fraction of sessions (0–1, default 0) so an error/feedback report
|
|
90
|
+
* can attach replay. Keep at 0 unless you have accepted the CPU/egress
|
|
91
|
+
* cost — do not set to 1 with `capture.replay: 'rrweb'`.
|
|
92
|
+
*/
|
|
93
|
+
replaysOnErrorSampleRate?: number;
|
|
62
94
|
/**
|
|
63
95
|
* Probabilistic sampling rate for automatic (non-user-initiated) error
|
|
64
96
|
* reports. Range 0–1, default 1 (send all). User-initiated feedback reports
|
|
@@ -1711,6 +1743,8 @@ interface MushiTesterReputation {
|
|
|
1711
1743
|
total_points: number;
|
|
1712
1744
|
}
|
|
1713
1745
|
|
|
1746
|
+
/** Replay the last POST via keepalive/beacon during pagehide. */
|
|
1747
|
+
declare function flushLastOutboundOnUnload(): boolean;
|
|
1714
1748
|
/** Header carrying the signed end-user identity token (verified server-side). */
|
|
1715
1749
|
declare const MUSHI_USER_TOKEN_HEADER = "X-Mushi-User-Token";
|
|
1716
1750
|
/** Project scope header — paired with the API key on every SDK request. */
|
|
@@ -1759,14 +1793,101 @@ interface ApiClientOptions {
|
|
|
1759
1793
|
* backend can verify it and scope identity-bound features to that user.
|
|
1760
1794
|
*/
|
|
1761
1795
|
getUserToken?: () => string | null | undefined;
|
|
1796
|
+
/**
|
|
1797
|
+
* Same-origin (or absolute) proxy. When set, replaces `apiEndpoint` as the
|
|
1798
|
+
* request base so browser calls stay first-party. See `MushiConfig.tunnel`.
|
|
1799
|
+
*/
|
|
1800
|
+
tunnel?: string;
|
|
1762
1801
|
}
|
|
1763
1802
|
declare const DEFAULT_API_ENDPOINT = "https://dxptnwrhwsqckaftyymj.supabase.co/functions/v1/api";
|
|
1764
1803
|
declare const MUSHI_INTERNAL_HEADER = "X-Mushi-Internal";
|
|
1765
1804
|
declare const MUSHI_INTERNAL_INIT_MARKER = "__mushiInternal";
|
|
1766
1805
|
type MushiInternalRequestKind = 'sdk-config' | 'report-submit' | 'report-status' | 'reporter-poll' | 'diagnose' | 'discovery' | 'community';
|
|
1806
|
+
/** Resolve the HTTP base: tunnel wins so ingest stays first-party. */
|
|
1807
|
+
declare function resolveRequestBaseUrl(apiEndpoint: string | undefined, tunnel?: string): string;
|
|
1767
1808
|
declare const DEFAULT_TIMEOUT = 10000;
|
|
1768
1809
|
declare const DEFAULT_MAX_RETRIES = 2;
|
|
1769
1810
|
declare function createApiClient(options: ApiClientOptions): MushiApiClient;
|
|
1811
|
+
declare function getBackoffDelay(attempt: number): number;
|
|
1812
|
+
/**
|
|
1813
|
+
* Parse a `Retry-After` header into a delay in milliseconds. The header comes
|
|
1814
|
+
* in two shapes (RFC 9110): delta-seconds, or an HTTP-date to wait until.
|
|
1815
|
+
* Returns null when the header is absent, malformed, or negative, so the
|
|
1816
|
+
* caller falls back to its own backoff curve.
|
|
1817
|
+
*/
|
|
1818
|
+
declare function parseRetryAfter(value: string | null | undefined, now?: number): number | null;
|
|
1819
|
+
|
|
1820
|
+
/**
|
|
1821
|
+
* FILE: packages/core/src/error-filters.ts
|
|
1822
|
+
* PURPOSE: Sentry-grade drop filters for automatic error capture.
|
|
1823
|
+
*
|
|
1824
|
+
* OVERVIEW:
|
|
1825
|
+
* - ignoreErrors — drop when the error message matches a string or RegExp
|
|
1826
|
+
* - denyUrls — drop when the script URL / stack frame matches
|
|
1827
|
+
* - allowUrls — when set, drop unless the script URL matches at least one
|
|
1828
|
+
*
|
|
1829
|
+
* USAGE:
|
|
1830
|
+
* - captureException / window.onerror / unhandledrejection only
|
|
1831
|
+
* - Never applied to user-submitted widget feedback
|
|
1832
|
+
*
|
|
1833
|
+
* NOTES:
|
|
1834
|
+
* - String matchers are case-sensitive substrings (Sentry JS semantics)
|
|
1835
|
+
* - Invalid RegExp sources are treated as non-matches, not throws
|
|
1836
|
+
*/
|
|
1837
|
+
type MushiErrorFilter = string | RegExp;
|
|
1838
|
+
declare function matchesErrorFilter(value: string | undefined | null, filters: readonly MushiErrorFilter[] | undefined): boolean;
|
|
1839
|
+
declare function shouldDropCapturedError(input: {
|
|
1840
|
+
message: string;
|
|
1841
|
+
filename?: string | null;
|
|
1842
|
+
ignoreErrors?: readonly MushiErrorFilter[];
|
|
1843
|
+
denyUrls?: readonly MushiErrorFilter[];
|
|
1844
|
+
allowUrls?: readonly MushiErrorFilter[];
|
|
1845
|
+
}): boolean;
|
|
1846
|
+
|
|
1847
|
+
/**
|
|
1848
|
+
* FILE: packages/core/src/unload-transport.ts
|
|
1849
|
+
* PURPOSE: Pagehide-safe report delivery (fetch keepalive + sendBeacon).
|
|
1850
|
+
*
|
|
1851
|
+
* OVERVIEW:
|
|
1852
|
+
* - fetch({ keepalive: true }) keeps custom X-Mushi-* headers (Sentry 2024+ primary)
|
|
1853
|
+
* - sendBeacon cannot set headers, so it wraps credentials in a beacon envelope
|
|
1854
|
+
* that only the same-origin tunnel unwraps
|
|
1855
|
+
*
|
|
1856
|
+
* NOTES:
|
|
1857
|
+
* - Beacon payloads over 60 KiB are skipped (browser sendBeacon limit ~64 KiB)
|
|
1858
|
+
* - Never put the API key in the query string
|
|
1859
|
+
*/
|
|
1860
|
+
declare const MUSHI_BEACON_MAX_BYTES: number;
|
|
1861
|
+
interface MushiBeaconEnvelope {
|
|
1862
|
+
mushiBeacon: true;
|
|
1863
|
+
path: string;
|
|
1864
|
+
headers: Record<string, string>;
|
|
1865
|
+
body: unknown;
|
|
1866
|
+
}
|
|
1867
|
+
declare function isMushiBeaconEnvelope(value: unknown): value is MushiBeaconEnvelope;
|
|
1868
|
+
declare function buildBeaconEnvelope(opts: {
|
|
1869
|
+
path: string;
|
|
1870
|
+
headers: Record<string, string>;
|
|
1871
|
+
body: unknown;
|
|
1872
|
+
}): MushiBeaconEnvelope;
|
|
1873
|
+
/** True when the URL is same-origin or relative (safe for sendBeacon + tunnel). */
|
|
1874
|
+
declare function isSameOriginOrRelative(url: string, origin?: string): boolean;
|
|
1875
|
+
declare function extractTunnelPath(url: string): string;
|
|
1876
|
+
interface SendOnUnloadOptions {
|
|
1877
|
+
url: string;
|
|
1878
|
+
headers: Record<string, string>;
|
|
1879
|
+
body: string;
|
|
1880
|
+
path?: string;
|
|
1881
|
+
fetchImpl?: typeof fetch;
|
|
1882
|
+
sendBeacon?: (url: string, data: Blob) => boolean;
|
|
1883
|
+
}
|
|
1884
|
+
/**
|
|
1885
|
+
* Deliver one JSON POST during pagehide. Prefers fetch keepalive (headers).
|
|
1886
|
+
* Falls back to sendBeacon with a credential envelope on same-origin URLs.
|
|
1887
|
+
*/
|
|
1888
|
+
declare function sendOnUnload(opts: SendOnUnloadOptions): boolean;
|
|
1889
|
+
declare function markPageUnloading(): void;
|
|
1890
|
+
declare function isPageUnloading(): boolean;
|
|
1770
1891
|
|
|
1771
1892
|
/**
|
|
1772
1893
|
* C7: Data residency region resolution.
|
|
@@ -2632,4 +2753,4 @@ declare function projectInitialsThemeIndex(projectId: string): number;
|
|
|
2632
2753
|
*/
|
|
2633
2754
|
declare function readPageFaviconHref(): string | null;
|
|
2634
2755
|
|
|
2635
|
-
export { type ApiClientOptions, type BreadcrumbBuffer, type BreadcrumbBufferOptions, DEFAULT_API_ENDPOINT, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, type EnvConfigDiagnostics, type EnvNearMiss, 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_BORDER, MUSHI_COLORS_DARK, MUSHI_COLORS_LIGHT, MUSHI_CONTROL_DISABLED, MUSHI_COPY, MUSHI_DURATION, MUSHI_GEOMETRY, MUSHI_IDENTITY_TOKEN_PREFIX, MUSHI_INTERNAL_HEADER, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INVERSE, MUSHI_LETTER_SPACING, MUSHI_MOTION, MUSHI_ON_ACCENT, MUSHI_OPACITY, MUSHI_PROJECT_HEADER, MUSHI_RADIUS, MUSHI_REPORTER_STATUS, MUSHI_SDK_PACKAGE_HEADER, MUSHI_SDK_VERSION_HEADER, MUSHI_SHADOW_INK, 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 MushiSessionEventPayload, 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, type SessionTrackerOptions, buildIdentityClaims, buildSdkIngestHeaders, captureEnvironment, checkReportPayloadSize, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, destroySessionTracker, diagnoseEnvConfig, estimateJsonBytes, expandPreset, faviconUrlCandidates, formatBytes, getDeviceFingerprintHash, getReporterToken, getSessionId, githubRepoDomainHint, hmacSha256Hex, initSessionTracker, isLikelyGenericFavicon, isUntrustedFaviconUrl, mushiPalette, mushiTokens, newUuid, noopLogger, normaliseThrown, originToDomain, parseIdentityToken, projectFaviconUrlCandidates, projectInitials, projectInitialsThemeIndex, readPageFaviconHref, resolveEnvConfig, resolveProjectDomain, resolveProjectFaviconDomains, resolveRegionEndpoint, resolveWidgetAccent, safeWidgetHex, scrubPii, scrubUrl, sha256Hex, trackPageView, updateSessionIdentity, validateConfig };
|
|
2756
|
+
export { type ApiClientOptions, type BreadcrumbBuffer, type BreadcrumbBufferOptions, DEFAULT_API_ENDPOINT, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, type EnvConfigDiagnostics, type EnvNearMiss, 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_BEACON_MAX_BYTES, MUSHI_BORDER, MUSHI_COLORS_DARK, MUSHI_COLORS_LIGHT, MUSHI_CONTROL_DISABLED, MUSHI_COPY, MUSHI_DURATION, MUSHI_GEOMETRY, MUSHI_IDENTITY_TOKEN_PREFIX, MUSHI_INTERNAL_HEADER, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INVERSE, MUSHI_LETTER_SPACING, MUSHI_MOTION, MUSHI_ON_ACCENT, MUSHI_OPACITY, MUSHI_PROJECT_HEADER, MUSHI_RADIUS, MUSHI_REPORTER_STATUS, MUSHI_SDK_PACKAGE_HEADER, MUSHI_SDK_VERSION_HEADER, MUSHI_SHADOW_INK, 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 MushiBeaconEnvelope, 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 MushiErrorFilter, 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 MushiSessionEventPayload, 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, type SessionTrackerOptions, buildBeaconEnvelope, buildIdentityClaims, buildSdkIngestHeaders, captureEnvironment, checkReportPayloadSize, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, destroySessionTracker, diagnoseEnvConfig, estimateJsonBytes, expandPreset, extractTunnelPath, faviconUrlCandidates, flushLastOutboundOnUnload, formatBytes, getBackoffDelay, getDeviceFingerprintHash, getReporterToken, getSessionId, githubRepoDomainHint, hmacSha256Hex, initSessionTracker, isLikelyGenericFavicon, isMushiBeaconEnvelope, isPageUnloading, isSameOriginOrRelative, isUntrustedFaviconUrl, markPageUnloading, matchesErrorFilter, mushiPalette, mushiTokens, newUuid, noopLogger, normaliseThrown, originToDomain, parseIdentityToken, parseRetryAfter, projectFaviconUrlCandidates, projectInitials, projectInitialsThemeIndex, readPageFaviconHref, resolveEnvConfig, resolveProjectDomain, resolveProjectFaviconDomains, resolveRegionEndpoint, resolveRequestBaseUrl, resolveWidgetAccent, safeWidgetHex, scrubPii, scrubUrl, sendOnUnload, sha256Hex, shouldDropCapturedError, trackPageView, updateSessionIdentity, validateConfig };
|