@tracelog/lib 0.5.0 → 0.5.1
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/README.md +86 -26
- package/dist/browser/tracelog.esm.js +2737 -0
- package/dist/browser/tracelog.js +2 -2731
- package/dist/cjs/constants/performance.constants.d.ts +5 -5
- package/dist/cjs/constants/performance.constants.js +6 -6
- package/dist/esm/constants/performance.constants.d.ts +5 -5
- package/dist/esm/constants/performance.constants.js +6 -6
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -15,39 +15,60 @@ A lightweight TypeScript library for web analytics and user behavior tracking. A
|
|
|
15
15
|
|
|
16
16
|
**Prerequisites**: Modern browser with ES6+ support. No server-side requirements.
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Initialize tracking with your project ID and start capturing events immediately:
|
|
18
|
+
## 📦 Which File Should I Use?
|
|
19
|
+
|
|
20
|
+
| Your Setup | File to Use | How to Use |
|
|
21
|
+
|-----------|-------------|------------|
|
|
22
|
+
| **npm/yarn** (React, Vue, Angular, etc.) | Automatic | `import { tracelog } from '@tracelog/lib'` |
|
|
23
|
+
| **HTML + `<script>` tag** | `tracelog.js` (IIFE) | `<script src="...tracelog.js"></script>` then use `tracelog.init()` |
|
|
24
|
+
| **HTML + `<script type="module">`** | `tracelog.esm.js` (ESM) | `import { tracelog } from '...tracelog.esm.js'` |
|
|
25
|
+
|
|
26
|
+
### Installation Methods
|
|
27
|
+
|
|
28
|
+
#### 1. NPM/Yarn (Recommended for Modern Apps)
|
|
29
|
+
```bash
|
|
30
|
+
npm install @tracelog/lib
|
|
31
|
+
```
|
|
34
32
|
|
|
35
33
|
```typescript
|
|
36
34
|
import { tracelog } from '@tracelog/lib';
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
36
|
+
tracelog.init({ id: 'your-project-id' });
|
|
37
|
+
tracelog.event('user_action', { data: 'example' });
|
|
38
|
+
```
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
**✅ Best for:** React, Vue, Angular, Next.js, Vite, webpack, or any bundler
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
#### 2. CDN - IIFE (Maximum Compatibility)
|
|
45
|
+
```html
|
|
46
|
+
<script src="https://cdn.jsdelivr.net/npm/@tracelog/lib@latest/dist/browser/tracelog.js"></script>
|
|
47
|
+
<script>
|
|
48
|
+
// tracelog is available globally
|
|
49
|
+
tracelog.init({ id: 'your-project-id' });
|
|
50
|
+
tracelog.event('page_view');
|
|
51
|
+
</script>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**✅ Best for:** WordPress, static HTML, CMS, legacy browsers, no build step
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
#### 3. CDN - ES Module (Modern Only)
|
|
59
|
+
```html
|
|
60
|
+
<script type="module">
|
|
61
|
+
import { tracelog } from 'https://cdn.jsdelivr.net/npm/@tracelog/lib@latest/dist/browser/tracelog.esm.js';
|
|
62
|
+
|
|
63
|
+
await tracelog.init({ id: 'your-project-id' });
|
|
64
|
+
tracelog.event('page_view');
|
|
65
|
+
</script>
|
|
48
66
|
```
|
|
49
67
|
|
|
50
|
-
|
|
68
|
+
**✅ Best for:** Modern browsers, no bundler, prefer native modules
|
|
69
|
+
**⚠️ Note:** Won't work in IE11 or older browsers
|
|
70
|
+
|
|
71
|
+
**Expected behavior**: Automatic tracking begins immediately. Check browser dev tools console for event logs (when `mode: 'qa'` or `mode: 'debug'`).
|
|
51
72
|
|
|
52
73
|
## Usage
|
|
53
74
|
|
|
@@ -248,6 +269,45 @@ This project uses a **branch protection strategy** to ensure code quality:
|
|
|
248
269
|
|
|
249
270
|
Follows [Semantic Versioning](https://semver.org/) (MAJOR.MINOR.PATCH). Breaking changes are documented in release notes with migration guides.
|
|
250
271
|
|
|
272
|
+
## Testing & Validation
|
|
273
|
+
|
|
274
|
+
Verify the installation works correctly:
|
|
275
|
+
|
|
276
|
+
### Quick Validation
|
|
277
|
+
|
|
278
|
+
Open DevTools Console and check for:
|
|
279
|
+
1. `[TraceLog:App] Initializing TraceLog` - Library loaded
|
|
280
|
+
2. `[TraceLog:SessionManager] Session started` - Session active
|
|
281
|
+
3. No errors or warnings
|
|
282
|
+
4. Events logged when you interact with the page
|
|
283
|
+
|
|
284
|
+
### Manual Test
|
|
285
|
+
|
|
286
|
+
```javascript
|
|
287
|
+
// Should work after installation
|
|
288
|
+
tracelog.init({
|
|
289
|
+
id: 'skip', // Use 'skip' for local testing
|
|
290
|
+
mode: 'debug' // Enables console logging
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// Send a test event
|
|
294
|
+
tracelog.event('test_event', { foo: 'bar' });
|
|
295
|
+
|
|
296
|
+
// Check DevTools Console for:
|
|
297
|
+
// [TraceLog:EventManager] Tracking event: test_event
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Playground
|
|
301
|
+
|
|
302
|
+
The library includes a full demo at [`playground/index.html`](playground/index.html):
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
npm run playground:setup # Build and copy library
|
|
306
|
+
npm run serve # Start server on localhost:3000
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Open http://localhost:3000 to see TraceLog in action with real-time event monitoring.
|
|
310
|
+
|
|
251
311
|
## License
|
|
252
312
|
|
|
253
313
|
MIT © TraceLog. See [LICENSE](LICENSE) file for details.
|