@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/dist/index.js
CHANGED
|
@@ -230,7 +230,8 @@ function createApiClient(options) {
|
|
|
230
230
|
if (cbFailures >= cbThreshold) cbOpenUntil = Date.now() + cbCooldownMs;
|
|
231
231
|
};
|
|
232
232
|
async function request(method, path, body, retries = maxRetries, internalKind, extraHeaders) {
|
|
233
|
-
|
|
233
|
+
const tracked = internalKind !== "reporter-poll";
|
|
234
|
+
if (tracked && cbIsOpen()) {
|
|
234
235
|
return { ok: false, error: { code: "CIRCUIT_OPEN", message: "Endpoint temporarily unavailable; retrying later." } };
|
|
235
236
|
}
|
|
236
237
|
const url = `${baseUrl}${path}`;
|
|
@@ -249,7 +250,7 @@ function createApiClient(options) {
|
|
|
249
250
|
...extraHeaders
|
|
250
251
|
};
|
|
251
252
|
const serialized = body ? JSON.stringify(body) : void 0;
|
|
252
|
-
if (serialized && method !== "GET") {
|
|
253
|
+
if (serialized && method !== "GET" && internalKind !== "reporter-poll") {
|
|
253
254
|
lastOutbound = { url, headers, body: serialized, path };
|
|
254
255
|
}
|
|
255
256
|
try {
|
|
@@ -289,8 +290,10 @@ function createApiClient(options) {
|
|
|
289
290
|
await sleep(retryAfterMs ?? getBackoffDelay(maxRetries - retries));
|
|
290
291
|
return request(method, path, body, retries - 1, internalKind, extraHeaders);
|
|
291
292
|
}
|
|
292
|
-
if (
|
|
293
|
-
|
|
293
|
+
if (tracked) {
|
|
294
|
+
if (unusable) cbRecordUnreachable();
|
|
295
|
+
else cbRecordReachable();
|
|
296
|
+
}
|
|
294
297
|
return {
|
|
295
298
|
ok: false,
|
|
296
299
|
error: {
|
|
@@ -302,7 +305,7 @@ function createApiClient(options) {
|
|
|
302
305
|
}
|
|
303
306
|
const payload = await response.json();
|
|
304
307
|
const data = payload && typeof payload === "object" && "ok" in payload && "data" in payload ? payload.data : payload;
|
|
305
|
-
cbRecordReachable();
|
|
308
|
+
if (tracked) cbRecordReachable();
|
|
306
309
|
return { ok: true, data };
|
|
307
310
|
} catch (error) {
|
|
308
311
|
clearTimeout(timer);
|
|
@@ -310,7 +313,7 @@ function createApiClient(options) {
|
|
|
310
313
|
await sleep(getBackoffDelay(maxRetries - retries));
|
|
311
314
|
return request(method, path, body, retries - 1, internalKind, extraHeaders);
|
|
312
315
|
}
|
|
313
|
-
cbRecordUnreachable();
|
|
316
|
+
if (tracked) cbRecordUnreachable();
|
|
314
317
|
return {
|
|
315
318
|
ok: false,
|
|
316
319
|
error: {
|
|
@@ -321,39 +324,17 @@ function createApiClient(options) {
|
|
|
321
324
|
}
|
|
322
325
|
}
|
|
323
326
|
async function requestForReporter(method, path, reporterToken, body) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const response = await fetch(url, {
|
|
329
|
-
method,
|
|
330
|
-
headers: {
|
|
331
|
-
"Content-Type": "application/json",
|
|
332
|
-
"X-Mushi-Api-Key": apiKey,
|
|
333
|
-
"X-Mushi-Project": projectId,
|
|
334
|
-
...sdkPackage ? { [MUSHI_SDK_PACKAGE_HEADER]: sdkPackage } : {},
|
|
335
|
-
...sdkVersion ? { [MUSHI_SDK_VERSION_HEADER]: sdkVersion } : {},
|
|
336
|
-
[MUSHI_INTERNAL_HEADER]: "reporter-poll",
|
|
327
|
+
try {
|
|
328
|
+
const tokenHash = await sha256Hex(reporterToken);
|
|
329
|
+
const ts = String(Date.now());
|
|
330
|
+
return await request(method, path, body, maxRetries, "reporter-poll", {
|
|
337
331
|
"X-Reporter-Token-Hash": tokenHash,
|
|
338
332
|
"X-Reporter-Ts": ts,
|
|
339
|
-
"X-Reporter-Hmac":
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
[MUSHI_INTERNAL_INIT_MARKER]: "reporter-poll"
|
|
344
|
-
});
|
|
345
|
-
if (!response.ok) {
|
|
346
|
-
const errorBody = await response.json().catch(() => ({}));
|
|
347
|
-
return {
|
|
348
|
-
ok: false,
|
|
349
|
-
error: {
|
|
350
|
-
code: `HTTP_${response.status}`,
|
|
351
|
-
message: errorBody.error?.message ?? errorBody.message ?? `HTTP ${response.status} error`
|
|
352
|
-
}
|
|
353
|
-
};
|
|
333
|
+
"X-Reporter-Hmac": await hmacSha256Hex(apiKey, `${projectId}.${ts}.${tokenHash}`)
|
|
334
|
+
});
|
|
335
|
+
} catch (error) {
|
|
336
|
+
return { ok: false, error: { code: "NETWORK_ERROR", message: error instanceof Error ? error.message : "Unknown error" } };
|
|
354
337
|
}
|
|
355
|
-
const payload = await response.json();
|
|
356
|
-
return { ok: true, data: payload.data ?? payload };
|
|
357
338
|
}
|
|
358
339
|
return {
|
|
359
340
|
async submitReport(report) {
|
|
@@ -404,6 +385,7 @@ function createApiClient(options) {
|
|
|
404
385
|
async listReporterReports(reporterToken) {
|
|
405
386
|
return requestForReporter("GET", "/v1/reporter/reports", reporterToken);
|
|
406
387
|
},
|
|
388
|
+
reporterRequest: requestForReporter,
|
|
407
389
|
async listReporterComments(reportId, reporterToken) {
|
|
408
390
|
return requestForReporter(
|
|
409
391
|
"GET",
|
|
@@ -841,6 +823,7 @@ var KNOWN_CONFIG_KEYS = [
|
|
|
841
823
|
"trackSessions",
|
|
842
824
|
"sentry",
|
|
843
825
|
"widget",
|
|
826
|
+
"notifications",
|
|
844
827
|
"capture",
|
|
845
828
|
"privacy",
|
|
846
829
|
"proactive",
|
|
@@ -2294,12 +2277,18 @@ var MUSHI_EVENTS = {
|
|
|
2294
2277
|
invite_sent: { surface: "console", required: [] },
|
|
2295
2278
|
upgrade_clicked: { surface: "console", required: ["plan"] },
|
|
2296
2279
|
test_report_sent: { surface: "console", required: ["project_id"] },
|
|
2280
|
+
diagnosis_viewed: { surface: "console", required: ["report_id", "project_id", "surface"] },
|
|
2297
2281
|
// ── Server-emitted (edge functions) ──────────────────────────────────────
|
|
2298
2282
|
project_created: { surface: "server", required: ["project_id"] },
|
|
2299
2283
|
key_minted: { surface: "server", required: ["project_id"] },
|
|
2300
2284
|
first_report_received: { surface: "server", required: ["project_id"] },
|
|
2285
|
+
first_diagnosis_ready: { surface: "server", required: ["project_id"] },
|
|
2301
2286
|
fix_merged: { surface: "server", required: ["project_id"] },
|
|
2302
2287
|
upgrade_completed: { surface: "server", required: ["project_id", "plan"] },
|
|
2288
|
+
repo_digest_created: { surface: "server", required: ["project_id"] },
|
|
2289
|
+
repo_diagram_generated: { surface: "server", required: ["project_id"] },
|
|
2290
|
+
repo_diagram_published: { surface: "server", required: ["project_id"] },
|
|
2291
|
+
public_diagram_viewed: { surface: "server", required: ["project_id"] },
|
|
2303
2292
|
// ── Growth loop (widget "Bug reports by Mushi" mark) ─────────────────────
|
|
2304
2293
|
loop_impression: { surface: "web", required: [] },
|
|
2305
2294
|
loop_click: { surface: "web", required: [] },
|