@mushi-mushi/web 1.22.2 → 1.22.3
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/dist/index.cjs +132 -121
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +132 -121
- package/dist/index.js.map +1 -1
- package/dist/mushi.loader.global.js +428 -428
- package/dist/mushi.loader.global.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2553,7 +2553,7 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
2553
2553
|
|
|
2554
2554
|
// src/version.ts
|
|
2555
2555
|
var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
|
|
2556
|
-
var MUSHI_SDK_VERSION = "1.22.
|
|
2556
|
+
var MUSHI_SDK_VERSION = "1.22.3" ;
|
|
2557
2557
|
var CATEGORY_ICONS = {
|
|
2558
2558
|
bug: "\u26A0\uFE0F",
|
|
2559
2559
|
slow: "\u{1F40C}",
|
|
@@ -5403,6 +5403,101 @@ function exposeMarketingRecorder(widget) {
|
|
|
5403
5403
|
};
|
|
5404
5404
|
globalThis.__mushiRecorder = api;
|
|
5405
5405
|
}
|
|
5406
|
+
|
|
5407
|
+
// src/history-patch.ts
|
|
5408
|
+
var capturedPushState = null;
|
|
5409
|
+
var capturedReplaceState = null;
|
|
5410
|
+
var nativePushState = null;
|
|
5411
|
+
var nativeReplaceState = null;
|
|
5412
|
+
var pushWrapper = null;
|
|
5413
|
+
var replaceWrapper = null;
|
|
5414
|
+
var popListener = null;
|
|
5415
|
+
var patched = false;
|
|
5416
|
+
var subscribers = /* @__PURE__ */ new Set();
|
|
5417
|
+
function notifyPush() {
|
|
5418
|
+
for (const sub of subscribers) {
|
|
5419
|
+
try {
|
|
5420
|
+
sub.onPush?.();
|
|
5421
|
+
} catch {
|
|
5422
|
+
}
|
|
5423
|
+
}
|
|
5424
|
+
}
|
|
5425
|
+
function notifyReplace() {
|
|
5426
|
+
for (const sub of subscribers) {
|
|
5427
|
+
try {
|
|
5428
|
+
sub.onReplace?.();
|
|
5429
|
+
} catch {
|
|
5430
|
+
}
|
|
5431
|
+
}
|
|
5432
|
+
}
|
|
5433
|
+
function notifyPop() {
|
|
5434
|
+
for (const sub of subscribers) {
|
|
5435
|
+
try {
|
|
5436
|
+
sub.onPop?.();
|
|
5437
|
+
} catch {
|
|
5438
|
+
}
|
|
5439
|
+
}
|
|
5440
|
+
}
|
|
5441
|
+
function ensurePatch() {
|
|
5442
|
+
if (patched || typeof window === "undefined") return;
|
|
5443
|
+
nativePushState = History.prototype.pushState;
|
|
5444
|
+
nativeReplaceState = History.prototype.replaceState;
|
|
5445
|
+
capturedPushState = nativePushState.bind(history);
|
|
5446
|
+
capturedReplaceState = nativeReplaceState.bind(history);
|
|
5447
|
+
pushWrapper = function historyPatchPushState(...args) {
|
|
5448
|
+
const call = capturedPushState ?? History.prototype.pushState.bind(history);
|
|
5449
|
+
const ret = call(...args);
|
|
5450
|
+
notifyPush();
|
|
5451
|
+
return ret;
|
|
5452
|
+
};
|
|
5453
|
+
replaceWrapper = function historyPatchReplaceState(...args) {
|
|
5454
|
+
const call = capturedReplaceState ?? History.prototype.replaceState.bind(history);
|
|
5455
|
+
const ret = call(...args);
|
|
5456
|
+
notifyReplace();
|
|
5457
|
+
return ret;
|
|
5458
|
+
};
|
|
5459
|
+
history.pushState = pushWrapper;
|
|
5460
|
+
history.replaceState = replaceWrapper;
|
|
5461
|
+
popListener = () => notifyPop();
|
|
5462
|
+
window.addEventListener("popstate", popListener);
|
|
5463
|
+
patched = true;
|
|
5464
|
+
}
|
|
5465
|
+
function uninstallPatch() {
|
|
5466
|
+
if (!patched || typeof window === "undefined") return;
|
|
5467
|
+
if (popListener) {
|
|
5468
|
+
window.removeEventListener("popstate", popListener);
|
|
5469
|
+
popListener = null;
|
|
5470
|
+
}
|
|
5471
|
+
if (pushWrapper && history.pushState === pushWrapper && nativePushState) {
|
|
5472
|
+
history.pushState = nativePushState;
|
|
5473
|
+
}
|
|
5474
|
+
if (replaceWrapper && history.replaceState === replaceWrapper && nativeReplaceState) {
|
|
5475
|
+
history.replaceState = nativeReplaceState;
|
|
5476
|
+
}
|
|
5477
|
+
pushWrapper = null;
|
|
5478
|
+
replaceWrapper = null;
|
|
5479
|
+
capturedPushState = null;
|
|
5480
|
+
capturedReplaceState = null;
|
|
5481
|
+
nativePushState = null;
|
|
5482
|
+
nativeReplaceState = null;
|
|
5483
|
+
patched = false;
|
|
5484
|
+
}
|
|
5485
|
+
function subscribeHistory(sub) {
|
|
5486
|
+
ensurePatch();
|
|
5487
|
+
subscribers.add(sub);
|
|
5488
|
+
return () => {
|
|
5489
|
+
subscribers.delete(sub);
|
|
5490
|
+
if (subscribers.size === 0) {
|
|
5491
|
+
uninstallPatch();
|
|
5492
|
+
}
|
|
5493
|
+
};
|
|
5494
|
+
}
|
|
5495
|
+
function uninstallHistoryPatchForce() {
|
|
5496
|
+
subscribers.clear();
|
|
5497
|
+
uninstallPatch();
|
|
5498
|
+
}
|
|
5499
|
+
|
|
5500
|
+
// src/rewards.ts
|
|
5406
5501
|
var MIN_FLUSH_INTERVAL = 3e4;
|
|
5407
5502
|
var DEFAULT_FLUSH_INTERVAL = 3e5;
|
|
5408
5503
|
var DWELL_SAMPLE_INTERVAL = 6e4;
|
|
@@ -5603,13 +5698,11 @@ function teardown() {
|
|
|
5603
5698
|
}
|
|
5604
5699
|
var routeObserver = null;
|
|
5605
5700
|
var clickHandler = null;
|
|
5606
|
-
var
|
|
5607
|
-
var origPushState = null;
|
|
5608
|
-
var pushStateWrapper = null;
|
|
5701
|
+
var historyUnsub = null;
|
|
5609
5702
|
var lastRoute = "";
|
|
5610
5703
|
var listenersInstalled = false;
|
|
5611
5704
|
function installActivityListeners(projectId) {
|
|
5612
|
-
if (listenersInstalled &&
|
|
5705
|
+
if (listenersInstalled && historyUnsub) {
|
|
5613
5706
|
return;
|
|
5614
5707
|
}
|
|
5615
5708
|
if (listenersInstalled) {
|
|
@@ -5626,15 +5719,11 @@ function installActivityListeners(projectId) {
|
|
|
5626
5719
|
enqueue({ action: "screen_view_unique_per_day", metadata: { route } });
|
|
5627
5720
|
}
|
|
5628
5721
|
};
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
};
|
|
5635
|
-
history.pushState = pushStateWrapper;
|
|
5636
|
-
popstateHandler = emitRoute;
|
|
5637
|
-
window.addEventListener("popstate", emitRoute);
|
|
5722
|
+
historyUnsub = subscribeHistory({
|
|
5723
|
+
onPush: emitRoute,
|
|
5724
|
+
onReplace: emitRoute,
|
|
5725
|
+
onPop: emitRoute
|
|
5726
|
+
});
|
|
5638
5727
|
emitRoute();
|
|
5639
5728
|
routeObserver = new MutationObserver(() => emitRoute());
|
|
5640
5729
|
const main = document.querySelector("main") ?? document.body;
|
|
@@ -5650,15 +5739,8 @@ function installActivityListeners(projectId) {
|
|
|
5650
5739
|
}
|
|
5651
5740
|
function removeActivityListeners() {
|
|
5652
5741
|
listenersInstalled = false;
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
}
|
|
5656
|
-
origPushState = null;
|
|
5657
|
-
pushStateWrapper = null;
|
|
5658
|
-
if (popstateHandler) {
|
|
5659
|
-
window.removeEventListener("popstate", popstateHandler);
|
|
5660
|
-
popstateHandler = null;
|
|
5661
|
-
}
|
|
5742
|
+
historyUnsub?.();
|
|
5743
|
+
historyUnsub = null;
|
|
5662
5744
|
routeObserver?.disconnect();
|
|
5663
5745
|
routeObserver = null;
|
|
5664
5746
|
if (clickHandler) {
|
|
@@ -6448,9 +6530,6 @@ function createElementSelector() {
|
|
|
6448
6530
|
var MAX_TIMELINE_ENTRIES = 120;
|
|
6449
6531
|
function createTimelineCapture() {
|
|
6450
6532
|
const entries = [];
|
|
6451
|
-
const capturedPushState = history.pushState.bind(history);
|
|
6452
|
-
const capturedReplaceState = history.replaceState.bind(history);
|
|
6453
|
-
const handlePopState = () => recordRoute("popstate");
|
|
6454
6533
|
const handleHashChange = () => recordRoute("hashchange");
|
|
6455
6534
|
recordRoute("initial");
|
|
6456
6535
|
function record(entry) {
|
|
@@ -6483,19 +6562,11 @@ function createTimelineCapture() {
|
|
|
6483
6562
|
}
|
|
6484
6563
|
});
|
|
6485
6564
|
}
|
|
6486
|
-
const
|
|
6487
|
-
|
|
6488
|
-
recordRoute("
|
|
6489
|
-
|
|
6490
|
-
};
|
|
6491
|
-
const replaceStateWrapper = function mushiReplaceState(...args) {
|
|
6492
|
-
const result = capturedReplaceState(...args);
|
|
6493
|
-
recordRoute("replaceState");
|
|
6494
|
-
return result;
|
|
6495
|
-
};
|
|
6496
|
-
history.pushState = pushStateWrapper2;
|
|
6497
|
-
history.replaceState = replaceStateWrapper;
|
|
6498
|
-
window.addEventListener("popstate", handlePopState);
|
|
6565
|
+
const unsubHistory = subscribeHistory({
|
|
6566
|
+
onPush: () => recordRoute("pushState"),
|
|
6567
|
+
onReplace: () => recordRoute("replaceState"),
|
|
6568
|
+
onPop: () => recordRoute("popstate")
|
|
6569
|
+
});
|
|
6499
6570
|
window.addEventListener("hashchange", handleHashChange);
|
|
6500
6571
|
document.addEventListener("click", handleClick, true);
|
|
6501
6572
|
return {
|
|
@@ -6535,13 +6606,7 @@ function createTimelineCapture() {
|
|
|
6535
6606
|
entries.length = 0;
|
|
6536
6607
|
},
|
|
6537
6608
|
destroy() {
|
|
6538
|
-
|
|
6539
|
-
history.pushState = capturedPushState;
|
|
6540
|
-
}
|
|
6541
|
-
if (history.replaceState === replaceStateWrapper) {
|
|
6542
|
-
history.replaceState = capturedReplaceState;
|
|
6543
|
-
}
|
|
6544
|
-
window.removeEventListener("popstate", handlePopState);
|
|
6609
|
+
unsubHistory();
|
|
6545
6610
|
window.removeEventListener("hashchange", handleHashChange);
|
|
6546
6611
|
document.removeEventListener("click", handleClick, true);
|
|
6547
6612
|
}
|
|
@@ -6701,32 +6766,16 @@ function createDiscoveryCapture(opts) {
|
|
|
6701
6766
|
flushNow: () => void 0
|
|
6702
6767
|
};
|
|
6703
6768
|
}
|
|
6704
|
-
const
|
|
6705
|
-
const
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
};
|
|
6711
|
-
const patchedReplace = function patched(...args) {
|
|
6712
|
-
const out = originalReplace(...args);
|
|
6713
|
-
onMaybeNavigation();
|
|
6714
|
-
return out;
|
|
6715
|
-
};
|
|
6716
|
-
window.history.pushState = patchedPush;
|
|
6717
|
-
window.history.replaceState = patchedReplace;
|
|
6718
|
-
const onPop = () => onMaybeNavigation();
|
|
6719
|
-
window.addEventListener("popstate", onPop);
|
|
6769
|
+
const onNav = () => onMaybeNavigation();
|
|
6770
|
+
const unsubHistory = subscribeHistory({
|
|
6771
|
+
onPush: onNav,
|
|
6772
|
+
onReplace: onNav,
|
|
6773
|
+
onPop: onNav
|
|
6774
|
+
});
|
|
6720
6775
|
scheduleEmit();
|
|
6721
6776
|
return {
|
|
6722
6777
|
destroy() {
|
|
6723
|
-
|
|
6724
|
-
if (window.history.pushState === patchedPush) {
|
|
6725
|
-
window.history.pushState = originalPush;
|
|
6726
|
-
}
|
|
6727
|
-
if (window.history.replaceState === patchedReplace) {
|
|
6728
|
-
window.history.replaceState = originalReplace;
|
|
6729
|
-
}
|
|
6778
|
+
unsubHistory();
|
|
6730
6779
|
if (pendingTimer) {
|
|
6731
6780
|
clearTimeout(pendingTimer);
|
|
6732
6781
|
pendingTimer = null;
|
|
@@ -7310,28 +7359,14 @@ function setupProactiveTriggers(callbacks, config = {}) {
|
|
|
7310
7359
|
let timer = null;
|
|
7311
7360
|
let lastPath = window.location?.pathname ?? "";
|
|
7312
7361
|
arm2();
|
|
7313
|
-
const
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
const result = origPush.apply(this, args);
|
|
7319
|
-
reset2();
|
|
7320
|
-
return result;
|
|
7321
|
-
};
|
|
7322
|
-
history2.replaceState = function(...args) {
|
|
7323
|
-
const result = origReplace.apply(this, args);
|
|
7324
|
-
reset2();
|
|
7325
|
-
return result;
|
|
7326
|
-
};
|
|
7327
|
-
}
|
|
7328
|
-
const onPop = () => reset2();
|
|
7329
|
-
window.addEventListener("popstate", onPop);
|
|
7362
|
+
const unsubHistory = subscribeHistory({
|
|
7363
|
+
onPush: reset2,
|
|
7364
|
+
onReplace: reset2,
|
|
7365
|
+
onPop: reset2
|
|
7366
|
+
});
|
|
7330
7367
|
cleanups.push(() => {
|
|
7331
7368
|
if (timer) clearTimeout(timer);
|
|
7332
|
-
|
|
7333
|
-
if (history2 && origPush) history2.pushState = origPush;
|
|
7334
|
-
if (history2 && origReplace) history2.replaceState = origReplace;
|
|
7369
|
+
unsubHistory();
|
|
7335
7370
|
});
|
|
7336
7371
|
}
|
|
7337
7372
|
const firstSessionEnabled = config.firstSession === true || typeof config.firstSession === "object" && config.firstSession !== null;
|
|
@@ -8456,16 +8491,17 @@ function createInstance(config) {
|
|
|
8456
8491
|
networkCap?.destroy();
|
|
8457
8492
|
perfCap?.destroy();
|
|
8458
8493
|
elementSelector?.deactivate();
|
|
8494
|
+
teardown();
|
|
8459
8495
|
detachAutoBreadcrumbs?.();
|
|
8460
8496
|
detachAutoBreadcrumbs = null;
|
|
8461
|
-
timelineCap.destroy();
|
|
8462
8497
|
discoveryCap?.destroy();
|
|
8463
8498
|
discoveryCap = null;
|
|
8499
|
+
timelineCap.destroy();
|
|
8500
|
+
uninstallHistoryPatchForce();
|
|
8464
8501
|
replayCap?.destroy();
|
|
8465
8502
|
replayCap = null;
|
|
8466
8503
|
offlineQueue.stopAutoSync();
|
|
8467
8504
|
stopReporterInboxPolling();
|
|
8468
|
-
teardown();
|
|
8469
8505
|
breadcrumbs.clear();
|
|
8470
8506
|
listeners.clear();
|
|
8471
8507
|
instance = null;
|
|
@@ -9127,37 +9163,12 @@ function installAutoBreadcrumbs(buffer) {
|
|
|
9127
9163
|
data: { url: window.location.href, kind }
|
|
9128
9164
|
});
|
|
9129
9165
|
};
|
|
9130
|
-
const
|
|
9131
|
-
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
const capturedReplace = window.history.replaceState.bind(window.history);
|
|
9135
|
-
const pushPatched = function patched(...args) {
|
|
9136
|
-
const ret = capturedPush(...args);
|
|
9137
|
-
try {
|
|
9138
|
-
dispatchRouteChange("pushState");
|
|
9139
|
-
} catch {
|
|
9140
|
-
}
|
|
9141
|
-
return ret;
|
|
9142
|
-
};
|
|
9143
|
-
const replacePatched = function patched(...args) {
|
|
9144
|
-
const ret = capturedReplace(...args);
|
|
9145
|
-
try {
|
|
9146
|
-
dispatchRouteChange("replaceState");
|
|
9147
|
-
} catch {
|
|
9148
|
-
}
|
|
9149
|
-
return ret;
|
|
9150
|
-
};
|
|
9151
|
-
window.history.pushState = pushPatched;
|
|
9152
|
-
window.history.replaceState = replacePatched;
|
|
9153
|
-
cleanups.push(() => {
|
|
9154
|
-
if (window.history.pushState === pushPatched) {
|
|
9155
|
-
window.history.pushState = capturedPush;
|
|
9156
|
-
}
|
|
9157
|
-
if (window.history.replaceState === replacePatched) {
|
|
9158
|
-
window.history.replaceState = capturedReplace;
|
|
9159
|
-
}
|
|
9166
|
+
const unsubHistory = subscribeHistory({
|
|
9167
|
+
onPush: () => dispatchRouteChange("pushState"),
|
|
9168
|
+
onReplace: () => dispatchRouteChange("replaceState"),
|
|
9169
|
+
onPop: () => dispatchRouteChange("popstate")
|
|
9160
9170
|
});
|
|
9171
|
+
cleanups.push(unsubHistory);
|
|
9161
9172
|
} catch {
|
|
9162
9173
|
}
|
|
9163
9174
|
try {
|