@mcp-fe/event-tracker 0.0.16 → 0.0.17
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/LICENSE +1 -1
- package/index.d.ts +1 -1
- package/index.js +224 -138
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
same page as the copyright notice for easier identification within
|
|
189
189
|
third-party archives.
|
|
190
190
|
|
|
191
|
-
Copyright 2026
|
|
191
|
+
Copyright 2026 Michal Kopecky
|
|
192
192
|
|
|
193
193
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
194
194
|
you may not use this file except in compliance with the License.
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
const m = typeof process < "u" && process.env?.NODE_ENV === "production", f = typeof process < "u" && process.env?.MCP_DEBUG, p = f === "true" || !m && f !== "false", n = {
|
|
2
|
+
log: (...t) => {
|
|
3
|
+
p && console.log(...t);
|
|
4
|
+
},
|
|
5
|
+
debug: (...t) => {
|
|
6
|
+
p && console.debug(...t);
|
|
7
|
+
},
|
|
8
|
+
info: (...t) => {
|
|
9
|
+
console.info(...t);
|
|
10
|
+
},
|
|
11
|
+
error: (...t) => {
|
|
12
|
+
console.error(...t);
|
|
13
|
+
},
|
|
14
|
+
warn: (...t) => {
|
|
15
|
+
p && console.warn(...t);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
class w {
|
|
2
19
|
// Configurable worker script URLs (defaults kept for backward compatibility)
|
|
3
20
|
sharedWorkerUrl = "/mcp-shared-worker.js";
|
|
4
21
|
serviceWorkerUrl = "/mcp-service-worker.js";
|
|
@@ -16,25 +33,34 @@ class g {
|
|
|
16
33
|
// Initialize and choose worker implementation (prefer SharedWorker)
|
|
17
34
|
// Accept either a ServiceWorkerRegistration OR WorkerInitOptions to configure URLs
|
|
18
35
|
async init(e) {
|
|
36
|
+
n.log("[WorkerClient] init() called", {
|
|
37
|
+
hasOptions: !!e,
|
|
38
|
+
currentWorkerType: this.workerType,
|
|
39
|
+
initInProgress: !!this.initPromise,
|
|
40
|
+
timestamp: Date.now()
|
|
41
|
+
});
|
|
19
42
|
let r;
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
r = e;
|
|
43
|
+
const o = e;
|
|
44
|
+
if (o && typeof o.scope == "string")
|
|
45
|
+
r = e, n.log("[WorkerClient] Using explicit ServiceWorker registration");
|
|
23
46
|
else if (e) {
|
|
24
|
-
const
|
|
25
|
-
|
|
47
|
+
const i = e;
|
|
48
|
+
n.log("[WorkerClient] Using WorkerClientInitOptions:", i), i.sharedWorkerUrl && (this.sharedWorkerUrl = i.sharedWorkerUrl), i.serviceWorkerUrl && (this.serviceWorkerUrl = i.serviceWorkerUrl), i.backendWsUrl && (this.backendWsUrl = i.backendWsUrl);
|
|
26
49
|
}
|
|
27
50
|
return this.initPromise ? this.initPromise.then(async () => {
|
|
28
51
|
r && this.workerType !== "service" && await this.init(r);
|
|
29
52
|
}) : (this.initPromise = (async () => {
|
|
30
53
|
try {
|
|
31
54
|
if (r) {
|
|
32
|
-
this.serviceWorkerRegistration = r, this.workerType = "service",
|
|
55
|
+
this.serviceWorkerRegistration = r, this.workerType = "service", n.info(
|
|
33
56
|
"[WorkerClient] Using ServiceWorker (explicit registration)"
|
|
34
57
|
);
|
|
35
58
|
try {
|
|
36
|
-
const
|
|
37
|
-
|
|
59
|
+
const s = {
|
|
60
|
+
type: "INIT",
|
|
61
|
+
backendUrl: this.backendWsUrl
|
|
62
|
+
};
|
|
63
|
+
this.pendingAuthToken && (s.token = this.pendingAuthToken), this.serviceWorkerRegistration.active ? this.serviceWorkerRegistration.active.postMessage(s) : "serviceWorker" in navigator && navigator.serviceWorker.controller && navigator.serviceWorker.controller.postMessage(s);
|
|
38
64
|
} catch {
|
|
39
65
|
}
|
|
40
66
|
return;
|
|
@@ -52,20 +78,20 @@ class g {
|
|
|
52
78
|
try {
|
|
53
79
|
this.sharedWorker = new SharedWorker(this.sharedWorkerUrl, {
|
|
54
80
|
type: "module"
|
|
55
|
-
}), this.sharedWorkerPort = this.sharedWorker.port, this.sharedWorkerPort.start(), await new Promise((r,
|
|
56
|
-
let
|
|
57
|
-
const
|
|
58
|
-
if (!
|
|
59
|
-
const
|
|
60
|
-
|
|
81
|
+
}), this.sharedWorkerPort = this.sharedWorker.port, this.sharedWorkerPort.start(), await new Promise((r, o) => {
|
|
82
|
+
let i = !1;
|
|
83
|
+
const s = setTimeout(() => {
|
|
84
|
+
if (!i) {
|
|
85
|
+
const k = this.sharedWorkerPort;
|
|
86
|
+
k && (k.onmessage = null), o(new Error("SharedWorker initialization timeout"));
|
|
61
87
|
}
|
|
62
|
-
}, 2e3),
|
|
63
|
-
if (!
|
|
64
|
-
return clearTimeout(
|
|
65
|
-
|
|
88
|
+
}, 2e3), l = this.sharedWorkerPort;
|
|
89
|
+
if (!l)
|
|
90
|
+
return clearTimeout(s), o(new Error("SharedWorker port not available"));
|
|
91
|
+
l.onmessage = (k) => {
|
|
66
92
|
try {
|
|
67
|
-
const
|
|
68
|
-
|
|
93
|
+
const h = k.data;
|
|
94
|
+
h && h.type === "CONNECTION_STATUS" && (clearTimeout(s), i = !0, this.workerType = "shared", l.onmessage = null, r());
|
|
69
95
|
} catch {
|
|
70
96
|
}
|
|
71
97
|
};
|
|
@@ -73,19 +99,25 @@ class g {
|
|
|
73
99
|
const e = this.sharedWorkerPort;
|
|
74
100
|
if (e) {
|
|
75
101
|
try {
|
|
76
|
-
const r = {
|
|
102
|
+
const r = {
|
|
103
|
+
type: "INIT",
|
|
104
|
+
backendUrl: this.backendWsUrl
|
|
105
|
+
};
|
|
77
106
|
this.pendingAuthToken && (r.token = this.pendingAuthToken), e.postMessage(r), this.pendingAuthToken = null;
|
|
78
107
|
} catch (r) {
|
|
79
|
-
|
|
108
|
+
n.warn(
|
|
109
|
+
"[WorkerClient] Failed to send INIT to SharedWorker port:",
|
|
110
|
+
r
|
|
111
|
+
);
|
|
80
112
|
}
|
|
81
113
|
e.onmessage = (r) => {
|
|
82
114
|
try {
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
const
|
|
86
|
-
this.connectionStatusCallbacks.forEach((
|
|
115
|
+
const o = r.data;
|
|
116
|
+
if (o && o.type === "CONNECTION_STATUS") {
|
|
117
|
+
const i = !!o.connected;
|
|
118
|
+
this.connectionStatusCallbacks.forEach((s) => {
|
|
87
119
|
try {
|
|
88
|
-
|
|
120
|
+
s(i);
|
|
89
121
|
} catch {
|
|
90
122
|
}
|
|
91
123
|
});
|
|
@@ -94,9 +126,9 @@ class g {
|
|
|
94
126
|
}
|
|
95
127
|
};
|
|
96
128
|
}
|
|
97
|
-
return
|
|
129
|
+
return n.info("[WorkerClient] Using SharedWorker"), !0;
|
|
98
130
|
} catch (e) {
|
|
99
|
-
return
|
|
131
|
+
return n.warn(
|
|
100
132
|
"[WorkerClient] SharedWorker not available, falling back to ServiceWorker:",
|
|
101
133
|
e
|
|
102
134
|
), !1;
|
|
@@ -107,68 +139,122 @@ class g {
|
|
|
107
139
|
try {
|
|
108
140
|
const e = await navigator.serviceWorker.getRegistration();
|
|
109
141
|
if (e) {
|
|
110
|
-
this.serviceWorkerRegistration = e, this.workerType = "service",
|
|
142
|
+
this.serviceWorkerRegistration = e, this.workerType = "service", n.info(
|
|
111
143
|
"[WorkerClient] Using existing ServiceWorker registration"
|
|
112
144
|
);
|
|
113
145
|
return;
|
|
114
146
|
}
|
|
115
147
|
this.serviceWorkerRegistration = await navigator.serviceWorker.register(
|
|
116
148
|
this.serviceWorkerUrl
|
|
117
|
-
), this.workerType = "service",
|
|
149
|
+
), this.workerType = "service", n.info("[WorkerClient] Using MCP ServiceWorker (fallback)");
|
|
118
150
|
try {
|
|
119
|
-
const r = {
|
|
151
|
+
const r = {
|
|
152
|
+
type: "INIT",
|
|
153
|
+
backendUrl: this.backendWsUrl
|
|
154
|
+
};
|
|
120
155
|
this.pendingAuthToken && (r.token = this.pendingAuthToken), this.serviceWorkerRegistration.active ? this.serviceWorkerRegistration.active.postMessage(r) : "serviceWorker" in navigator && navigator.serviceWorker.controller && navigator.serviceWorker.controller.postMessage(r), this.pendingAuthToken = null;
|
|
121
156
|
} catch {
|
|
122
157
|
}
|
|
123
158
|
} catch (e) {
|
|
124
|
-
throw
|
|
125
|
-
"[WorkerClient] Failed to register ServiceWorker:",
|
|
126
|
-
e
|
|
127
|
-
), e;
|
|
159
|
+
throw n.error("[WorkerClient] Failed to register ServiceWorker:", e), e;
|
|
128
160
|
}
|
|
129
161
|
else
|
|
130
162
|
throw new Error("Neither SharedWorker nor ServiceWorker is supported");
|
|
131
163
|
}
|
|
132
164
|
// Low-level request that expects a reply via MessageChannel
|
|
133
|
-
async request(e, r,
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
165
|
+
async request(e, r, o = 5e3) {
|
|
166
|
+
if (n.log("[WorkerClient] Request started:", {
|
|
167
|
+
type: e,
|
|
168
|
+
payload: r,
|
|
169
|
+
timeoutMs: o,
|
|
170
|
+
workerType: this.workerType,
|
|
171
|
+
hasSharedWorkerPort: !!this.sharedWorkerPort,
|
|
172
|
+
hasServiceWorkerReg: !!this.serviceWorkerRegistration
|
|
173
|
+
}), this.workerType === "shared" && this.sharedWorkerPort)
|
|
174
|
+
return new Promise((i, s) => {
|
|
175
|
+
const l = new MessageChannel(), k = Math.random().toString(36).substring(7), h = Date.now(), d = setTimeout(() => {
|
|
176
|
+
const a = Date.now() - h;
|
|
177
|
+
n.error("[WorkerClient] Request timeout:", {
|
|
178
|
+
type: e,
|
|
179
|
+
requestId: k,
|
|
180
|
+
elapsed: a,
|
|
181
|
+
timeoutMs: o
|
|
182
|
+
}), l.port1.onmessage = null, s(new Error("Request timeout"));
|
|
183
|
+
}, o);
|
|
184
|
+
l.port1.onmessage = (a) => {
|
|
185
|
+
try {
|
|
186
|
+
const c = Date.now() - h;
|
|
187
|
+
n.log("[WorkerClient] Request response received:", {
|
|
188
|
+
type: e,
|
|
189
|
+
requestId: k,
|
|
190
|
+
elapsed: c,
|
|
191
|
+
success: a.data?.success
|
|
192
|
+
}), clearTimeout(d), a.data && a.data.success ? i(a.data) : a.data && a.data.success === !1 ? s(new Error(a.data.error || "Worker error")) : i(a.data);
|
|
193
|
+
} catch (c) {
|
|
194
|
+
clearTimeout(d), l.port1.onmessage = null, s(
|
|
195
|
+
c instanceof Error ? c : new Error(String(c))
|
|
196
|
+
);
|
|
197
|
+
}
|
|
141
198
|
};
|
|
142
199
|
try {
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
145
|
-
return clearTimeout(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
200
|
+
const a = this.sharedWorkerPort;
|
|
201
|
+
if (!a)
|
|
202
|
+
return clearTimeout(d), n.error("[WorkerClient] SharedWorker port not available"), s(new Error("SharedWorker port not available"));
|
|
203
|
+
n.log("[WorkerClient] Posting message to SharedWorker:", {
|
|
204
|
+
type: e,
|
|
205
|
+
requestId: k
|
|
206
|
+
}), a.postMessage({ type: e, ...r || {} }, [l.port2]);
|
|
207
|
+
} catch (a) {
|
|
208
|
+
clearTimeout(d), n.error("[WorkerClient] Failed to post message:", a), s(a instanceof Error ? a : new Error(String(a)));
|
|
149
209
|
}
|
|
150
210
|
});
|
|
151
211
|
if (this.workerType === "service" && this.serviceWorkerRegistration) {
|
|
152
|
-
const
|
|
153
|
-
if (!
|
|
154
|
-
if (!
|
|
212
|
+
const i = this.serviceWorkerRegistration;
|
|
213
|
+
if (!i) throw new Error("Service worker registration missing");
|
|
214
|
+
if (!i.active && (n.log("[WorkerClient] ServiceWorker not active, waiting..."), await navigator.serviceWorker.ready, !i.active))
|
|
155
215
|
throw new Error("Service worker not active");
|
|
156
|
-
return new Promise((
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
216
|
+
return new Promise((s, l) => {
|
|
217
|
+
const k = new MessageChannel(), h = Math.random().toString(36).substring(7), d = Date.now(), a = setTimeout(() => {
|
|
218
|
+
const c = Date.now() - d;
|
|
219
|
+
n.error("[WorkerClient] ServiceWorker request timeout:", {
|
|
220
|
+
type: e,
|
|
221
|
+
requestId: h,
|
|
222
|
+
elapsed: c,
|
|
223
|
+
timeoutMs: o
|
|
224
|
+
}), k.port1.onmessage = null, l(new Error("Request timeout"));
|
|
225
|
+
}, o);
|
|
226
|
+
k.port1.onmessage = (c) => {
|
|
227
|
+
try {
|
|
228
|
+
const g = Date.now() - d;
|
|
229
|
+
n.log("[WorkerClient] ServiceWorker response received:", {
|
|
230
|
+
type: e,
|
|
231
|
+
requestId: h,
|
|
232
|
+
elapsed: g,
|
|
233
|
+
success: c.data?.success
|
|
234
|
+
}), clearTimeout(a), c.data && c.data.success ? s(c.data) : c.data && c.data.success === !1 ? l(new Error(c.data.error || "Worker error")) : s(c.data);
|
|
235
|
+
} catch (g) {
|
|
236
|
+
clearTimeout(a), k.port1.onmessage = null, l(
|
|
237
|
+
g instanceof Error ? g : new Error(String(g))
|
|
238
|
+
);
|
|
239
|
+
}
|
|
162
240
|
};
|
|
163
241
|
try {
|
|
164
|
-
const
|
|
165
|
-
if (!
|
|
166
|
-
return clearTimeout(
|
|
242
|
+
const c = i.active;
|
|
243
|
+
if (!c)
|
|
244
|
+
return clearTimeout(a), n.error(
|
|
245
|
+
"[WorkerClient] ServiceWorker active instance not available"
|
|
246
|
+
), l(
|
|
167
247
|
new Error("Service worker active instance not available")
|
|
168
248
|
);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
249
|
+
n.log("[WorkerClient] Posting message to ServiceWorker:", {
|
|
250
|
+
type: e,
|
|
251
|
+
requestId: h
|
|
252
|
+
}), c.postMessage({ type: e, ...r || {} }, [k.port2]);
|
|
253
|
+
} catch (c) {
|
|
254
|
+
clearTimeout(a), n.error(
|
|
255
|
+
"[WorkerClient] Failed to post message to ServiceWorker:",
|
|
256
|
+
c
|
|
257
|
+
), l(c instanceof Error ? c : new Error(String(c)));
|
|
172
258
|
}
|
|
173
259
|
});
|
|
174
260
|
}
|
|
@@ -179,8 +265,8 @@ class g {
|
|
|
179
265
|
if (this.workerType === "shared" && this.sharedWorkerPort) {
|
|
180
266
|
try {
|
|
181
267
|
this.sharedWorkerPort.postMessage({ type: e, ...r || {} });
|
|
182
|
-
} catch (
|
|
183
|
-
|
|
268
|
+
} catch (o) {
|
|
269
|
+
n.error("[WorkerClient] Failed to post to SharedWorker:", o);
|
|
184
270
|
}
|
|
185
271
|
return;
|
|
186
272
|
}
|
|
@@ -190,10 +276,10 @@ class g {
|
|
|
190
276
|
type: e,
|
|
191
277
|
...r || {}
|
|
192
278
|
});
|
|
193
|
-
} catch (
|
|
194
|
-
|
|
279
|
+
} catch (o) {
|
|
280
|
+
n.error(
|
|
195
281
|
"[WorkerClient] Failed to post to ServiceWorker (active):",
|
|
196
|
-
|
|
282
|
+
o
|
|
197
283
|
);
|
|
198
284
|
}
|
|
199
285
|
return;
|
|
@@ -204,17 +290,17 @@ class g {
|
|
|
204
290
|
type: e,
|
|
205
291
|
...r || {}
|
|
206
292
|
});
|
|
207
|
-
} catch (
|
|
208
|
-
|
|
293
|
+
} catch (o) {
|
|
294
|
+
n.error(
|
|
209
295
|
"[WorkerClient] Failed to post to ServiceWorker.controller:",
|
|
210
|
-
|
|
296
|
+
o
|
|
211
297
|
);
|
|
212
298
|
}
|
|
213
299
|
return;
|
|
214
300
|
}
|
|
215
301
|
if (e === "SET_AUTH_TOKEN" && r) {
|
|
216
|
-
const
|
|
217
|
-
typeof
|
|
302
|
+
const o = r.token;
|
|
303
|
+
typeof o == "string" && (this.pendingAuthToken = o);
|
|
218
304
|
}
|
|
219
305
|
}
|
|
220
306
|
sendAuthTokenToServiceWorker(e) {
|
|
@@ -225,7 +311,7 @@ class g {
|
|
|
225
311
|
token: e
|
|
226
312
|
});
|
|
227
313
|
} catch (r) {
|
|
228
|
-
|
|
314
|
+
n.error(
|
|
229
315
|
"[WorkerClient] Failed to send auth token to ServiceWorker:",
|
|
230
316
|
r
|
|
231
317
|
);
|
|
@@ -237,7 +323,7 @@ class g {
|
|
|
237
323
|
token: e
|
|
238
324
|
});
|
|
239
325
|
} catch (r) {
|
|
240
|
-
|
|
326
|
+
n.error(
|
|
241
327
|
"[WorkerClient] Failed to send auth token to ServiceWorker.controller:",
|
|
242
328
|
r
|
|
243
329
|
);
|
|
@@ -269,7 +355,7 @@ class g {
|
|
|
269
355
|
try {
|
|
270
356
|
this.sharedWorkerPort.postMessage({ type: "SET_AUTH_TOKEN", token: e }), this.pendingAuthToken = null;
|
|
271
357
|
} catch (r) {
|
|
272
|
-
|
|
358
|
+
n.error(
|
|
273
359
|
"[WorkerClient] Failed to set auth token on SharedWorker:",
|
|
274
360
|
r
|
|
275
361
|
);
|
|
@@ -277,75 +363,75 @@ class g {
|
|
|
277
363
|
else this.workerType === "service" && (this.sendAuthTokenToServiceWorker(e), this.pendingAuthToken = null);
|
|
278
364
|
}
|
|
279
365
|
}
|
|
280
|
-
const
|
|
281
|
-
async function
|
|
366
|
+
const T = "user-activity-db", S = 1, W = "user-events";
|
|
367
|
+
async function y() {
|
|
282
368
|
return new Promise((t, e) => {
|
|
283
|
-
const r = indexedDB.open(
|
|
284
|
-
r.onerror = () => e(r.error), r.onsuccess = () => t(r.result), r.onupgradeneeded = (
|
|
285
|
-
const
|
|
286
|
-
if (!
|
|
287
|
-
const
|
|
288
|
-
|
|
369
|
+
const r = indexedDB.open(T, S);
|
|
370
|
+
r.onerror = () => e(r.error), r.onsuccess = () => t(r.result), r.onupgradeneeded = (o) => {
|
|
371
|
+
const i = o.target.result;
|
|
372
|
+
if (!i.objectStoreNames.contains(W)) {
|
|
373
|
+
const s = i.createObjectStore(W, { keyPath: "id" });
|
|
374
|
+
s.createIndex("timestamp", "timestamp", { unique: !1 }), s.createIndex("type", "type", { unique: !1 }), s.createIndex("path", "path", { unique: !1 });
|
|
289
375
|
}
|
|
290
376
|
};
|
|
291
377
|
});
|
|
292
378
|
}
|
|
293
|
-
async function
|
|
294
|
-
const
|
|
295
|
-
return new Promise((
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
let
|
|
299
|
-
|
|
300
|
-
},
|
|
379
|
+
async function C(t) {
|
|
380
|
+
const i = (await y()).transaction([W], "readonly").objectStore(W).index("timestamp");
|
|
381
|
+
return new Promise((s, l) => {
|
|
382
|
+
const k = i.getAll();
|
|
383
|
+
k.onsuccess = () => {
|
|
384
|
+
let h = k.result;
|
|
385
|
+
h.sort((d, a) => a.timestamp - d.timestamp), s(h);
|
|
386
|
+
}, k.onerror = () => l(k.error);
|
|
301
387
|
});
|
|
302
388
|
}
|
|
303
|
-
const
|
|
304
|
-
async function
|
|
305
|
-
return
|
|
389
|
+
const u = new w();
|
|
390
|
+
async function E(t) {
|
|
391
|
+
return u.init(t);
|
|
306
392
|
}
|
|
307
|
-
async function
|
|
393
|
+
async function v(t) {
|
|
308
394
|
const e = { ...t, timestamp: Date.now() };
|
|
309
|
-
await
|
|
395
|
+
await u.request("STORE_EVENT", { event: e });
|
|
310
396
|
}
|
|
311
|
-
async function
|
|
312
|
-
const t = await
|
|
397
|
+
async function b() {
|
|
398
|
+
const t = await C();
|
|
313
399
|
return Array.isArray(t) ? t : [];
|
|
314
400
|
}
|
|
315
|
-
async function
|
|
316
|
-
return
|
|
401
|
+
async function U() {
|
|
402
|
+
return u.getConnectionStatus();
|
|
317
403
|
}
|
|
318
|
-
function
|
|
319
|
-
|
|
404
|
+
function N(t) {
|
|
405
|
+
u.setAuthToken(t);
|
|
320
406
|
}
|
|
321
|
-
function
|
|
322
|
-
|
|
407
|
+
function P(t) {
|
|
408
|
+
u.onConnectionStatus(t);
|
|
323
409
|
}
|
|
324
|
-
function
|
|
325
|
-
|
|
410
|
+
function A(t) {
|
|
411
|
+
u.offConnectionStatus(t);
|
|
326
412
|
}
|
|
327
|
-
async function
|
|
328
|
-
return
|
|
413
|
+
async function R(t, e, r) {
|
|
414
|
+
return v({ type: "navigation", from: t, to: e, path: r || e });
|
|
329
415
|
}
|
|
330
|
-
async function
|
|
331
|
-
const
|
|
332
|
-
return
|
|
416
|
+
async function I(t, e, r) {
|
|
417
|
+
const o = t.id || void 0, i = t.className || void 0, s = t.textContent?.trim().substring(0, 100) || void 0, l = t.tagName.toLowerCase();
|
|
418
|
+
return v({
|
|
333
419
|
type: "click",
|
|
334
|
-
element:
|
|
335
|
-
elementId:
|
|
336
|
-
elementClass:
|
|
337
|
-
elementText:
|
|
420
|
+
element: l,
|
|
421
|
+
elementId: o,
|
|
422
|
+
elementClass: i,
|
|
423
|
+
elementText: s,
|
|
338
424
|
path: e || window.location.pathname,
|
|
339
425
|
metadata: r
|
|
340
426
|
});
|
|
341
427
|
}
|
|
342
|
-
async function
|
|
343
|
-
const
|
|
344
|
-
return
|
|
428
|
+
async function M(t, e, r) {
|
|
429
|
+
const o = t.id || void 0, i = t.className || void 0, s = t.tagName.toLowerCase();
|
|
430
|
+
return v({
|
|
345
431
|
type: "input",
|
|
346
|
-
element:
|
|
347
|
-
elementId:
|
|
348
|
-
elementClass:
|
|
432
|
+
element: s,
|
|
433
|
+
elementId: o,
|
|
434
|
+
elementClass: i,
|
|
349
435
|
path: r || window.location.pathname,
|
|
350
436
|
metadata: {
|
|
351
437
|
valueLength: e?.length || 0,
|
|
@@ -353,8 +439,8 @@ async function A(t, e, r) {
|
|
|
353
439
|
}
|
|
354
440
|
});
|
|
355
441
|
}
|
|
356
|
-
async function
|
|
357
|
-
return
|
|
442
|
+
async function _(t, e, r) {
|
|
443
|
+
return v({
|
|
358
444
|
type: "custom",
|
|
359
445
|
path: r || window.location.pathname,
|
|
360
446
|
metadata: {
|
|
@@ -364,15 +450,15 @@ async function N(t, e, r) {
|
|
|
364
450
|
});
|
|
365
451
|
}
|
|
366
452
|
export {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
453
|
+
U as getConnectionStatus,
|
|
454
|
+
b as getStoredEvents,
|
|
455
|
+
E as initEventTracker,
|
|
456
|
+
A as offConnectionStatus,
|
|
457
|
+
P as onConnectionStatus,
|
|
458
|
+
N as setAuthToken,
|
|
459
|
+
I as trackClick,
|
|
460
|
+
_ as trackCustom,
|
|
461
|
+
v as trackEvent,
|
|
462
|
+
M as trackInput,
|
|
463
|
+
R as trackNavigation
|
|
378
464
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-fe/event-tracker",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://mcp-fe.ai",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"main": "./index.js",
|
|
14
14
|
"types": "./index.d.ts",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@mcp-fe/mcp-worker": "0.0.
|
|
16
|
+
"@mcp-fe/mcp-worker": "0.0.17"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"access": "public"
|