@mushi-mushi/web 1.26.0 → 1.27.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/SECURITY.md +49 -0
- package/dist/headless.cjs +1206 -0
- package/dist/headless.cjs.map +1 -0
- package/dist/headless.d.cts +88 -0
- package/dist/headless.d.ts +88 -0
- package/dist/headless.js +1194 -0
- package/dist/headless.js.map +1 -0
- package/dist/index.cjs +228 -74
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -62
- package/dist/index.d.ts +3 -62
- package/dist/index.js +229 -75
- package/dist/index.js.map +1 -1
- package/dist/mushi.loader.global.js +439 -439
- package/dist/mushi.loader.global.js.map +1 -1
- package/dist/otel.cjs +60 -0
- package/dist/otel.cjs.map +1 -0
- package/dist/otel.d.cts +80 -0
- package/dist/otel.d.ts +80 -0
- package/dist/otel.js +58 -0
- package/dist/otel.js.map +1 -0
- package/dist/timeline-BuqAn2FH.d.cts +63 -0
- package/dist/timeline-BuqAn2FH.d.ts +63 -0
- package/package.json +25 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiAssistantReply, MushiWidgetConfig, MushiLeaderboardEntry, MushiCrossAppReport, MushiTesterReputation,
|
|
1
|
+
import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiAssistantReply, MushiWidgetConfig, MushiLeaderboardEntry, MushiCrossAppReport, MushiTesterReputation, MushiApiCascadeConfig } from '@mushi-mushi/core';
|
|
2
2
|
export { MushiApiCascadeConfig, MushiConfig, MushiConsoleEntry, MushiDiagnosticsResult, MushiEnvironment, MushiEventHandler, MushiEventType, MushiNetworkEntry, MushiPerformanceMetrics, MushiReport, MushiReportCategory, MushiSDKInstance, MushiTimelineEntry, MushiTimelineKind, MushiUrlMatcher, MushiWidgetConfig } from '@mushi-mushi/core';
|
|
3
|
+
export { C as ConsoleCapture, E as ElementSelector, N as NetworkCapture, P as PerformanceCapture, S as ScreenshotCapture, T as TimelineCapture, c as createConsoleCapture, a as createElementSelector, b as createNetworkCapture, d as createPerformanceCapture, e as createScreenshotCapture, f as createTimelineCapture } from './timeline-BuqAn2FH.cjs';
|
|
3
4
|
export { MushiLocale, getAvailableLocales, getLocale } from './i18n/index.cjs';
|
|
4
5
|
|
|
5
6
|
declare class Mushi {
|
|
@@ -517,66 +518,6 @@ declare class MushiWidget {
|
|
|
517
518
|
recorderOpenMyReports(): void;
|
|
518
519
|
}
|
|
519
520
|
|
|
520
|
-
interface ConsoleCapture {
|
|
521
|
-
getEntries(): MushiConsoleEntry[];
|
|
522
|
-
clear(): void;
|
|
523
|
-
destroy(): void;
|
|
524
|
-
}
|
|
525
|
-
declare function createConsoleCapture(): ConsoleCapture;
|
|
526
|
-
|
|
527
|
-
interface NetworkCapture {
|
|
528
|
-
getEntries(): MushiNetworkEntry[];
|
|
529
|
-
clear(): void;
|
|
530
|
-
updateOptions(options: NetworkCaptureOptions): void;
|
|
531
|
-
destroy(): void;
|
|
532
|
-
}
|
|
533
|
-
interface NetworkCaptureOptions {
|
|
534
|
-
apiEndpoint?: string;
|
|
535
|
-
ignoreUrls?: MushiUrlMatcher[];
|
|
536
|
-
tracePropagation?: MushiTracePropagationConfig;
|
|
537
|
-
sessionId?: string;
|
|
538
|
-
}
|
|
539
|
-
declare function createNetworkCapture(options?: NetworkCaptureOptions): NetworkCapture;
|
|
540
|
-
|
|
541
|
-
interface ScreenshotCapture {
|
|
542
|
-
take(): Promise<string | null>;
|
|
543
|
-
updateOptions(options: ScreenshotCaptureOptions): void;
|
|
544
|
-
}
|
|
545
|
-
interface ScreenshotCaptureOptions {
|
|
546
|
-
privacy?: MushiPrivacyConfig;
|
|
547
|
-
/** Callback invoked when capture fails (taint, security policy, etc.). */
|
|
548
|
-
onFailed?: (reason: 'taint' | 'error') => void;
|
|
549
|
-
}
|
|
550
|
-
declare function createScreenshotCapture(options?: ScreenshotCaptureOptions): ScreenshotCapture;
|
|
551
|
-
|
|
552
|
-
interface PerformanceCapture {
|
|
553
|
-
getMetrics(): MushiPerformanceMetrics;
|
|
554
|
-
destroy(): void;
|
|
555
|
-
}
|
|
556
|
-
declare function createPerformanceCapture(): PerformanceCapture;
|
|
557
|
-
|
|
558
|
-
interface ElementSelector {
|
|
559
|
-
activate(): Promise<MushiSelectedElement | null>;
|
|
560
|
-
deactivate(): void;
|
|
561
|
-
isActive(): boolean;
|
|
562
|
-
}
|
|
563
|
-
declare function createElementSelector(): ElementSelector;
|
|
564
|
-
|
|
565
|
-
interface TimelineCapture {
|
|
566
|
-
setScreen(screen: {
|
|
567
|
-
name: string;
|
|
568
|
-
route?: string;
|
|
569
|
-
feature?: string;
|
|
570
|
-
}): void;
|
|
571
|
-
getEntries(input?: {
|
|
572
|
-
consoleLogs?: MushiConsoleEntry[] | null;
|
|
573
|
-
networkLogs?: MushiNetworkEntry[] | null;
|
|
574
|
-
}): MushiTimelineEntry[];
|
|
575
|
-
clear(): void;
|
|
576
|
-
destroy(): void;
|
|
577
|
-
}
|
|
578
|
-
declare function createTimelineCapture(): TimelineCapture;
|
|
579
|
-
|
|
580
521
|
/**
|
|
581
522
|
* FILE: packages/web/src/build-widget-theme.ts
|
|
582
523
|
* PURPOSE: Resolve Shadow-DOM CSS variables from @mushi-mushi/core tokens.
|
|
@@ -746,4 +687,4 @@ interface ProactiveTriggerCleanup {
|
|
|
746
687
|
}
|
|
747
688
|
declare function setupProactiveTriggers(callbacks: ProactiveTriggerCallbacks, config?: ProactiveTriggerConfig): ProactiveTriggerCleanup;
|
|
748
689
|
|
|
749
|
-
export {
|
|
690
|
+
export { Mushi, MushiWidget, type ProactiveConfig, type ProactiveManager, type ProactiveTriggerCallbacks, type ProactiveTriggerCleanup, type WidgetThemeVars, createProactiveManager, getWidgetPreviewTokens, getWidgetThemeVars, setupProactiveTriggers };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiAssistantReply, MushiWidgetConfig, MushiLeaderboardEntry, MushiCrossAppReport, MushiTesterReputation,
|
|
1
|
+
import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiAssistantReply, MushiWidgetConfig, MushiLeaderboardEntry, MushiCrossAppReport, MushiTesterReputation, MushiApiCascadeConfig } from '@mushi-mushi/core';
|
|
2
2
|
export { MushiApiCascadeConfig, MushiConfig, MushiConsoleEntry, MushiDiagnosticsResult, MushiEnvironment, MushiEventHandler, MushiEventType, MushiNetworkEntry, MushiPerformanceMetrics, MushiReport, MushiReportCategory, MushiSDKInstance, MushiTimelineEntry, MushiTimelineKind, MushiUrlMatcher, MushiWidgetConfig } from '@mushi-mushi/core';
|
|
3
|
+
export { C as ConsoleCapture, E as ElementSelector, N as NetworkCapture, P as PerformanceCapture, S as ScreenshotCapture, T as TimelineCapture, c as createConsoleCapture, a as createElementSelector, b as createNetworkCapture, d as createPerformanceCapture, e as createScreenshotCapture, f as createTimelineCapture } from './timeline-BuqAn2FH.js';
|
|
3
4
|
export { MushiLocale, getAvailableLocales, getLocale } from './i18n/index.js';
|
|
4
5
|
|
|
5
6
|
declare class Mushi {
|
|
@@ -517,66 +518,6 @@ declare class MushiWidget {
|
|
|
517
518
|
recorderOpenMyReports(): void;
|
|
518
519
|
}
|
|
519
520
|
|
|
520
|
-
interface ConsoleCapture {
|
|
521
|
-
getEntries(): MushiConsoleEntry[];
|
|
522
|
-
clear(): void;
|
|
523
|
-
destroy(): void;
|
|
524
|
-
}
|
|
525
|
-
declare function createConsoleCapture(): ConsoleCapture;
|
|
526
|
-
|
|
527
|
-
interface NetworkCapture {
|
|
528
|
-
getEntries(): MushiNetworkEntry[];
|
|
529
|
-
clear(): void;
|
|
530
|
-
updateOptions(options: NetworkCaptureOptions): void;
|
|
531
|
-
destroy(): void;
|
|
532
|
-
}
|
|
533
|
-
interface NetworkCaptureOptions {
|
|
534
|
-
apiEndpoint?: string;
|
|
535
|
-
ignoreUrls?: MushiUrlMatcher[];
|
|
536
|
-
tracePropagation?: MushiTracePropagationConfig;
|
|
537
|
-
sessionId?: string;
|
|
538
|
-
}
|
|
539
|
-
declare function createNetworkCapture(options?: NetworkCaptureOptions): NetworkCapture;
|
|
540
|
-
|
|
541
|
-
interface ScreenshotCapture {
|
|
542
|
-
take(): Promise<string | null>;
|
|
543
|
-
updateOptions(options: ScreenshotCaptureOptions): void;
|
|
544
|
-
}
|
|
545
|
-
interface ScreenshotCaptureOptions {
|
|
546
|
-
privacy?: MushiPrivacyConfig;
|
|
547
|
-
/** Callback invoked when capture fails (taint, security policy, etc.). */
|
|
548
|
-
onFailed?: (reason: 'taint' | 'error') => void;
|
|
549
|
-
}
|
|
550
|
-
declare function createScreenshotCapture(options?: ScreenshotCaptureOptions): ScreenshotCapture;
|
|
551
|
-
|
|
552
|
-
interface PerformanceCapture {
|
|
553
|
-
getMetrics(): MushiPerformanceMetrics;
|
|
554
|
-
destroy(): void;
|
|
555
|
-
}
|
|
556
|
-
declare function createPerformanceCapture(): PerformanceCapture;
|
|
557
|
-
|
|
558
|
-
interface ElementSelector {
|
|
559
|
-
activate(): Promise<MushiSelectedElement | null>;
|
|
560
|
-
deactivate(): void;
|
|
561
|
-
isActive(): boolean;
|
|
562
|
-
}
|
|
563
|
-
declare function createElementSelector(): ElementSelector;
|
|
564
|
-
|
|
565
|
-
interface TimelineCapture {
|
|
566
|
-
setScreen(screen: {
|
|
567
|
-
name: string;
|
|
568
|
-
route?: string;
|
|
569
|
-
feature?: string;
|
|
570
|
-
}): void;
|
|
571
|
-
getEntries(input?: {
|
|
572
|
-
consoleLogs?: MushiConsoleEntry[] | null;
|
|
573
|
-
networkLogs?: MushiNetworkEntry[] | null;
|
|
574
|
-
}): MushiTimelineEntry[];
|
|
575
|
-
clear(): void;
|
|
576
|
-
destroy(): void;
|
|
577
|
-
}
|
|
578
|
-
declare function createTimelineCapture(): TimelineCapture;
|
|
579
|
-
|
|
580
521
|
/**
|
|
581
522
|
* FILE: packages/web/src/build-widget-theme.ts
|
|
582
523
|
* PURPOSE: Resolve Shadow-DOM CSS variables from @mushi-mushi/core tokens.
|
|
@@ -746,4 +687,4 @@ interface ProactiveTriggerCleanup {
|
|
|
746
687
|
}
|
|
747
688
|
declare function setupProactiveTriggers(callbacks: ProactiveTriggerCallbacks, config?: ProactiveTriggerConfig): ProactiveTriggerCleanup;
|
|
748
689
|
|
|
749
|
-
export {
|
|
690
|
+
export { Mushi, MushiWidget, type ProactiveConfig, type ProactiveManager, type ProactiveTriggerCallbacks, type ProactiveTriggerCleanup, type WidgetThemeVars, createProactiveManager, getWidgetPreviewTokens, getWidgetThemeVars, setupProactiveTriggers };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mushiPalette, resolveWidgetAccent, MUSHI_REPORTER_STATUS, MUSHI_GEOMETRY, MUSHI_Z, MUSHI_MOTION, MUSHI_TYPE, MUSHI_BANNER_BRAND_BORDER, MUSHI_BANNER_NEON, MUSHI_INVERSE, MUSHI_ON_ACCENT, MUSHI_ACCENT_SHADOW, MUSHI_TIER_COLORS, readPageFaviconHref, resolveEnvConfig, diagnoseEnvConfig, validateConfig, expandPreset, createLogger, noopLogger, createApiClient, initSessionTracker, getReporterToken, createPreFilter, createOfflineQueue, createRateLimiter, createPiiScrubber, createBreadcrumbBuffer, getDeviceFingerprintHash, MAX_SCREENSHOT_DATA_URL_BYTES, captureEnvironment, getSessionId, newUuid, DEFAULT_API_ENDPOINT, MUSHI_DURATION, MUSHI_SPACING, MUSHI_RADIUS, isLikelyGenericFavicon, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INTERNAL_HEADER, MUSHI_COLORS_LIGHT, parseIdentityToken, updateSessionIdentity, normaliseThrown, destroySessionTracker, resolveProjectDomain, projectInitials, projectFaviconUrlCandidates, sha256Hex } from '@mushi-mushi/core';
|
|
1
|
+
import { mushiPalette, resolveWidgetAccent, MUSHI_REPORTER_STATUS, MUSHI_GEOMETRY, MUSHI_Z, MUSHI_MOTION, MUSHI_TYPE, MUSHI_BANNER_BRAND_BORDER, MUSHI_BANNER_NEON, MUSHI_INVERSE, MUSHI_ON_ACCENT, MUSHI_ACCENT_SHADOW, MUSHI_TIER_COLORS, readPageFaviconHref, scrubUrl, resolveEnvConfig, diagnoseEnvConfig, validateConfig, expandPreset, createLogger, noopLogger, createApiClient, initSessionTracker, getReporterToken, createPreFilter, createOfflineQueue, createRateLimiter, createPiiScrubber, createBreadcrumbBuffer, getDeviceFingerprintHash, MAX_SCREENSHOT_DATA_URL_BYTES, captureEnvironment, getSessionId, newUuid, DEFAULT_API_ENDPOINT, MUSHI_DURATION, MUSHI_SPACING, MUSHI_RADIUS, isLikelyGenericFavicon, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INTERNAL_HEADER, MUSHI_COLORS_LIGHT, parseIdentityToken, updateSessionIdentity, normaliseThrown, destroySessionTracker, resolveProjectDomain, projectInitials, projectFaviconUrlCandidates, sha256Hex } from '@mushi-mushi/core';
|
|
2
2
|
|
|
3
3
|
// src/capture/compress-screenshot.ts
|
|
4
4
|
async function compressScreenshotDataUrl(dataUrl, maxBytes = MAX_SCREENSHOT_DATA_URL_BYTES) {
|
|
@@ -2673,7 +2673,7 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
2673
2673
|
|
|
2674
2674
|
// src/version.ts
|
|
2675
2675
|
var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
|
|
2676
|
-
var MUSHI_SDK_VERSION = "1.
|
|
2676
|
+
var MUSHI_SDK_VERSION = "1.27.0" ;
|
|
2677
2677
|
var ASSISTANT_SESSION_STORAGE_KEY = "mushi-assistant-session-v1";
|
|
2678
2678
|
function loadAssistantSession() {
|
|
2679
2679
|
try {
|
|
@@ -6333,59 +6333,6 @@ function renderConsentBanner(projectId, config) {
|
|
|
6333
6333
|
});
|
|
6334
6334
|
document.body.appendChild(consentHost);
|
|
6335
6335
|
}
|
|
6336
|
-
|
|
6337
|
-
// src/capture/console.ts
|
|
6338
|
-
var MAX_ENTRIES = 50;
|
|
6339
|
-
var MAX_MESSAGE_LENGTH = 500;
|
|
6340
|
-
function createConsoleCapture() {
|
|
6341
|
-
const entries = [];
|
|
6342
|
-
const originals = {};
|
|
6343
|
-
const wrappers = {};
|
|
6344
|
-
const levels = ["log", "warn", "error", "info", "debug"];
|
|
6345
|
-
for (const level of levels) {
|
|
6346
|
-
const original = console[level];
|
|
6347
|
-
originals[level] = original;
|
|
6348
|
-
const wrapper = (...args) => {
|
|
6349
|
-
const message = args.map((arg) => {
|
|
6350
|
-
try {
|
|
6351
|
-
return typeof arg === "string" ? arg : JSON.stringify(arg);
|
|
6352
|
-
} catch {
|
|
6353
|
-
return String(arg);
|
|
6354
|
-
}
|
|
6355
|
-
}).join(" ").slice(0, MAX_MESSAGE_LENGTH);
|
|
6356
|
-
const entry = {
|
|
6357
|
-
level,
|
|
6358
|
-
message,
|
|
6359
|
-
timestamp: Date.now()
|
|
6360
|
-
};
|
|
6361
|
-
if (level === "error" && args[0] instanceof Error) {
|
|
6362
|
-
entry.stack = args[0].stack?.slice(0, 1e3);
|
|
6363
|
-
}
|
|
6364
|
-
entries.push(entry);
|
|
6365
|
-
if (entries.length > MAX_ENTRIES) {
|
|
6366
|
-
entries.shift();
|
|
6367
|
-
}
|
|
6368
|
-
original.call(console, ...args);
|
|
6369
|
-
};
|
|
6370
|
-
wrappers[level] = wrapper;
|
|
6371
|
-
console[level] = wrapper;
|
|
6372
|
-
}
|
|
6373
|
-
return {
|
|
6374
|
-
getEntries() {
|
|
6375
|
-
return [...entries];
|
|
6376
|
-
},
|
|
6377
|
-
clear() {
|
|
6378
|
-
entries.length = 0;
|
|
6379
|
-
},
|
|
6380
|
-
destroy() {
|
|
6381
|
-
for (const level of levels) {
|
|
6382
|
-
if (originals[level] && console[level] === wrappers[level]) {
|
|
6383
|
-
console[level] = originals[level];
|
|
6384
|
-
}
|
|
6385
|
-
}
|
|
6386
|
-
}
|
|
6387
|
-
};
|
|
6388
|
-
}
|
|
6389
6336
|
var DEFAULT_INTERNAL_URL_MATCHERS = [
|
|
6390
6337
|
/\/v1\/sdk(?:\/|$)/,
|
|
6391
6338
|
/\/v1\/reports(?:\/|$)/,
|
|
@@ -6449,7 +6396,7 @@ function readHeader(headers, name) {
|
|
|
6449
6396
|
}
|
|
6450
6397
|
|
|
6451
6398
|
// src/capture/network.ts
|
|
6452
|
-
var
|
|
6399
|
+
var MAX_ENTRIES = 30;
|
|
6453
6400
|
var TRACEPARENT_VERSION = "00";
|
|
6454
6401
|
function generateTraceparent() {
|
|
6455
6402
|
const traceBytes = crypto.getRandomValues(new Uint8Array(16));
|
|
@@ -6473,9 +6420,21 @@ function matchesCorsUrls(url, corsUrls) {
|
|
|
6473
6420
|
}
|
|
6474
6421
|
return false;
|
|
6475
6422
|
}
|
|
6423
|
+
var _activeCorrelationStack = [];
|
|
6424
|
+
function getActiveCorrelationId() {
|
|
6425
|
+
return _activeCorrelationStack[_activeCorrelationStack.length - 1];
|
|
6426
|
+
}
|
|
6427
|
+
function generateCorrelationId() {
|
|
6428
|
+
const bytes = crypto.getRandomValues(new Uint8Array(4));
|
|
6429
|
+
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
6430
|
+
}
|
|
6476
6431
|
function createNetworkCapture(options = {}) {
|
|
6477
6432
|
const entries = [];
|
|
6478
6433
|
const originalFetch = globalThis.fetch;
|
|
6434
|
+
const OriginalXHR = typeof XMLHttpRequest !== "undefined" ? XMLHttpRequest : null;
|
|
6435
|
+
const originalXhrOpen = OriginalXHR ? XMLHttpRequest.prototype.open : null;
|
|
6436
|
+
const originalXhrSend = OriginalXHR ? XMLHttpRequest.prototype.send : null;
|
|
6437
|
+
const originalXhrSetRequestHeader = OriginalXHR ? XMLHttpRequest.prototype.setRequestHeader : null;
|
|
6479
6438
|
let activeOptions = options;
|
|
6480
6439
|
let fetchWrapper;
|
|
6481
6440
|
globalThis.fetch = fetchWrapper = async function mushiFetchInterceptor(input, init) {
|
|
@@ -6484,6 +6443,7 @@ function createNetworkCapture(options = {}) {
|
|
|
6484
6443
|
const url = getRequestUrl(input);
|
|
6485
6444
|
const internalKind = getInternalRequestKind(input, init);
|
|
6486
6445
|
const shouldRecord = !internalKind && !shouldIgnoreMushiUrl(url, activeOptions);
|
|
6446
|
+
const correlationId = shouldRecord ? generateCorrelationId() : void 0;
|
|
6487
6447
|
let traceId;
|
|
6488
6448
|
let patchedInit = init;
|
|
6489
6449
|
const tp = activeOptions.tracePropagation;
|
|
@@ -6497,6 +6457,7 @@ function createNetworkCapture(options = {}) {
|
|
|
6497
6457
|
}
|
|
6498
6458
|
patchedInit = { ...init, headers: existingHeaders };
|
|
6499
6459
|
}
|
|
6460
|
+
if (correlationId) _activeCorrelationStack.push(correlationId);
|
|
6500
6461
|
try {
|
|
6501
6462
|
const response = await originalFetch.call(globalThis, input, patchedInit);
|
|
6502
6463
|
if (shouldRecord) {
|
|
@@ -6506,7 +6467,9 @@ function createNetworkCapture(options = {}) {
|
|
|
6506
6467
|
status: response.status,
|
|
6507
6468
|
duration: Date.now() - startTime,
|
|
6508
6469
|
timestamp: startTime,
|
|
6509
|
-
|
|
6470
|
+
captureMethod: "fetch",
|
|
6471
|
+
...traceId ? { traceId } : {},
|
|
6472
|
+
...correlationId ? { correlationId } : {}
|
|
6510
6473
|
});
|
|
6511
6474
|
}
|
|
6512
6475
|
return response;
|
|
@@ -6519,15 +6482,99 @@ function createNetworkCapture(options = {}) {
|
|
|
6519
6482
|
duration: Date.now() - startTime,
|
|
6520
6483
|
timestamp: startTime,
|
|
6521
6484
|
error: error instanceof Error ? error.message : "Network error",
|
|
6522
|
-
|
|
6485
|
+
captureMethod: "fetch",
|
|
6486
|
+
...traceId ? { traceId } : {},
|
|
6487
|
+
...correlationId ? { correlationId } : {}
|
|
6523
6488
|
});
|
|
6524
6489
|
}
|
|
6525
6490
|
throw error;
|
|
6491
|
+
} finally {
|
|
6492
|
+
if (correlationId) {
|
|
6493
|
+
const idx = _activeCorrelationStack.lastIndexOf(correlationId);
|
|
6494
|
+
if (idx !== -1) _activeCorrelationStack.splice(idx, 1);
|
|
6495
|
+
}
|
|
6526
6496
|
}
|
|
6527
6497
|
};
|
|
6498
|
+
const xhrStateMap = typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : null;
|
|
6499
|
+
if (OriginalXHR && originalXhrOpen && originalXhrSend && originalXhrSetRequestHeader && xhrStateMap) {
|
|
6500
|
+
const _originalOpen = originalXhrOpen;
|
|
6501
|
+
XMLHttpRequest.prototype.open = function mushiXhrOpen(...args) {
|
|
6502
|
+
const [method, url] = args;
|
|
6503
|
+
const urlStr = typeof url === "string" ? url : String(url);
|
|
6504
|
+
const shouldRecord = !shouldIgnoreMushiUrl(urlStr, activeOptions);
|
|
6505
|
+
const correlationId = shouldRecord ? generateCorrelationId() : void 0;
|
|
6506
|
+
let traceId;
|
|
6507
|
+
let storedTraceparent;
|
|
6508
|
+
const tp = activeOptions.tracePropagation;
|
|
6509
|
+
if (shouldRecord && tp?.enabled && tp.corsUrls?.length && matchesCorsUrls(urlStr, tp.corsUrls)) {
|
|
6510
|
+
const generated = generateTraceparent();
|
|
6511
|
+
traceId = generated.traceId;
|
|
6512
|
+
storedTraceparent = generated.traceparent;
|
|
6513
|
+
}
|
|
6514
|
+
const _prevXhrState = xhrStateMap.get(this);
|
|
6515
|
+
if (_prevXhrState?._listener) {
|
|
6516
|
+
this.removeEventListener("readystatechange", _prevXhrState._listener);
|
|
6517
|
+
}
|
|
6518
|
+
xhrStateMap.set(this, {
|
|
6519
|
+
method: String(method).toUpperCase(),
|
|
6520
|
+
url: truncateUrl(urlStr),
|
|
6521
|
+
startTime: 0,
|
|
6522
|
+
// set in .send()
|
|
6523
|
+
shouldRecord,
|
|
6524
|
+
...traceId ? { traceId } : {},
|
|
6525
|
+
...correlationId ? { correlationId } : {},
|
|
6526
|
+
// Attach the traceparent string as an extra prop for injection in .send().
|
|
6527
|
+
...storedTraceparent ? { _traceparent: storedTraceparent } : {}
|
|
6528
|
+
});
|
|
6529
|
+
_originalOpen.apply(this, args);
|
|
6530
|
+
};
|
|
6531
|
+
XMLHttpRequest.prototype.send = function mushiXhrSend(body) {
|
|
6532
|
+
const state = xhrStateMap.get(this);
|
|
6533
|
+
if (state) {
|
|
6534
|
+
state.startTime = Date.now();
|
|
6535
|
+
const xhrTraceparent = state._traceparent;
|
|
6536
|
+
if (xhrTraceparent) {
|
|
6537
|
+
originalXhrSetRequestHeader.call(this, "traceparent", xhrTraceparent);
|
|
6538
|
+
if (activeOptions.sessionId) {
|
|
6539
|
+
originalXhrSetRequestHeader.call(this, "x-mushi-session", activeOptions.sessionId);
|
|
6540
|
+
}
|
|
6541
|
+
}
|
|
6542
|
+
if (state.correlationId) _activeCorrelationStack.push(state.correlationId);
|
|
6543
|
+
const _readystateHandler = () => {
|
|
6544
|
+
if (this.readyState !== 4) return;
|
|
6545
|
+
if (state.shouldRecord) {
|
|
6546
|
+
const duration = Date.now() - state.startTime;
|
|
6547
|
+
const entry = {
|
|
6548
|
+
method: state.method,
|
|
6549
|
+
url: state.url,
|
|
6550
|
+
status: this.status,
|
|
6551
|
+
duration,
|
|
6552
|
+
timestamp: state.startTime,
|
|
6553
|
+
captureMethod: "xhr",
|
|
6554
|
+
...state.traceId ? { traceId: state.traceId } : {},
|
|
6555
|
+
...state.correlationId ? { correlationId: state.correlationId } : {}
|
|
6556
|
+
};
|
|
6557
|
+
if (this.status === 0) {
|
|
6558
|
+
entry.error = "XHR network error or aborted";
|
|
6559
|
+
}
|
|
6560
|
+
addEntry(entry);
|
|
6561
|
+
}
|
|
6562
|
+
if (state.correlationId) {
|
|
6563
|
+
const idx = _activeCorrelationStack.lastIndexOf(state.correlationId);
|
|
6564
|
+
if (idx !== -1) _activeCorrelationStack.splice(idx, 1);
|
|
6565
|
+
}
|
|
6566
|
+
};
|
|
6567
|
+
state._listener = _readystateHandler;
|
|
6568
|
+
this.addEventListener("readystatechange", _readystateHandler);
|
|
6569
|
+
}
|
|
6570
|
+
originalXhrSend.call(this, body);
|
|
6571
|
+
};
|
|
6572
|
+
}
|
|
6573
|
+
const xhrOpenWrapper = OriginalXHR ? XMLHttpRequest.prototype.open : null;
|
|
6574
|
+
const xhrSendWrapper = OriginalXHR ? XMLHttpRequest.prototype.send : null;
|
|
6528
6575
|
function addEntry(entry) {
|
|
6529
6576
|
entries.push(entry);
|
|
6530
|
-
if (entries.length >
|
|
6577
|
+
if (entries.length > MAX_ENTRIES) {
|
|
6531
6578
|
entries.shift();
|
|
6532
6579
|
}
|
|
6533
6580
|
}
|
|
@@ -6545,22 +6592,86 @@ function createNetworkCapture(options = {}) {
|
|
|
6545
6592
|
if (globalThis.fetch === fetchWrapper) {
|
|
6546
6593
|
globalThis.fetch = originalFetch;
|
|
6547
6594
|
}
|
|
6595
|
+
if (OriginalXHR && originalXhrOpen && originalXhrSend) {
|
|
6596
|
+
if (xhrOpenWrapper && XMLHttpRequest.prototype.open === xhrOpenWrapper) {
|
|
6597
|
+
XMLHttpRequest.prototype.open = originalXhrOpen;
|
|
6598
|
+
}
|
|
6599
|
+
if (xhrSendWrapper && XMLHttpRequest.prototype.send === xhrSendWrapper) {
|
|
6600
|
+
XMLHttpRequest.prototype.send = originalXhrSend;
|
|
6601
|
+
}
|
|
6602
|
+
}
|
|
6548
6603
|
}
|
|
6549
6604
|
};
|
|
6550
6605
|
}
|
|
6551
6606
|
function truncateUrl(url) {
|
|
6607
|
+
const scrubbed = scrubUrl(url);
|
|
6552
6608
|
try {
|
|
6553
|
-
const parsed = new URL(
|
|
6609
|
+
const parsed = new URL(scrubbed);
|
|
6554
6610
|
const path = parsed.pathname + parsed.search;
|
|
6555
6611
|
if (path.length > 200) {
|
|
6556
6612
|
return parsed.origin + path.slice(0, 200) + "...";
|
|
6557
6613
|
}
|
|
6558
6614
|
return parsed.origin + path;
|
|
6559
6615
|
} catch {
|
|
6560
|
-
return
|
|
6616
|
+
return scrubbed.slice(0, 200);
|
|
6561
6617
|
}
|
|
6562
6618
|
}
|
|
6563
6619
|
|
|
6620
|
+
// src/capture/console.ts
|
|
6621
|
+
var MAX_ENTRIES2 = 50;
|
|
6622
|
+
var MAX_MESSAGE_LENGTH = 500;
|
|
6623
|
+
function createConsoleCapture() {
|
|
6624
|
+
const entries = [];
|
|
6625
|
+
const originals = {};
|
|
6626
|
+
const wrappers = {};
|
|
6627
|
+
const levels = ["log", "warn", "error", "info", "debug"];
|
|
6628
|
+
for (const level of levels) {
|
|
6629
|
+
const original = console[level];
|
|
6630
|
+
originals[level] = original;
|
|
6631
|
+
const wrapper = (...args) => {
|
|
6632
|
+
const message = args.map((arg) => {
|
|
6633
|
+
try {
|
|
6634
|
+
return typeof arg === "string" ? arg : JSON.stringify(arg);
|
|
6635
|
+
} catch {
|
|
6636
|
+
return String(arg);
|
|
6637
|
+
}
|
|
6638
|
+
}).join(" ").slice(0, MAX_MESSAGE_LENGTH);
|
|
6639
|
+
const correlationId = getActiveCorrelationId();
|
|
6640
|
+
const entry = {
|
|
6641
|
+
level,
|
|
6642
|
+
message,
|
|
6643
|
+
timestamp: Date.now(),
|
|
6644
|
+
...correlationId ? { correlationId } : {}
|
|
6645
|
+
};
|
|
6646
|
+
if (level === "error" && args[0] instanceof Error) {
|
|
6647
|
+
entry.stack = args[0].stack?.slice(0, 1e3);
|
|
6648
|
+
}
|
|
6649
|
+
entries.push(entry);
|
|
6650
|
+
if (entries.length > MAX_ENTRIES2) {
|
|
6651
|
+
entries.shift();
|
|
6652
|
+
}
|
|
6653
|
+
original.call(console, ...args);
|
|
6654
|
+
};
|
|
6655
|
+
wrappers[level] = wrapper;
|
|
6656
|
+
console[level] = wrapper;
|
|
6657
|
+
}
|
|
6658
|
+
return {
|
|
6659
|
+
getEntries() {
|
|
6660
|
+
return [...entries];
|
|
6661
|
+
},
|
|
6662
|
+
clear() {
|
|
6663
|
+
entries.length = 0;
|
|
6664
|
+
},
|
|
6665
|
+
destroy() {
|
|
6666
|
+
for (const level of levels) {
|
|
6667
|
+
if (originals[level] && console[level] === wrappers[level]) {
|
|
6668
|
+
console[level] = originals[level];
|
|
6669
|
+
}
|
|
6670
|
+
}
|
|
6671
|
+
}
|
|
6672
|
+
};
|
|
6673
|
+
}
|
|
6674
|
+
|
|
6564
6675
|
// src/capture/screenshot.ts
|
|
6565
6676
|
function createScreenshotCapture(options = {}) {
|
|
6566
6677
|
let activeOptions = options;
|
|
@@ -7094,8 +7205,6 @@ function createElementSelector() {
|
|
|
7094
7205
|
}
|
|
7095
7206
|
return { activate, deactivate, isActive: () => active };
|
|
7096
7207
|
}
|
|
7097
|
-
|
|
7098
|
-
// src/capture/timeline.ts
|
|
7099
7208
|
var MAX_TIMELINE_ENTRIES = 120;
|
|
7100
7209
|
function createTimelineCapture() {
|
|
7101
7210
|
const entries = [];
|
|
@@ -7112,8 +7221,11 @@ function createTimelineCapture() {
|
|
|
7112
7221
|
kind: "route",
|
|
7113
7222
|
payload: {
|
|
7114
7223
|
source,
|
|
7115
|
-
|
|
7116
|
-
|
|
7224
|
+
// Query VALUES are a PII channel (`?token=…`, `?email=…`) — scrub
|
|
7225
|
+
// them at capture, both in the search string and inside hash-router
|
|
7226
|
+
// fragments (`#/path?query`). Keys and paths are preserved.
|
|
7227
|
+
route: scrubUrl(`${location.pathname}${location.search}${location.hash}`),
|
|
7228
|
+
href: scrubUrl(location.href)
|
|
7117
7229
|
}
|
|
7118
7230
|
});
|
|
7119
7231
|
}
|
|
@@ -7200,6 +7312,18 @@ function normalizeSegment(seg) {
|
|
|
7200
7312
|
if (SLUG_HASHY_RE.test(seg) && /\d/.test(seg)) return "[id]";
|
|
7201
7313
|
return seg;
|
|
7202
7314
|
}
|
|
7315
|
+
function deriveRoute(pathname, hash, templates) {
|
|
7316
|
+
if (hash.startsWith("#/")) {
|
|
7317
|
+
const raw = hash.slice(1);
|
|
7318
|
+
const qIdx = raw.indexOf("?");
|
|
7319
|
+
const hashPath = qIdx === -1 ? raw : raw.slice(0, qIdx);
|
|
7320
|
+
const hashTemplates = templates?.map(
|
|
7321
|
+
(t) => t.startsWith("/#/") ? t.slice(2) : t
|
|
7322
|
+
);
|
|
7323
|
+
return "/#" + normalizeRoute(hashPath, hashTemplates);
|
|
7324
|
+
}
|
|
7325
|
+
return normalizeRoute(pathname, templates);
|
|
7326
|
+
}
|
|
7203
7327
|
function normalizeRoute(pathname, templates) {
|
|
7204
7328
|
const clean = pathname.length > 1 && pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
|
|
7205
7329
|
if (templates?.length) {
|
|
@@ -7243,9 +7367,14 @@ function readTestids() {
|
|
|
7243
7367
|
function readQueryParamKeys() {
|
|
7244
7368
|
if (typeof window === "undefined") return [];
|
|
7245
7369
|
try {
|
|
7246
|
-
const params = new URLSearchParams(window.location.search);
|
|
7247
7370
|
const out = /* @__PURE__ */ new Set();
|
|
7248
|
-
|
|
7371
|
+
const collect = (qs) => {
|
|
7372
|
+
new URLSearchParams(qs).forEach((_, key) => out.add(key));
|
|
7373
|
+
};
|
|
7374
|
+
collect(window.location.search);
|
|
7375
|
+
const hash = window.location.hash;
|
|
7376
|
+
const qIdx = hash.indexOf("?");
|
|
7377
|
+
if (hash.startsWith("#/") && qIdx !== -1) collect(hash.slice(qIdx + 1));
|
|
7249
7378
|
return Array.from(out).sort();
|
|
7250
7379
|
} catch {
|
|
7251
7380
|
return [];
|
|
@@ -7292,7 +7421,11 @@ function createDiscoveryCapture(opts) {
|
|
|
7292
7421
|
let pendingTimer = null;
|
|
7293
7422
|
async function emitForCurrent() {
|
|
7294
7423
|
if (typeof window === "undefined") return;
|
|
7295
|
-
const route =
|
|
7424
|
+
const route = deriveRoute(
|
|
7425
|
+
window.location.pathname,
|
|
7426
|
+
window.location.hash,
|
|
7427
|
+
config.routeTemplates
|
|
7428
|
+
);
|
|
7296
7429
|
const now = Date.now();
|
|
7297
7430
|
const last = lastEmittedAt.get(route) ?? 0;
|
|
7298
7431
|
if (now - last < throttleMs) return;
|
|
@@ -7324,7 +7457,8 @@ function createDiscoveryCapture(opts) {
|
|
|
7324
7457
|
}
|
|
7325
7458
|
function onMaybeNavigation() {
|
|
7326
7459
|
if (typeof window === "undefined") return;
|
|
7327
|
-
const
|
|
7460
|
+
const hashPart = window.location.hash.startsWith("#/") ? window.location.hash : "";
|
|
7461
|
+
const path = window.location.pathname + window.location.search + hashPart;
|
|
7328
7462
|
if (path === lastPath) return;
|
|
7329
7463
|
lastPath = path;
|
|
7330
7464
|
scheduleEmit();
|
|
@@ -7341,10 +7475,12 @@ function createDiscoveryCapture(opts) {
|
|
|
7341
7475
|
onReplace: onNav,
|
|
7342
7476
|
onPop: onNav
|
|
7343
7477
|
});
|
|
7478
|
+
window.addEventListener("hashchange", onNav);
|
|
7344
7479
|
scheduleEmit();
|
|
7345
7480
|
return {
|
|
7346
7481
|
destroy() {
|
|
7347
7482
|
unsubHistory();
|
|
7483
|
+
window.removeEventListener("hashchange", onNav);
|
|
7348
7484
|
if (pendingTimer) {
|
|
7349
7485
|
clearTimeout(pendingTimer);
|
|
7350
7486
|
pendingTimer = null;
|
|
@@ -8163,6 +8299,14 @@ function createInstance(config) {
|
|
|
8163
8299
|
return next;
|
|
8164
8300
|
});
|
|
8165
8301
|
}
|
|
8302
|
+
function scrubConsoleForWire(logs) {
|
|
8303
|
+
if (!logs) return logs;
|
|
8304
|
+
return logs.map((entry) => ({
|
|
8305
|
+
...entry,
|
|
8306
|
+
message: piiScrubber.scrub(entry.message),
|
|
8307
|
+
...entry.stack ? { stack: piiScrubber.scrub(entry.stack) } : {}
|
|
8308
|
+
}));
|
|
8309
|
+
}
|
|
8166
8310
|
function scrubTagsForWire(tags) {
|
|
8167
8311
|
if (!tags) return void 0;
|
|
8168
8312
|
const out = {};
|
|
@@ -8311,7 +8455,9 @@ function createInstance(config) {
|
|
|
8311
8455
|
discoveryCap = null;
|
|
8312
8456
|
}
|
|
8313
8457
|
const replayMode = activeConfig.capture?.replay ?? "off";
|
|
8314
|
-
|
|
8458
|
+
const replaySampleRate = activeConfig.replaySampleRate ?? 1;
|
|
8459
|
+
const replaySampled = replaySampleRate >= 1 || Math.random() < replaySampleRate;
|
|
8460
|
+
if ((replayMode === "rrweb" || replayMode === "lite") && replaySampled) {
|
|
8315
8461
|
const generation = ++replayGeneration;
|
|
8316
8462
|
void createReplayCapture({
|
|
8317
8463
|
redactSelectors: activeConfig.privacy?.redactSelectors
|
|
@@ -8850,6 +8996,13 @@ function createInstance(config) {
|
|
|
8850
8996
|
});
|
|
8851
8997
|
}
|
|
8852
8998
|
}
|
|
8999
|
+
const isAutomatic = pendingProactiveTrigger !== null;
|
|
9000
|
+
if (isAutomatic && config.sampleRate !== void 0 && config.sampleRate < 1) {
|
|
9001
|
+
if (config.sampleRate <= 0 || Math.random() > config.sampleRate) {
|
|
9002
|
+
log.debug("Report dropped by sampleRate", { sampleRate: config.sampleRate, trigger: pendingProactiveTrigger });
|
|
9003
|
+
return void 0;
|
|
9004
|
+
}
|
|
9005
|
+
}
|
|
8853
9006
|
if (!rateLimiter.tryConsume()) {
|
|
8854
9007
|
log.warn("Report throttled \u2014 rate limit exceeded");
|
|
8855
9008
|
return void 0;
|
|
@@ -8857,7 +9010,7 @@ function createInstance(config) {
|
|
|
8857
9010
|
const scrubbedDescription = piiScrubber.scrub(preFilter.truncate(description));
|
|
8858
9011
|
const sentryCtx = config.sentry ? captureSentryContext(config.sentry) : void 0;
|
|
8859
9012
|
const fingerprintHash = await getDeviceFingerprintHash().catch(() => null);
|
|
8860
|
-
const consoleLogs = activeConfig.capture?.console === false ? void 0 : consoleCap?.getEntries();
|
|
9013
|
+
const consoleLogs = activeConfig.capture?.console === false ? void 0 : scrubConsoleForWire(consoleCap?.getEntries());
|
|
8861
9014
|
const networkLogs = activeConfig.capture?.network === false ? void 0 : networkCap?.getEntries();
|
|
8862
9015
|
const reportBreadcrumbs = scrubBreadcrumbsForWire(breadcrumbs.getAll());
|
|
8863
9016
|
const stickyTagSnapshot = scrubTagsForWire(
|
|
@@ -8935,10 +9088,11 @@ function createInstance(config) {
|
|
|
8935
9088
|
config.integrations.custom(builder);
|
|
8936
9089
|
}
|
|
8937
9090
|
let finalReport = report;
|
|
8938
|
-
|
|
9091
|
+
const sendHook = config.beforeSend ?? config.beforeSendFeedback;
|
|
9092
|
+
if (sendHook) {
|
|
8939
9093
|
try {
|
|
8940
9094
|
const hookResult = await Promise.race([
|
|
8941
|
-
Promise.resolve(
|
|
9095
|
+
Promise.resolve(sendHook(report)),
|
|
8942
9096
|
// 2s timeout — async hooks must not block the user's "submit"
|
|
8943
9097
|
// for longer than the network would. Falls back to original.
|
|
8944
9098
|
new Promise(
|
|
@@ -8946,12 +9100,12 @@ function createInstance(config) {
|
|
|
8946
9100
|
)
|
|
8947
9101
|
]);
|
|
8948
9102
|
if (hookResult === null) {
|
|
8949
|
-
log.info("Report dropped by
|
|
9103
|
+
log.info("Report dropped by beforeSend hook", { reportId: report.id });
|
|
8950
9104
|
return;
|
|
8951
9105
|
}
|
|
8952
9106
|
finalReport = hookResult;
|
|
8953
9107
|
} catch (err) {
|
|
8954
|
-
log.warn("
|
|
9108
|
+
log.warn("beforeSend hook threw \u2014 sending unmodified report", {
|
|
8955
9109
|
error: err instanceof Error ? err.message : String(err)
|
|
8956
9110
|
});
|
|
8957
9111
|
}
|