@mushi-mushi/core 1.29.0 → 1.31.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 +1 -1
- package/dist/index.cjs +25 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -1857
- package/dist/index.d.ts +27 -1857
- package/dist/index.js +25 -36
- package/dist/index.js.map +1 -1
- package/dist/reporter-channels.cjs +42 -0
- package/dist/reporter-channels.cjs.map +1 -0
- package/dist/reporter-channels.d.cts +1 -0
- package/dist/reporter-channels.d.ts +1 -0
- package/dist/reporter-channels.js +39 -0
- package/dist/reporter-channels.js.map +1 -0
- package/dist/reporter-ui.cjs +574 -0
- package/dist/reporter-ui.cjs.map +1 -0
- package/dist/reporter-ui.d.cts +189 -0
- package/dist/reporter-ui.d.ts +189 -0
- package/dist/reporter-ui.js +551 -0
- package/dist/reporter-ui.js.map +1 -0
- package/dist/types-0j5BJ3aC.d.cts +2100 -0
- package/dist/types-0j5BJ3aC.d.ts +2100 -0
- package/package.json +31 -1
package/README.md
CHANGED
|
@@ -141,4 +141,4 @@ MIT
|
|
|
141
141
|
<!-- mushi-readme-stats-footer -->
|
|
142
142
|
---
|
|
143
143
|
|
|
144
|
-
<sub>Monorepo scale (July 2026):
|
|
144
|
+
<sub>Monorepo scale (July 2026): 64 edge functions · 410 SQL migrations · 13 outbound plugins · 11 inbound adapters · 19 pipeline agents. Canonical counts: <a href="https://github.com/kensaurus/mushi-mushi/blob/master/docs/stats.md">docs/stats.md</a> · <code>pnpm docs-stats</code></sub>
|
package/dist/index.cjs
CHANGED
|
@@ -232,7 +232,8 @@ function createApiClient(options) {
|
|
|
232
232
|
if (cbFailures >= cbThreshold) cbOpenUntil = Date.now() + cbCooldownMs;
|
|
233
233
|
};
|
|
234
234
|
async function request(method, path, body, retries = maxRetries, internalKind, extraHeaders) {
|
|
235
|
-
|
|
235
|
+
const tracked = internalKind !== "reporter-poll";
|
|
236
|
+
if (tracked && cbIsOpen()) {
|
|
236
237
|
return { ok: false, error: { code: "CIRCUIT_OPEN", message: "Endpoint temporarily unavailable; retrying later." } };
|
|
237
238
|
}
|
|
238
239
|
const url = `${baseUrl}${path}`;
|
|
@@ -251,7 +252,7 @@ function createApiClient(options) {
|
|
|
251
252
|
...extraHeaders
|
|
252
253
|
};
|
|
253
254
|
const serialized = body ? JSON.stringify(body) : void 0;
|
|
254
|
-
if (serialized && method !== "GET") {
|
|
255
|
+
if (serialized && method !== "GET" && internalKind !== "reporter-poll") {
|
|
255
256
|
lastOutbound = { url, headers, body: serialized, path };
|
|
256
257
|
}
|
|
257
258
|
try {
|
|
@@ -291,8 +292,10 @@ function createApiClient(options) {
|
|
|
291
292
|
await sleep(retryAfterMs ?? getBackoffDelay(maxRetries - retries));
|
|
292
293
|
return request(method, path, body, retries - 1, internalKind, extraHeaders);
|
|
293
294
|
}
|
|
294
|
-
if (
|
|
295
|
-
|
|
295
|
+
if (tracked) {
|
|
296
|
+
if (unusable) cbRecordUnreachable();
|
|
297
|
+
else cbRecordReachable();
|
|
298
|
+
}
|
|
296
299
|
return {
|
|
297
300
|
ok: false,
|
|
298
301
|
error: {
|
|
@@ -304,7 +307,7 @@ function createApiClient(options) {
|
|
|
304
307
|
}
|
|
305
308
|
const payload = await response.json();
|
|
306
309
|
const data = payload && typeof payload === "object" && "ok" in payload && "data" in payload ? payload.data : payload;
|
|
307
|
-
cbRecordReachable();
|
|
310
|
+
if (tracked) cbRecordReachable();
|
|
308
311
|
return { ok: true, data };
|
|
309
312
|
} catch (error) {
|
|
310
313
|
clearTimeout(timer);
|
|
@@ -312,7 +315,7 @@ function createApiClient(options) {
|
|
|
312
315
|
await sleep(getBackoffDelay(maxRetries - retries));
|
|
313
316
|
return request(method, path, body, retries - 1, internalKind, extraHeaders);
|
|
314
317
|
}
|
|
315
|
-
cbRecordUnreachable();
|
|
318
|
+
if (tracked) cbRecordUnreachable();
|
|
316
319
|
return {
|
|
317
320
|
ok: false,
|
|
318
321
|
error: {
|
|
@@ -323,39 +326,17 @@ function createApiClient(options) {
|
|
|
323
326
|
}
|
|
324
327
|
}
|
|
325
328
|
async function requestForReporter(method, path, reporterToken, body) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
const response = await fetch(url, {
|
|
331
|
-
method,
|
|
332
|
-
headers: {
|
|
333
|
-
"Content-Type": "application/json",
|
|
334
|
-
"X-Mushi-Api-Key": apiKey,
|
|
335
|
-
"X-Mushi-Project": projectId,
|
|
336
|
-
...sdkPackage ? { [MUSHI_SDK_PACKAGE_HEADER]: sdkPackage } : {},
|
|
337
|
-
...sdkVersion ? { [MUSHI_SDK_VERSION_HEADER]: sdkVersion } : {},
|
|
338
|
-
[MUSHI_INTERNAL_HEADER]: "reporter-poll",
|
|
329
|
+
try {
|
|
330
|
+
const tokenHash = await sha256Hex(reporterToken);
|
|
331
|
+
const ts = String(Date.now());
|
|
332
|
+
return await request(method, path, body, maxRetries, "reporter-poll", {
|
|
339
333
|
"X-Reporter-Token-Hash": tokenHash,
|
|
340
334
|
"X-Reporter-Ts": ts,
|
|
341
|
-
"X-Reporter-Hmac":
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
[MUSHI_INTERNAL_INIT_MARKER]: "reporter-poll"
|
|
346
|
-
});
|
|
347
|
-
if (!response.ok) {
|
|
348
|
-
const errorBody = await response.json().catch(() => ({}));
|
|
349
|
-
return {
|
|
350
|
-
ok: false,
|
|
351
|
-
error: {
|
|
352
|
-
code: `HTTP_${response.status}`,
|
|
353
|
-
message: errorBody.error?.message ?? errorBody.message ?? `HTTP ${response.status} error`
|
|
354
|
-
}
|
|
355
|
-
};
|
|
335
|
+
"X-Reporter-Hmac": await hmacSha256Hex(apiKey, `${projectId}.${ts}.${tokenHash}`)
|
|
336
|
+
});
|
|
337
|
+
} catch (error) {
|
|
338
|
+
return { ok: false, error: { code: "NETWORK_ERROR", message: error instanceof Error ? error.message : "Unknown error" } };
|
|
356
339
|
}
|
|
357
|
-
const payload = await response.json();
|
|
358
|
-
return { ok: true, data: payload.data ?? payload };
|
|
359
340
|
}
|
|
360
341
|
return {
|
|
361
342
|
async submitReport(report) {
|
|
@@ -406,6 +387,7 @@ function createApiClient(options) {
|
|
|
406
387
|
async listReporterReports(reporterToken) {
|
|
407
388
|
return requestForReporter("GET", "/v1/reporter/reports", reporterToken);
|
|
408
389
|
},
|
|
390
|
+
reporterRequest: requestForReporter,
|
|
409
391
|
async listReporterComments(reportId, reporterToken) {
|
|
410
392
|
return requestForReporter(
|
|
411
393
|
"GET",
|
|
@@ -843,6 +825,7 @@ var KNOWN_CONFIG_KEYS = [
|
|
|
843
825
|
"trackSessions",
|
|
844
826
|
"sentry",
|
|
845
827
|
"widget",
|
|
828
|
+
"notifications",
|
|
846
829
|
"capture",
|
|
847
830
|
"privacy",
|
|
848
831
|
"proactive",
|
|
@@ -2296,12 +2279,18 @@ var MUSHI_EVENTS = {
|
|
|
2296
2279
|
invite_sent: { surface: "console", required: [] },
|
|
2297
2280
|
upgrade_clicked: { surface: "console", required: ["plan"] },
|
|
2298
2281
|
test_report_sent: { surface: "console", required: ["project_id"] },
|
|
2282
|
+
diagnosis_viewed: { surface: "console", required: ["report_id", "project_id", "surface"] },
|
|
2299
2283
|
// ── Server-emitted (edge functions) ──────────────────────────────────────
|
|
2300
2284
|
project_created: { surface: "server", required: ["project_id"] },
|
|
2301
2285
|
key_minted: { surface: "server", required: ["project_id"] },
|
|
2302
2286
|
first_report_received: { surface: "server", required: ["project_id"] },
|
|
2287
|
+
first_diagnosis_ready: { surface: "server", required: ["project_id"] },
|
|
2303
2288
|
fix_merged: { surface: "server", required: ["project_id"] },
|
|
2304
2289
|
upgrade_completed: { surface: "server", required: ["project_id", "plan"] },
|
|
2290
|
+
repo_digest_created: { surface: "server", required: ["project_id"] },
|
|
2291
|
+
repo_diagram_generated: { surface: "server", required: ["project_id"] },
|
|
2292
|
+
repo_diagram_published: { surface: "server", required: ["project_id"] },
|
|
2293
|
+
public_diagram_viewed: { surface: "server", required: ["project_id"] },
|
|
2305
2294
|
// ── Growth loop (widget "Bug reports by Mushi" mark) ─────────────────────
|
|
2306
2295
|
loop_impression: { surface: "web", required: [] },
|
|
2307
2296
|
loop_click: { surface: "web", required: [] },
|