@mcp-fe/event-tracker 0.0.14 → 0.0.16

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 ADDED
@@ -0,0 +1,203 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity granting the License.
13
+
14
+ "Legal Entity" shall mean the union of the acting entity and all
15
+ other entities that control, are controlled by, or are under common
16
+ control with that entity. For the purposes of this definition,
17
+ "control" means (i) the power, direct or indirect, to cause the
18
+ direction or management of such entity, whether by contract or
19
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity
23
+ exercising permissions granted by this License.
24
+
25
+ "Source" shall mean the preferred form for making modifications,
26
+ including but not limited to software source code, documentation
27
+ source, and configuration files.
28
+
29
+ "Object" shall mean any form resulting from mechanical
30
+ transformation or translation of a Source form, including but
31
+ not limited to compiled object code, generated documentation,
32
+ and conversions to other media types.
33
+
34
+ "Work" shall mean the work of authorship, whether in Source or
35
+ Object form, made available under the License, as indicated by a
36
+ copyright notice that is included in or attached to the work
37
+ (which shall not include communications that are solely about
38
+ and bear an appropriate legal notice).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based upon (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and derivative works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control
57
+ systems, and issue tracking systems that are managed by, or on behalf
58
+ of, the Licensor for the purpose of discussing and improving the Work,
59
+ but excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to use, reproduce, modify, merge, publish,
70
+ distribute, sublicense, and/or sell copies of the Work, and to
71
+ permit persons to whom the Work is furnished to do so, subject to
72
+ the following conditions:
73
+
74
+ The above copyright notice and this permission notice shall be
75
+ included in all copies or substantial portions of the Work.
76
+
77
+ 3. Grant of Patent License. Subject to the terms and conditions of
78
+ this License, each Contributor hereby grants to You a perpetual,
79
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
80
+ (except as stated in this section) patent license to make, have made,
81
+ use, offer to sell, sell, import, and otherwise transfer the Work,
82
+ where such license applies only to those patent claims licensable
83
+ by such Contributor that are necessarily infringed by their
84
+ Contribution(s) alone or by combination of their Contribution(s)
85
+ with the Work to which such Contribution(s) was submitted. If You
86
+ institute patent litigation against any entity (including a
87
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
88
+ or a Contribution incorporated within the Work constitutes direct
89
+ or contributory patent infringement, then any patent licenses
90
+ granted to You under this License for that Work shall terminate
91
+ as of the date such litigation is filed.
92
+
93
+ 4. Redistribution. You may reproduce and distribute copies of the
94
+ Work or Derivative Works thereof in any medium, with or without
95
+ modifications, and in Source or Object form, provided that You
96
+ meet the following conditions:
97
+
98
+ (a) You must give any other recipients of the Work or
99
+ Derivative Works a copy of this License; and
100
+
101
+ (b) You must cause any modified files to carry prominent notices
102
+ stating that You changed the files; and
103
+
104
+ (c) You must retain, in the Source form of any Derivative Works
105
+ that You distribute, all copyright, patent, trademark, and
106
+ attribution notices from the Source form of the Work,
107
+ excluding those notices that do not pertain to any part of
108
+ the Derivative Works; and
109
+
110
+ (d) If the Work includes a "NOTICE" text file as part of its
111
+ distribution, then any Derivative Works that You distribute must
112
+ include a readable copy of the attribution notices contained
113
+ within such NOTICE file, excluding those notices that do not
114
+ pertain to any part of the Derivative Works, in at least one
115
+ of the following places: within a NOTICE text file distributed
116
+ as part of the Derivative Works; within the Source form or
117
+ documentation, if provided along with the Derivative Works; or,
118
+ within a display generated by the Derivative Works, if and
119
+ wherever such third-party notices normally appear. The contents
120
+ of the NOTICE file are for informational purposes only and
121
+ do not modify the License. You may add Your own attribution
122
+ notices within Derivative Works that You distribute, alongside
123
+ or as an addendum to the NOTICE text from the Work, provided
124
+ that such additional attribution notices cannot be construed
125
+ as modifying the License.
126
+
127
+ You may add Your own copyright notice to Your modifications and
128
+ may provide additional or different license terms and conditions
129
+ for use, reproduction, or distribution of Your modifications, or
130
+ for any such Derivative Works as a whole, provided Your use,
131
+ reproduction, and distribution of the Work otherwise complies with
132
+ the conditions stated in this License.
133
+
134
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
135
+ any Contribution intentionally submitted for inclusion in the Work
136
+ by You to the Licensor shall be under the terms and conditions of
137
+ this License, without any additional terms or conditions.
138
+ Notwithstanding the above, nothing herein shall supersede or modify
139
+ the terms of any separate license agreement you may have executed
140
+ with Licensor regarding such Contributions.
141
+
142
+ 6. Trademarks. This License does not grant permission to use the trade
143
+ names, trademarks, service marks, or product names of the Licensor,
144
+ except as required for reasonable and customary use in describing the
145
+ origin of the Work and reproducing the content of the NOTICE file.
146
+
147
+ 7. Disclaimer of Warranty. Unless required by applicable law or
148
+ agreed to in writing, Licensor provides the Work (and each
149
+ Contributor provides its Contributions) on an "AS IS" BASIS,
150
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
151
+ implied, including, without limitation, any warranties or conditions
152
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
153
+ PARTICULAR PURPOSE. You are solely responsible for determining the
154
+ appropriateness of using or redistributing the Work and assume any
155
+ risks associated with Your exercise of permissions under this License.
156
+
157
+ 8. Limitation of Liability. In no event and under no legal theory,
158
+ whether in tort (including negligence), contract, or otherwise,
159
+ unless required by applicable law (such as deliberate and grossly
160
+ negligent acts) or agreed to in writing, shall any Contributor be
161
+ liable to You for damages, including any direct, indirect, special,
162
+ incidental, or consequential damages of any character arising as a
163
+ result of this License or out of the use or inability to use the
164
+ Work (including but not limited to damages for loss of goodwill,
165
+ work stoppage, computer failure or malfunction, or any and all
166
+ other commercial damages or losses), even if such Contributor
167
+ has been advised of the possibility of such damages.
168
+
169
+ 9. Accepting Warranty or Support. You may choose to offer, and to
170
+ charge a fee for, warranty, support, indemnity or other liability
171
+ obligations and/or rights consistent with this License. However, in
172
+ accepting such obligations, You may act only on Your own behalf and on
173
+ Your sole responsibility, not on behalf of any other Contributor, and
174
+ only if You agree to indemnify, defend, and hold each Contributor
175
+ harmless for any liability incurred by, or claims asserted against,
176
+ such Contributor by reason of your accepting any such warranty or support.
177
+
178
+ END OF TERMS AND CONDITIONS
179
+
180
+ APPENDIX: How to apply the Apache License to your work.
181
+
182
+ To apply the Apache License to your work, attach the following
183
+ boilerplate notice, with the fields enclosed by brackets "[]"
184
+ replaced with your own identifying information. (Don't include
185
+ the brackets!) The text should be enclosed in the appropriate
186
+ comment syntax for the file format. We also recommend that a
187
+ file or class name and description of purpose be included on the
188
+ same page as the copyright notice for easier identification within
189
+ third-party archives.
190
+
191
+ Copyright 2026 [name of copyright owner]
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
package/README.md CHANGED
@@ -1,11 +1,460 @@
1
- # event-tracker
1
+ # @mcp-fe/event-tracker
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ Framework-agnostic event tracking library for the MCP-FE (Model Context Protocol - Frontend Edge) ecosystem. This library provides a simple, clean API for tracking user interactions and making them available to AI agents through the MCP protocol.
4
4
 
5
- ## Building
5
+ ## Overview
6
6
 
7
- Run `nx build event-tracker` to build the library.
7
+ `@mcp-fe/event-tracker` is a lightweight wrapper around [`@mcp-fe/mcp-worker`](../mcp-worker/README.md) that provides an ergonomic API for tracking user events in any JavaScript application. It serves as the foundation for framework-specific integrations like [`@mcp-fe/react-event-tracker`](../react-event-tracker/README.md).
8
8
 
9
- ## Running unit tests
9
+ ### Key Features
10
10
 
11
- Run `nx test event-tracker` to execute the unit tests via [Vitest](https://vitest.dev/).
11
+ - **Framework Agnostic**: Works with any JavaScript framework or vanilla JS
12
+ - **Simple API**: Clean, intuitive functions for common tracking needs
13
+ - **Rich Event Data**: Captures element details, metadata, and context
14
+ - **Connection Management**: Built-in WebSocket connection status monitoring
15
+ - **Authentication Support**: Token-based authentication for user-specific events
16
+ - **TypeScript Support**: Full type definitions included
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install @mcp-fe/event-tracker
22
+ # or
23
+ pnpm add @mcp-fe/event-tracker
24
+ # or
25
+ yarn add @mcp-fe/event-tracker
26
+ ```
27
+
28
+ ### Dependencies
29
+
30
+ This package requires [`@mcp-fe/mcp-worker`](../mcp-worker/README.md) which is automatically installed as a dependency. Make sure to set up the worker files as described in the mcp-worker documentation.
31
+
32
+ ## Quick Start
33
+
34
+ ```typescript
35
+ import {
36
+ initEventTracker,
37
+ trackEvent,
38
+ trackNavigation,
39
+ trackClick
40
+ } from '@mcp-fe/event-tracker';
41
+
42
+ // Initialize the event tracker
43
+ await initEventTracker({
44
+ backendWsUrl: 'ws://localhost:3001'
45
+ });
46
+
47
+ // Track user interactions
48
+ await trackNavigation('/home', '/products');
49
+ await trackClick(document.getElementById('buy-button'));
50
+
51
+ // Track custom events
52
+ await trackEvent({
53
+ type: 'custom',
54
+ metadata: {
55
+ eventName: 'purchase_completed',
56
+ orderId: '12345',
57
+ amount: 99.99
58
+ }
59
+ });
60
+ ```
61
+
62
+ ## API Reference
63
+
64
+ ### Initialization
65
+
66
+ #### `initEventTracker(options?)`
67
+
68
+ Initialize the event tracking system. This sets up the underlying MCP worker.
69
+
70
+ **Parameters:**
71
+ - `options?: ServiceWorkerRegistration | WorkerClientInitOptions`
72
+
73
+ **WorkerClientInitOptions:**
74
+ ```typescript
75
+ interface WorkerClientInitOptions {
76
+ sharedWorkerUrl?: string; // Default: '/mcp-shared-worker.js'
77
+ serviceWorkerUrl?: string; // Default: '/mcp-service-worker.js'
78
+ backendWsUrl?: string; // Default: 'ws://localhost:3001'
79
+ }
80
+ ```
81
+
82
+ **Examples:**
83
+ ```typescript
84
+ // Basic initialization
85
+ await initEventTracker();
86
+
87
+ // With custom WebSocket URL
88
+ await initEventTracker({
89
+ backendWsUrl: 'wss://my-mcp-server.com/ws'
90
+ });
91
+
92
+ // With custom worker paths
93
+ await initEventTracker({
94
+ sharedWorkerUrl: '/assets/workers/mcp-shared-worker.js',
95
+ backendWsUrl: 'ws://localhost:3001'
96
+ });
97
+
98
+ // Using existing ServiceWorker registration
99
+ const registration = await navigator.serviceWorker.register('/mcp-service-worker.js');
100
+ await initEventTracker(registration);
101
+ ```
102
+
103
+ ### Event Tracking
104
+
105
+ #### `trackEvent(eventData)`
106
+
107
+ Track a generic user event with custom data.
108
+
109
+ **Parameters:**
110
+ - `eventData: UserEventData`
111
+
112
+ **UserEventData Interface:**
113
+ ```typescript
114
+ interface UserEventData {
115
+ type: 'navigation' | 'click' | 'input' | 'custom';
116
+ path?: string; // Current page path
117
+ from?: string; // Previous location (navigation events)
118
+ to?: string; // Next location (navigation events)
119
+ element?: string; // HTML element tag name
120
+ elementId?: string; // Element ID attribute
121
+ elementClass?: string; // Element CSS classes
122
+ elementText?: string; // Element text content (truncated to 100 chars)
123
+ metadata?: Record<string, unknown>; // Additional event data
124
+ }
125
+ ```
126
+
127
+ **Example:**
128
+ ```typescript
129
+ await trackEvent({
130
+ type: 'custom',
131
+ path: '/dashboard',
132
+ metadata: {
133
+ eventName: 'feature_used',
134
+ feature: 'export_data',
135
+ format: 'csv',
136
+ recordCount: 150
137
+ }
138
+ });
139
+ ```
140
+
141
+ #### `trackNavigation(from, to, path?)`
142
+
143
+ Track navigation between routes or pages.
144
+
145
+ **Parameters:**
146
+ - `from: string` - Previous route/URL
147
+ - `to: string` - Current route/URL
148
+ - `path?: string` - Optional explicit path (defaults to `to`)
149
+
150
+ **Example:**
151
+ ```typescript
152
+ // Basic navigation tracking
153
+ await trackNavigation('/home', '/products');
154
+
155
+ // With explicit path
156
+ await trackNavigation('/users/123', '/users/456', '/users');
157
+ ```
158
+
159
+ #### `trackClick(element, path?, metadata?)`
160
+
161
+ Track click events on HTML elements with automatic element data extraction.
162
+
163
+ **Parameters:**
164
+ - `element: HTMLElement` - The clicked element
165
+ - `path?: string` - Current page path (defaults to `window.location.pathname`)
166
+ - `metadata?: Record<string, unknown>` - Additional click data
167
+
168
+ **Example:**
169
+ ```typescript
170
+ // Track button click
171
+ const button = document.getElementById('submit-btn');
172
+ await trackClick(button);
173
+
174
+ // With additional metadata
175
+ const link = document.querySelector('a[data-product-id="123"]');
176
+ await trackClick(link, '/products', {
177
+ productId: '123',
178
+ category: 'electronics',
179
+ price: 299.99
180
+ });
181
+
182
+ // Event listener example
183
+ document.addEventListener('click', async (event) => {
184
+ if (event.target instanceof HTMLElement) {
185
+ await trackClick(event.target);
186
+ }
187
+ });
188
+ ```
189
+
190
+ #### `trackInput(element, value?, path?)`
191
+
192
+ Track input changes in forms with debouncing and value length tracking.
193
+
194
+ **Parameters:**
195
+ - `element: HTMLElement` - The input element
196
+ - `value?: string` - Input value (stored securely with length tracking)
197
+ - `path?: string` - Current page path
198
+
199
+ **Example:**
200
+ ```typescript
201
+ // Track input change
202
+ const emailInput = document.getElementById('email');
203
+ await trackInput(emailInput, emailInput.value);
204
+
205
+ // Event listener with debouncing
206
+ let timeoutId;
207
+ document.addEventListener('input', (event) => {
208
+ if (event.target instanceof HTMLInputElement) {
209
+ clearTimeout(timeoutId);
210
+ timeoutId = setTimeout(async () => {
211
+ await trackInput(event.target, event.target.value);
212
+ }, 1000); // 1 second debounce
213
+ }
214
+ });
215
+ ```
216
+
217
+ #### `trackCustom(eventName, metadata?, path?)`
218
+
219
+ Convenient wrapper for tracking custom business events.
220
+
221
+ **Parameters:**
222
+ - `eventName: string` - Name of the custom event
223
+ - `metadata?: Record<string, unknown>` - Event-specific data
224
+ - `path?: string` - Current page path
225
+
226
+ **Example:**
227
+ ```typescript
228
+ // Track business events
229
+ await trackCustom('purchase_completed', {
230
+ orderId: '12345',
231
+ amount: 99.99,
232
+ currency: 'USD',
233
+ items: ['product-1', 'product-2']
234
+ });
235
+
236
+ await trackCustom('search_performed', {
237
+ query: 'javascript tutorials',
238
+ results: 42,
239
+ filters: ['beginner', 'video']
240
+ });
241
+
242
+ await trackCustom('error_occurred', {
243
+ errorType: 'validation',
244
+ field: 'email',
245
+ message: 'Invalid email format'
246
+ });
247
+ ```
248
+
249
+ ### Connection Management
250
+
251
+ #### `getConnectionStatus()`
252
+
253
+ Check if the MCP worker is connected to the proxy server.
254
+
255
+ **Returns:** `Promise<boolean>`
256
+
257
+ **Example:**
258
+ ```typescript
259
+ const isConnected = await getConnectionStatus();
260
+ if (!isConnected) {
261
+ console.warn('MCP connection lost, events may not be available to AI agents');
262
+ }
263
+ ```
264
+
265
+ #### `onConnectionStatus(callback)` / `offConnectionStatus(callback)`
266
+
267
+ Subscribe to connection status changes.
268
+
269
+ **Parameters:**
270
+ - `callback: (connected: boolean) => void` - Status change callback
271
+
272
+ **Example:**
273
+ ```typescript
274
+ const handleConnectionChange = (connected) => {
275
+ console.log('MCP connection:', connected ? 'Connected' : 'Disconnected');
276
+
277
+ // Update UI indicator
278
+ const indicator = document.getElementById('connection-status');
279
+ indicator.className = connected ? 'connected' : 'disconnected';
280
+ indicator.textContent = connected ? '🟢 Connected' : '🔴 Offline';
281
+ };
282
+
283
+ // Start listening
284
+ onConnectionStatus(handleConnectionChange);
285
+
286
+ // Stop listening (e.g., on component unmount)
287
+ offConnectionStatus(handleConnectionChange);
288
+ ```
289
+
290
+ ### Authentication
291
+
292
+ #### `setAuthToken(token)`
293
+
294
+ Set authentication token for associating events with specific users.
295
+
296
+ **Parameters:**
297
+ - `token: string` - Authentication token (e.g., JWT)
298
+
299
+ **Example:**
300
+ ```typescript
301
+ // After user login
302
+ async function handleLogin(credentials) {
303
+ const response = await authenticateUser(credentials);
304
+
305
+ // Set token for MCP tracking
306
+ setAuthToken(response.accessToken);
307
+
308
+ // Track login event
309
+ await trackCustom('user_logged_in', {
310
+ userId: response.user.id,
311
+ method: 'password'
312
+ });
313
+ }
314
+
315
+ // On logout
316
+ async function handleLogout() {
317
+ await trackCustom('user_logged_out');
318
+
319
+ // Clear authentication
320
+ setAuthToken('');
321
+ }
322
+ ```
323
+
324
+
325
+ ## Integration with AI Agents
326
+
327
+ Once events are tracked and stored, AI agents can query them through the MCP protocol:
328
+
329
+ ```json
330
+ {
331
+ "jsonrpc": "2.0",
332
+ "method": "tools/call",
333
+ "params": {
334
+ "name": "get_user_events",
335
+ "arguments": {
336
+ "type": "click",
337
+ "limit": 10,
338
+ "startTime": 1705712400000
339
+ }
340
+ }
341
+ }
342
+ ```
343
+
344
+ This enables AI agents to:
345
+ - Provide context-aware customer support
346
+ - Debug user interface issues
347
+ - Analyze user behavior patterns
348
+ - Guide users through complex workflows
349
+ - Understand error scenarios and user frustration points
350
+
351
+ ## Best Practices
352
+
353
+ ### Event Granularity
354
+
355
+ ```typescript
356
+ // ✅ Good: Track meaningful interactions
357
+ await trackClick(submitButton, '/checkout', {
358
+ step: 'payment',
359
+ amount: totalAmount
360
+ });
361
+
362
+ // ❌ Too granular: Don't track every mouseover
363
+ document.addEventListener('mouseover', trackEvent); // Avoid this
364
+ ```
365
+
366
+ ### Sensitive Data
367
+
368
+ ```typescript
369
+ // ✅ Good: Track input activity without sensitive values
370
+ await trackInput(passwordInput, undefined, '/login'); // Don't pass actual password
371
+
372
+ // ✅ Good: Track metadata about sensitive operations
373
+ await trackCustom('payment_submitted', {
374
+ amount: 99.99,
375
+ currency: 'USD',
376
+ // Don't include card numbers or CVV
377
+ });
378
+ ```
379
+
380
+ ### Performance
381
+
382
+ ```typescript
383
+ // ✅ Good: Debounce high-frequency events
384
+ let searchTimeout;
385
+ searchInput.addEventListener('input', () => {
386
+ clearTimeout(searchTimeout);
387
+ searchTimeout = setTimeout(async () => {
388
+ await trackInput(searchInput, searchInput.value);
389
+ }, 500);
390
+ });
391
+
392
+ // ✅ Good: Batch related events
393
+ await Promise.all([
394
+ trackCustom('form_submitted'),
395
+ trackNavigation('/form', '/success')
396
+ ]);
397
+ ```
398
+
399
+ ## Error Handling
400
+
401
+ ```typescript
402
+ // Wrap tracking calls in try-catch for production resilience
403
+ async function safeTrackEvent(eventData) {
404
+ try {
405
+ await trackEvent(eventData);
406
+ } catch (error) {
407
+ // Log error but don't break user experience
408
+ console.warn('Failed to track event:', error);
409
+ }
410
+ }
411
+
412
+ // Check connection before critical tracking
413
+ const isConnected = await getConnectionStatus();
414
+ if (isConnected) {
415
+ await trackCustom('critical_business_event', eventData);
416
+ } else {
417
+ // Store locally or queue for later
418
+ localStorage.setItem('pending_events', JSON.stringify([eventData]));
419
+ }
420
+ ```
421
+
422
+ ## Troubleshooting
423
+
424
+ ### Events Not Being Stored
425
+
426
+ 1. **Check worker initialization**: Ensure `initEventTracker()` completed successfully
427
+ 2. **Verify worker files**: Make sure MCP worker files are in your public directory
428
+ 3. **Check connection**: Use `getConnectionStatus()` to verify proxy connection
429
+
430
+ ### Connection Issues
431
+
432
+ 1. **Proxy server**: Verify the MCP proxy server is running at the specified WebSocket URL
433
+ 2. **CORS**: Check browser console for CORS errors
434
+ 3. **WebSocket**: Verify WebSocket connection in browser Developer Tools
435
+
436
+ ### Memory Usage
437
+
438
+ 1. **Event cleanup**: Periodically clean old events from IndexedDB
439
+ 2. **Debouncing**: Use appropriate debouncing for high-frequency events
440
+ 3. **Selective tracking**: Only track events that provide value to AI agents
441
+
442
+ ## Requirements
443
+
444
+ - **Modern Browser**: ES2020+ support
445
+ - **MCP Worker Setup**: Requires [`@mcp-fe/mcp-worker`](../mcp-worker/README.md) configuration
446
+ - **MCP Proxy Server**: A running MCP proxy server to collect events
447
+
448
+ ## Related Packages
449
+
450
+ - **[@mcp-fe/mcp-worker](../mcp-worker/README.md)**: Core MCP worker implementation
451
+ - **[@mcp-fe/react-event-tracker](../react-event-tracker/README.md)**: React-specific integration
452
+ - **[Main MCP-FE Project](../../README.md)**: Complete ecosystem documentation
453
+
454
+ ## Credits
455
+
456
+ Created and maintained with ❤️ by [Michal Kopecký](https://github.com/kopecmi8).
457
+
458
+ ## License
459
+
460
+ Licensed under the Apache License, Version 2.0. See the [LICENSE](../../LICENSE) file for details.
package/index.d.ts CHANGED
@@ -1,2 +1,17 @@
1
+ /**
2
+ * Copyright 2026 MCP-FE Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
1
16
  export * from './lib/event-tracker';
2
17
  //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../libs/event-tracker/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../libs/event-tracker/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,19 @@
1
1
  {
2
2
  "name": "@mcp-fe/event-tracker",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
+ "license": "Apache-2.0",
5
+ "homepage": "https://mcp-fe.ai",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/mcp-fe/mcp-fe.git",
9
+ "directory": "libs/event-tracker"
10
+ },
4
11
  "private": false,
5
12
  "type": "module",
6
13
  "main": "./index.js",
7
14
  "types": "./index.d.ts",
8
15
  "dependencies": {
9
- "@mcp-fe/mcp-worker": "0.0.14"
16
+ "@mcp-fe/mcp-worker": "0.0.16"
10
17
  },
11
18
  "publishConfig": {
12
19
  "access": "public"