mushi-mushi 0.8.15 → 1.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -14
- package/dist/angular.cjs +113 -0
- package/dist/angular.d.cts +95 -0
- package/dist/angular.d.ts +95 -0
- package/dist/angular.js +88 -0
- package/dist/bin.js +85 -0
- package/dist/core.cjs +24 -0
- package/dist/core.d.cts +10 -0
- package/dist/core.d.ts +10 -0
- package/dist/core.js +2 -0
- package/dist/headless.cjs +24 -0
- package/dist/headless.d.cts +1 -0
- package/dist/headless.d.ts +1 -0
- package/dist/headless.js +2 -0
- package/dist/i18n.cjs +24 -0
- package/dist/i18n.d.cts +1 -0
- package/dist/i18n.d.ts +1 -0
- package/dist/i18n.js +2 -0
- package/dist/index.cjs +24 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -84
- package/dist/node-express.cjs +24 -0
- package/dist/node-express.d.cts +1 -0
- package/dist/node-express.d.ts +1 -0
- package/dist/node-express.js +2 -0
- package/dist/node-fastify.cjs +24 -0
- package/dist/node-fastify.d.cts +1 -0
- package/dist/node-fastify.d.ts +1 -0
- package/dist/node-fastify.js +2 -0
- package/dist/node-hono.cjs +24 -0
- package/dist/node-hono.d.cts +1 -0
- package/dist/node-hono.d.ts +1 -0
- package/dist/node-hono.js +2 -0
- package/dist/node.cjs +24 -0
- package/dist/node.d.cts +1 -0
- package/dist/node.d.ts +1 -0
- package/dist/node.js +2 -0
- package/dist/otel.cjs +24 -0
- package/dist/otel.d.cts +1 -0
- package/dist/otel.d.ts +1 -0
- package/dist/otel.js +2 -0
- package/dist/react.cjs +318 -0
- package/dist/react.d.cts +153 -0
- package/dist/react.d.ts +153 -0
- package/dist/react.js +280 -0
- package/dist/svelte.cjs +83 -0
- package/dist/svelte.d.cts +87 -0
- package/dist/svelte.d.ts +87 -0
- package/dist/svelte.js +53 -0
- package/dist/test-utils.cjs +24 -0
- package/dist/test-utils.d.cts +1 -0
- package/dist/test-utils.d.ts +1 -0
- package/dist/test-utils.js +2 -0
- package/dist/vue.cjs +89 -0
- package/dist/vue.d.cts +25 -0
- package/dist/vue.d.ts +25 -0
- package/dist/vue.js +59 -0
- package/package.json +254 -5
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ npx mushi-mushi
|
|
|
12
12
|
|
|
13
13
|
**[See a sample diagnosis →](https://kensaur.us/mushi-mushi/docs/demo/diagnosis)** No signup, nothing to install.
|
|
14
14
|
|
|
15
|
-
<sub>`mushi-mushi` is the setup command. It adds
|
|
15
|
+
<sub>`mushi-mushi` is the one package you install: the setup command and the SDK. It adds Mushi Mushi to the app you already have: React, Next.js, Vue, Nuxt, Svelte, SvelteKit, Angular, React Native, Expo, Capacitor, Node or plain JavaScript. [Launcher docs](https://kensaur.us/mushi-mushi/docs/sdks/launcher)</sub>
|
|
16
16
|
|
|
17
17
|
[](https://www.npmjs.com/package/mushi-mushi)
|
|
18
18
|
[](https://www.npmjs.com/package/mushi-mushi)
|
|
@@ -47,11 +47,11 @@ Who it's for and where each group starts: [who it's for](https://kensaur.us/mush
|
|
|
47
47
|
npx mushi-mushi
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
The wizard signs you in through your browser, detects your framework, installs
|
|
50
|
+
The wizard signs you in through your browser, detects your framework, installs `mushi-mushi` (React Native and Capacitor get their native package), writes env vars to `.env.local` (with the right prefix for your framework, such as `NEXT_PUBLIC_`, `NUXT_PUBLIC_`, `VITE_`, `EXPO_PUBLIC_`, `REACT_APP_` or `PUBLIC_`, or bare `MUSHI_*` names for servers and bare React Native), prints the snippet to paste into your app, and offers to send a test report. It never overwrites an existing env var and never edits your source.
|
|
51
51
|
|
|
52
52
|
```tsx
|
|
53
53
|
// After the wizard runs (React + Vite example, src/main.tsx):
|
|
54
|
-
import { MushiProvider } from '
|
|
54
|
+
import { MushiProvider } from 'mushi-mushi/react'
|
|
55
55
|
|
|
56
56
|
createRoot(document.getElementById('root')!).render(
|
|
57
57
|
<MushiProvider config={{
|
|
@@ -139,21 +139,23 @@ Editors connect over MCP: Cursor, Claude Code, VS Code, Windsurf, Cline, Claude
|
|
|
139
139
|
|
|
140
140
|
## Framework support
|
|
141
141
|
|
|
142
|
-
| Framework | Install
|
|
143
|
-
| ------------------------------- |
|
|
144
|
-
| React, Next.js, Create React App, Remix |
|
|
145
|
-
| Vue 3 / Nuxt |
|
|
146
|
-
| Svelte / SvelteKit |
|
|
147
|
-
| Angular 17+ |
|
|
148
|
-
|
|
|
149
|
-
|
|
|
150
|
-
|
|
|
151
|
-
|
|
|
142
|
+
| Framework | Install | Import from |
|
|
143
|
+
| ------------------------------- | ----------------------- | --------------------------------------------- |
|
|
144
|
+
| React, Next.js, Create React App, Remix | `mushi-mushi` | `mushi-mushi/react` |
|
|
145
|
+
| Vue 3 / Nuxt | `mushi-mushi` | `mushi-mushi/vue` |
|
|
146
|
+
| Svelte / SvelteKit | `mushi-mushi` | `mushi-mushi/svelte` |
|
|
147
|
+
| Angular 17+ | `mushi-mushi` | `mushi-mushi/angular` |
|
|
148
|
+
| Astro, Solid, plain JavaScript | `mushi-mushi` | `mushi-mushi` |
|
|
149
|
+
| Node (Express / Fastify / Hono) | `mushi-mushi` | `mushi-mushi/node` (server-side errors), `mushi-mushi/node/express`, `/fastify`, `/hono` |
|
|
150
|
+
| React Native / Expo | `@mushi-mushi/react-native` | `@mushi-mushi/react-native` (Metro) |
|
|
151
|
+
| Capacitor / Ionic | `@mushi-mushi/capacitor` | `@mushi-mushi/capacitor` (native code registers as a top-level dependency) |
|
|
152
152
|
| Flutter / Dart | Git dependency, a preview, not on pub.dev yet ([how](https://github.com/kensaurus/mushi-mushi/tree/master/packages/flutter#install)) |
|
|
153
153
|
| iOS native (Swift) | SwiftPM from the repo, a preview, not tagged yet ([how](https://github.com/kensaurus/mushi-mushi/tree/master/packages/ios#install)) |
|
|
154
154
|
| Android native (Kotlin/Java) | Build from source, a preview, not on Maven Central yet ([how](https://github.com/kensaurus/mushi-mushi/tree/master/packages/android#install)) |
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
Prefer to skip the wizard? `npm install mushi-mushi` and wire it up by hand. Your framework (React, Vue, Svelte, Angular, Express…) is an optional peer: `mushi-mushi` never installs one you don't use. More entry points: `mushi-mushi/headless`, `mushi-mushi/i18n`, `mushi-mushi/otel`, `mushi-mushi/test-utils` and `mushi-mushi/core` (types).
|
|
157
|
+
|
|
158
|
+
Already on `@mushi-mushi/react`, `@mushi-mushi/web` or another `@mushi-mushi/*` SDK? It keeps working and keeps getting updates. `mushi-mushi` ships the same code; switch when you like by changing the import path.
|
|
157
159
|
|
|
158
160
|
---
|
|
159
161
|
|
package/dist/angular.cjs
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/angular.ts
|
|
21
|
+
var angular_exports = {};
|
|
22
|
+
__export(angular_exports, {
|
|
23
|
+
MUSHI_CONFIG: () => MUSHI_CONFIG,
|
|
24
|
+
MushiErrorHandler: () => MushiErrorHandler,
|
|
25
|
+
MushiService: () => MushiService,
|
|
26
|
+
provideMushi: () => provideMushi,
|
|
27
|
+
provideMushiAngular: () => provideMushiAngular
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(angular_exports);
|
|
30
|
+
|
|
31
|
+
// ../angular/dist/index.js
|
|
32
|
+
var import_core = require("@angular/core");
|
|
33
|
+
var import_web = require("@mushi-mushi/web");
|
|
34
|
+
var MUSHI_CONFIG = new import_core.InjectionToken("MushiConfig");
|
|
35
|
+
var isBrowser = () => typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined" && typeof globalThis.document !== "undefined";
|
|
36
|
+
var MushiService = class {
|
|
37
|
+
constructor(config) {
|
|
38
|
+
if (config && isBrowser()) {
|
|
39
|
+
import_web.Mushi.init(config);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
report(data) {
|
|
43
|
+
return import_web.Mushi.getInstance()?.captureEvent({
|
|
44
|
+
description: data.description,
|
|
45
|
+
category: data.category,
|
|
46
|
+
metadata: data.metadata
|
|
47
|
+
}) ?? Promise.resolve(null);
|
|
48
|
+
}
|
|
49
|
+
/** @deprecated Use report() — kept for backwards compatibility */
|
|
50
|
+
async submitReport(data) {
|
|
51
|
+
await this.report(data);
|
|
52
|
+
}
|
|
53
|
+
/** Attach the signed-in user to reports and analytics (same as `Mushi.identify()`). */
|
|
54
|
+
identify(userId, traits) {
|
|
55
|
+
import_web.Mushi.getInstance()?.identify(userId, traits);
|
|
56
|
+
}
|
|
57
|
+
captureError(error, context) {
|
|
58
|
+
import_web.Mushi.getInstance()?.captureException(error, { metadata: context }).catch(() => {
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var MushiErrorHandler = class extends import_core.ErrorHandler {
|
|
63
|
+
service;
|
|
64
|
+
constructor(service) {
|
|
65
|
+
super();
|
|
66
|
+
this.service = service;
|
|
67
|
+
}
|
|
68
|
+
handleError(error) {
|
|
69
|
+
this.service.captureError(error);
|
|
70
|
+
super.handleError(error);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
function mushiProviders(config, serviceFactory) {
|
|
74
|
+
return [
|
|
75
|
+
{ provide: MUSHI_CONFIG, useValue: config },
|
|
76
|
+
{ provide: MushiService, useFactory: serviceFactory, deps: [MUSHI_CONFIG] },
|
|
77
|
+
{ provide: MushiErrorHandler, useFactory: (service) => new MushiErrorHandler(service), deps: [MushiService] },
|
|
78
|
+
{ provide: import_core.ErrorHandler, useExisting: MushiErrorHandler },
|
|
79
|
+
// Angular resolves ErrorHandler lazily, on the first error, so nothing
|
|
80
|
+
// would construct MushiService (and call Mushi.init) at startup. The
|
|
81
|
+
// environment initializer does. It is the v14+ token rather than
|
|
82
|
+
// provideEnvironmentInitializer() (v19+) so the >=17 peer range holds.
|
|
83
|
+
{
|
|
84
|
+
provide: import_core.ENVIRONMENT_INITIALIZER,
|
|
85
|
+
multi: true,
|
|
86
|
+
useValue: () => {
|
|
87
|
+
(0, import_core.inject)(MushiService);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
function provideMushi(config) {
|
|
93
|
+
let shared = null;
|
|
94
|
+
const serviceFor = (cfg) => shared ??= new MushiService(cfg);
|
|
95
|
+
let legacyHandler = null;
|
|
96
|
+
const providers = (0, import_core.makeEnvironmentProviders)(mushiProviders(config, serviceFor));
|
|
97
|
+
Object.defineProperties(providers, {
|
|
98
|
+
service: { get: () => serviceFor(config) },
|
|
99
|
+
errorHandler: { get: () => legacyHandler ??= new MushiErrorHandler(serviceFor(config)) }
|
|
100
|
+
});
|
|
101
|
+
return providers;
|
|
102
|
+
}
|
|
103
|
+
function provideMushiAngular(config) {
|
|
104
|
+
return mushiProviders(config, (cfg) => new MushiService(cfg));
|
|
105
|
+
}
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
108
|
+
MUSHI_CONFIG,
|
|
109
|
+
MushiErrorHandler,
|
|
110
|
+
MushiService,
|
|
111
|
+
provideMushi,
|
|
112
|
+
provideMushiAngular
|
|
113
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { InjectionToken, EnvironmentProviders, ErrorHandler, Provider } from '@angular/core';
|
|
2
|
+
import { MushiConfig, MushiReportCategory } from '@mushi-mushi/core';
|
|
3
|
+
export { MushiConfig, MushiReportCategory, MushiSDKInstance } from '@mushi-mushi/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* FILE: packages/angular/src/index.ts
|
|
7
|
+
* PURPOSE: Angular SDK for Mushi Mushi — delegates entirely to @mushi-mushi/web
|
|
8
|
+
* so offline queue, PII scrubber, breadcrumb buffer, rate limiter,
|
|
9
|
+
* INP capture, beforeSendFeedback, and onCrashedLastRun are all
|
|
10
|
+
* inherited automatically. Mirrors the React provider pattern.
|
|
11
|
+
*
|
|
12
|
+
* Round 8 (2026-05-21):
|
|
13
|
+
* - `MushiConfig` is now the canonical core type (no narrow re-shape).
|
|
14
|
+
* - SSR guard around `Mushi.init` so Angular Universal / @nguniversal
|
|
15
|
+
* prerender doesn't reach for `window` on the server.
|
|
16
|
+
*
|
|
17
|
+
* No decorators, on purpose. This package is built with tsup, not ng-packagr,
|
|
18
|
+
* so an `@Injectable()` class ships as a runtime decorator call whose factory
|
|
19
|
+
* Angular must compile with `@angular/compiler` — which AOT apps (every
|
|
20
|
+
* `ng build`) never load, so DI threw "needs to be compiled using the JIT
|
|
21
|
+
* compiler". Every provider below is an explicit factory with explicit
|
|
22
|
+
* `deps`, which Angular resolves without compiling anything.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
declare const MUSHI_CONFIG: InjectionToken<MushiConfig>;
|
|
26
|
+
/**
|
|
27
|
+
* App-wide Mushi handle. Provided by `provideMushi()` / `provideMushiAngular()`
|
|
28
|
+
* and read with `inject(MushiService)`. Do not list the class itself in a
|
|
29
|
+
* `providers` array: it has no compiled factory, so use the provider functions.
|
|
30
|
+
*/
|
|
31
|
+
declare class MushiService {
|
|
32
|
+
constructor(config?: MushiConfig);
|
|
33
|
+
report(data: {
|
|
34
|
+
description: string;
|
|
35
|
+
category: MushiReportCategory;
|
|
36
|
+
metadata?: Record<string, unknown>;
|
|
37
|
+
}): Promise<string | null>;
|
|
38
|
+
/** @deprecated Use report() — kept for backwards compatibility */
|
|
39
|
+
submitReport(data: {
|
|
40
|
+
description: string;
|
|
41
|
+
category: MushiReportCategory;
|
|
42
|
+
metadata?: Record<string, unknown>;
|
|
43
|
+
}): Promise<void>;
|
|
44
|
+
/** Attach the signed-in user to reports and analytics (same as `Mushi.identify()`). */
|
|
45
|
+
identify(userId: string, traits?: {
|
|
46
|
+
email?: string;
|
|
47
|
+
name?: string;
|
|
48
|
+
[k: string]: unknown;
|
|
49
|
+
}): void;
|
|
50
|
+
captureError(error: unknown, context?: Record<string, unknown>): void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Angular `ErrorHandler` that reports uncaught errors to Mushi, then logs them
|
|
54
|
+
* exactly like Angular's default handler so the console output does not change.
|
|
55
|
+
*/
|
|
56
|
+
declare class MushiErrorHandler extends ErrorHandler {
|
|
57
|
+
private service;
|
|
58
|
+
constructor(service: MushiService);
|
|
59
|
+
handleError(error: unknown): void;
|
|
60
|
+
}
|
|
61
|
+
/** `provideMushi()`'s return value: environment providers, plus the original `{ service, errorHandler }` accessors. */
|
|
62
|
+
type MushiEnvironmentProviders = EnvironmentProviders & {
|
|
63
|
+
/** @deprecated Inject `MushiService` instead. Same instance DI hands out. */
|
|
64
|
+
readonly service: MushiService;
|
|
65
|
+
/** @deprecated Provided as Angular's `ErrorHandler` automatically. */
|
|
66
|
+
readonly errorHandler: MushiErrorHandler;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* App-level setup for `bootstrapApplication` (or `NgModule.providers`):
|
|
70
|
+
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* bootstrapApplication(AppComponent, {
|
|
73
|
+
* providers: [provideMushi({ projectId: '…', apiKey: '…' })],
|
|
74
|
+
* })
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* Provides `MushiService`, installs `MushiErrorHandler` as Angular's
|
|
78
|
+
* `ErrorHandler`, and initialises the SDK at startup (browser only).
|
|
79
|
+
*/
|
|
80
|
+
declare function provideMushi(config: MushiConfig): MushiEnvironmentProviders;
|
|
81
|
+
/**
|
|
82
|
+
* The same providers as a plain `Provider[]`, for spreading:
|
|
83
|
+
*
|
|
84
|
+
* ```ts
|
|
85
|
+
* bootstrapApplication(AppComponent, {
|
|
86
|
+
* providers: [...provideMushiAngular({ projectId: '…', apiKey: '…' })],
|
|
87
|
+
* })
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* `MushiService` reads `MUSHI_CONFIG` through DI, so SSR-aware platforms
|
|
91
|
+
* (Angular Universal) can override it per request.
|
|
92
|
+
*/
|
|
93
|
+
declare function provideMushiAngular(config: MushiConfig): Provider[];
|
|
94
|
+
|
|
95
|
+
export { MUSHI_CONFIG, type MushiEnvironmentProviders, MushiErrorHandler, MushiService, provideMushi, provideMushiAngular };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { InjectionToken, EnvironmentProviders, ErrorHandler, Provider } from '@angular/core';
|
|
2
|
+
import { MushiConfig, MushiReportCategory } from '@mushi-mushi/core';
|
|
3
|
+
export { MushiConfig, MushiReportCategory, MushiSDKInstance } from '@mushi-mushi/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* FILE: packages/angular/src/index.ts
|
|
7
|
+
* PURPOSE: Angular SDK for Mushi Mushi — delegates entirely to @mushi-mushi/web
|
|
8
|
+
* so offline queue, PII scrubber, breadcrumb buffer, rate limiter,
|
|
9
|
+
* INP capture, beforeSendFeedback, and onCrashedLastRun are all
|
|
10
|
+
* inherited automatically. Mirrors the React provider pattern.
|
|
11
|
+
*
|
|
12
|
+
* Round 8 (2026-05-21):
|
|
13
|
+
* - `MushiConfig` is now the canonical core type (no narrow re-shape).
|
|
14
|
+
* - SSR guard around `Mushi.init` so Angular Universal / @nguniversal
|
|
15
|
+
* prerender doesn't reach for `window` on the server.
|
|
16
|
+
*
|
|
17
|
+
* No decorators, on purpose. This package is built with tsup, not ng-packagr,
|
|
18
|
+
* so an `@Injectable()` class ships as a runtime decorator call whose factory
|
|
19
|
+
* Angular must compile with `@angular/compiler` — which AOT apps (every
|
|
20
|
+
* `ng build`) never load, so DI threw "needs to be compiled using the JIT
|
|
21
|
+
* compiler". Every provider below is an explicit factory with explicit
|
|
22
|
+
* `deps`, which Angular resolves without compiling anything.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
declare const MUSHI_CONFIG: InjectionToken<MushiConfig>;
|
|
26
|
+
/**
|
|
27
|
+
* App-wide Mushi handle. Provided by `provideMushi()` / `provideMushiAngular()`
|
|
28
|
+
* and read with `inject(MushiService)`. Do not list the class itself in a
|
|
29
|
+
* `providers` array: it has no compiled factory, so use the provider functions.
|
|
30
|
+
*/
|
|
31
|
+
declare class MushiService {
|
|
32
|
+
constructor(config?: MushiConfig);
|
|
33
|
+
report(data: {
|
|
34
|
+
description: string;
|
|
35
|
+
category: MushiReportCategory;
|
|
36
|
+
metadata?: Record<string, unknown>;
|
|
37
|
+
}): Promise<string | null>;
|
|
38
|
+
/** @deprecated Use report() — kept for backwards compatibility */
|
|
39
|
+
submitReport(data: {
|
|
40
|
+
description: string;
|
|
41
|
+
category: MushiReportCategory;
|
|
42
|
+
metadata?: Record<string, unknown>;
|
|
43
|
+
}): Promise<void>;
|
|
44
|
+
/** Attach the signed-in user to reports and analytics (same as `Mushi.identify()`). */
|
|
45
|
+
identify(userId: string, traits?: {
|
|
46
|
+
email?: string;
|
|
47
|
+
name?: string;
|
|
48
|
+
[k: string]: unknown;
|
|
49
|
+
}): void;
|
|
50
|
+
captureError(error: unknown, context?: Record<string, unknown>): void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Angular `ErrorHandler` that reports uncaught errors to Mushi, then logs them
|
|
54
|
+
* exactly like Angular's default handler so the console output does not change.
|
|
55
|
+
*/
|
|
56
|
+
declare class MushiErrorHandler extends ErrorHandler {
|
|
57
|
+
private service;
|
|
58
|
+
constructor(service: MushiService);
|
|
59
|
+
handleError(error: unknown): void;
|
|
60
|
+
}
|
|
61
|
+
/** `provideMushi()`'s return value: environment providers, plus the original `{ service, errorHandler }` accessors. */
|
|
62
|
+
type MushiEnvironmentProviders = EnvironmentProviders & {
|
|
63
|
+
/** @deprecated Inject `MushiService` instead. Same instance DI hands out. */
|
|
64
|
+
readonly service: MushiService;
|
|
65
|
+
/** @deprecated Provided as Angular's `ErrorHandler` automatically. */
|
|
66
|
+
readonly errorHandler: MushiErrorHandler;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* App-level setup for `bootstrapApplication` (or `NgModule.providers`):
|
|
70
|
+
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* bootstrapApplication(AppComponent, {
|
|
73
|
+
* providers: [provideMushi({ projectId: '…', apiKey: '…' })],
|
|
74
|
+
* })
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* Provides `MushiService`, installs `MushiErrorHandler` as Angular's
|
|
78
|
+
* `ErrorHandler`, and initialises the SDK at startup (browser only).
|
|
79
|
+
*/
|
|
80
|
+
declare function provideMushi(config: MushiConfig): MushiEnvironmentProviders;
|
|
81
|
+
/**
|
|
82
|
+
* The same providers as a plain `Provider[]`, for spreading:
|
|
83
|
+
*
|
|
84
|
+
* ```ts
|
|
85
|
+
* bootstrapApplication(AppComponent, {
|
|
86
|
+
* providers: [...provideMushiAngular({ projectId: '…', apiKey: '…' })],
|
|
87
|
+
* })
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* `MushiService` reads `MUSHI_CONFIG` through DI, so SSR-aware platforms
|
|
91
|
+
* (Angular Universal) can override it per request.
|
|
92
|
+
*/
|
|
93
|
+
declare function provideMushiAngular(config: MushiConfig): Provider[];
|
|
94
|
+
|
|
95
|
+
export { MUSHI_CONFIG, type MushiEnvironmentProviders, MushiErrorHandler, MushiService, provideMushi, provideMushiAngular };
|
package/dist/angular.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// ../angular/dist/index.js
|
|
2
|
+
import {
|
|
3
|
+
ENVIRONMENT_INITIALIZER,
|
|
4
|
+
ErrorHandler,
|
|
5
|
+
InjectionToken,
|
|
6
|
+
inject,
|
|
7
|
+
makeEnvironmentProviders
|
|
8
|
+
} from "@angular/core";
|
|
9
|
+
import { Mushi } from "@mushi-mushi/web";
|
|
10
|
+
var MUSHI_CONFIG = new InjectionToken("MushiConfig");
|
|
11
|
+
var isBrowser = () => typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined" && typeof globalThis.document !== "undefined";
|
|
12
|
+
var MushiService = class {
|
|
13
|
+
constructor(config) {
|
|
14
|
+
if (config && isBrowser()) {
|
|
15
|
+
Mushi.init(config);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
report(data) {
|
|
19
|
+
return Mushi.getInstance()?.captureEvent({
|
|
20
|
+
description: data.description,
|
|
21
|
+
category: data.category,
|
|
22
|
+
metadata: data.metadata
|
|
23
|
+
}) ?? Promise.resolve(null);
|
|
24
|
+
}
|
|
25
|
+
/** @deprecated Use report() — kept for backwards compatibility */
|
|
26
|
+
async submitReport(data) {
|
|
27
|
+
await this.report(data);
|
|
28
|
+
}
|
|
29
|
+
/** Attach the signed-in user to reports and analytics (same as `Mushi.identify()`). */
|
|
30
|
+
identify(userId, traits) {
|
|
31
|
+
Mushi.getInstance()?.identify(userId, traits);
|
|
32
|
+
}
|
|
33
|
+
captureError(error, context) {
|
|
34
|
+
Mushi.getInstance()?.captureException(error, { metadata: context }).catch(() => {
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var MushiErrorHandler = class extends ErrorHandler {
|
|
39
|
+
service;
|
|
40
|
+
constructor(service) {
|
|
41
|
+
super();
|
|
42
|
+
this.service = service;
|
|
43
|
+
}
|
|
44
|
+
handleError(error) {
|
|
45
|
+
this.service.captureError(error);
|
|
46
|
+
super.handleError(error);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
function mushiProviders(config, serviceFactory) {
|
|
50
|
+
return [
|
|
51
|
+
{ provide: MUSHI_CONFIG, useValue: config },
|
|
52
|
+
{ provide: MushiService, useFactory: serviceFactory, deps: [MUSHI_CONFIG] },
|
|
53
|
+
{ provide: MushiErrorHandler, useFactory: (service) => new MushiErrorHandler(service), deps: [MushiService] },
|
|
54
|
+
{ provide: ErrorHandler, useExisting: MushiErrorHandler },
|
|
55
|
+
// Angular resolves ErrorHandler lazily, on the first error, so nothing
|
|
56
|
+
// would construct MushiService (and call Mushi.init) at startup. The
|
|
57
|
+
// environment initializer does. It is the v14+ token rather than
|
|
58
|
+
// provideEnvironmentInitializer() (v19+) so the >=17 peer range holds.
|
|
59
|
+
{
|
|
60
|
+
provide: ENVIRONMENT_INITIALIZER,
|
|
61
|
+
multi: true,
|
|
62
|
+
useValue: () => {
|
|
63
|
+
inject(MushiService);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
function provideMushi(config) {
|
|
69
|
+
let shared = null;
|
|
70
|
+
const serviceFor = (cfg) => shared ??= new MushiService(cfg);
|
|
71
|
+
let legacyHandler = null;
|
|
72
|
+
const providers = makeEnvironmentProviders(mushiProviders(config, serviceFor));
|
|
73
|
+
Object.defineProperties(providers, {
|
|
74
|
+
service: { get: () => serviceFor(config) },
|
|
75
|
+
errorHandler: { get: () => legacyHandler ??= new MushiErrorHandler(serviceFor(config)) }
|
|
76
|
+
});
|
|
77
|
+
return providers;
|
|
78
|
+
}
|
|
79
|
+
function provideMushiAngular(config) {
|
|
80
|
+
return mushiProviders(config, (cfg) => new MushiService(cfg));
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
MUSHI_CONFIG,
|
|
84
|
+
MushiErrorHandler,
|
|
85
|
+
MushiService,
|
|
86
|
+
provideMushi,
|
|
87
|
+
provideMushiAngular
|
|
88
|
+
};
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/bin.ts
|
|
4
|
+
import { spawnSync } from "child_process";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
import { runInit } from "@mushi-mushi/cli/init";
|
|
7
|
+
import {
|
|
8
|
+
parseArgs,
|
|
9
|
+
assertNodeVersion,
|
|
10
|
+
FLAGS_HELP
|
|
11
|
+
} from "@mushi-mushi/cli/wizard-args";
|
|
12
|
+
var VERSION = true ? "1.35.0" : "0.0.0-dev";
|
|
13
|
+
var BIN = "mushi-mushi";
|
|
14
|
+
var ISSUES_URL = "https://github.com/kensaurus/mushi-mushi/issues";
|
|
15
|
+
var HELP = `mushi-mushi \u2014 bug-reporting SDK launcher
|
|
16
|
+
|
|
17
|
+
Usage:
|
|
18
|
+
npx mushi-mushi run the setup wizard (interactive)
|
|
19
|
+
npx mushi-mushi --yes same, taking the defaults (required in CI and AI-agent shells)
|
|
20
|
+
npx mushi-mushi init same, with optional flags
|
|
21
|
+
|
|
22
|
+
Other commands (setup, status, reports, deploy, test, login, config, ...)
|
|
23
|
+
are forwarded to @mushi-mushi/cli, e.g. \`npx mushi-mushi setup --ide cursor\`.
|
|
24
|
+
|
|
25
|
+
${FLAGS_HELP}`;
|
|
26
|
+
function forwardToCli(argv) {
|
|
27
|
+
const cliBin = fileURLToPath(import.meta.resolve("@mushi-mushi/cli"));
|
|
28
|
+
const result = spawnSync(process.execPath, [cliBin, ...argv], { stdio: "inherit" });
|
|
29
|
+
if (result.error) {
|
|
30
|
+
process.stderr.write(`${BIN}: could not start @mushi-mushi/cli (${result.error.message})
|
|
31
|
+
`);
|
|
32
|
+
} else if (result.signal) {
|
|
33
|
+
process.stderr.write(`${BIN}: @mushi-mushi/cli was stopped by ${result.signal}
|
|
34
|
+
`);
|
|
35
|
+
}
|
|
36
|
+
process.exit(result.status ?? 1);
|
|
37
|
+
}
|
|
38
|
+
async function main() {
|
|
39
|
+
assertNodeVersion(BIN);
|
|
40
|
+
const rawArgs = process.argv.slice(2);
|
|
41
|
+
const first = rawArgs[0];
|
|
42
|
+
if (first !== void 0 && first !== "init" && !first.startsWith("-")) {
|
|
43
|
+
forwardToCli(rawArgs);
|
|
44
|
+
}
|
|
45
|
+
let parsed;
|
|
46
|
+
try {
|
|
47
|
+
parsed = parseArgs(rawArgs);
|
|
48
|
+
} catch (err) {
|
|
49
|
+
process.stderr.write(`${err instanceof Error ? err.message : String(err)}
|
|
50
|
+
`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
if (parsed.showHelp) {
|
|
54
|
+
process.stdout.write(HELP + "\n");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (parsed.showVersion) {
|
|
58
|
+
process.stdout.write(VERSION + "\n");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
await runInit({
|
|
62
|
+
projectId: parsed.projectId,
|
|
63
|
+
apiKey: parsed.apiKey,
|
|
64
|
+
framework: parsed.framework,
|
|
65
|
+
skipInstall: parsed.skipInstall,
|
|
66
|
+
yes: parsed.yes,
|
|
67
|
+
cwd: parsed.cwd,
|
|
68
|
+
endpoint: parsed.endpoint,
|
|
69
|
+
sendTestReport: parsed.skipTestReport ? false : void 0,
|
|
70
|
+
audit: parsed.audit
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
main().catch((err) => {
|
|
74
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
75
|
+
process.stderr.write(`
|
|
76
|
+
${BIN}: ${message}
|
|
77
|
+
`);
|
|
78
|
+
if (process.env.DEBUG?.includes("mushi") && err instanceof Error && err.stack) {
|
|
79
|
+
process.stderr.write(err.stack + "\n");
|
|
80
|
+
}
|
|
81
|
+
process.stderr.write(`
|
|
82
|
+
If this is a bug, please report it at ${ISSUES_URL}
|
|
83
|
+
`);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
});
|
package/dist/core.cjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/core.ts
|
|
18
|
+
var core_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(core_exports);
|
|
20
|
+
__reExport(core_exports, require("@mushi-mushi/core"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@mushi-mushi/core")
|
|
24
|
+
});
|
package/dist/core.d.cts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from '@mushi-mushi/core';
|
|
2
|
+
import '@mushi-mushi/web/headless';
|
|
3
|
+
import '@mushi-mushi/web/i18n';
|
|
4
|
+
import '@mushi-mushi/web';
|
|
5
|
+
import '@mushi-mushi/node/express';
|
|
6
|
+
import '@mushi-mushi/node/fastify';
|
|
7
|
+
import '@mushi-mushi/node/hono';
|
|
8
|
+
import '@mushi-mushi/node';
|
|
9
|
+
import '@mushi-mushi/web/otel';
|
|
10
|
+
import '@mushi-mushi/web/test-utils';
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from '@mushi-mushi/core';
|
|
2
|
+
import '@mushi-mushi/web/headless';
|
|
3
|
+
import '@mushi-mushi/web/i18n';
|
|
4
|
+
import '@mushi-mushi/web';
|
|
5
|
+
import '@mushi-mushi/node/express';
|
|
6
|
+
import '@mushi-mushi/node/fastify';
|
|
7
|
+
import '@mushi-mushi/node/hono';
|
|
8
|
+
import '@mushi-mushi/node';
|
|
9
|
+
import '@mushi-mushi/web/otel';
|
|
10
|
+
import '@mushi-mushi/web/test-utils';
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/headless.ts
|
|
18
|
+
var headless_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(headless_exports);
|
|
20
|
+
__reExport(headless_exports, require("@mushi-mushi/web/headless"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@mushi-mushi/web/headless")
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@mushi-mushi/web/headless';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@mushi-mushi/web/headless';
|
package/dist/headless.js
ADDED
package/dist/i18n.cjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/i18n.ts
|
|
18
|
+
var i18n_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(i18n_exports);
|
|
20
|
+
__reExport(i18n_exports, require("@mushi-mushi/web/i18n"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@mushi-mushi/web/i18n")
|
|
24
|
+
});
|
package/dist/i18n.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@mushi-mushi/web/i18n';
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@mushi-mushi/web/i18n';
|
package/dist/i18n.js
ADDED