@mushi-mushi/core 1.11.0 → 1.13.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 +96 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +110 -3
- package/dist/index.d.ts +110 -3
- package/dist/index.js +92 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -129,6 +129,51 @@ interface MushiWidgetConfig {
|
|
|
129
129
|
* avoidSelectors: ['[data-mobile-header]', '#sign-in-cta']
|
|
130
130
|
*/
|
|
131
131
|
avoidSelectors?: string[];
|
|
132
|
+
/**
|
|
133
|
+
* Override the default five-category picker with a custom category list.
|
|
134
|
+
* When set, the widget renders these categories instead of the built-in
|
|
135
|
+
* `bug / slow / visual / confusing / other` set.
|
|
136
|
+
*
|
|
137
|
+
* Each custom category maps onto one of the five built-in `MushiReportCategory`
|
|
138
|
+
* values via `baseCategory` (defaults to `'other'`). The custom id is
|
|
139
|
+
* preserved as `userCategory` on the report so the Mushi console can filter
|
|
140
|
+
* by it independently of the LLM-assigned `category`.
|
|
141
|
+
*
|
|
142
|
+
* Deep-link helpers (`open`, `openWith`, `report`) accept the custom `id`
|
|
143
|
+
* in addition to the built-in enum values when this option is set.
|
|
144
|
+
*
|
|
145
|
+
* When absent, behaviour is identical to the historical defaults (backward-compatible).
|
|
146
|
+
*/
|
|
147
|
+
categories?: MushiCustomCategory[];
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Descriptor for a single entry in a host-app custom category list.
|
|
151
|
+
* Passed as `widget.categories` to `Mushi.init()`.
|
|
152
|
+
*/
|
|
153
|
+
interface MushiCustomCategory {
|
|
154
|
+
/** Unique identifier used in `openWith(id)` / `report({ category: id })`. */
|
|
155
|
+
id: string;
|
|
156
|
+
/** Human-readable label shown in the category picker step. */
|
|
157
|
+
label: string;
|
|
158
|
+
/** Optional helper text shown beneath the label. */
|
|
159
|
+
description?: string;
|
|
160
|
+
/**
|
|
161
|
+
* Localised intent options displayed on the second step ("What happened?").
|
|
162
|
+
* When omitted, the widget skips the intent step and goes straight to
|
|
163
|
+
* the description.
|
|
164
|
+
*/
|
|
165
|
+
intents?: string[];
|
|
166
|
+
/**
|
|
167
|
+
* Emoji or single-character icon rendered next to the label in the picker.
|
|
168
|
+
* Falls back to a neutral bubble when absent.
|
|
169
|
+
*/
|
|
170
|
+
icon?: string;
|
|
171
|
+
/**
|
|
172
|
+
* Which built-in `MushiReportCategory` value this custom category maps to
|
|
173
|
+
* for server-side classification. Defaults to `'other'`.
|
|
174
|
+
* The custom `id` is always preserved in `report.userCategory`.
|
|
175
|
+
*/
|
|
176
|
+
baseCategory?: MushiReportCategory;
|
|
132
177
|
}
|
|
133
178
|
/** Optional flat link in the rich banner action row (admin-console BetaBanner style). */
|
|
134
179
|
interface MushiBannerLink {
|
|
@@ -543,6 +588,13 @@ interface MushiReport {
|
|
|
543
588
|
id: string;
|
|
544
589
|
projectId: string;
|
|
545
590
|
category: MushiReportCategory;
|
|
591
|
+
/**
|
|
592
|
+
* Custom category identifier set by the host app via `widget.categories`.
|
|
593
|
+
* Preserved as `reports.user_category` on the server so the Mushi console
|
|
594
|
+
* can filter by it independently of the LLM-assigned `category`.
|
|
595
|
+
* Not set when the host uses the default built-in category set.
|
|
596
|
+
*/
|
|
597
|
+
userCategory?: string;
|
|
546
598
|
description: string;
|
|
547
599
|
userIntent?: string;
|
|
548
600
|
environment: MushiEnvironment;
|
|
@@ -552,6 +604,8 @@ interface MushiReport {
|
|
|
552
604
|
timeline?: MushiTimelineEntry[];
|
|
553
605
|
screenshotDataUrl?: string;
|
|
554
606
|
selectedElement?: MushiSelectedElement;
|
|
607
|
+
/** rrweb / lite rolling-buffer events attached on submit when capture.replay is enabled. */
|
|
608
|
+
replayEvents?: unknown[];
|
|
555
609
|
metadata?: Record<string, unknown>;
|
|
556
610
|
sessionId?: string;
|
|
557
611
|
reporterToken: string;
|
|
@@ -955,9 +1009,12 @@ interface MushiSDKInstance {
|
|
|
955
1009
|
* feature-request shortcut. Pass `{ category }` to deep-link into a
|
|
956
1010
|
* specific bug intent, or `{ featureRequest: true }` to deep-link into
|
|
957
1011
|
* the feature-request description step (skips intent picker).
|
|
1012
|
+
*
|
|
1013
|
+
* When `widget.categories` is configured, `category` also accepts a
|
|
1014
|
+
* custom category `id` from that list.
|
|
958
1015
|
*/
|
|
959
1016
|
report(options?: {
|
|
960
|
-
category?: MushiReportCategory;
|
|
1017
|
+
category?: MushiReportCategory | string;
|
|
961
1018
|
featureRequest?: boolean;
|
|
962
1019
|
}): void;
|
|
963
1020
|
on(event: MushiEventType, handler: MushiEventHandler): () => void;
|
|
@@ -974,7 +1031,12 @@ interface MushiSDKInstance {
|
|
|
974
1031
|
}): void;
|
|
975
1032
|
isOpen(): boolean;
|
|
976
1033
|
open(): void;
|
|
977
|
-
|
|
1034
|
+
/**
|
|
1035
|
+
* Open the widget deep-linked to a specific category. Accepts a built-in
|
|
1036
|
+
* `MushiReportCategory` value or a custom category `id` when
|
|
1037
|
+
* `widget.categories` is configured.
|
|
1038
|
+
*/
|
|
1039
|
+
openWith(category: MushiReportCategory | string): void;
|
|
978
1040
|
show(): void;
|
|
979
1041
|
hide(): void;
|
|
980
1042
|
attachTo(selectorOrElement: string | Element, options?: MushiWidgetConfig): () => void;
|
|
@@ -1167,6 +1229,26 @@ interface MushiApiClient {
|
|
|
1167
1229
|
reopenReporterReport(reportId: string, reporterToken: string, note?: string): Promise<MushiApiResponse<{
|
|
1168
1230
|
outcome: Record<string, unknown>;
|
|
1169
1231
|
}>>;
|
|
1232
|
+
/** List in-app notifications for the authenticated reporter. */
|
|
1233
|
+
listNotifications(reporterToken: string, opts?: {
|
|
1234
|
+
since?: string;
|
|
1235
|
+
limit?: number;
|
|
1236
|
+
}): Promise<MushiApiResponse<{
|
|
1237
|
+
notifications: Array<Record<string, unknown>>;
|
|
1238
|
+
}>>;
|
|
1239
|
+
/** Mark a single reporter notification as read. */
|
|
1240
|
+
markNotificationRead(notificationId: string, reporterToken: string): Promise<MushiApiResponse<{
|
|
1241
|
+
ok: boolean;
|
|
1242
|
+
}>>;
|
|
1243
|
+
/** List the reporter-facing feature board (public roadmap tickets). */
|
|
1244
|
+
listReporterFeatureBoard(reporterToken: string): Promise<MushiApiResponse<{
|
|
1245
|
+
tickets: Array<Record<string, unknown>>;
|
|
1246
|
+
}>>;
|
|
1247
|
+
/** Toggle the reporter's vote on a feature-board ticket. */
|
|
1248
|
+
voteReporterFeatureBoard(requestId: string, reporterToken: string): Promise<MushiApiResponse<{
|
|
1249
|
+
voted: boolean;
|
|
1250
|
+
action: string;
|
|
1251
|
+
}>>;
|
|
1170
1252
|
/**
|
|
1171
1253
|
* Submit a batch of activity events for the current user.
|
|
1172
1254
|
* Requires rewards to be enabled on the project.
|
|
@@ -1518,6 +1600,31 @@ interface BreadcrumbBufferOptions {
|
|
|
1518
1600
|
}
|
|
1519
1601
|
declare function createBreadcrumbBuffer(options?: BreadcrumbBufferOptions): BreadcrumbBuffer;
|
|
1520
1602
|
|
|
1603
|
+
/**
|
|
1604
|
+
* Client-side payload size guards — prevents silent edge-function failures
|
|
1605
|
+
* when screenshots or log buffers inflate the report body past gateway limits.
|
|
1606
|
+
*/
|
|
1607
|
+
/** Supabase edge functions tolerate ~6 MB; stay under 4 MB for headroom. */
|
|
1608
|
+
declare const MAX_REPORT_PAYLOAD_BYTES: number;
|
|
1609
|
+
/** Screenshot data URLs above this are downscaled or dropped before POST. */
|
|
1610
|
+
declare const MAX_SCREENSHOT_DATA_URL_BYTES: number;
|
|
1611
|
+
interface PayloadGuardResult {
|
|
1612
|
+
ok: boolean;
|
|
1613
|
+
bytes: number;
|
|
1614
|
+
maxBytes: number;
|
|
1615
|
+
reason?: string;
|
|
1616
|
+
/**
|
|
1617
|
+
* True when the payload could not be serialized at all (e.g. a circular
|
|
1618
|
+
* reference in `metadata`). This is a distinct failure from "too large" —
|
|
1619
|
+
* the caller should surface a `SERIALIZE_FAILED` rather than a misleading
|
|
1620
|
+
* "payload too large" message.
|
|
1621
|
+
*/
|
|
1622
|
+
serializeFailed?: boolean;
|
|
1623
|
+
}
|
|
1624
|
+
declare function estimateJsonBytes(value: unknown): number;
|
|
1625
|
+
declare function checkReportPayloadSize(payload: unknown, maxBytes?: number): PayloadGuardResult;
|
|
1626
|
+
declare function formatBytes(n: number): string;
|
|
1627
|
+
|
|
1521
1628
|
/**
|
|
1522
1629
|
* Normalise *anything* a host might throw — `Error`, string, plain
|
|
1523
1630
|
* object, `null`, frozen DOMException — into the shape Mushi reports
|
|
@@ -1602,4 +1709,4 @@ declare function createLogger(options: LoggerOptions): Logger;
|
|
|
1602
1709
|
*/
|
|
1603
1710
|
declare const noopLogger: Logger;
|
|
1604
1711
|
|
|
1605
|
-
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 };
|
|
1712
|
+
export { type ApiClientOptions, type BreadcrumbBuffer, type BreadcrumbBufferOptions, DEFAULT_API_ENDPOINT, type LogEntry, type LogFormat, type LogLevel, type Logger, type LoggerOptions, MAX_REPORT_PAYLOAD_BYTES, MAX_SCREENSHOT_DATA_URL_BYTES, MUSHI_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 MushiCustomCategory, 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 PayloadGuardResult, type PiiScrubberConfig, type PreFilterResult, REGION_ENDPOINTS, type RateLimiter, type RateLimiterConfig, captureEnvironment, checkReportPayloadSize, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, estimateJsonBytes, formatBytes, getDeviceFingerprintHash, getReporterToken, getSessionId, newUuid, noopLogger, normaliseThrown, resolveRegionEndpoint, scrubPii };
|
package/dist/index.d.ts
CHANGED
|
@@ -129,6 +129,51 @@ interface MushiWidgetConfig {
|
|
|
129
129
|
* avoidSelectors: ['[data-mobile-header]', '#sign-in-cta']
|
|
130
130
|
*/
|
|
131
131
|
avoidSelectors?: string[];
|
|
132
|
+
/**
|
|
133
|
+
* Override the default five-category picker with a custom category list.
|
|
134
|
+
* When set, the widget renders these categories instead of the built-in
|
|
135
|
+
* `bug / slow / visual / confusing / other` set.
|
|
136
|
+
*
|
|
137
|
+
* Each custom category maps onto one of the five built-in `MushiReportCategory`
|
|
138
|
+
* values via `baseCategory` (defaults to `'other'`). The custom id is
|
|
139
|
+
* preserved as `userCategory` on the report so the Mushi console can filter
|
|
140
|
+
* by it independently of the LLM-assigned `category`.
|
|
141
|
+
*
|
|
142
|
+
* Deep-link helpers (`open`, `openWith`, `report`) accept the custom `id`
|
|
143
|
+
* in addition to the built-in enum values when this option is set.
|
|
144
|
+
*
|
|
145
|
+
* When absent, behaviour is identical to the historical defaults (backward-compatible).
|
|
146
|
+
*/
|
|
147
|
+
categories?: MushiCustomCategory[];
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Descriptor for a single entry in a host-app custom category list.
|
|
151
|
+
* Passed as `widget.categories` to `Mushi.init()`.
|
|
152
|
+
*/
|
|
153
|
+
interface MushiCustomCategory {
|
|
154
|
+
/** Unique identifier used in `openWith(id)` / `report({ category: id })`. */
|
|
155
|
+
id: string;
|
|
156
|
+
/** Human-readable label shown in the category picker step. */
|
|
157
|
+
label: string;
|
|
158
|
+
/** Optional helper text shown beneath the label. */
|
|
159
|
+
description?: string;
|
|
160
|
+
/**
|
|
161
|
+
* Localised intent options displayed on the second step ("What happened?").
|
|
162
|
+
* When omitted, the widget skips the intent step and goes straight to
|
|
163
|
+
* the description.
|
|
164
|
+
*/
|
|
165
|
+
intents?: string[];
|
|
166
|
+
/**
|
|
167
|
+
* Emoji or single-character icon rendered next to the label in the picker.
|
|
168
|
+
* Falls back to a neutral bubble when absent.
|
|
169
|
+
*/
|
|
170
|
+
icon?: string;
|
|
171
|
+
/**
|
|
172
|
+
* Which built-in `MushiReportCategory` value this custom category maps to
|
|
173
|
+
* for server-side classification. Defaults to `'other'`.
|
|
174
|
+
* The custom `id` is always preserved in `report.userCategory`.
|
|
175
|
+
*/
|
|
176
|
+
baseCategory?: MushiReportCategory;
|
|
132
177
|
}
|
|
133
178
|
/** Optional flat link in the rich banner action row (admin-console BetaBanner style). */
|
|
134
179
|
interface MushiBannerLink {
|
|
@@ -543,6 +588,13 @@ interface MushiReport {
|
|
|
543
588
|
id: string;
|
|
544
589
|
projectId: string;
|
|
545
590
|
category: MushiReportCategory;
|
|
591
|
+
/**
|
|
592
|
+
* Custom category identifier set by the host app via `widget.categories`.
|
|
593
|
+
* Preserved as `reports.user_category` on the server so the Mushi console
|
|
594
|
+
* can filter by it independently of the LLM-assigned `category`.
|
|
595
|
+
* Not set when the host uses the default built-in category set.
|
|
596
|
+
*/
|
|
597
|
+
userCategory?: string;
|
|
546
598
|
description: string;
|
|
547
599
|
userIntent?: string;
|
|
548
600
|
environment: MushiEnvironment;
|
|
@@ -552,6 +604,8 @@ interface MushiReport {
|
|
|
552
604
|
timeline?: MushiTimelineEntry[];
|
|
553
605
|
screenshotDataUrl?: string;
|
|
554
606
|
selectedElement?: MushiSelectedElement;
|
|
607
|
+
/** rrweb / lite rolling-buffer events attached on submit when capture.replay is enabled. */
|
|
608
|
+
replayEvents?: unknown[];
|
|
555
609
|
metadata?: Record<string, unknown>;
|
|
556
610
|
sessionId?: string;
|
|
557
611
|
reporterToken: string;
|
|
@@ -955,9 +1009,12 @@ interface MushiSDKInstance {
|
|
|
955
1009
|
* feature-request shortcut. Pass `{ category }` to deep-link into a
|
|
956
1010
|
* specific bug intent, or `{ featureRequest: true }` to deep-link into
|
|
957
1011
|
* the feature-request description step (skips intent picker).
|
|
1012
|
+
*
|
|
1013
|
+
* When `widget.categories` is configured, `category` also accepts a
|
|
1014
|
+
* custom category `id` from that list.
|
|
958
1015
|
*/
|
|
959
1016
|
report(options?: {
|
|
960
|
-
category?: MushiReportCategory;
|
|
1017
|
+
category?: MushiReportCategory | string;
|
|
961
1018
|
featureRequest?: boolean;
|
|
962
1019
|
}): void;
|
|
963
1020
|
on(event: MushiEventType, handler: MushiEventHandler): () => void;
|
|
@@ -974,7 +1031,12 @@ interface MushiSDKInstance {
|
|
|
974
1031
|
}): void;
|
|
975
1032
|
isOpen(): boolean;
|
|
976
1033
|
open(): void;
|
|
977
|
-
|
|
1034
|
+
/**
|
|
1035
|
+
* Open the widget deep-linked to a specific category. Accepts a built-in
|
|
1036
|
+
* `MushiReportCategory` value or a custom category `id` when
|
|
1037
|
+
* `widget.categories` is configured.
|
|
1038
|
+
*/
|
|
1039
|
+
openWith(category: MushiReportCategory | string): void;
|
|
978
1040
|
show(): void;
|
|
979
1041
|
hide(): void;
|
|
980
1042
|
attachTo(selectorOrElement: string | Element, options?: MushiWidgetConfig): () => void;
|
|
@@ -1167,6 +1229,26 @@ interface MushiApiClient {
|
|
|
1167
1229
|
reopenReporterReport(reportId: string, reporterToken: string, note?: string): Promise<MushiApiResponse<{
|
|
1168
1230
|
outcome: Record<string, unknown>;
|
|
1169
1231
|
}>>;
|
|
1232
|
+
/** List in-app notifications for the authenticated reporter. */
|
|
1233
|
+
listNotifications(reporterToken: string, opts?: {
|
|
1234
|
+
since?: string;
|
|
1235
|
+
limit?: number;
|
|
1236
|
+
}): Promise<MushiApiResponse<{
|
|
1237
|
+
notifications: Array<Record<string, unknown>>;
|
|
1238
|
+
}>>;
|
|
1239
|
+
/** Mark a single reporter notification as read. */
|
|
1240
|
+
markNotificationRead(notificationId: string, reporterToken: string): Promise<MushiApiResponse<{
|
|
1241
|
+
ok: boolean;
|
|
1242
|
+
}>>;
|
|
1243
|
+
/** List the reporter-facing feature board (public roadmap tickets). */
|
|
1244
|
+
listReporterFeatureBoard(reporterToken: string): Promise<MushiApiResponse<{
|
|
1245
|
+
tickets: Array<Record<string, unknown>>;
|
|
1246
|
+
}>>;
|
|
1247
|
+
/** Toggle the reporter's vote on a feature-board ticket. */
|
|
1248
|
+
voteReporterFeatureBoard(requestId: string, reporterToken: string): Promise<MushiApiResponse<{
|
|
1249
|
+
voted: boolean;
|
|
1250
|
+
action: string;
|
|
1251
|
+
}>>;
|
|
1170
1252
|
/**
|
|
1171
1253
|
* Submit a batch of activity events for the current user.
|
|
1172
1254
|
* Requires rewards to be enabled on the project.
|
|
@@ -1518,6 +1600,31 @@ interface BreadcrumbBufferOptions {
|
|
|
1518
1600
|
}
|
|
1519
1601
|
declare function createBreadcrumbBuffer(options?: BreadcrumbBufferOptions): BreadcrumbBuffer;
|
|
1520
1602
|
|
|
1603
|
+
/**
|
|
1604
|
+
* Client-side payload size guards — prevents silent edge-function failures
|
|
1605
|
+
* when screenshots or log buffers inflate the report body past gateway limits.
|
|
1606
|
+
*/
|
|
1607
|
+
/** Supabase edge functions tolerate ~6 MB; stay under 4 MB for headroom. */
|
|
1608
|
+
declare const MAX_REPORT_PAYLOAD_BYTES: number;
|
|
1609
|
+
/** Screenshot data URLs above this are downscaled or dropped before POST. */
|
|
1610
|
+
declare const MAX_SCREENSHOT_DATA_URL_BYTES: number;
|
|
1611
|
+
interface PayloadGuardResult {
|
|
1612
|
+
ok: boolean;
|
|
1613
|
+
bytes: number;
|
|
1614
|
+
maxBytes: number;
|
|
1615
|
+
reason?: string;
|
|
1616
|
+
/**
|
|
1617
|
+
* True when the payload could not be serialized at all (e.g. a circular
|
|
1618
|
+
* reference in `metadata`). This is a distinct failure from "too large" —
|
|
1619
|
+
* the caller should surface a `SERIALIZE_FAILED` rather than a misleading
|
|
1620
|
+
* "payload too large" message.
|
|
1621
|
+
*/
|
|
1622
|
+
serializeFailed?: boolean;
|
|
1623
|
+
}
|
|
1624
|
+
declare function estimateJsonBytes(value: unknown): number;
|
|
1625
|
+
declare function checkReportPayloadSize(payload: unknown, maxBytes?: number): PayloadGuardResult;
|
|
1626
|
+
declare function formatBytes(n: number): string;
|
|
1627
|
+
|
|
1521
1628
|
/**
|
|
1522
1629
|
* Normalise *anything* a host might throw — `Error`, string, plain
|
|
1523
1630
|
* object, `null`, frozen DOMException — into the shape Mushi reports
|
|
@@ -1602,4 +1709,4 @@ declare function createLogger(options: LoggerOptions): Logger;
|
|
|
1602
1709
|
*/
|
|
1603
1710
|
declare const noopLogger: Logger;
|
|
1604
1711
|
|
|
1605
|
-
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 };
|
|
1712
|
+
export { type ApiClientOptions, type BreadcrumbBuffer, type BreadcrumbBufferOptions, DEFAULT_API_ENDPOINT, type LogEntry, type LogFormat, type LogLevel, type Logger, type LoggerOptions, MAX_REPORT_PAYLOAD_BYTES, MAX_SCREENSHOT_DATA_URL_BYTES, MUSHI_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 MushiCustomCategory, 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 PayloadGuardResult, type PiiScrubberConfig, type PreFilterResult, REGION_ENDPOINTS, type RateLimiter, type RateLimiterConfig, captureEnvironment, checkReportPayloadSize, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, estimateJsonBytes, formatBytes, getDeviceFingerprintHash, getReporterToken, getSessionId, newUuid, noopLogger, normaliseThrown, resolveRegionEndpoint, scrubPii };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
1
|
+
// src/payload-guard.ts
|
|
2
|
+
var MAX_REPORT_PAYLOAD_BYTES = 4 * 1024 * 1024;
|
|
3
|
+
var MAX_SCREENSHOT_DATA_URL_BYTES = 1.5 * 1024 * 1024;
|
|
4
|
+
function safeStringify(value) {
|
|
5
|
+
try {
|
|
6
|
+
return JSON.stringify(value);
|
|
7
|
+
} catch {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function estimateJsonBytes(value) {
|
|
12
|
+
const json = safeStringify(value);
|
|
13
|
+
return json === null ? Number.MAX_SAFE_INTEGER : new TextEncoder().encode(json).length;
|
|
14
|
+
}
|
|
15
|
+
function checkReportPayloadSize(payload, maxBytes = MAX_REPORT_PAYLOAD_BYTES) {
|
|
16
|
+
const json = safeStringify(payload);
|
|
17
|
+
if (json === null) {
|
|
18
|
+
return {
|
|
19
|
+
ok: false,
|
|
20
|
+
bytes: 0,
|
|
21
|
+
maxBytes,
|
|
22
|
+
serializeFailed: true,
|
|
23
|
+
reason: "Report could not be serialized (circular reference in metadata?)"
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const bytes = new TextEncoder().encode(json).length;
|
|
27
|
+
if (bytes <= maxBytes) {
|
|
28
|
+
return { ok: true, bytes, maxBytes };
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
ok: false,
|
|
32
|
+
bytes,
|
|
33
|
+
maxBytes,
|
|
34
|
+
reason: `Report payload ${formatBytes(bytes)} exceeds limit ${formatBytes(maxBytes)}`
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function formatBytes(n) {
|
|
38
|
+
if (n < 1024) return `${n} B`;
|
|
39
|
+
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
|
|
40
|
+
return `${(n / (1024 * 1024)).toFixed(2)} MB`;
|
|
41
|
+
}
|
|
42
|
+
|
|
1
43
|
// src/api-client.ts
|
|
2
44
|
var DEFAULT_API_ENDPOINT = "https://dxptnwrhwsqckaftyymj.supabase.co/functions/v1/api";
|
|
3
45
|
var MUSHI_INTERNAL_HEADER = "X-Mushi-Internal";
|
|
@@ -107,6 +149,16 @@ function createApiClient(options) {
|
|
|
107
149
|
}
|
|
108
150
|
return {
|
|
109
151
|
async submitReport(report) {
|
|
152
|
+
const guard = checkReportPayloadSize(report);
|
|
153
|
+
if (!guard.ok) {
|
|
154
|
+
return {
|
|
155
|
+
ok: false,
|
|
156
|
+
error: {
|
|
157
|
+
code: guard.serializeFailed ? "SERIALIZE_FAILED" : "PAYLOAD_TOO_LARGE",
|
|
158
|
+
message: guard.reason ?? "Report payload exceeds size limit"
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
110
162
|
return request("POST", "/v1/reports", report, maxRetries, "report-submit");
|
|
111
163
|
},
|
|
112
164
|
async getReportStatus(reportId) {
|
|
@@ -154,6 +206,40 @@ function createApiClient(options) {
|
|
|
154
206
|
{ note: note ?? "" }
|
|
155
207
|
);
|
|
156
208
|
},
|
|
209
|
+
async listNotifications(reporterToken, opts) {
|
|
210
|
+
const qs = new URLSearchParams();
|
|
211
|
+
if (opts?.since) qs.set("since", opts.since);
|
|
212
|
+
if (opts?.limit) qs.set("limit", String(opts.limit));
|
|
213
|
+
const suffix = qs.size ? `?${qs.toString()}` : "";
|
|
214
|
+
return requestForReporter(
|
|
215
|
+
"GET",
|
|
216
|
+
`/v1/notifications${suffix}`,
|
|
217
|
+
reporterToken
|
|
218
|
+
);
|
|
219
|
+
},
|
|
220
|
+
async markNotificationRead(notificationId, reporterToken) {
|
|
221
|
+
return requestForReporter(
|
|
222
|
+
"POST",
|
|
223
|
+
`/v1/notifications/${notificationId}/read`,
|
|
224
|
+
reporterToken,
|
|
225
|
+
{}
|
|
226
|
+
);
|
|
227
|
+
},
|
|
228
|
+
async listReporterFeatureBoard(reporterToken) {
|
|
229
|
+
return requestForReporter(
|
|
230
|
+
"GET",
|
|
231
|
+
"/v1/reporter/feature-board",
|
|
232
|
+
reporterToken
|
|
233
|
+
);
|
|
234
|
+
},
|
|
235
|
+
async voteReporterFeatureBoard(requestId, reporterToken) {
|
|
236
|
+
return requestForReporter(
|
|
237
|
+
"POST",
|
|
238
|
+
`/v1/reporter/feature-board/${requestId}/vote`,
|
|
239
|
+
reporterToken,
|
|
240
|
+
{}
|
|
241
|
+
);
|
|
242
|
+
},
|
|
157
243
|
// ─── Rewards program (P1) ──────────────────────────────────
|
|
158
244
|
async submitActivity(userId, events, opts) {
|
|
159
245
|
return request(
|
|
@@ -796,7 +882,11 @@ function createOfflineQueue(config = {}) {
|
|
|
796
882
|
}
|
|
797
883
|
sent++;
|
|
798
884
|
} else {
|
|
799
|
-
const permanent = result.error?.code === "HTTP_400" || result.error?.code === "
|
|
885
|
+
const permanent = result.error?.code === "HTTP_400" || result.error?.code === "HTTP_413" || result.error?.code === "HTTP_422" || result.error?.code === "INGEST_ERROR" || result.error?.code === "VALIDATION_ERROR" || // A payload that exceeds the size guard will never shrink on its own;
|
|
886
|
+
// retrying re-serialises the multi-MB body every sync tick and wedges
|
|
887
|
+
// the queue (it matches neither permanent nor transient otherwise).
|
|
888
|
+
// SERIALIZE_FAILED (circular ref) is likewise unrecoverable on retry.
|
|
889
|
+
result.error?.code === "PAYLOAD_TOO_LARGE" || result.error?.code === "SERIALIZE_FAILED" || typeof result.error?.message === "string" && /invalid payload|description must be at least|validation/i.test(
|
|
800
890
|
result.error.message
|
|
801
891
|
);
|
|
802
892
|
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"));
|
|
@@ -1336,6 +1426,6 @@ function normaliseThrown(thrown) {
|
|
|
1336
1426
|
return { name: "Error", message: String(thrown) };
|
|
1337
1427
|
}
|
|
1338
1428
|
|
|
1339
|
-
export { DEFAULT_API_ENDPOINT, MUSHI_INTERNAL_HEADER, MUSHI_INTERNAL_INIT_MARKER, REGION_ENDPOINTS, captureEnvironment, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, getDeviceFingerprintHash, getReporterToken, getSessionId, newUuid, noopLogger, normaliseThrown, resolveRegionEndpoint, scrubPii };
|
|
1429
|
+
export { DEFAULT_API_ENDPOINT, MAX_REPORT_PAYLOAD_BYTES, MAX_SCREENSHOT_DATA_URL_BYTES, MUSHI_INTERNAL_HEADER, MUSHI_INTERNAL_INIT_MARKER, REGION_ENDPOINTS, captureEnvironment, checkReportPayloadSize, createApiClient, createBreadcrumbBuffer, createLogger, createOfflineQueue, createPiiScrubber, createPreFilter, createRateLimiter, estimateJsonBytes, formatBytes, getDeviceFingerprintHash, getReporterToken, getSessionId, newUuid, noopLogger, normaliseThrown, resolveRegionEndpoint, scrubPii };
|
|
1340
1430
|
//# sourceMappingURL=index.js.map
|
|
1341
1431
|
//# sourceMappingURL=index.js.map
|