@mcp-fe/react-event-tracker 0.0.13 → 0.0.14
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.
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { WorkerClientInitOptions } from '@mcp-fe/event-tracker';
|
|
2
|
-
export declare function useReactRouterEventTracker(initOptions?: WorkerClientInitOptions):
|
|
2
|
+
export declare function useReactRouterEventTracker(initOptions?: WorkerClientInitOptions): {
|
|
3
|
+
setAuthToken: (token: string) => void;
|
|
4
|
+
};
|
|
3
5
|
//# sourceMappingURL=useReactRouterEventTracker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReactRouterEventTracker.d.ts","sourceRoot":"","sources":["../../../../libs/react-event-tracker/src/hooks/useReactRouterEventTracker.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"useReactRouterEventTracker.d.ts","sourceRoot":"","sources":["../../../../libs/react-event-tracker/src/hooks/useReactRouterEventTracker.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAC;AAE/B,wBAAgB,0BAA0B,CAAC,WAAW,CAAC,EAAE,uBAAuB,GAAG;IAAE,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,CA2F3H"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { WorkerClientInitOptions } from '@mcp-fe/event-tracker';
|
|
2
|
-
export declare function useTanstackRouterEventTracker(initOptions?: WorkerClientInitOptions):
|
|
2
|
+
export declare function useTanstackRouterEventTracker(initOptions?: WorkerClientInitOptions): {
|
|
3
|
+
setAuthToken: (token: string) => void;
|
|
4
|
+
};
|
|
3
5
|
//# sourceMappingURL=useTanstackRouterEventTracker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTanstackRouterEventTracker.d.ts","sourceRoot":"","sources":["../../../../libs/react-event-tracker/src/hooks/useTanstackRouterEventTracker.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"useTanstackRouterEventTracker.d.ts","sourceRoot":"","sources":["../../../../libs/react-event-tracker/src/hooks/useTanstackRouterEventTracker.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAC;AAE/B,wBAAgB,6BAA6B,CAAC,WAAW,CAAC,EAAE,uBAAuB,GAAG;IAAE,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,CA2F9H"}
|
package/index.mjs
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
import * as S from "react";
|
|
2
|
-
import L, { useRef as R, useState as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
2
|
+
import L, { useRef as R, useState as Z, useEffect as _ } from "react";
|
|
3
|
+
const ce = Object.prototype.hasOwnProperty;
|
|
4
|
+
function ee(t, e, r = 0) {
|
|
5
5
|
if (t === e)
|
|
6
6
|
return t;
|
|
7
7
|
if (r > 500) return e;
|
|
8
|
-
const o = e, n =
|
|
9
|
-
if (!n && !(
|
|
10
|
-
const l = n ? t :
|
|
8
|
+
const o = e, n = K(t) && K(o);
|
|
9
|
+
if (!n && !(z(t) && z(o))) return o;
|
|
10
|
+
const l = n ? t : V(t);
|
|
11
11
|
if (!l) return o;
|
|
12
|
-
const a = n ? o :
|
|
12
|
+
const a = n ? o : V(o);
|
|
13
13
|
if (!a) return o;
|
|
14
14
|
const c = l.length, i = a.length, s = n ? new Array(i) : {};
|
|
15
15
|
let h = 0;
|
|
16
16
|
for (let v = 0; v < i; v++) {
|
|
17
17
|
const p = n ? v : a[v], u = t[p], f = o[p];
|
|
18
18
|
if (u === f) {
|
|
19
|
-
s[p] = u, (n ? v < c :
|
|
19
|
+
s[p] = u, (n ? v < c : ce.call(t, p)) && h++;
|
|
20
20
|
continue;
|
|
21
21
|
}
|
|
22
22
|
if (u === null || f === null || typeof u != "object" || typeof f != "object") {
|
|
23
23
|
s[p] = f;
|
|
24
24
|
continue;
|
|
25
25
|
}
|
|
26
|
-
const d =
|
|
26
|
+
const d = ee(u, f, r + 1);
|
|
27
27
|
s[p] = d, d === u && h++;
|
|
28
28
|
}
|
|
29
29
|
return c === i && h === c ? t : s;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function V(t) {
|
|
32
32
|
const e = [], r = Object.getOwnPropertyNames(t);
|
|
33
33
|
for (const n of r) {
|
|
34
34
|
if (!Object.prototype.propertyIsEnumerable.call(t, n)) return !1;
|
|
@@ -41,24 +41,24 @@ function M(t) {
|
|
|
41
41
|
}
|
|
42
42
|
return e;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
if (!
|
|
44
|
+
function z(t) {
|
|
45
|
+
if (!G(t))
|
|
46
46
|
return !1;
|
|
47
47
|
const e = t.constructor;
|
|
48
48
|
if (typeof e > "u")
|
|
49
49
|
return !0;
|
|
50
50
|
const r = e.prototype;
|
|
51
|
-
return !(!
|
|
51
|
+
return !(!G(r) || !r.hasOwnProperty("isPrototypeOf"));
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function G(t) {
|
|
54
54
|
return Object.prototype.toString.call(t) === "[object Object]";
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function K(t) {
|
|
57
57
|
return Array.isArray(t) && t.length === Object.keys(t).length;
|
|
58
58
|
}
|
|
59
|
-
var
|
|
60
|
-
function
|
|
61
|
-
if (!
|
|
59
|
+
var ue = process.env.NODE_ENV === "production";
|
|
60
|
+
function le(t, e) {
|
|
61
|
+
if (!ue) {
|
|
62
62
|
if (t)
|
|
63
63
|
return;
|
|
64
64
|
var r = "Warning: " + e;
|
|
@@ -70,10 +70,10 @@ function ue(t, e) {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
var C = { exports: {} }, A = {}, N = { exports: {} }, b = {};
|
|
73
|
-
var
|
|
74
|
-
function
|
|
75
|
-
if (
|
|
76
|
-
|
|
73
|
+
var H;
|
|
74
|
+
function fe() {
|
|
75
|
+
if (H) return b;
|
|
76
|
+
H = 1;
|
|
77
77
|
var t = L;
|
|
78
78
|
function e(v, p) {
|
|
79
79
|
return v === p && (v !== 0 || 1 / v === 1 / p) || v !== v && p !== p;
|
|
@@ -112,9 +112,9 @@ function le() {
|
|
|
112
112
|
return b.useSyncExternalStore = t.useSyncExternalStore !== void 0 ? t.useSyncExternalStore : h, b;
|
|
113
113
|
}
|
|
114
114
|
var I = {};
|
|
115
|
-
var
|
|
116
|
-
function
|
|
117
|
-
return
|
|
115
|
+
var F;
|
|
116
|
+
function de() {
|
|
117
|
+
return F || (F = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
118
118
|
function t(u, f) {
|
|
119
119
|
return u === f && (u !== 0 || 1 / u === 1 / f) || u !== u && f !== f;
|
|
120
120
|
}
|
|
@@ -165,15 +165,15 @@ function fe() {
|
|
|
165
165
|
I.useSyncExternalStore = n.useSyncExternalStore !== void 0 ? n.useSyncExternalStore : p, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
166
166
|
})()), I;
|
|
167
167
|
}
|
|
168
|
-
var F;
|
|
169
|
-
function ee() {
|
|
170
|
-
return F || (F = 1, process.env.NODE_ENV === "production" ? N.exports = le() : N.exports = fe()), N.exports;
|
|
171
|
-
}
|
|
172
168
|
var q;
|
|
173
|
-
function
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
169
|
+
function te() {
|
|
170
|
+
return q || (q = 1, process.env.NODE_ENV === "production" ? N.exports = fe() : N.exports = de()), N.exports;
|
|
171
|
+
}
|
|
172
|
+
var X;
|
|
173
|
+
function he() {
|
|
174
|
+
if (X) return A;
|
|
175
|
+
X = 1;
|
|
176
|
+
var t = L, e = te();
|
|
177
177
|
function r(s, h) {
|
|
178
178
|
return s === h && (s !== 0 || 1 / s === 1 / h) || s !== s && h !== h;
|
|
179
179
|
}
|
|
@@ -221,14 +221,14 @@ function de() {
|
|
|
221
221
|
}, A;
|
|
222
222
|
}
|
|
223
223
|
var P = {};
|
|
224
|
-
var
|
|
225
|
-
function
|
|
226
|
-
return
|
|
224
|
+
var $;
|
|
225
|
+
function ve() {
|
|
226
|
+
return $ || ($ = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
227
227
|
function t(s, h) {
|
|
228
228
|
return s === h && (s !== 0 || 1 / s === 1 / h) || s !== s && h !== h;
|
|
229
229
|
}
|
|
230
230
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
231
|
-
var e = L, r =
|
|
231
|
+
var e = L, r = te(), o = typeof Object.is == "function" ? Object.is : t, n = r.useSyncExternalStore, l = e.useRef, a = e.useEffect, c = e.useMemo, i = e.useDebugValue;
|
|
232
232
|
P.useSyncExternalStoreWithSelector = function(s, h, v, p, u) {
|
|
233
233
|
var f = l(null);
|
|
234
234
|
if (f.current === null) {
|
|
@@ -273,14 +273,14 @@ function he() {
|
|
|
273
273
|
}, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
274
274
|
})()), P;
|
|
275
275
|
}
|
|
276
|
-
var
|
|
277
|
-
function
|
|
278
|
-
return
|
|
276
|
+
var j;
|
|
277
|
+
function pe() {
|
|
278
|
+
return j || (j = 1, process.env.NODE_ENV === "production" ? C.exports = he() : C.exports = ve()), C.exports;
|
|
279
279
|
}
|
|
280
|
-
var
|
|
281
|
-
function
|
|
282
|
-
const o = r.equal ??
|
|
283
|
-
return
|
|
280
|
+
var ke = pe();
|
|
281
|
+
function me(t, e = (o) => o, r = {}) {
|
|
282
|
+
const o = r.equal ?? ge;
|
|
283
|
+
return ke.useSyncExternalStoreWithSelector(
|
|
284
284
|
t.subscribe,
|
|
285
285
|
() => t.state,
|
|
286
286
|
() => t.state,
|
|
@@ -288,7 +288,7 @@ function ke(t, e = (o) => o, r = {}) {
|
|
|
288
288
|
o
|
|
289
289
|
);
|
|
290
290
|
}
|
|
291
|
-
function
|
|
291
|
+
function ge(t, e) {
|
|
292
292
|
if (Object.is(t, e))
|
|
293
293
|
return !0;
|
|
294
294
|
if (typeof t != "object" || t === null || typeof e != "object" || e === null)
|
|
@@ -307,38 +307,38 @@ function me(t, e) {
|
|
|
307
307
|
}
|
|
308
308
|
if (t instanceof Date && e instanceof Date)
|
|
309
309
|
return t.getTime() === e.getTime();
|
|
310
|
-
const r =
|
|
311
|
-
if (r.length !==
|
|
310
|
+
const r = Y(t);
|
|
311
|
+
if (r.length !== Y(e).length)
|
|
312
312
|
return !1;
|
|
313
313
|
for (let o = 0; o < r.length; o++)
|
|
314
314
|
if (!Object.prototype.hasOwnProperty.call(e, r[o]) || !Object.is(t[r[o]], e[r[o]]))
|
|
315
315
|
return !1;
|
|
316
316
|
return !0;
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function Y(t) {
|
|
319
319
|
return Object.keys(t).concat(
|
|
320
320
|
Object.getOwnPropertySymbols(t)
|
|
321
321
|
);
|
|
322
322
|
}
|
|
323
323
|
const U = S.createContext(null);
|
|
324
|
-
function
|
|
324
|
+
function Ee() {
|
|
325
325
|
return typeof document > "u" ? U : window.__TSR_ROUTER_CONTEXT__ ? window.__TSR_ROUTER_CONTEXT__ : (window.__TSR_ROUTER_CONTEXT__ = U, U);
|
|
326
326
|
}
|
|
327
|
-
function
|
|
328
|
-
const e = S.useContext(
|
|
329
|
-
return
|
|
327
|
+
function Se(t) {
|
|
328
|
+
const e = S.useContext(Ee());
|
|
329
|
+
return le(
|
|
330
330
|
!((t?.warn ?? !0) && !e),
|
|
331
331
|
"useRouter must be used inside a <RouterProvider> component!"
|
|
332
332
|
), e;
|
|
333
333
|
}
|
|
334
|
-
function
|
|
335
|
-
const e =
|
|
334
|
+
function _e(t) {
|
|
335
|
+
const e = Se({
|
|
336
336
|
warn: t?.router === void 0
|
|
337
337
|
}), r = t?.router || e, o = R(void 0);
|
|
338
|
-
return
|
|
338
|
+
return me(r.__store, (n) => {
|
|
339
339
|
if (t?.select) {
|
|
340
340
|
if (t.structuralSharing ?? r.options.defaultStructuralSharing) {
|
|
341
|
-
const l =
|
|
341
|
+
const l = ee(
|
|
342
342
|
o.current,
|
|
343
343
|
t.select(n)
|
|
344
344
|
);
|
|
@@ -349,12 +349,12 @@ function Se(t) {
|
|
|
349
349
|
return n;
|
|
350
350
|
});
|
|
351
351
|
}
|
|
352
|
-
function
|
|
353
|
-
return
|
|
352
|
+
function ye(t) {
|
|
353
|
+
return _e({
|
|
354
354
|
select: (e) => e.location
|
|
355
355
|
});
|
|
356
356
|
}
|
|
357
|
-
class
|
|
357
|
+
class Te {
|
|
358
358
|
// Configurable worker script URLs (defaults kept for backward compatibility)
|
|
359
359
|
sharedWorkerUrl = "/mcp-shared-worker.js";
|
|
360
360
|
serviceWorkerUrl = "/mcp-service-worker.js";
|
|
@@ -633,20 +633,23 @@ class ye {
|
|
|
633
633
|
else this.workerType === "service" && (this.sendAuthTokenToServiceWorker(e), this.pendingAuthToken = null);
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
|
-
const
|
|
636
|
+
const D = new Te();
|
|
637
637
|
async function re(t) {
|
|
638
|
-
return
|
|
638
|
+
return D.init(t);
|
|
639
639
|
}
|
|
640
|
-
async function
|
|
640
|
+
async function x(t) {
|
|
641
641
|
const e = { ...t, timestamp: Date.now() };
|
|
642
|
-
await
|
|
642
|
+
await D.request("STORE_EVENT", { event: e });
|
|
643
643
|
}
|
|
644
|
-
|
|
645
|
-
|
|
644
|
+
function ne(t) {
|
|
645
|
+
D.setAuthToken(t);
|
|
646
646
|
}
|
|
647
647
|
async function oe(t, e, r) {
|
|
648
|
+
return x({ type: "navigation", from: t, to: e, path: r || e });
|
|
649
|
+
}
|
|
650
|
+
async function ie(t, e, r) {
|
|
648
651
|
const o = t.id || void 0, n = t.className || void 0, l = t.textContent?.trim().substring(0, 100) || void 0, a = t.tagName.toLowerCase();
|
|
649
|
-
return
|
|
652
|
+
return x({
|
|
650
653
|
type: "click",
|
|
651
654
|
element: a,
|
|
652
655
|
elementId: o,
|
|
@@ -656,9 +659,9 @@ async function oe(t, e, r) {
|
|
|
656
659
|
metadata: r
|
|
657
660
|
});
|
|
658
661
|
}
|
|
659
|
-
async function
|
|
662
|
+
async function se(t, e, r) {
|
|
660
663
|
const o = t.id || void 0, n = t.className || void 0, l = t.tagName.toLowerCase();
|
|
661
|
-
return
|
|
664
|
+
return x({
|
|
662
665
|
type: "input",
|
|
663
666
|
element: l,
|
|
664
667
|
elementId: o,
|
|
@@ -670,9 +673,9 @@ async function ie(t, e, r) {
|
|
|
670
673
|
}
|
|
671
674
|
});
|
|
672
675
|
}
|
|
673
|
-
function
|
|
674
|
-
const e =
|
|
675
|
-
_(() => {
|
|
676
|
+
function Pe(t) {
|
|
677
|
+
const e = ye(), [r, o] = Z(!1), n = R(e.pathname), l = R(null);
|
|
678
|
+
return _(() => {
|
|
676
679
|
n.current !== e.pathname && (l.current = n.current, n.current = e.pathname);
|
|
677
680
|
}, [e.pathname]), _(() => {
|
|
678
681
|
re(t).then(() => o(!0)).catch((a) => {
|
|
@@ -681,7 +684,7 @@ function Ie(t) {
|
|
|
681
684
|
}, [t]), _(() => {
|
|
682
685
|
if (!r) return;
|
|
683
686
|
const a = l.current, c = n.current;
|
|
684
|
-
a && a !== c &&
|
|
687
|
+
a && a !== c && oe(a, c, c).catch((i) => {
|
|
685
688
|
console.error("Failed to track navigation:", i);
|
|
686
689
|
});
|
|
687
690
|
}, [e.pathname, r]), _(() => {
|
|
@@ -689,7 +692,7 @@ function Ie(t) {
|
|
|
689
692
|
const a = (c) => {
|
|
690
693
|
const i = c.target;
|
|
691
694
|
if (!i) return;
|
|
692
|
-
i.tagName === "BUTTON" || i.tagName === "A" || i.closest("button") || i.closest("a") ||
|
|
695
|
+
i.tagName === "BUTTON" || i.tagName === "A" || i.closest("button") || i.closest("a") || ie(i, n.current).catch((h) => {
|
|
693
696
|
console.error("Failed to track click:", h);
|
|
694
697
|
});
|
|
695
698
|
};
|
|
@@ -700,7 +703,7 @@ function Ie(t) {
|
|
|
700
703
|
const c = (i) => {
|
|
701
704
|
const s = i.target;
|
|
702
705
|
s && (s.tagName === "INPUT" || s.tagName === "TEXTAREA") && (clearTimeout(a), a = setTimeout(() => {
|
|
703
|
-
|
|
706
|
+
se(s, s.value, n.current).catch(
|
|
704
707
|
(h) => {
|
|
705
708
|
console.error("Failed to track input:", h);
|
|
706
709
|
}
|
|
@@ -710,57 +713,59 @@ function Ie(t) {
|
|
|
710
713
|
return document.addEventListener("input", c, !0), () => {
|
|
711
714
|
clearTimeout(a), document.removeEventListener("input", c, !0);
|
|
712
715
|
};
|
|
713
|
-
}, [r])
|
|
716
|
+
}, [r]), {
|
|
717
|
+
setAuthToken: ne
|
|
718
|
+
};
|
|
714
719
|
}
|
|
715
|
-
var
|
|
720
|
+
var B;
|
|
716
721
|
(function(t) {
|
|
717
722
|
t.Pop = "POP", t.Push = "PUSH", t.Replace = "REPLACE";
|
|
718
|
-
})(
|
|
719
|
-
function
|
|
723
|
+
})(B || (B = {}));
|
|
724
|
+
function J(t, e) {
|
|
720
725
|
throw new Error(e);
|
|
721
726
|
}
|
|
722
|
-
var
|
|
727
|
+
var Q;
|
|
723
728
|
(function(t) {
|
|
724
729
|
t.data = "data", t.deferred = "deferred", t.redirect = "redirect", t.error = "error";
|
|
725
|
-
})(
|
|
726
|
-
const
|
|
727
|
-
new Set(
|
|
728
|
-
const
|
|
729
|
-
new Set(
|
|
730
|
-
const Oe = /* @__PURE__ */ S.createContext(null);
|
|
731
|
-
process.env.NODE_ENV !== "production" && (Oe.displayName = "DataRouter");
|
|
730
|
+
})(Q || (Q = {}));
|
|
731
|
+
const ae = ["post", "put", "patch", "delete"];
|
|
732
|
+
new Set(ae);
|
|
733
|
+
const Oe = ["get", ...ae];
|
|
734
|
+
new Set(Oe);
|
|
732
735
|
const We = /* @__PURE__ */ S.createContext(null);
|
|
733
|
-
process.env.NODE_ENV !== "production" && (We.displayName = "
|
|
736
|
+
process.env.NODE_ENV !== "production" && (We.displayName = "DataRouter");
|
|
734
737
|
const we = /* @__PURE__ */ S.createContext(null);
|
|
735
|
-
process.env.NODE_ENV !== "production" && (we.displayName = "
|
|
738
|
+
process.env.NODE_ENV !== "production" && (we.displayName = "DataRouterState");
|
|
736
739
|
const Re = /* @__PURE__ */ S.createContext(null);
|
|
737
|
-
process.env.NODE_ENV !== "production" && (Re.displayName = "
|
|
738
|
-
const
|
|
739
|
-
process.env.NODE_ENV !== "production" && (
|
|
740
|
-
const
|
|
740
|
+
process.env.NODE_ENV !== "production" && (Re.displayName = "Await");
|
|
741
|
+
const Ce = /* @__PURE__ */ S.createContext(null);
|
|
742
|
+
process.env.NODE_ENV !== "production" && (Ce.displayName = "Navigation");
|
|
743
|
+
const M = /* @__PURE__ */ S.createContext(null);
|
|
744
|
+
process.env.NODE_ENV !== "production" && (M.displayName = "Location");
|
|
745
|
+
const Ne = /* @__PURE__ */ S.createContext({
|
|
741
746
|
outlet: null,
|
|
742
747
|
matches: [],
|
|
743
748
|
isDataRoute: !1
|
|
744
749
|
});
|
|
745
|
-
process.env.NODE_ENV !== "production" && (
|
|
746
|
-
const
|
|
747
|
-
process.env.NODE_ENV !== "production" && (
|
|
748
|
-
function Le() {
|
|
749
|
-
return S.useContext(x) != null;
|
|
750
|
-
}
|
|
750
|
+
process.env.NODE_ENV !== "production" && (Ne.displayName = "Route");
|
|
751
|
+
const Le = /* @__PURE__ */ S.createContext(null);
|
|
752
|
+
process.env.NODE_ENV !== "production" && (Le.displayName = "RouteError");
|
|
751
753
|
function Ae() {
|
|
752
|
-
return
|
|
754
|
+
return S.useContext(M) != null;
|
|
755
|
+
}
|
|
756
|
+
function be() {
|
|
757
|
+
return Ae() || (process.env.NODE_ENV !== "production" ? J(
|
|
753
758
|
!1,
|
|
754
759
|
// TODO: This error is probably because they somehow have 2 versions of the
|
|
755
760
|
// router loaded. We can help them understand how to avoid that.
|
|
756
761
|
"useLocation() may be used only in the context of a <Router> component."
|
|
757
|
-
) :
|
|
762
|
+
) : J()), S.useContext(M).location;
|
|
758
763
|
}
|
|
759
764
|
new Promise(() => {
|
|
760
765
|
});
|
|
761
|
-
function
|
|
762
|
-
const e =
|
|
763
|
-
_(() => {
|
|
766
|
+
function Ue(t) {
|
|
767
|
+
const e = be(), [r, o] = Z(!1), n = R(e.pathname), l = R(null);
|
|
768
|
+
return _(() => {
|
|
764
769
|
l.current = n.current, n.current = e.pathname;
|
|
765
770
|
}, [e.pathname]), _(() => {
|
|
766
771
|
re(t).then(() => {
|
|
@@ -771,7 +776,7 @@ function Pe(t) {
|
|
|
771
776
|
}, [t]), _(() => {
|
|
772
777
|
if (!r) return;
|
|
773
778
|
const a = l.current, c = n.current;
|
|
774
|
-
a && a !== c &&
|
|
779
|
+
a && a !== c && oe(a, c, c).catch((i) => {
|
|
775
780
|
console.error("Failed to track navigation:", i);
|
|
776
781
|
});
|
|
777
782
|
}, [e.pathname, r]), _(() => {
|
|
@@ -779,7 +784,7 @@ function Pe(t) {
|
|
|
779
784
|
const a = (c) => {
|
|
780
785
|
const i = c.target;
|
|
781
786
|
if (!i) return;
|
|
782
|
-
i.tagName === "BUTTON" || i.tagName === "A" || i.closest("button") || i.closest("a") ||
|
|
787
|
+
i.tagName === "BUTTON" || i.tagName === "A" || i.closest("button") || i.closest("a") || ie(i, n.current).catch((h) => {
|
|
783
788
|
console.error("Failed to track click:", h);
|
|
784
789
|
});
|
|
785
790
|
};
|
|
@@ -790,7 +795,7 @@ function Pe(t) {
|
|
|
790
795
|
const c = (i) => {
|
|
791
796
|
const s = i.target;
|
|
792
797
|
s && (s.tagName === "INPUT" || s.tagName === "TEXTAREA") && (clearTimeout(a), a = setTimeout(() => {
|
|
793
|
-
|
|
798
|
+
se(s, s.value, n.current).catch(
|
|
794
799
|
(h) => {
|
|
795
800
|
console.error("Failed to track input:", h);
|
|
796
801
|
}
|
|
@@ -800,9 +805,11 @@ function Pe(t) {
|
|
|
800
805
|
return document.addEventListener("input", c, !0), () => {
|
|
801
806
|
clearTimeout(a), document.removeEventListener("input", c, !0);
|
|
802
807
|
};
|
|
803
|
-
}, [r])
|
|
808
|
+
}, [r]), {
|
|
809
|
+
setAuthToken: ne
|
|
810
|
+
};
|
|
804
811
|
}
|
|
805
812
|
export {
|
|
806
|
-
|
|
807
|
-
|
|
813
|
+
Ue as useReactRouterEventTracker,
|
|
814
|
+
Pe as useTanstackRouterEventTracker
|
|
808
815
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-fe/react-event-tracker",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@mcp-fe/event-tracker": "0.0.
|
|
14
|
+
"@mcp-fe/event-tracker": "0.0.14"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"react": ">=19.0.0",
|