@mushi-mushi/core 1.8.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +35 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +85 -1
- package/dist/index.d.ts +85 -1
- package/dist/index.js +35 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -263,6 +263,39 @@ interface MushiCaptureConfig {
|
|
|
263
263
|
* Nothing else. No DOM beyond the summary, no query values, no PII.
|
|
264
264
|
*/
|
|
265
265
|
discoverInventory?: boolean | MushiDiscoverInventoryConfig;
|
|
266
|
+
/**
|
|
267
|
+
* W3C trace-context propagation for OTel-style frontend→backend correlation.
|
|
268
|
+
*
|
|
269
|
+
* When enabled, the SDK injects a W3C `traceparent` header and an
|
|
270
|
+
* `x-mushi-session` header into every fetch/XHR request whose URL matches
|
|
271
|
+
* the `corsUrls` allowlist. The generated trace_id is recorded on each
|
|
272
|
+
* captured network entry so a bug report can be correlated with the
|
|
273
|
+
* backend span that handled the failing request.
|
|
274
|
+
*
|
|
275
|
+
* Default: disabled. Enable only for origins you control to avoid CORS issues.
|
|
276
|
+
* The backend (node SDK or Supabase edge function) must include
|
|
277
|
+
* `traceparent` and `x-mushi-session` in `Access-Control-Allow-Headers`.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* capture: {
|
|
281
|
+
* tracePropagation: {
|
|
282
|
+
* enabled: true,
|
|
283
|
+
* corsUrls: [/api\.myapp\.com/, /localhost:3000/],
|
|
284
|
+
* }
|
|
285
|
+
* }
|
|
286
|
+
*/
|
|
287
|
+
tracePropagation?: MushiTracePropagationConfig;
|
|
288
|
+
}
|
|
289
|
+
interface MushiTracePropagationConfig {
|
|
290
|
+
/** Enable W3C traceparent injection. Defaults to false. */
|
|
291
|
+
enabled?: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* URL patterns for which the SDK injects `traceparent` + `x-mushi-session`
|
|
294
|
+
* headers. Only requests matching at least one pattern are instrumented.
|
|
295
|
+
* Strings are substring-matched; RegExp values are tested against the full URL.
|
|
296
|
+
* Required when `enabled` is true — an empty allowlist silently disables propagation.
|
|
297
|
+
*/
|
|
298
|
+
corsUrls?: Array<string | RegExp>;
|
|
266
299
|
}
|
|
267
300
|
/**
|
|
268
301
|
* Fine-grained controls for `discoverInventory`. Defaults are tuned
|
|
@@ -816,6 +849,13 @@ interface MushiNetworkEntry {
|
|
|
816
849
|
requestHeaders?: Record<string, string>;
|
|
817
850
|
responseHeaders?: Record<string, string>;
|
|
818
851
|
error?: string;
|
|
852
|
+
/**
|
|
853
|
+
* W3C trace ID (32-char lowercase hex) injected by the SDK's trace propagation
|
|
854
|
+
* feature. Present only when `capture.tracePropagation.enabled` is true AND
|
|
855
|
+
* the request URL matched the `corsUrls` allowlist.
|
|
856
|
+
* Used to correlate this network entry with a backend span in the admin console.
|
|
857
|
+
*/
|
|
858
|
+
traceId?: string;
|
|
819
859
|
}
|
|
820
860
|
interface MushiPerformanceMetrics {
|
|
821
861
|
fcp?: number;
|
|
@@ -1025,6 +1065,28 @@ interface MushiSDKInstance {
|
|
|
1025
1065
|
* welcome" nudges (first-session, beta-onboarding).
|
|
1026
1066
|
*/
|
|
1027
1067
|
pulseTrigger(): void;
|
|
1068
|
+
/**
|
|
1069
|
+
* Returns the signed-in reporter's own report history.
|
|
1070
|
+
* Keyed to the persistent `reporterToken` stored in localStorage /
|
|
1071
|
+
* AsyncStorage. Returns an empty array when no token exists yet.
|
|
1072
|
+
*/
|
|
1073
|
+
listMyReports(): Promise<MushiReporterReport[]>;
|
|
1074
|
+
/**
|
|
1075
|
+
* Returns the comment thread for a given report. Only returns comments
|
|
1076
|
+
* visible to the reporter (their own comments + team replies).
|
|
1077
|
+
*/
|
|
1078
|
+
listMyComments(reportId: string): Promise<MushiReporterComment[]>;
|
|
1079
|
+
/**
|
|
1080
|
+
* Post a follow-up comment on one of the reporter's own reports.
|
|
1081
|
+
* Returns the newly created comment, or null on failure.
|
|
1082
|
+
*/
|
|
1083
|
+
replyToReport(reportId: string, body: string): Promise<MushiReporterComment | null>;
|
|
1084
|
+
/**
|
|
1085
|
+
* Returns the global contributor hall-of-fame ranked by total points.
|
|
1086
|
+
* Safe to call without an authenticated user; uses public endpoint.
|
|
1087
|
+
* @param limit Maximum entries to return (default 20).
|
|
1088
|
+
*/
|
|
1089
|
+
getHallOfFame(limit?: number): Promise<MushiHallOfFameEntry[]>;
|
|
1028
1090
|
}
|
|
1029
1091
|
interface MushiCaptureExceptionOptions {
|
|
1030
1092
|
/** Override the default `'bug'` category (e.g. `'slow'` for timeouts). */
|
|
@@ -1124,6 +1186,20 @@ interface MushiApiClient {
|
|
|
1124
1186
|
items: unknown[];
|
|
1125
1187
|
total: number;
|
|
1126
1188
|
}>>;
|
|
1189
|
+
/** Fetch the project's public leaderboard (top contributors). */
|
|
1190
|
+
getHallOfFame(limit?: number): Promise<MushiApiResponse<{
|
|
1191
|
+
data: Array<{
|
|
1192
|
+
display_name: string;
|
|
1193
|
+
email_hash: string | null;
|
|
1194
|
+
tier_slug: string | null;
|
|
1195
|
+
tier_name: string | null;
|
|
1196
|
+
points_30d: number;
|
|
1197
|
+
total_points: number;
|
|
1198
|
+
}>;
|
|
1199
|
+
meta: {
|
|
1200
|
+
project_name: string;
|
|
1201
|
+
};
|
|
1202
|
+
}>>;
|
|
1127
1203
|
}
|
|
1128
1204
|
/**
|
|
1129
1205
|
* Wire shape of a single discovery event sent by the SDK to
|
|
@@ -1187,6 +1263,14 @@ interface MushiReporterComment {
|
|
|
1187
1263
|
visible_to_reporter?: boolean;
|
|
1188
1264
|
created_at: string;
|
|
1189
1265
|
}
|
|
1266
|
+
interface MushiHallOfFameEntry {
|
|
1267
|
+
display_name: string;
|
|
1268
|
+
email_hash: string | null;
|
|
1269
|
+
tier_slug: string | null;
|
|
1270
|
+
tier_name: string | null;
|
|
1271
|
+
points_30d: number;
|
|
1272
|
+
total_points: number;
|
|
1273
|
+
}
|
|
1190
1274
|
|
|
1191
1275
|
interface ApiClientOptions {
|
|
1192
1276
|
projectId: string;
|
|
@@ -1497,4 +1581,4 @@ declare function createLogger(options: LoggerOptions): Logger;
|
|
|
1497
1581
|
*/
|
|
1498
1582
|
declare const noopLogger: Logger;
|
|
1499
1583
|
|
|
1500
|
-
export { type ApiClientOptions, type BreadcrumbBuffer, type BreadcrumbBufferOptions, DEFAULT_API_ENDPOINT, type LogEntry, type LogFormat, type LogLevel, type Logger, type LoggerOptions, MUSHI_INTERNAL_HEADER, MUSHI_INTERNAL_INIT_MARKER, type MushiActivityEvent, type MushiApiCascadeConfig, type MushiApiClient, type MushiApiResponse, type MushiBannerConfig, type MushiBannerLink, type MushiBetaChangelogEntry, type MushiBetaModeConfig, type MushiBreadcrumb, type MushiCaptureConfig, type MushiCaptureEventInput, type MushiCaptureExceptionOptions, type MushiConfig, type MushiConsoleEntry, type MushiCooldownConfig, type MushiDiagnosticsResult, type MushiDiscoverInventoryConfig, type MushiDiscoveryEventPayload, type MushiEnvironment, type MushiEventHandler, type MushiEventType, type MushiIntegrationsConfig, type MushiInternalRequestKind, type MushiNetworkEntry, type MushiOfflineConfig, type MushiOnDeviceClassifier, type MushiOnDeviceClassifierInput, type MushiOnDeviceClassifierResult, 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 MushiTierResult, type MushiTimelineEntry, type MushiTimelineKind, type MushiUrlMatcher, type MushiWidgetAnchor, type MushiWidgetConfig, type NormalisedException, type OfflineQueue, type PiiScrubberConfig, type PreFilterResult, REGION_ENDPOINTS, type RateLimiter, type RateLimiterConfig, captureEnvironment, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, getDeviceFingerprintHash, getReporterToken, getSessionId, newUuid, noopLogger, normaliseThrown, resolveRegionEndpoint, scrubPii };
|
|
1584
|
+
export { type ApiClientOptions, type BreadcrumbBuffer, type BreadcrumbBufferOptions, DEFAULT_API_ENDPOINT, type LogEntry, type LogFormat, type LogLevel, type Logger, type LoggerOptions, MUSHI_INTERNAL_HEADER, MUSHI_INTERNAL_INIT_MARKER, type MushiActivityEvent, type MushiApiCascadeConfig, type MushiApiClient, type MushiApiResponse, type MushiBannerConfig, type MushiBannerLink, type MushiBetaChangelogEntry, type MushiBetaModeConfig, type MushiBreadcrumb, type MushiCaptureConfig, type MushiCaptureEventInput, type MushiCaptureExceptionOptions, type MushiConfig, type MushiConsoleEntry, type MushiCooldownConfig, type MushiDiagnosticsResult, type MushiDiscoverInventoryConfig, type MushiDiscoveryEventPayload, type MushiEnvironment, type MushiEventHandler, type MushiEventType, type MushiHallOfFameEntry, type MushiIntegrationsConfig, type MushiInternalRequestKind, type MushiNetworkEntry, type MushiOfflineConfig, type MushiOnDeviceClassifier, type MushiOnDeviceClassifierInput, type MushiOnDeviceClassifierResult, 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 MushiTierResult, type MushiTimelineEntry, type MushiTimelineKind, type MushiTracePropagationConfig, type MushiUrlMatcher, type MushiWidgetAnchor, type MushiWidgetConfig, type NormalisedException, type OfflineQueue, type PiiScrubberConfig, type PreFilterResult, REGION_ENDPOINTS, type RateLimiter, type RateLimiterConfig, captureEnvironment, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, getDeviceFingerprintHash, getReporterToken, getSessionId, newUuid, noopLogger, normaliseThrown, resolveRegionEndpoint, scrubPii };
|
package/dist/index.d.ts
CHANGED
|
@@ -263,6 +263,39 @@ interface MushiCaptureConfig {
|
|
|
263
263
|
* Nothing else. No DOM beyond the summary, no query values, no PII.
|
|
264
264
|
*/
|
|
265
265
|
discoverInventory?: boolean | MushiDiscoverInventoryConfig;
|
|
266
|
+
/**
|
|
267
|
+
* W3C trace-context propagation for OTel-style frontend→backend correlation.
|
|
268
|
+
*
|
|
269
|
+
* When enabled, the SDK injects a W3C `traceparent` header and an
|
|
270
|
+
* `x-mushi-session` header into every fetch/XHR request whose URL matches
|
|
271
|
+
* the `corsUrls` allowlist. The generated trace_id is recorded on each
|
|
272
|
+
* captured network entry so a bug report can be correlated with the
|
|
273
|
+
* backend span that handled the failing request.
|
|
274
|
+
*
|
|
275
|
+
* Default: disabled. Enable only for origins you control to avoid CORS issues.
|
|
276
|
+
* The backend (node SDK or Supabase edge function) must include
|
|
277
|
+
* `traceparent` and `x-mushi-session` in `Access-Control-Allow-Headers`.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* capture: {
|
|
281
|
+
* tracePropagation: {
|
|
282
|
+
* enabled: true,
|
|
283
|
+
* corsUrls: [/api\.myapp\.com/, /localhost:3000/],
|
|
284
|
+
* }
|
|
285
|
+
* }
|
|
286
|
+
*/
|
|
287
|
+
tracePropagation?: MushiTracePropagationConfig;
|
|
288
|
+
}
|
|
289
|
+
interface MushiTracePropagationConfig {
|
|
290
|
+
/** Enable W3C traceparent injection. Defaults to false. */
|
|
291
|
+
enabled?: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* URL patterns for which the SDK injects `traceparent` + `x-mushi-session`
|
|
294
|
+
* headers. Only requests matching at least one pattern are instrumented.
|
|
295
|
+
* Strings are substring-matched; RegExp values are tested against the full URL.
|
|
296
|
+
* Required when `enabled` is true — an empty allowlist silently disables propagation.
|
|
297
|
+
*/
|
|
298
|
+
corsUrls?: Array<string | RegExp>;
|
|
266
299
|
}
|
|
267
300
|
/**
|
|
268
301
|
* Fine-grained controls for `discoverInventory`. Defaults are tuned
|
|
@@ -816,6 +849,13 @@ interface MushiNetworkEntry {
|
|
|
816
849
|
requestHeaders?: Record<string, string>;
|
|
817
850
|
responseHeaders?: Record<string, string>;
|
|
818
851
|
error?: string;
|
|
852
|
+
/**
|
|
853
|
+
* W3C trace ID (32-char lowercase hex) injected by the SDK's trace propagation
|
|
854
|
+
* feature. Present only when `capture.tracePropagation.enabled` is true AND
|
|
855
|
+
* the request URL matched the `corsUrls` allowlist.
|
|
856
|
+
* Used to correlate this network entry with a backend span in the admin console.
|
|
857
|
+
*/
|
|
858
|
+
traceId?: string;
|
|
819
859
|
}
|
|
820
860
|
interface MushiPerformanceMetrics {
|
|
821
861
|
fcp?: number;
|
|
@@ -1025,6 +1065,28 @@ interface MushiSDKInstance {
|
|
|
1025
1065
|
* welcome" nudges (first-session, beta-onboarding).
|
|
1026
1066
|
*/
|
|
1027
1067
|
pulseTrigger(): void;
|
|
1068
|
+
/**
|
|
1069
|
+
* Returns the signed-in reporter's own report history.
|
|
1070
|
+
* Keyed to the persistent `reporterToken` stored in localStorage /
|
|
1071
|
+
* AsyncStorage. Returns an empty array when no token exists yet.
|
|
1072
|
+
*/
|
|
1073
|
+
listMyReports(): Promise<MushiReporterReport[]>;
|
|
1074
|
+
/**
|
|
1075
|
+
* Returns the comment thread for a given report. Only returns comments
|
|
1076
|
+
* visible to the reporter (their own comments + team replies).
|
|
1077
|
+
*/
|
|
1078
|
+
listMyComments(reportId: string): Promise<MushiReporterComment[]>;
|
|
1079
|
+
/**
|
|
1080
|
+
* Post a follow-up comment on one of the reporter's own reports.
|
|
1081
|
+
* Returns the newly created comment, or null on failure.
|
|
1082
|
+
*/
|
|
1083
|
+
replyToReport(reportId: string, body: string): Promise<MushiReporterComment | null>;
|
|
1084
|
+
/**
|
|
1085
|
+
* Returns the global contributor hall-of-fame ranked by total points.
|
|
1086
|
+
* Safe to call without an authenticated user; uses public endpoint.
|
|
1087
|
+
* @param limit Maximum entries to return (default 20).
|
|
1088
|
+
*/
|
|
1089
|
+
getHallOfFame(limit?: number): Promise<MushiHallOfFameEntry[]>;
|
|
1028
1090
|
}
|
|
1029
1091
|
interface MushiCaptureExceptionOptions {
|
|
1030
1092
|
/** Override the default `'bug'` category (e.g. `'slow'` for timeouts). */
|
|
@@ -1124,6 +1186,20 @@ interface MushiApiClient {
|
|
|
1124
1186
|
items: unknown[];
|
|
1125
1187
|
total: number;
|
|
1126
1188
|
}>>;
|
|
1189
|
+
/** Fetch the project's public leaderboard (top contributors). */
|
|
1190
|
+
getHallOfFame(limit?: number): Promise<MushiApiResponse<{
|
|
1191
|
+
data: Array<{
|
|
1192
|
+
display_name: string;
|
|
1193
|
+
email_hash: string | null;
|
|
1194
|
+
tier_slug: string | null;
|
|
1195
|
+
tier_name: string | null;
|
|
1196
|
+
points_30d: number;
|
|
1197
|
+
total_points: number;
|
|
1198
|
+
}>;
|
|
1199
|
+
meta: {
|
|
1200
|
+
project_name: string;
|
|
1201
|
+
};
|
|
1202
|
+
}>>;
|
|
1127
1203
|
}
|
|
1128
1204
|
/**
|
|
1129
1205
|
* Wire shape of a single discovery event sent by the SDK to
|
|
@@ -1187,6 +1263,14 @@ interface MushiReporterComment {
|
|
|
1187
1263
|
visible_to_reporter?: boolean;
|
|
1188
1264
|
created_at: string;
|
|
1189
1265
|
}
|
|
1266
|
+
interface MushiHallOfFameEntry {
|
|
1267
|
+
display_name: string;
|
|
1268
|
+
email_hash: string | null;
|
|
1269
|
+
tier_slug: string | null;
|
|
1270
|
+
tier_name: string | null;
|
|
1271
|
+
points_30d: number;
|
|
1272
|
+
total_points: number;
|
|
1273
|
+
}
|
|
1190
1274
|
|
|
1191
1275
|
interface ApiClientOptions {
|
|
1192
1276
|
projectId: string;
|
|
@@ -1497,4 +1581,4 @@ declare function createLogger(options: LoggerOptions): Logger;
|
|
|
1497
1581
|
*/
|
|
1498
1582
|
declare const noopLogger: Logger;
|
|
1499
1583
|
|
|
1500
|
-
export { type ApiClientOptions, type BreadcrumbBuffer, type BreadcrumbBufferOptions, DEFAULT_API_ENDPOINT, type LogEntry, type LogFormat, type LogLevel, type Logger, type LoggerOptions, MUSHI_INTERNAL_HEADER, MUSHI_INTERNAL_INIT_MARKER, type MushiActivityEvent, type MushiApiCascadeConfig, type MushiApiClient, type MushiApiResponse, type MushiBannerConfig, type MushiBannerLink, type MushiBetaChangelogEntry, type MushiBetaModeConfig, type MushiBreadcrumb, type MushiCaptureConfig, type MushiCaptureEventInput, type MushiCaptureExceptionOptions, type MushiConfig, type MushiConsoleEntry, type MushiCooldownConfig, type MushiDiagnosticsResult, type MushiDiscoverInventoryConfig, type MushiDiscoveryEventPayload, type MushiEnvironment, type MushiEventHandler, type MushiEventType, type MushiIntegrationsConfig, type MushiInternalRequestKind, type MushiNetworkEntry, type MushiOfflineConfig, type MushiOnDeviceClassifier, type MushiOnDeviceClassifierInput, type MushiOnDeviceClassifierResult, 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 MushiTierResult, type MushiTimelineEntry, type MushiTimelineKind, type MushiUrlMatcher, type MushiWidgetAnchor, type MushiWidgetConfig, type NormalisedException, type OfflineQueue, type PiiScrubberConfig, type PreFilterResult, REGION_ENDPOINTS, type RateLimiter, type RateLimiterConfig, captureEnvironment, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, getDeviceFingerprintHash, getReporterToken, getSessionId, newUuid, noopLogger, normaliseThrown, resolveRegionEndpoint, scrubPii };
|
|
1584
|
+
export { type ApiClientOptions, type BreadcrumbBuffer, type BreadcrumbBufferOptions, DEFAULT_API_ENDPOINT, type LogEntry, type LogFormat, type LogLevel, type Logger, type LoggerOptions, MUSHI_INTERNAL_HEADER, MUSHI_INTERNAL_INIT_MARKER, type MushiActivityEvent, type MushiApiCascadeConfig, type MushiApiClient, type MushiApiResponse, type MushiBannerConfig, type MushiBannerLink, type MushiBetaChangelogEntry, type MushiBetaModeConfig, type MushiBreadcrumb, type MushiCaptureConfig, type MushiCaptureEventInput, type MushiCaptureExceptionOptions, type MushiConfig, type MushiConsoleEntry, type MushiCooldownConfig, type MushiDiagnosticsResult, type MushiDiscoverInventoryConfig, type MushiDiscoveryEventPayload, type MushiEnvironment, type MushiEventHandler, type MushiEventType, type MushiHallOfFameEntry, type MushiIntegrationsConfig, type MushiInternalRequestKind, type MushiNetworkEntry, type MushiOfflineConfig, type MushiOnDeviceClassifier, type MushiOnDeviceClassifierInput, type MushiOnDeviceClassifierResult, 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 MushiTierResult, type MushiTimelineEntry, type MushiTimelineKind, type MushiTracePropagationConfig, type MushiUrlMatcher, type MushiWidgetAnchor, type MushiWidgetConfig, type NormalisedException, type OfflineQueue, type PiiScrubberConfig, type PreFilterResult, REGION_ENDPOINTS, type RateLimiter, type RateLimiterConfig, captureEnvironment, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, getDeviceFingerprintHash, getReporterToken, getSessionId, newUuid, noopLogger, normaliseThrown, resolveRegionEndpoint, scrubPii };
|
package/dist/index.js
CHANGED
|
@@ -192,6 +192,15 @@ function createApiClient(options) {
|
|
|
192
192
|
1,
|
|
193
193
|
"reporter-poll"
|
|
194
194
|
);
|
|
195
|
+
},
|
|
196
|
+
async getHallOfFame(limit = 10) {
|
|
197
|
+
return request(
|
|
198
|
+
"GET",
|
|
199
|
+
`/v1/sdk/hall-of-fame?limit=${limit}`,
|
|
200
|
+
void 0,
|
|
201
|
+
1,
|
|
202
|
+
"reporter-poll"
|
|
203
|
+
);
|
|
195
204
|
}
|
|
196
205
|
};
|
|
197
206
|
}
|
|
@@ -290,8 +299,10 @@ var SPAM_PATTERNS = [
|
|
|
290
299
|
// numbers only
|
|
291
300
|
/^[^a-zA-Z\u00C0-\u024F\u4E00-\u9FFF\u3040-\u309F\u30A0-\u30FF]{10,}$/,
|
|
292
301
|
// no real letters
|
|
293
|
-
|
|
294
|
-
//
|
|
302
|
+
// "test" removed — users legitimately write "I was testing…" in real reports.
|
|
303
|
+
// Keep clearly-nonsense patterns that are never real sentences.
|
|
304
|
+
/^(asdf|qwerty|lorem ipsum)[.,!?\s]*$/i
|
|
305
|
+
// standalone keyboard-mash or placeholder
|
|
295
306
|
];
|
|
296
307
|
var GIBBERISH_PATTERN = /^[bcdfghjklmnpqrstvwxz]{6,}/i;
|
|
297
308
|
function createPreFilter(config = {}) {
|
|
@@ -581,9 +592,11 @@ var DB_VERSION = 1;
|
|
|
581
592
|
var LS_KEY = "mushi_offline_queue";
|
|
582
593
|
var BATCH_SIZE = 10;
|
|
583
594
|
var MAX_BACKOFF_MS = 6e4;
|
|
595
|
+
var AUTO_FLUSH_INTERVAL_MS = 3e4;
|
|
584
596
|
function createOfflineQueue(config = {}) {
|
|
585
597
|
const { enabled = true, maxQueueSize = 50, syncOnReconnect = true, encryptAtRest = true } = config;
|
|
586
598
|
let syncCleanup = null;
|
|
599
|
+
let flushInterval = null;
|
|
587
600
|
let backendType = null;
|
|
588
601
|
async function wrapForStorage(report) {
|
|
589
602
|
const queuedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -778,6 +791,7 @@ function createOfflineQueue(config = {}) {
|
|
|
778
791
|
const permanent = result.error?.code === "HTTP_400" || result.error?.code === "HTTP_422" || result.error?.code === "INGEST_ERROR" || result.error?.code === "VALIDATION_ERROR" || typeof result.error?.message === "string" && /invalid payload|description must be at least|validation/i.test(
|
|
779
792
|
result.error.message
|
|
780
793
|
);
|
|
794
|
+
const transient = !permanent && (result.error?.code === "NETWORK_ERROR" || result.error?.code === "HTTP_403" || result.error?.code === "HTTP_429" || result.error?.code === "HTTP_502" || result.error?.code === "HTTP_503" || result.error?.code === "HTTP_504" || typeof result.error?.code === "string" && result.error.code.startsWith("HTTP_5"));
|
|
781
795
|
if (permanent) {
|
|
782
796
|
try {
|
|
783
797
|
if (backend === "indexeddb") await idbDelete(rowId);
|
|
@@ -785,6 +799,11 @@ function createOfflineQueue(config = {}) {
|
|
|
785
799
|
} catch {
|
|
786
800
|
lsDelete(rowId);
|
|
787
801
|
}
|
|
802
|
+
} else if (transient) {
|
|
803
|
+
queueLog.debug("Offline queue: transient failure, will retry", {
|
|
804
|
+
id: rowId,
|
|
805
|
+
code: result.error?.code
|
|
806
|
+
});
|
|
788
807
|
}
|
|
789
808
|
failed++;
|
|
790
809
|
if (i < batch.length - 1) {
|
|
@@ -820,14 +839,25 @@ function createOfflineQueue(config = {}) {
|
|
|
820
839
|
}
|
|
821
840
|
function startAutoSync(client) {
|
|
822
841
|
if (!enabled || !syncOnReconnect || typeof window === "undefined") return;
|
|
823
|
-
const
|
|
842
|
+
const tryFlush = () => {
|
|
824
843
|
if (navigator.onLine) {
|
|
825
844
|
flush(client).catch(() => {
|
|
826
845
|
});
|
|
827
846
|
}
|
|
828
847
|
};
|
|
829
|
-
window.addEventListener("online",
|
|
830
|
-
|
|
848
|
+
window.addEventListener("online", tryFlush);
|
|
849
|
+
flushInterval = setInterval(() => {
|
|
850
|
+
void size().then((n) => {
|
|
851
|
+
if (n > 0) tryFlush();
|
|
852
|
+
});
|
|
853
|
+
}, AUTO_FLUSH_INTERVAL_MS);
|
|
854
|
+
syncCleanup = () => {
|
|
855
|
+
window.removeEventListener("online", tryFlush);
|
|
856
|
+
if (flushInterval) {
|
|
857
|
+
clearInterval(flushInterval);
|
|
858
|
+
flushInterval = null;
|
|
859
|
+
}
|
|
860
|
+
};
|
|
831
861
|
}
|
|
832
862
|
function stopAutoSync() {
|
|
833
863
|
syncCleanup?.();
|