@mushi-mushi/web 1.22.2 → 1.22.4
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 +131 -121
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +131 -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 +2 -2
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.4" ;
|
|
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,10 @@ function installActivityListeners(projectId) {
|
|
|
5626
5719
|
enqueue({ action: "screen_view_unique_per_day", metadata: { route } });
|
|
5627
5720
|
}
|
|
5628
5721
|
};
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
emitRoute();
|
|
5634
|
-
};
|
|
5635
|
-
history.pushState = pushStateWrapper;
|
|
5636
|
-
popstateHandler = emitRoute;
|
|
5637
|
-
window.addEventListener("popstate", emitRoute);
|
|
5722
|
+
historyUnsub = subscribeHistory({
|
|
5723
|
+
onPush: emitRoute,
|
|
5724
|
+
onPop: emitRoute
|
|
5725
|
+
});
|
|
5638
5726
|
emitRoute();
|
|
5639
5727
|
routeObserver = new MutationObserver(() => emitRoute());
|
|
5640
5728
|
const main = document.querySelector("main") ?? document.body;
|
|
@@ -5650,15 +5738,8 @@ function installActivityListeners(projectId) {
|
|
|
5650
5738
|
}
|
|
5651
5739
|
function removeActivityListeners() {
|
|
5652
5740
|
listenersInstalled = false;
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
}
|
|
5656
|
-
origPushState = null;
|
|
5657
|
-
pushStateWrapper = null;
|
|
5658
|
-
if (popstateHandler) {
|
|
5659
|
-
window.removeEventListener("popstate", popstateHandler);
|
|
5660
|
-
popstateHandler = null;
|
|
5661
|
-
}
|
|
5741
|
+
historyUnsub?.();
|
|
5742
|
+
historyUnsub = null;
|
|
5662
5743
|
routeObserver?.disconnect();
|
|
5663
5744
|
routeObserver = null;
|
|
5664
5745
|
if (clickHandler) {
|
|
@@ -6448,9 +6529,6 @@ function createElementSelector() {
|
|
|
6448
6529
|
var MAX_TIMELINE_ENTRIES = 120;
|
|
6449
6530
|
function createTimelineCapture() {
|
|
6450
6531
|
const entries = [];
|
|
6451
|
-
const capturedPushState = history.pushState.bind(history);
|
|
6452
|
-
const capturedReplaceState = history.replaceState.bind(history);
|
|
6453
|
-
const handlePopState = () => recordRoute("popstate");
|
|
6454
6532
|
const handleHashChange = () => recordRoute("hashchange");
|
|
6455
6533
|
recordRoute("initial");
|
|
6456
6534
|
function record(entry) {
|
|
@@ -6483,19 +6561,11 @@ function createTimelineCapture() {
|
|
|
6483
6561
|
}
|
|
6484
6562
|
});
|
|
6485
6563
|
}
|
|
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);
|
|
6564
|
+
const unsubHistory = subscribeHistory({
|
|
6565
|
+
onPush: () => recordRoute("pushState"),
|
|
6566
|
+
onReplace: () => recordRoute("replaceState"),
|
|
6567
|
+
onPop: () => recordRoute("popstate")
|
|
6568
|
+
});
|
|
6499
6569
|
window.addEventListener("hashchange", handleHashChange);
|
|
6500
6570
|
document.addEventListener("click", handleClick, true);
|
|
6501
6571
|
return {
|
|
@@ -6535,13 +6605,7 @@ function createTimelineCapture() {
|
|
|
6535
6605
|
entries.length = 0;
|
|
6536
6606
|
},
|
|
6537
6607
|
destroy() {
|
|
6538
|
-
|
|
6539
|
-
history.pushState = capturedPushState;
|
|
6540
|
-
}
|
|
6541
|
-
if (history.replaceState === replaceStateWrapper) {
|
|
6542
|
-
history.replaceState = capturedReplaceState;
|
|
6543
|
-
}
|
|
6544
|
-
window.removeEventListener("popstate", handlePopState);
|
|
6608
|
+
unsubHistory();
|
|
6545
6609
|
window.removeEventListener("hashchange", handleHashChange);
|
|
6546
6610
|
document.removeEventListener("click", handleClick, true);
|
|
6547
6611
|
}
|
|
@@ -6701,32 +6765,16 @@ function createDiscoveryCapture(opts) {
|
|
|
6701
6765
|
flushNow: () => void 0
|
|
6702
6766
|
};
|
|
6703
6767
|
}
|
|
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);
|
|
6768
|
+
const onNav = () => onMaybeNavigation();
|
|
6769
|
+
const unsubHistory = subscribeHistory({
|
|
6770
|
+
onPush: onNav,
|
|
6771
|
+
onReplace: onNav,
|
|
6772
|
+
onPop: onNav
|
|
6773
|
+
});
|
|
6720
6774
|
scheduleEmit();
|
|
6721
6775
|
return {
|
|
6722
6776
|
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
|
-
}
|
|
6777
|
+
unsubHistory();
|
|
6730
6778
|
if (pendingTimer) {
|
|
6731
6779
|
clearTimeout(pendingTimer);
|
|
6732
6780
|
pendingTimer = null;
|
|
@@ -7310,28 +7358,14 @@ function setupProactiveTriggers(callbacks, config = {}) {
|
|
|
7310
7358
|
let timer = null;
|
|
7311
7359
|
let lastPath = window.location?.pathname ?? "";
|
|
7312
7360
|
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);
|
|
7361
|
+
const unsubHistory = subscribeHistory({
|
|
7362
|
+
onPush: reset2,
|
|
7363
|
+
onReplace: reset2,
|
|
7364
|
+
onPop: reset2
|
|
7365
|
+
});
|
|
7330
7366
|
cleanups.push(() => {
|
|
7331
7367
|
if (timer) clearTimeout(timer);
|
|
7332
|
-
|
|
7333
|
-
if (history2 && origPush) history2.pushState = origPush;
|
|
7334
|
-
if (history2 && origReplace) history2.replaceState = origReplace;
|
|
7368
|
+
unsubHistory();
|
|
7335
7369
|
});
|
|
7336
7370
|
}
|
|
7337
7371
|
const firstSessionEnabled = config.firstSession === true || typeof config.firstSession === "object" && config.firstSession !== null;
|
|
@@ -8456,16 +8490,17 @@ function createInstance(config) {
|
|
|
8456
8490
|
networkCap?.destroy();
|
|
8457
8491
|
perfCap?.destroy();
|
|
8458
8492
|
elementSelector?.deactivate();
|
|
8493
|
+
teardown();
|
|
8459
8494
|
detachAutoBreadcrumbs?.();
|
|
8460
8495
|
detachAutoBreadcrumbs = null;
|
|
8461
|
-
timelineCap.destroy();
|
|
8462
8496
|
discoveryCap?.destroy();
|
|
8463
8497
|
discoveryCap = null;
|
|
8498
|
+
timelineCap.destroy();
|
|
8499
|
+
uninstallHistoryPatchForce();
|
|
8464
8500
|
replayCap?.destroy();
|
|
8465
8501
|
replayCap = null;
|
|
8466
8502
|
offlineQueue.stopAutoSync();
|
|
8467
8503
|
stopReporterInboxPolling();
|
|
8468
|
-
teardown();
|
|
8469
8504
|
breadcrumbs.clear();
|
|
8470
8505
|
listeners.clear();
|
|
8471
8506
|
instance = null;
|
|
@@ -9127,37 +9162,12 @@ function installAutoBreadcrumbs(buffer) {
|
|
|
9127
9162
|
data: { url: window.location.href, kind }
|
|
9128
9163
|
});
|
|
9129
9164
|
};
|
|
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
|
-
}
|
|
9165
|
+
const unsubHistory = subscribeHistory({
|
|
9166
|
+
onPush: () => dispatchRouteChange("pushState"),
|
|
9167
|
+
onReplace: () => dispatchRouteChange("replaceState"),
|
|
9168
|
+
onPop: () => dispatchRouteChange("popstate")
|
|
9160
9169
|
});
|
|
9170
|
+
cleanups.push(unsubHistory);
|
|
9161
9171
|
} catch {
|
|
9162
9172
|
}
|
|
9163
9173
|
try {
|