@mushi-mushi/web 1.22.1 → 1.22.2
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 +106 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +106 -31
- package/dist/index.js.map +1 -1
- package/dist/mushi.loader.global.js +290 -290
- package/dist/mushi.loader.global.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2551,7 +2551,7 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
2551
2551
|
|
|
2552
2552
|
// src/version.ts
|
|
2553
2553
|
var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
|
|
2554
|
-
var MUSHI_SDK_VERSION = "1.22.
|
|
2554
|
+
var MUSHI_SDK_VERSION = "1.22.2" ;
|
|
2555
2555
|
var CATEGORY_ICONS = {
|
|
2556
2556
|
bug: "\u26A0\uFE0F",
|
|
2557
2557
|
slow: "\u{1F40C}",
|
|
@@ -5577,13 +5577,42 @@ async function fetchLeaderboard(limit = 10) {
|
|
|
5577
5577
|
return null;
|
|
5578
5578
|
}
|
|
5579
5579
|
}
|
|
5580
|
+
function teardown() {
|
|
5581
|
+
if (flushTimer) {
|
|
5582
|
+
clearInterval(flushTimer);
|
|
5583
|
+
flushTimer = null;
|
|
5584
|
+
}
|
|
5585
|
+
if (dwellTimer) {
|
|
5586
|
+
clearInterval(dwellTimer);
|
|
5587
|
+
dwellTimer = null;
|
|
5588
|
+
}
|
|
5589
|
+
removeActivityListeners();
|
|
5590
|
+
removeTierBadge();
|
|
5591
|
+
if (consentHost) {
|
|
5592
|
+
consentHost.remove();
|
|
5593
|
+
consentHost = null;
|
|
5594
|
+
}
|
|
5595
|
+
pendingEvents = [];
|
|
5596
|
+
currentUserId = null;
|
|
5597
|
+
apiClient = null;
|
|
5598
|
+
optedIn = false;
|
|
5599
|
+
tierCache = null;
|
|
5600
|
+
rewardsApiBackoffUntil = 0;
|
|
5601
|
+
}
|
|
5580
5602
|
var routeObserver = null;
|
|
5581
5603
|
var clickHandler = null;
|
|
5604
|
+
var popstateHandler = null;
|
|
5582
5605
|
var origPushState = null;
|
|
5606
|
+
var pushStateWrapper = null;
|
|
5583
5607
|
var lastRoute = "";
|
|
5584
5608
|
var listenersInstalled = false;
|
|
5585
5609
|
function installActivityListeners(projectId) {
|
|
5586
|
-
if (listenersInstalled)
|
|
5610
|
+
if (listenersInstalled && pushStateWrapper && history.pushState === pushStateWrapper) {
|
|
5611
|
+
return;
|
|
5612
|
+
}
|
|
5613
|
+
if (listenersInstalled) {
|
|
5614
|
+
removeActivityListeners();
|
|
5615
|
+
}
|
|
5587
5616
|
listenersInstalled = true;
|
|
5588
5617
|
const emitRoute = () => {
|
|
5589
5618
|
const route = location.pathname;
|
|
@@ -5595,11 +5624,14 @@ function installActivityListeners(projectId) {
|
|
|
5595
5624
|
enqueue({ action: "screen_view_unique_per_day", metadata: { route } });
|
|
5596
5625
|
}
|
|
5597
5626
|
};
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5627
|
+
const capturedPushState = history.pushState.bind(history);
|
|
5628
|
+
origPushState = capturedPushState;
|
|
5629
|
+
pushStateWrapper = function(...args) {
|
|
5630
|
+
capturedPushState(...args);
|
|
5601
5631
|
emitRoute();
|
|
5602
5632
|
};
|
|
5633
|
+
history.pushState = pushStateWrapper;
|
|
5634
|
+
popstateHandler = emitRoute;
|
|
5603
5635
|
window.addEventListener("popstate", emitRoute);
|
|
5604
5636
|
emitRoute();
|
|
5605
5637
|
routeObserver = new MutationObserver(() => emitRoute());
|
|
@@ -5614,6 +5646,24 @@ function installActivityListeners(projectId) {
|
|
|
5614
5646
|
};
|
|
5615
5647
|
document.addEventListener("click", clickHandler, { capture: true, passive: true });
|
|
5616
5648
|
}
|
|
5649
|
+
function removeActivityListeners() {
|
|
5650
|
+
listenersInstalled = false;
|
|
5651
|
+
if (origPushState && history.pushState === pushStateWrapper) {
|
|
5652
|
+
history.pushState = origPushState;
|
|
5653
|
+
}
|
|
5654
|
+
origPushState = null;
|
|
5655
|
+
pushStateWrapper = null;
|
|
5656
|
+
if (popstateHandler) {
|
|
5657
|
+
window.removeEventListener("popstate", popstateHandler);
|
|
5658
|
+
popstateHandler = null;
|
|
5659
|
+
}
|
|
5660
|
+
routeObserver?.disconnect();
|
|
5661
|
+
routeObserver = null;
|
|
5662
|
+
if (clickHandler) {
|
|
5663
|
+
document.removeEventListener("click", clickHandler, { capture: true });
|
|
5664
|
+
clickHandler = null;
|
|
5665
|
+
}
|
|
5666
|
+
}
|
|
5617
5667
|
var badgeHost = null;
|
|
5618
5668
|
function renderTierBadge(tier, config) {
|
|
5619
5669
|
if (!config.showInWidget) return;
|
|
@@ -5662,6 +5712,10 @@ function renderTierBadge(tier, config) {
|
|
|
5662
5712
|
`;
|
|
5663
5713
|
document.body.appendChild(badgeHost);
|
|
5664
5714
|
}
|
|
5715
|
+
function removeTierBadge() {
|
|
5716
|
+
badgeHost?.remove();
|
|
5717
|
+
badgeHost = null;
|
|
5718
|
+
}
|
|
5665
5719
|
var consentHost = null;
|
|
5666
5720
|
function renderConsentBanner(projectId, config) {
|
|
5667
5721
|
if (consentHost) return;
|
|
@@ -5736,11 +5790,12 @@ var MAX_MESSAGE_LENGTH = 500;
|
|
|
5736
5790
|
function createConsoleCapture() {
|
|
5737
5791
|
const entries = [];
|
|
5738
5792
|
const originals = {};
|
|
5793
|
+
const wrappers = {};
|
|
5739
5794
|
const levels = ["log", "warn", "error", "info", "debug"];
|
|
5740
5795
|
for (const level of levels) {
|
|
5741
5796
|
const original = console[level];
|
|
5742
5797
|
originals[level] = original;
|
|
5743
|
-
|
|
5798
|
+
const wrapper = (...args) => {
|
|
5744
5799
|
const message = args.map((arg) => {
|
|
5745
5800
|
try {
|
|
5746
5801
|
return typeof arg === "string" ? arg : JSON.stringify(arg);
|
|
@@ -5762,6 +5817,8 @@ function createConsoleCapture() {
|
|
|
5762
5817
|
}
|
|
5763
5818
|
original.call(console, ...args);
|
|
5764
5819
|
};
|
|
5820
|
+
wrappers[level] = wrapper;
|
|
5821
|
+
console[level] = wrapper;
|
|
5765
5822
|
}
|
|
5766
5823
|
return {
|
|
5767
5824
|
getEntries() {
|
|
@@ -5772,7 +5829,7 @@ function createConsoleCapture() {
|
|
|
5772
5829
|
},
|
|
5773
5830
|
destroy() {
|
|
5774
5831
|
for (const level of levels) {
|
|
5775
|
-
if (originals[level]) {
|
|
5832
|
+
if (originals[level] && console[level] === wrappers[level]) {
|
|
5776
5833
|
console[level] = originals[level];
|
|
5777
5834
|
}
|
|
5778
5835
|
}
|
|
@@ -5870,7 +5927,8 @@ function createNetworkCapture(options = {}) {
|
|
|
5870
5927
|
const entries = [];
|
|
5871
5928
|
const originalFetch = globalThis.fetch;
|
|
5872
5929
|
let activeOptions = options;
|
|
5873
|
-
|
|
5930
|
+
let fetchWrapper;
|
|
5931
|
+
globalThis.fetch = fetchWrapper = async function mushiFetchInterceptor(input, init) {
|
|
5874
5932
|
const startTime = Date.now();
|
|
5875
5933
|
const method = init?.method?.toUpperCase() ?? "GET";
|
|
5876
5934
|
const url = getRequestUrl(input);
|
|
@@ -5934,7 +5992,9 @@ function createNetworkCapture(options = {}) {
|
|
|
5934
5992
|
activeOptions = nextOptions;
|
|
5935
5993
|
},
|
|
5936
5994
|
destroy() {
|
|
5937
|
-
globalThis.fetch
|
|
5995
|
+
if (globalThis.fetch === fetchWrapper) {
|
|
5996
|
+
globalThis.fetch = originalFetch;
|
|
5997
|
+
}
|
|
5938
5998
|
}
|
|
5939
5999
|
};
|
|
5940
6000
|
}
|
|
@@ -6386,8 +6446,8 @@ function createElementSelector() {
|
|
|
6386
6446
|
var MAX_TIMELINE_ENTRIES = 120;
|
|
6387
6447
|
function createTimelineCapture() {
|
|
6388
6448
|
const entries = [];
|
|
6389
|
-
const
|
|
6390
|
-
const
|
|
6449
|
+
const capturedPushState = history.pushState.bind(history);
|
|
6450
|
+
const capturedReplaceState = history.replaceState.bind(history);
|
|
6391
6451
|
const handlePopState = () => recordRoute("popstate");
|
|
6392
6452
|
const handleHashChange = () => recordRoute("hashchange");
|
|
6393
6453
|
recordRoute("initial");
|
|
@@ -6421,16 +6481,18 @@ function createTimelineCapture() {
|
|
|
6421
6481
|
}
|
|
6422
6482
|
});
|
|
6423
6483
|
}
|
|
6424
|
-
|
|
6425
|
-
const result =
|
|
6484
|
+
const pushStateWrapper2 = function mushiPushState(...args) {
|
|
6485
|
+
const result = capturedPushState(...args);
|
|
6426
6486
|
recordRoute("pushState");
|
|
6427
6487
|
return result;
|
|
6428
6488
|
};
|
|
6429
|
-
|
|
6430
|
-
const result =
|
|
6489
|
+
const replaceStateWrapper = function mushiReplaceState(...args) {
|
|
6490
|
+
const result = capturedReplaceState(...args);
|
|
6431
6491
|
recordRoute("replaceState");
|
|
6432
6492
|
return result;
|
|
6433
6493
|
};
|
|
6494
|
+
history.pushState = pushStateWrapper2;
|
|
6495
|
+
history.replaceState = replaceStateWrapper;
|
|
6434
6496
|
window.addEventListener("popstate", handlePopState);
|
|
6435
6497
|
window.addEventListener("hashchange", handleHashChange);
|
|
6436
6498
|
document.addEventListener("click", handleClick, true);
|
|
@@ -6471,8 +6533,12 @@ function createTimelineCapture() {
|
|
|
6471
6533
|
entries.length = 0;
|
|
6472
6534
|
},
|
|
6473
6535
|
destroy() {
|
|
6474
|
-
history.pushState
|
|
6475
|
-
|
|
6536
|
+
if (history.pushState === pushStateWrapper2) {
|
|
6537
|
+
history.pushState = capturedPushState;
|
|
6538
|
+
}
|
|
6539
|
+
if (history.replaceState === replaceStateWrapper) {
|
|
6540
|
+
history.replaceState = capturedReplaceState;
|
|
6541
|
+
}
|
|
6476
6542
|
window.removeEventListener("popstate", handlePopState);
|
|
6477
6543
|
window.removeEventListener("hashchange", handleHashChange);
|
|
6478
6544
|
document.removeEventListener("click", handleClick, true);
|
|
@@ -8388,6 +8454,8 @@ function createInstance(config) {
|
|
|
8388
8454
|
networkCap?.destroy();
|
|
8389
8455
|
perfCap?.destroy();
|
|
8390
8456
|
elementSelector?.deactivate();
|
|
8457
|
+
detachAutoBreadcrumbs?.();
|
|
8458
|
+
detachAutoBreadcrumbs = null;
|
|
8391
8459
|
timelineCap.destroy();
|
|
8392
8460
|
discoveryCap?.destroy();
|
|
8393
8461
|
discoveryCap = null;
|
|
@@ -8395,8 +8463,7 @@ function createInstance(config) {
|
|
|
8395
8463
|
replayCap = null;
|
|
8396
8464
|
offlineQueue.stopAutoSync();
|
|
8397
8465
|
stopReporterInboxPolling();
|
|
8398
|
-
|
|
8399
|
-
detachAutoBreadcrumbs = null;
|
|
8466
|
+
teardown();
|
|
8400
8467
|
breadcrumbs.clear();
|
|
8401
8468
|
listeners.clear();
|
|
8402
8469
|
instance = null;
|
|
@@ -9061,34 +9128,40 @@ function installAutoBreadcrumbs(buffer) {
|
|
|
9061
9128
|
const onPop = () => dispatchRouteChange("popstate");
|
|
9062
9129
|
window.addEventListener("popstate", onPop, { passive: true });
|
|
9063
9130
|
cleanups.push(() => window.removeEventListener("popstate", onPop));
|
|
9064
|
-
const
|
|
9065
|
-
const
|
|
9066
|
-
|
|
9067
|
-
const ret =
|
|
9131
|
+
const capturedPush = window.history.pushState.bind(window.history);
|
|
9132
|
+
const capturedReplace = window.history.replaceState.bind(window.history);
|
|
9133
|
+
const pushPatched = function patched(...args) {
|
|
9134
|
+
const ret = capturedPush(...args);
|
|
9068
9135
|
try {
|
|
9069
9136
|
dispatchRouteChange("pushState");
|
|
9070
9137
|
} catch {
|
|
9071
9138
|
}
|
|
9072
9139
|
return ret;
|
|
9073
9140
|
};
|
|
9074
|
-
|
|
9075
|
-
const ret =
|
|
9141
|
+
const replacePatched = function patched(...args) {
|
|
9142
|
+
const ret = capturedReplace(...args);
|
|
9076
9143
|
try {
|
|
9077
9144
|
dispatchRouteChange("replaceState");
|
|
9078
9145
|
} catch {
|
|
9079
9146
|
}
|
|
9080
9147
|
return ret;
|
|
9081
9148
|
};
|
|
9149
|
+
window.history.pushState = pushPatched;
|
|
9150
|
+
window.history.replaceState = replacePatched;
|
|
9082
9151
|
cleanups.push(() => {
|
|
9083
|
-
window.history.pushState
|
|
9084
|
-
|
|
9152
|
+
if (window.history.pushState === pushPatched) {
|
|
9153
|
+
window.history.pushState = capturedPush;
|
|
9154
|
+
}
|
|
9155
|
+
if (window.history.replaceState === replacePatched) {
|
|
9156
|
+
window.history.replaceState = capturedReplace;
|
|
9157
|
+
}
|
|
9085
9158
|
});
|
|
9086
9159
|
} catch {
|
|
9087
9160
|
}
|
|
9088
9161
|
try {
|
|
9089
9162
|
const origError = console.error;
|
|
9090
9163
|
const origWarn = console.warn;
|
|
9091
|
-
|
|
9164
|
+
const errorWrapper = function(...args) {
|
|
9092
9165
|
try {
|
|
9093
9166
|
buffer.add({
|
|
9094
9167
|
category: "console",
|
|
@@ -9099,7 +9172,7 @@ function installAutoBreadcrumbs(buffer) {
|
|
|
9099
9172
|
}
|
|
9100
9173
|
return origError.apply(this, args);
|
|
9101
9174
|
};
|
|
9102
|
-
|
|
9175
|
+
const warnWrapper = function(...args) {
|
|
9103
9176
|
try {
|
|
9104
9177
|
buffer.add({
|
|
9105
9178
|
category: "console",
|
|
@@ -9110,9 +9183,11 @@ function installAutoBreadcrumbs(buffer) {
|
|
|
9110
9183
|
}
|
|
9111
9184
|
return origWarn.apply(this, args);
|
|
9112
9185
|
};
|
|
9186
|
+
console.error = errorWrapper;
|
|
9187
|
+
console.warn = warnWrapper;
|
|
9113
9188
|
cleanups.push(() => {
|
|
9114
|
-
console.error = origError;
|
|
9115
|
-
console.warn = origWarn;
|
|
9189
|
+
if (console.error === errorWrapper) console.error = origError;
|
|
9190
|
+
if (console.warn === warnWrapper) console.warn = origWarn;
|
|
9116
9191
|
});
|
|
9117
9192
|
} catch {
|
|
9118
9193
|
}
|