@mushi-mushi/core 1.0.0 → 1.2.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/CONTRIBUTING.md +27 -0
- package/dist/index.cjs +47 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +151 -5
- package/dist/index.d.ts +151 -5
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.cts
CHANGED
|
@@ -66,6 +66,38 @@ interface MushiWidgetConfig {
|
|
|
66
66
|
brandFooter?: boolean;
|
|
67
67
|
/** How the widget should surface SDK freshness warnings. Defaults to auto. */
|
|
68
68
|
outdatedBanner?: 'auto' | 'banner' | 'console-only' | 'off';
|
|
69
|
+
/**
|
|
70
|
+
* Beta mode: injects discreet "early access" messaging into the widget panel.
|
|
71
|
+
* Shows a beta strip on the category step and a contact footer on the success
|
|
72
|
+
* step. Designed to reduce user frustration with in-progress apps while
|
|
73
|
+
* actively inviting feedback.
|
|
74
|
+
*/
|
|
75
|
+
betaMode?: MushiBetaModeConfig;
|
|
76
|
+
}
|
|
77
|
+
interface MushiBetaModeConfig {
|
|
78
|
+
enabled?: boolean;
|
|
79
|
+
/** Display name of the app shown in the beta strip. Defaults to 'This app'. */
|
|
80
|
+
appName?: string;
|
|
81
|
+
/** Contact email shown on success step for direct founder/dev reach. */
|
|
82
|
+
contactEmail?: string;
|
|
83
|
+
/** Override the default beta strip message. */
|
|
84
|
+
message?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Optional perks shown to the user for opting in as a beta tester.
|
|
87
|
+
* e.g. ['Early access to new lessons', 'Priority bug fix queue'].
|
|
88
|
+
*/
|
|
89
|
+
perks?: string[];
|
|
90
|
+
/**
|
|
91
|
+
* Version-tied release notes rendered as a collapsible "What's new in this build"
|
|
92
|
+
* row in the widget. Closes the feedback loop — "did you fix what I reported?"
|
|
93
|
+
* Only the first entry (latest) is shown by default.
|
|
94
|
+
*/
|
|
95
|
+
changelogItems?: MushiBetaChangelogEntry[];
|
|
96
|
+
}
|
|
97
|
+
interface MushiBetaChangelogEntry {
|
|
98
|
+
version: string;
|
|
99
|
+
date?: string;
|
|
100
|
+
items: string[];
|
|
69
101
|
}
|
|
70
102
|
interface MushiWidgetInset {
|
|
71
103
|
top?: number | 'auto';
|
|
@@ -256,10 +288,62 @@ interface MushiOfflineConfig {
|
|
|
256
288
|
}
|
|
257
289
|
interface MushiRewardsConfig {
|
|
258
290
|
enabled?: boolean;
|
|
259
|
-
|
|
291
|
+
/**
|
|
292
|
+
* P1: when true the SDK auto-tracks route navigations, [data-testid] clicks,
|
|
293
|
+
* and session dwell time and flushes them to POST /v1/sdk/activity.
|
|
294
|
+
* Default false. Requires opted_in_to_rewards = true from the end user.
|
|
295
|
+
*/
|
|
296
|
+
trackActivity?: boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Activity batch flush interval in ms. Default 300_000 (5 min).
|
|
299
|
+
* Minimum 30_000 (30s) — smaller values are clamped.
|
|
300
|
+
*/
|
|
301
|
+
flushIntervalMs?: number;
|
|
302
|
+
/**
|
|
303
|
+
* Show a tier + points footer in the SDK widget.
|
|
304
|
+
* Default false.
|
|
305
|
+
*/
|
|
306
|
+
showInWidget?: boolean;
|
|
307
|
+
/**
|
|
308
|
+
* Whether to show a "+X pts" toast notification on each award.
|
|
309
|
+
* Default true when enabled.
|
|
310
|
+
*/
|
|
260
311
|
showNotifications?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* 'auto' — immediately opt the user in when identify() is called.
|
|
314
|
+
* 'explicit' — SDK surfaces a one-time consent prompt. Default 'explicit'.
|
|
315
|
+
*/
|
|
316
|
+
consentMode?: 'auto' | 'explicit';
|
|
317
|
+
/**
|
|
318
|
+
* P2: callback that returns a host-app JWT for server-side identity
|
|
319
|
+
* verification before monetary rewards are issued. Return null to skip
|
|
320
|
+
* verification for non-monetary actions.
|
|
321
|
+
*/
|
|
322
|
+
verifyUserToken?: () => Promise<string | null>;
|
|
323
|
+
/**
|
|
324
|
+
* @deprecated Superseded by server-side reward_webhooks table.
|
|
325
|
+
* Kept for backwards compatibility; has no effect from v0.10.0.
|
|
326
|
+
*/
|
|
261
327
|
webhookOnReward?: string;
|
|
262
328
|
}
|
|
329
|
+
interface MushiReputationResult {
|
|
330
|
+
totalPoints: number;
|
|
331
|
+
points30d: number;
|
|
332
|
+
reputation: number;
|
|
333
|
+
confirmedBugs: number;
|
|
334
|
+
totalReports: number;
|
|
335
|
+
}
|
|
336
|
+
interface MushiTierResult {
|
|
337
|
+
id: string;
|
|
338
|
+
slug: string;
|
|
339
|
+
displayName: string;
|
|
340
|
+
pointsThreshold: number;
|
|
341
|
+
perks: Record<string, unknown>;
|
|
342
|
+
}
|
|
343
|
+
interface MushiActivityEvent {
|
|
344
|
+
action: string;
|
|
345
|
+
metadata?: Record<string, unknown>;
|
|
346
|
+
}
|
|
263
347
|
type MushiReportCategory = 'bug' | 'slow' | 'visual' | 'confusing' | 'other';
|
|
264
348
|
type MushiReportStatus = 'pending' | 'submitted' | 'classified' | 'grouped' | 'fixing' | 'fixed' | 'dismissed';
|
|
265
349
|
interface MushiReport {
|
|
@@ -336,13 +420,21 @@ interface MushiBreadcrumb {
|
|
|
336
420
|
/**
|
|
337
421
|
* Coarse bucket for filtering / coloring in the report drawer.
|
|
338
422
|
* - `navigation` — route or url change
|
|
339
|
-
* - `ui.click` — user clicked a `[data-testid]` element
|
|
423
|
+
* - `ui.click` — user clicked a `[data-testid]` element (web SDK)
|
|
424
|
+
* - `ui.tap` — user tapped a `UIView` / Android `View` (native SDKs)
|
|
340
425
|
* - `console` — `console.error` / `console.warn` callsite
|
|
341
|
-
* - `xhr` / `fetch` — network request that errored or 4xx/5xx
|
|
426
|
+
* - `xhr` / `fetch` — network request that errored or 4xx/5xx (web SDK)
|
|
427
|
+
* - `network` — network failure on iOS / Android (native SDKs)
|
|
342
428
|
* - `lifecycle` — Mushi SDK init / open / submit / queue
|
|
343
429
|
* - `custom` — host called `Mushi.addBreadcrumb()`
|
|
430
|
+
*
|
|
431
|
+
* Admin tooling that filters by interaction should treat
|
|
432
|
+
* `ui.click` ∪ `ui.tap` as one bucket and `xhr` ∪ `fetch` ∪ `network`
|
|
433
|
+
* as one bucket. Native enums are platform-idiomatic (`tap` on touch
|
|
434
|
+
* devices, `network` because iOS/Android don't expose `XHR` / `fetch`
|
|
435
|
+
* separately) — every wire string is documented in the native READMEs.
|
|
344
436
|
*/
|
|
345
|
-
category: 'navigation' | 'ui.click' | 'console' | 'xhr' | 'fetch' | 'lifecycle' | 'custom';
|
|
437
|
+
category: 'navigation' | 'ui.click' | 'ui.tap' | 'console' | 'xhr' | 'fetch' | 'network' | 'lifecycle' | 'custom';
|
|
346
438
|
/**
|
|
347
439
|
* Severity — `info` is the default. `warning` / `error` map to a
|
|
348
440
|
* coloured pill in the drawer; the Triage LLM uses these to decide
|
|
@@ -706,6 +798,24 @@ interface MushiSDKInstance {
|
|
|
706
798
|
setTags(tags: Record<string, string | number | boolean>): void;
|
|
707
799
|
/** Remove a single tag, or all tags when called with no argument. */
|
|
708
800
|
clearTag(key?: string): void;
|
|
801
|
+
/**
|
|
802
|
+
* Returns the current user's reputation + legacy point totals from the
|
|
803
|
+
* reporter_reputation table. Available even when the rewards program is
|
|
804
|
+
* disabled (legacy surface).
|
|
805
|
+
*/
|
|
806
|
+
getReputation(): Promise<MushiReputationResult | null>;
|
|
807
|
+
/**
|
|
808
|
+
* Returns the current user's tier from the rewards program.
|
|
809
|
+
* Returns null when the user has not yet been identified or the project
|
|
810
|
+
* has rewards_enabled = false.
|
|
811
|
+
*/
|
|
812
|
+
getTier(): Promise<MushiTierResult | null>;
|
|
813
|
+
/**
|
|
814
|
+
* Manually record a host-defined activity event (e.g. 'lesson_completed').
|
|
815
|
+
* The SDK batches these and flushes to POST /v1/sdk/activity.
|
|
816
|
+
* No-op when rewards are disabled or the user has not opted in.
|
|
817
|
+
*/
|
|
818
|
+
recordActivity(action: string, metadata?: Record<string, unknown>): void;
|
|
709
819
|
}
|
|
710
820
|
interface MushiCaptureExceptionOptions {
|
|
711
821
|
/** Override the default `'bug'` category (e.g. `'slow'` for timeouts). */
|
|
@@ -769,6 +879,42 @@ interface MushiApiClient {
|
|
|
769
879
|
replyToReporterReport(reportId: string, reporterToken: string, body: string): Promise<MushiApiResponse<{
|
|
770
880
|
comment: MushiReporterComment;
|
|
771
881
|
}>>;
|
|
882
|
+
/**
|
|
883
|
+
* Submit a batch of activity events for the current user.
|
|
884
|
+
* Requires rewards to be enabled on the project.
|
|
885
|
+
*/
|
|
886
|
+
submitActivity(userId: string, events: MushiActivityEvent[], opts?: {
|
|
887
|
+
userTraits?: {
|
|
888
|
+
email?: string;
|
|
889
|
+
name?: string;
|
|
890
|
+
provider?: string;
|
|
891
|
+
};
|
|
892
|
+
reporterTokenHash?: string;
|
|
893
|
+
optedIn?: boolean;
|
|
894
|
+
/** P2: host-app JWT; when present the server attempts verifyHostJwt
|
|
895
|
+
* and updates end_users.jwt_verified_at if valid. Required for
|
|
896
|
+
* monetary payout eligibility. */
|
|
897
|
+
hostJwt?: string;
|
|
898
|
+
}): Promise<MushiApiResponse<{
|
|
899
|
+
accepted: number;
|
|
900
|
+
total: number;
|
|
901
|
+
}>>;
|
|
902
|
+
/** Fetch the current user's point totals (requires userId). */
|
|
903
|
+
getMyPoints(userId: string): Promise<MushiApiResponse<{
|
|
904
|
+
total_points: number;
|
|
905
|
+
points_30d: number;
|
|
906
|
+
points_lifetime: number;
|
|
907
|
+
tier: MushiTierResult | null;
|
|
908
|
+
}>>;
|
|
909
|
+
/** Fetch the current user's tier (requires userId). */
|
|
910
|
+
getMyTier(userId: string): Promise<MushiApiResponse<MushiTierResult | null>>;
|
|
911
|
+
/** Fetch the current user's activity history (requires userId). */
|
|
912
|
+
getMyHistory(userId: string, opts?: {
|
|
913
|
+
limit?: number;
|
|
914
|
+
}): Promise<MushiApiResponse<{
|
|
915
|
+
items: unknown[];
|
|
916
|
+
total: number;
|
|
917
|
+
}>>;
|
|
772
918
|
}
|
|
773
919
|
/**
|
|
774
920
|
* Wire shape of a single discovery event sent by the SDK to
|
|
@@ -1121,4 +1267,4 @@ declare function createLogger(options: LoggerOptions): Logger;
|
|
|
1121
1267
|
*/
|
|
1122
1268
|
declare const noopLogger: Logger;
|
|
1123
1269
|
|
|
1124
|
-
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 MushiApiCascadeConfig, type MushiApiClient, type MushiApiResponse, 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 MushiRewardsConfig, type MushiRuntimeSdkConfig, type MushiSDKInstance, type MushiSdkVersionInfo, type MushiSelectedElement, type MushiSentryConfig, type MushiSentryContext, 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, noopLogger, normaliseThrown, resolveRegionEndpoint, scrubPii };
|
|
1270
|
+
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 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, noopLogger, normaliseThrown, resolveRegionEndpoint, scrubPii };
|
package/dist/index.d.ts
CHANGED
|
@@ -66,6 +66,38 @@ interface MushiWidgetConfig {
|
|
|
66
66
|
brandFooter?: boolean;
|
|
67
67
|
/** How the widget should surface SDK freshness warnings. Defaults to auto. */
|
|
68
68
|
outdatedBanner?: 'auto' | 'banner' | 'console-only' | 'off';
|
|
69
|
+
/**
|
|
70
|
+
* Beta mode: injects discreet "early access" messaging into the widget panel.
|
|
71
|
+
* Shows a beta strip on the category step and a contact footer on the success
|
|
72
|
+
* step. Designed to reduce user frustration with in-progress apps while
|
|
73
|
+
* actively inviting feedback.
|
|
74
|
+
*/
|
|
75
|
+
betaMode?: MushiBetaModeConfig;
|
|
76
|
+
}
|
|
77
|
+
interface MushiBetaModeConfig {
|
|
78
|
+
enabled?: boolean;
|
|
79
|
+
/** Display name of the app shown in the beta strip. Defaults to 'This app'. */
|
|
80
|
+
appName?: string;
|
|
81
|
+
/** Contact email shown on success step for direct founder/dev reach. */
|
|
82
|
+
contactEmail?: string;
|
|
83
|
+
/** Override the default beta strip message. */
|
|
84
|
+
message?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Optional perks shown to the user for opting in as a beta tester.
|
|
87
|
+
* e.g. ['Early access to new lessons', 'Priority bug fix queue'].
|
|
88
|
+
*/
|
|
89
|
+
perks?: string[];
|
|
90
|
+
/**
|
|
91
|
+
* Version-tied release notes rendered as a collapsible "What's new in this build"
|
|
92
|
+
* row in the widget. Closes the feedback loop — "did you fix what I reported?"
|
|
93
|
+
* Only the first entry (latest) is shown by default.
|
|
94
|
+
*/
|
|
95
|
+
changelogItems?: MushiBetaChangelogEntry[];
|
|
96
|
+
}
|
|
97
|
+
interface MushiBetaChangelogEntry {
|
|
98
|
+
version: string;
|
|
99
|
+
date?: string;
|
|
100
|
+
items: string[];
|
|
69
101
|
}
|
|
70
102
|
interface MushiWidgetInset {
|
|
71
103
|
top?: number | 'auto';
|
|
@@ -256,10 +288,62 @@ interface MushiOfflineConfig {
|
|
|
256
288
|
}
|
|
257
289
|
interface MushiRewardsConfig {
|
|
258
290
|
enabled?: boolean;
|
|
259
|
-
|
|
291
|
+
/**
|
|
292
|
+
* P1: when true the SDK auto-tracks route navigations, [data-testid] clicks,
|
|
293
|
+
* and session dwell time and flushes them to POST /v1/sdk/activity.
|
|
294
|
+
* Default false. Requires opted_in_to_rewards = true from the end user.
|
|
295
|
+
*/
|
|
296
|
+
trackActivity?: boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Activity batch flush interval in ms. Default 300_000 (5 min).
|
|
299
|
+
* Minimum 30_000 (30s) — smaller values are clamped.
|
|
300
|
+
*/
|
|
301
|
+
flushIntervalMs?: number;
|
|
302
|
+
/**
|
|
303
|
+
* Show a tier + points footer in the SDK widget.
|
|
304
|
+
* Default false.
|
|
305
|
+
*/
|
|
306
|
+
showInWidget?: boolean;
|
|
307
|
+
/**
|
|
308
|
+
* Whether to show a "+X pts" toast notification on each award.
|
|
309
|
+
* Default true when enabled.
|
|
310
|
+
*/
|
|
260
311
|
showNotifications?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* 'auto' — immediately opt the user in when identify() is called.
|
|
314
|
+
* 'explicit' — SDK surfaces a one-time consent prompt. Default 'explicit'.
|
|
315
|
+
*/
|
|
316
|
+
consentMode?: 'auto' | 'explicit';
|
|
317
|
+
/**
|
|
318
|
+
* P2: callback that returns a host-app JWT for server-side identity
|
|
319
|
+
* verification before monetary rewards are issued. Return null to skip
|
|
320
|
+
* verification for non-monetary actions.
|
|
321
|
+
*/
|
|
322
|
+
verifyUserToken?: () => Promise<string | null>;
|
|
323
|
+
/**
|
|
324
|
+
* @deprecated Superseded by server-side reward_webhooks table.
|
|
325
|
+
* Kept for backwards compatibility; has no effect from v0.10.0.
|
|
326
|
+
*/
|
|
261
327
|
webhookOnReward?: string;
|
|
262
328
|
}
|
|
329
|
+
interface MushiReputationResult {
|
|
330
|
+
totalPoints: number;
|
|
331
|
+
points30d: number;
|
|
332
|
+
reputation: number;
|
|
333
|
+
confirmedBugs: number;
|
|
334
|
+
totalReports: number;
|
|
335
|
+
}
|
|
336
|
+
interface MushiTierResult {
|
|
337
|
+
id: string;
|
|
338
|
+
slug: string;
|
|
339
|
+
displayName: string;
|
|
340
|
+
pointsThreshold: number;
|
|
341
|
+
perks: Record<string, unknown>;
|
|
342
|
+
}
|
|
343
|
+
interface MushiActivityEvent {
|
|
344
|
+
action: string;
|
|
345
|
+
metadata?: Record<string, unknown>;
|
|
346
|
+
}
|
|
263
347
|
type MushiReportCategory = 'bug' | 'slow' | 'visual' | 'confusing' | 'other';
|
|
264
348
|
type MushiReportStatus = 'pending' | 'submitted' | 'classified' | 'grouped' | 'fixing' | 'fixed' | 'dismissed';
|
|
265
349
|
interface MushiReport {
|
|
@@ -336,13 +420,21 @@ interface MushiBreadcrumb {
|
|
|
336
420
|
/**
|
|
337
421
|
* Coarse bucket for filtering / coloring in the report drawer.
|
|
338
422
|
* - `navigation` — route or url change
|
|
339
|
-
* - `ui.click` — user clicked a `[data-testid]` element
|
|
423
|
+
* - `ui.click` — user clicked a `[data-testid]` element (web SDK)
|
|
424
|
+
* - `ui.tap` — user tapped a `UIView` / Android `View` (native SDKs)
|
|
340
425
|
* - `console` — `console.error` / `console.warn` callsite
|
|
341
|
-
* - `xhr` / `fetch` — network request that errored or 4xx/5xx
|
|
426
|
+
* - `xhr` / `fetch` — network request that errored or 4xx/5xx (web SDK)
|
|
427
|
+
* - `network` — network failure on iOS / Android (native SDKs)
|
|
342
428
|
* - `lifecycle` — Mushi SDK init / open / submit / queue
|
|
343
429
|
* - `custom` — host called `Mushi.addBreadcrumb()`
|
|
430
|
+
*
|
|
431
|
+
* Admin tooling that filters by interaction should treat
|
|
432
|
+
* `ui.click` ∪ `ui.tap` as one bucket and `xhr` ∪ `fetch` ∪ `network`
|
|
433
|
+
* as one bucket. Native enums are platform-idiomatic (`tap` on touch
|
|
434
|
+
* devices, `network` because iOS/Android don't expose `XHR` / `fetch`
|
|
435
|
+
* separately) — every wire string is documented in the native READMEs.
|
|
344
436
|
*/
|
|
345
|
-
category: 'navigation' | 'ui.click' | 'console' | 'xhr' | 'fetch' | 'lifecycle' | 'custom';
|
|
437
|
+
category: 'navigation' | 'ui.click' | 'ui.tap' | 'console' | 'xhr' | 'fetch' | 'network' | 'lifecycle' | 'custom';
|
|
346
438
|
/**
|
|
347
439
|
* Severity — `info` is the default. `warning` / `error` map to a
|
|
348
440
|
* coloured pill in the drawer; the Triage LLM uses these to decide
|
|
@@ -706,6 +798,24 @@ interface MushiSDKInstance {
|
|
|
706
798
|
setTags(tags: Record<string, string | number | boolean>): void;
|
|
707
799
|
/** Remove a single tag, or all tags when called with no argument. */
|
|
708
800
|
clearTag(key?: string): void;
|
|
801
|
+
/**
|
|
802
|
+
* Returns the current user's reputation + legacy point totals from the
|
|
803
|
+
* reporter_reputation table. Available even when the rewards program is
|
|
804
|
+
* disabled (legacy surface).
|
|
805
|
+
*/
|
|
806
|
+
getReputation(): Promise<MushiReputationResult | null>;
|
|
807
|
+
/**
|
|
808
|
+
* Returns the current user's tier from the rewards program.
|
|
809
|
+
* Returns null when the user has not yet been identified or the project
|
|
810
|
+
* has rewards_enabled = false.
|
|
811
|
+
*/
|
|
812
|
+
getTier(): Promise<MushiTierResult | null>;
|
|
813
|
+
/**
|
|
814
|
+
* Manually record a host-defined activity event (e.g. 'lesson_completed').
|
|
815
|
+
* The SDK batches these and flushes to POST /v1/sdk/activity.
|
|
816
|
+
* No-op when rewards are disabled or the user has not opted in.
|
|
817
|
+
*/
|
|
818
|
+
recordActivity(action: string, metadata?: Record<string, unknown>): void;
|
|
709
819
|
}
|
|
710
820
|
interface MushiCaptureExceptionOptions {
|
|
711
821
|
/** Override the default `'bug'` category (e.g. `'slow'` for timeouts). */
|
|
@@ -769,6 +879,42 @@ interface MushiApiClient {
|
|
|
769
879
|
replyToReporterReport(reportId: string, reporterToken: string, body: string): Promise<MushiApiResponse<{
|
|
770
880
|
comment: MushiReporterComment;
|
|
771
881
|
}>>;
|
|
882
|
+
/**
|
|
883
|
+
* Submit a batch of activity events for the current user.
|
|
884
|
+
* Requires rewards to be enabled on the project.
|
|
885
|
+
*/
|
|
886
|
+
submitActivity(userId: string, events: MushiActivityEvent[], opts?: {
|
|
887
|
+
userTraits?: {
|
|
888
|
+
email?: string;
|
|
889
|
+
name?: string;
|
|
890
|
+
provider?: string;
|
|
891
|
+
};
|
|
892
|
+
reporterTokenHash?: string;
|
|
893
|
+
optedIn?: boolean;
|
|
894
|
+
/** P2: host-app JWT; when present the server attempts verifyHostJwt
|
|
895
|
+
* and updates end_users.jwt_verified_at if valid. Required for
|
|
896
|
+
* monetary payout eligibility. */
|
|
897
|
+
hostJwt?: string;
|
|
898
|
+
}): Promise<MushiApiResponse<{
|
|
899
|
+
accepted: number;
|
|
900
|
+
total: number;
|
|
901
|
+
}>>;
|
|
902
|
+
/** Fetch the current user's point totals (requires userId). */
|
|
903
|
+
getMyPoints(userId: string): Promise<MushiApiResponse<{
|
|
904
|
+
total_points: number;
|
|
905
|
+
points_30d: number;
|
|
906
|
+
points_lifetime: number;
|
|
907
|
+
tier: MushiTierResult | null;
|
|
908
|
+
}>>;
|
|
909
|
+
/** Fetch the current user's tier (requires userId). */
|
|
910
|
+
getMyTier(userId: string): Promise<MushiApiResponse<MushiTierResult | null>>;
|
|
911
|
+
/** Fetch the current user's activity history (requires userId). */
|
|
912
|
+
getMyHistory(userId: string, opts?: {
|
|
913
|
+
limit?: number;
|
|
914
|
+
}): Promise<MushiApiResponse<{
|
|
915
|
+
items: unknown[];
|
|
916
|
+
total: number;
|
|
917
|
+
}>>;
|
|
772
918
|
}
|
|
773
919
|
/**
|
|
774
920
|
* Wire shape of a single discovery event sent by the SDK to
|
|
@@ -1121,4 +1267,4 @@ declare function createLogger(options: LoggerOptions): Logger;
|
|
|
1121
1267
|
*/
|
|
1122
1268
|
declare const noopLogger: Logger;
|
|
1123
1269
|
|
|
1124
|
-
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 MushiApiCascadeConfig, type MushiApiClient, type MushiApiResponse, 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 MushiRewardsConfig, type MushiRuntimeSdkConfig, type MushiSDKInstance, type MushiSdkVersionInfo, type MushiSelectedElement, type MushiSentryConfig, type MushiSentryContext, 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, noopLogger, normaliseThrown, resolveRegionEndpoint, scrubPii };
|
|
1270
|
+
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 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, noopLogger, normaliseThrown, resolveRegionEndpoint, scrubPii };
|
package/dist/index.js
CHANGED
|
@@ -145,6 +145,53 @@ function createApiClient(options) {
|
|
|
145
145
|
reporterToken,
|
|
146
146
|
{ body }
|
|
147
147
|
);
|
|
148
|
+
},
|
|
149
|
+
// ─── Rewards program (P1) ──────────────────────────────────
|
|
150
|
+
async submitActivity(userId, events, opts) {
|
|
151
|
+
return request(
|
|
152
|
+
"POST",
|
|
153
|
+
"/v1/sdk/activity",
|
|
154
|
+
{
|
|
155
|
+
user_id: userId,
|
|
156
|
+
user_traits: opts?.userTraits,
|
|
157
|
+
opted_in: opts?.optedIn,
|
|
158
|
+
reporter_token_hash: opts?.reporterTokenHash,
|
|
159
|
+
// P2: JWT for monetary verification; omitted when null
|
|
160
|
+
...opts?.hostJwt ? { host_jwt: opts.hostJwt } : {},
|
|
161
|
+
events
|
|
162
|
+
},
|
|
163
|
+
1,
|
|
164
|
+
// best-effort, 1 retry
|
|
165
|
+
"discovery"
|
|
166
|
+
);
|
|
167
|
+
},
|
|
168
|
+
async getMyPoints(userId) {
|
|
169
|
+
return request(
|
|
170
|
+
"GET",
|
|
171
|
+
`/v1/sdk/me/points?userId=${encodeURIComponent(userId)}`,
|
|
172
|
+
void 0,
|
|
173
|
+
1,
|
|
174
|
+
"reporter-poll"
|
|
175
|
+
);
|
|
176
|
+
},
|
|
177
|
+
async getMyTier(userId) {
|
|
178
|
+
return request(
|
|
179
|
+
"GET",
|
|
180
|
+
`/v1/sdk/me/tier?userId=${encodeURIComponent(userId)}`,
|
|
181
|
+
void 0,
|
|
182
|
+
1,
|
|
183
|
+
"reporter-poll"
|
|
184
|
+
);
|
|
185
|
+
},
|
|
186
|
+
async getMyHistory(userId, opts) {
|
|
187
|
+
const qs = new URLSearchParams({ userId, ...opts?.limit ? { limit: String(opts.limit) } : {} });
|
|
188
|
+
return request(
|
|
189
|
+
"GET",
|
|
190
|
+
`/v1/sdk/me/history?${qs}`,
|
|
191
|
+
void 0,
|
|
192
|
+
1,
|
|
193
|
+
"reporter-poll"
|
|
194
|
+
);
|
|
148
195
|
}
|
|
149
196
|
};
|
|
150
197
|
}
|