@mushi-mushi/core 1.26.0 → 1.27.1
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 +12 -1
- package/SECURITY.md +49 -0
- package/dist/index.cjs +83 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +80 -2
- package/dist/index.d.ts +80 -2
- package/dist/index.js +83 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -46,7 +46,52 @@ interface MushiConfig {
|
|
|
46
46
|
* when omitted (legacy Vercel Analytics wiring).
|
|
47
47
|
*/
|
|
48
48
|
appVersion?: string;
|
|
49
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Probabilistic sampling rate for session-replay recording (rrweb/lite).
|
|
51
|
+
* Range 0–1, default 1 (record all sessions). The sampling decision is made
|
|
52
|
+
* once at session init — a sampled-out session never loads the rrweb chunk,
|
|
53
|
+
* reducing bundle cost and CPU for excluded users.
|
|
54
|
+
*
|
|
55
|
+
* Independent of `sampleRate` (error reporting). A session can have replay
|
|
56
|
+
* on but errors sampled, or vice versa.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* replaySampleRate: 0.2 // record replay for ~20% of sessions
|
|
60
|
+
*/
|
|
61
|
+
replaySampleRate?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Probabilistic sampling rate for automatic (non-user-initiated) error
|
|
64
|
+
* reports. Range 0–1, default 1 (send all). User-initiated feedback reports
|
|
65
|
+
* are always sent regardless of this value.
|
|
66
|
+
*
|
|
67
|
+
* Examples:
|
|
68
|
+
* sampleRate: 0.1 → send ~10% of auto-captured errors
|
|
69
|
+
* sampleRate: 1 → send all (default)
|
|
70
|
+
* sampleRate: 0 → send none (disables automatic capture; feedback unaffected)
|
|
71
|
+
*
|
|
72
|
+
* When rate limiting or circuit breaker is also active, the stricter of the
|
|
73
|
+
* two gates applies. Use sampleRate for sustained high-volume apps; use
|
|
74
|
+
* rate limiting for burst protection.
|
|
75
|
+
*/
|
|
76
|
+
sampleRate?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Hook called before ANY report (error, exception, or user feedback) is
|
|
79
|
+
* sent. Return null to cancel the report; return the (possibly modified)
|
|
80
|
+
* report to proceed. Async version supported — resolution is awaited before
|
|
81
|
+
* submission. Runs AFTER built-in PII scrubbing.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* beforeSend: (report) => {
|
|
85
|
+
* if (report.category === 'bug' && report.description.includes('internal')) return null
|
|
86
|
+
* return { ...report, description: sanitize(report.description) }
|
|
87
|
+
* }
|
|
88
|
+
*/
|
|
89
|
+
beforeSend?: (report: MushiReport) => MushiReport | null | Promise<MushiReport | null>;
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated Use `beforeSend` instead. `beforeSendFeedback` is kept for
|
|
92
|
+
* backwards compatibility and applies only to user-submitted feedback reports.
|
|
93
|
+
* `beforeSend` covers all report types and takes precedence when both are set.
|
|
94
|
+
*/
|
|
50
95
|
beforeSendFeedback?: (report: MushiReport) => MushiReport | null | Promise<MushiReport | null>;
|
|
51
96
|
/** Called once if the app crashed during the previous session. */
|
|
52
97
|
onCrashedLastRun?: (crashed: boolean) => void;
|
|
@@ -774,6 +819,13 @@ interface MushiBreadcrumb {
|
|
|
774
819
|
message: string;
|
|
775
820
|
/** Optional structured payload — kept small to keep ingest cheap. */
|
|
776
821
|
data?: Record<string, unknown>;
|
|
822
|
+
/**
|
|
823
|
+
* Correlation ID linking this breadcrumb to the `MushiNetworkEntry` and
|
|
824
|
+
* `MushiConsoleEntry` entries emitted during the same network request's
|
|
825
|
+
* lifetime (Phase 3b). Set for `fetch` / `xhr` category crumbs and for
|
|
826
|
+
* console entries captured while a request was in-flight.
|
|
827
|
+
*/
|
|
828
|
+
correlationId?: string;
|
|
777
829
|
}
|
|
778
830
|
/**
|
|
779
831
|
* Snapshot of Sentry's current scope at report submission. Captured by
|
|
@@ -985,6 +1037,13 @@ interface MushiConsoleEntry {
|
|
|
985
1037
|
message: string;
|
|
986
1038
|
timestamp: number;
|
|
987
1039
|
stack?: string;
|
|
1040
|
+
/**
|
|
1041
|
+
* Correlation ID linking this console entry to the network request that was
|
|
1042
|
+
* active when this log was emitted (e.g. the fetch whose catch block called
|
|
1043
|
+
* console.error). Matches `MushiNetworkEntry.correlationId`. Set by the SDK's
|
|
1044
|
+
* active-request tracker (Phase 3b).
|
|
1045
|
+
*/
|
|
1046
|
+
correlationId?: string;
|
|
988
1047
|
}
|
|
989
1048
|
interface MushiNetworkEntry {
|
|
990
1049
|
method: string;
|
|
@@ -1002,6 +1061,17 @@ interface MushiNetworkEntry {
|
|
|
1002
1061
|
* Used to correlate this network entry with a backend span in the admin console.
|
|
1003
1062
|
*/
|
|
1004
1063
|
traceId?: string;
|
|
1064
|
+
/**
|
|
1065
|
+
* Whether this entry was captured by the fetch interceptor or the XHR interceptor
|
|
1066
|
+
* (Phase 3a). Used for row-level provenance badges in the console UI.
|
|
1067
|
+
*/
|
|
1068
|
+
captureMethod?: 'fetch' | 'xhr';
|
|
1069
|
+
/**
|
|
1070
|
+
* Correlation ID shared with `MushiConsoleEntry.correlationId` and
|
|
1071
|
+
* `MushiBreadcrumb.correlationId` for entries emitted during this request's
|
|
1072
|
+
* lifetime (Phase 3b). Enables "highlight all logs/crumbs from this request."
|
|
1073
|
+
*/
|
|
1074
|
+
correlationId?: string;
|
|
1005
1075
|
}
|
|
1006
1076
|
interface MushiPerformanceMetrics {
|
|
1007
1077
|
fcp?: number;
|
|
@@ -2037,6 +2107,14 @@ declare function createPiiScrubber(config?: PiiScrubberConfig): {
|
|
|
2037
2107
|
scrubObject: <T extends Record<string, unknown>>(obj: T, keys: string[]) => T;
|
|
2038
2108
|
};
|
|
2039
2109
|
declare function scrubPii(text: string, config?: PiiScrubberConfig): string;
|
|
2110
|
+
/**
|
|
2111
|
+
* Scrub the query-string portion(s) of a URL — both the standard `?…` part
|
|
2112
|
+
* and any `?…` inside the hash fragment (hash routers like RealWorld's
|
|
2113
|
+
* `#/path?query` carry their query inside the fragment). Path segments and
|
|
2114
|
+
* param keys are left untouched; only values are redacted. Accepts absolute
|
|
2115
|
+
* or relative URLs and never throws.
|
|
2116
|
+
*/
|
|
2117
|
+
declare function scrubUrl(url: string, config?: PiiScrubberConfig): string;
|
|
2040
2118
|
|
|
2041
2119
|
/**
|
|
2042
2120
|
* Ring-buffer breadcrumb store. Capped at `max` entries (default 50);
|
|
@@ -2554,4 +2632,4 @@ declare function projectInitialsThemeIndex(projectId: string): number;
|
|
|
2554
2632
|
*/
|
|
2555
2633
|
declare function readPageFaviconHref(): string | null;
|
|
2556
2634
|
|
|
2557
|
-
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, sha256Hex, trackPageView, updateSessionIdentity, validateConfig };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -46,7 +46,52 @@ interface MushiConfig {
|
|
|
46
46
|
* when omitted (legacy Vercel Analytics wiring).
|
|
47
47
|
*/
|
|
48
48
|
appVersion?: string;
|
|
49
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Probabilistic sampling rate for session-replay recording (rrweb/lite).
|
|
51
|
+
* Range 0–1, default 1 (record all sessions). The sampling decision is made
|
|
52
|
+
* once at session init — a sampled-out session never loads the rrweb chunk,
|
|
53
|
+
* reducing bundle cost and CPU for excluded users.
|
|
54
|
+
*
|
|
55
|
+
* Independent of `sampleRate` (error reporting). A session can have replay
|
|
56
|
+
* on but errors sampled, or vice versa.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* replaySampleRate: 0.2 // record replay for ~20% of sessions
|
|
60
|
+
*/
|
|
61
|
+
replaySampleRate?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Probabilistic sampling rate for automatic (non-user-initiated) error
|
|
64
|
+
* reports. Range 0–1, default 1 (send all). User-initiated feedback reports
|
|
65
|
+
* are always sent regardless of this value.
|
|
66
|
+
*
|
|
67
|
+
* Examples:
|
|
68
|
+
* sampleRate: 0.1 → send ~10% of auto-captured errors
|
|
69
|
+
* sampleRate: 1 → send all (default)
|
|
70
|
+
* sampleRate: 0 → send none (disables automatic capture; feedback unaffected)
|
|
71
|
+
*
|
|
72
|
+
* When rate limiting or circuit breaker is also active, the stricter of the
|
|
73
|
+
* two gates applies. Use sampleRate for sustained high-volume apps; use
|
|
74
|
+
* rate limiting for burst protection.
|
|
75
|
+
*/
|
|
76
|
+
sampleRate?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Hook called before ANY report (error, exception, or user feedback) is
|
|
79
|
+
* sent. Return null to cancel the report; return the (possibly modified)
|
|
80
|
+
* report to proceed. Async version supported — resolution is awaited before
|
|
81
|
+
* submission. Runs AFTER built-in PII scrubbing.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* beforeSend: (report) => {
|
|
85
|
+
* if (report.category === 'bug' && report.description.includes('internal')) return null
|
|
86
|
+
* return { ...report, description: sanitize(report.description) }
|
|
87
|
+
* }
|
|
88
|
+
*/
|
|
89
|
+
beforeSend?: (report: MushiReport) => MushiReport | null | Promise<MushiReport | null>;
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated Use `beforeSend` instead. `beforeSendFeedback` is kept for
|
|
92
|
+
* backwards compatibility and applies only to user-submitted feedback reports.
|
|
93
|
+
* `beforeSend` covers all report types and takes precedence when both are set.
|
|
94
|
+
*/
|
|
50
95
|
beforeSendFeedback?: (report: MushiReport) => MushiReport | null | Promise<MushiReport | null>;
|
|
51
96
|
/** Called once if the app crashed during the previous session. */
|
|
52
97
|
onCrashedLastRun?: (crashed: boolean) => void;
|
|
@@ -774,6 +819,13 @@ interface MushiBreadcrumb {
|
|
|
774
819
|
message: string;
|
|
775
820
|
/** Optional structured payload — kept small to keep ingest cheap. */
|
|
776
821
|
data?: Record<string, unknown>;
|
|
822
|
+
/**
|
|
823
|
+
* Correlation ID linking this breadcrumb to the `MushiNetworkEntry` and
|
|
824
|
+
* `MushiConsoleEntry` entries emitted during the same network request's
|
|
825
|
+
* lifetime (Phase 3b). Set for `fetch` / `xhr` category crumbs and for
|
|
826
|
+
* console entries captured while a request was in-flight.
|
|
827
|
+
*/
|
|
828
|
+
correlationId?: string;
|
|
777
829
|
}
|
|
778
830
|
/**
|
|
779
831
|
* Snapshot of Sentry's current scope at report submission. Captured by
|
|
@@ -985,6 +1037,13 @@ interface MushiConsoleEntry {
|
|
|
985
1037
|
message: string;
|
|
986
1038
|
timestamp: number;
|
|
987
1039
|
stack?: string;
|
|
1040
|
+
/**
|
|
1041
|
+
* Correlation ID linking this console entry to the network request that was
|
|
1042
|
+
* active when this log was emitted (e.g. the fetch whose catch block called
|
|
1043
|
+
* console.error). Matches `MushiNetworkEntry.correlationId`. Set by the SDK's
|
|
1044
|
+
* active-request tracker (Phase 3b).
|
|
1045
|
+
*/
|
|
1046
|
+
correlationId?: string;
|
|
988
1047
|
}
|
|
989
1048
|
interface MushiNetworkEntry {
|
|
990
1049
|
method: string;
|
|
@@ -1002,6 +1061,17 @@ interface MushiNetworkEntry {
|
|
|
1002
1061
|
* Used to correlate this network entry with a backend span in the admin console.
|
|
1003
1062
|
*/
|
|
1004
1063
|
traceId?: string;
|
|
1064
|
+
/**
|
|
1065
|
+
* Whether this entry was captured by the fetch interceptor or the XHR interceptor
|
|
1066
|
+
* (Phase 3a). Used for row-level provenance badges in the console UI.
|
|
1067
|
+
*/
|
|
1068
|
+
captureMethod?: 'fetch' | 'xhr';
|
|
1069
|
+
/**
|
|
1070
|
+
* Correlation ID shared with `MushiConsoleEntry.correlationId` and
|
|
1071
|
+
* `MushiBreadcrumb.correlationId` for entries emitted during this request's
|
|
1072
|
+
* lifetime (Phase 3b). Enables "highlight all logs/crumbs from this request."
|
|
1073
|
+
*/
|
|
1074
|
+
correlationId?: string;
|
|
1005
1075
|
}
|
|
1006
1076
|
interface MushiPerformanceMetrics {
|
|
1007
1077
|
fcp?: number;
|
|
@@ -2037,6 +2107,14 @@ declare function createPiiScrubber(config?: PiiScrubberConfig): {
|
|
|
2037
2107
|
scrubObject: <T extends Record<string, unknown>>(obj: T, keys: string[]) => T;
|
|
2038
2108
|
};
|
|
2039
2109
|
declare function scrubPii(text: string, config?: PiiScrubberConfig): string;
|
|
2110
|
+
/**
|
|
2111
|
+
* Scrub the query-string portion(s) of a URL — both the standard `?…` part
|
|
2112
|
+
* and any `?…` inside the hash fragment (hash routers like RealWorld's
|
|
2113
|
+
* `#/path?query` carry their query inside the fragment). Path segments and
|
|
2114
|
+
* param keys are left untouched; only values are redacted. Accepts absolute
|
|
2115
|
+
* or relative URLs and never throws.
|
|
2116
|
+
*/
|
|
2117
|
+
declare function scrubUrl(url: string, config?: PiiScrubberConfig): string;
|
|
2040
2118
|
|
|
2041
2119
|
/**
|
|
2042
2120
|
* Ring-buffer breadcrumb store. Capped at `max` entries (default 50);
|
|
@@ -2554,4 +2632,4 @@ declare function projectInitialsThemeIndex(projectId: string): number;
|
|
|
2554
2632
|
*/
|
|
2555
2633
|
declare function readPageFaviconHref(): string | null;
|
|
2556
2634
|
|
|
2557
|
-
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, sha256Hex, trackPageView, updateSessionIdentity, validateConfig };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -503,9 +503,9 @@ function isRetryable(error) {
|
|
|
503
503
|
|
|
504
504
|
// src/region.ts
|
|
505
505
|
var REGION_ENDPOINTS = {
|
|
506
|
-
us:
|
|
507
|
-
eu:
|
|
508
|
-
jp:
|
|
506
|
+
us: DEFAULT_API_ENDPOINT,
|
|
507
|
+
eu: DEFAULT_API_ENDPOINT,
|
|
508
|
+
jp: DEFAULT_API_ENDPOINT
|
|
509
509
|
};
|
|
510
510
|
var ROUTING_CACHE_KEY = "mushi_region_v1";
|
|
511
511
|
var ROUTING_CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -697,6 +697,8 @@ var KNOWN_CONFIG_KEYS = [
|
|
|
697
697
|
"debug",
|
|
698
698
|
"enabled",
|
|
699
699
|
"appVersion",
|
|
700
|
+
"sampleRate",
|
|
701
|
+
"beforeSend",
|
|
700
702
|
"beforeSendFeedback",
|
|
701
703
|
"onCrashedLastRun"
|
|
702
704
|
];
|
|
@@ -1052,12 +1054,27 @@ function openKeyDb() {
|
|
|
1052
1054
|
return new Promise((resolve, reject) => {
|
|
1053
1055
|
const req = indexedDB.open(KEY_DB, 1);
|
|
1054
1056
|
req.onupgradeneeded = () => {
|
|
1057
|
+
try {
|
|
1058
|
+
const db = req.result;
|
|
1059
|
+
if (!db) return;
|
|
1060
|
+
if (!db.objectStoreNames.contains(KEY_STORE)) {
|
|
1061
|
+
db.createObjectStore(KEY_STORE);
|
|
1062
|
+
}
|
|
1063
|
+
} catch {
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
req.onsuccess = () => {
|
|
1055
1067
|
const db = req.result;
|
|
1056
|
-
if (!db.objectStoreNames.contains(KEY_STORE)) {
|
|
1057
|
-
|
|
1068
|
+
if (!db || !db.objectStoreNames.contains(KEY_STORE)) {
|
|
1069
|
+
try {
|
|
1070
|
+
db?.close();
|
|
1071
|
+
} catch {
|
|
1072
|
+
}
|
|
1073
|
+
reject(new Error("key object store unavailable"));
|
|
1074
|
+
return;
|
|
1058
1075
|
}
|
|
1076
|
+
resolve(db);
|
|
1059
1077
|
};
|
|
1060
|
-
req.onsuccess = () => resolve(req.result);
|
|
1061
1078
|
req.onerror = () => reject(req.error);
|
|
1062
1079
|
});
|
|
1063
1080
|
}
|
|
@@ -1200,12 +1217,28 @@ function createOfflineQueue(config = {}) {
|
|
|
1200
1217
|
return new Promise((resolve, reject) => {
|
|
1201
1218
|
const request = indexedDB.open(DB_NAME, DB_VERSION);
|
|
1202
1219
|
request.onupgradeneeded = () => {
|
|
1220
|
+
try {
|
|
1221
|
+
const db = request.result;
|
|
1222
|
+
if (!db) return;
|
|
1223
|
+
if (!db.objectStoreNames.contains(STORE_NAME)) {
|
|
1224
|
+
db.createObjectStore(STORE_NAME, { keyPath: "id" });
|
|
1225
|
+
}
|
|
1226
|
+
} catch {
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
request.onsuccess = () => {
|
|
1203
1230
|
const db = request.result;
|
|
1204
|
-
if (!db.objectStoreNames.contains(STORE_NAME)) {
|
|
1205
|
-
|
|
1231
|
+
if (!db || !db.objectStoreNames.contains(STORE_NAME)) {
|
|
1232
|
+
backendType = "localstorage";
|
|
1233
|
+
try {
|
|
1234
|
+
db?.close();
|
|
1235
|
+
} catch {
|
|
1236
|
+
}
|
|
1237
|
+
reject(new Error("queue object store unavailable"));
|
|
1238
|
+
return;
|
|
1206
1239
|
}
|
|
1240
|
+
resolve(db);
|
|
1207
1241
|
};
|
|
1208
|
-
request.onsuccess = () => resolve(request.result);
|
|
1209
1242
|
request.onerror = () => {
|
|
1210
1243
|
backendType = "localstorage";
|
|
1211
1244
|
reject(request.error);
|
|
@@ -2034,6 +2067,46 @@ function createPiiScrubber(config = {}) {
|
|
|
2034
2067
|
function scrubPii(text, config) {
|
|
2035
2068
|
return createPiiScrubber(config).scrub(text);
|
|
2036
2069
|
}
|
|
2070
|
+
var SENSITIVE_QUERY_KEY_SUBSTRING_RE = /token|jwt|passw|pwd|secret|api[-_]?key|apikey|auth|session|signature|email|phone|ssn/i;
|
|
2071
|
+
var SENSITIVE_QUERY_KEY_EXACT_RE = /^(?:key|code|sig)$/i;
|
|
2072
|
+
function isSensitiveQueryKey(key) {
|
|
2073
|
+
let decoded = key;
|
|
2074
|
+
try {
|
|
2075
|
+
decoded = decodeURIComponent(key);
|
|
2076
|
+
} catch {
|
|
2077
|
+
}
|
|
2078
|
+
return SENSITIVE_QUERY_KEY_SUBSTRING_RE.test(decoded) || SENSITIVE_QUERY_KEY_EXACT_RE.test(decoded);
|
|
2079
|
+
}
|
|
2080
|
+
function scrubQueryPairs(query, scrub) {
|
|
2081
|
+
return query.split("&").map((pair) => {
|
|
2082
|
+
const eq = pair.indexOf("=");
|
|
2083
|
+
if (eq === -1) return pair;
|
|
2084
|
+
const key = pair.slice(0, eq);
|
|
2085
|
+
const value = pair.slice(eq + 1);
|
|
2086
|
+
if (value.length === 0) return pair;
|
|
2087
|
+
if (isSensitiveQueryKey(key)) return `${key}=[Scrubbed]`;
|
|
2088
|
+
let decoded = value;
|
|
2089
|
+
try {
|
|
2090
|
+
decoded = decodeURIComponent(value);
|
|
2091
|
+
} catch {
|
|
2092
|
+
}
|
|
2093
|
+
const scrubbed = scrub(decoded);
|
|
2094
|
+
if (scrubbed !== decoded) return `${key}=${encodeURIComponent(scrubbed)}`;
|
|
2095
|
+
return pair;
|
|
2096
|
+
}).join("&");
|
|
2097
|
+
}
|
|
2098
|
+
function scrubUrl(url, config) {
|
|
2099
|
+
if (!url || !url.includes("?") && !url.includes("#")) return url;
|
|
2100
|
+
const { scrub } = createPiiScrubber(config);
|
|
2101
|
+
const scrubPart = (part) => {
|
|
2102
|
+
const qIdx = part.indexOf("?");
|
|
2103
|
+
if (qIdx === -1) return part;
|
|
2104
|
+
return part.slice(0, qIdx + 1) + scrubQueryPairs(part.slice(qIdx + 1), scrub);
|
|
2105
|
+
};
|
|
2106
|
+
const hashIdx = url.indexOf("#");
|
|
2107
|
+
if (hashIdx === -1) return scrubPart(url);
|
|
2108
|
+
return scrubPart(url.slice(0, hashIdx)) + scrubPart(url.slice(hashIdx));
|
|
2109
|
+
}
|
|
2037
2110
|
|
|
2038
2111
|
// src/breadcrumbs.ts
|
|
2039
2112
|
var DEFAULT_MAX = 50;
|
|
@@ -2537,6 +2610,6 @@ function isSafeFaviconHref(href) {
|
|
|
2537
2610
|
}
|
|
2538
2611
|
}
|
|
2539
2612
|
|
|
2540
|
-
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_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, REGION_ENDPOINTS, 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, sha256Hex, trackPageView, updateSessionIdentity, validateConfig };
|
|
2613
|
+
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_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, REGION_ENDPOINTS, 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 };
|
|
2541
2614
|
//# sourceMappingURL=index.js.map
|
|
2542
2615
|
//# sourceMappingURL=index.js.map
|