@journium/js 1.0.0 → 1.0.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 +88 -272
- package/dist/client.d.ts +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +102 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -6
- package/dist/index.esm.js +102 -114
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +102 -114
- package/dist/index.umd.js.map +1 -1
- package/dist/journium.d.ts +0 -4
- package/dist/journium.d.ts.map +1 -1
- package/dist/pageview.d.ts +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -8,63 +8,108 @@
|
|
|
8
8
|
|
|
9
9
|
Track events, pageviews, and user interactions with ease. Perfect for SPAs, vanilla JavaScript apps, and any web application.
|
|
10
10
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
### Installation
|
|
11
|
+
## Installation
|
|
14
12
|
|
|
13
|
+
### npm
|
|
15
14
|
```bash
|
|
16
15
|
npm install @journium/js
|
|
17
16
|
```
|
|
18
17
|
|
|
19
|
-
###
|
|
18
|
+
### pnpm
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add @journium/js
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### yarn
|
|
24
|
+
```bash
|
|
25
|
+
yarn add @journium/js
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Basic Setup
|
|
29
|
+
|
|
30
|
+
### Initialize Journium
|
|
31
|
+
Initialize the Journium SDK with your publishable key to start tracking events.
|
|
20
32
|
|
|
21
33
|
```javascript
|
|
22
34
|
import { init } from '@journium/js';
|
|
23
35
|
|
|
24
|
-
// Initialize Journium
|
|
25
36
|
const journium = init({
|
|
26
|
-
|
|
27
|
-
apiHost: 'https://your-journium-instance.com'
|
|
37
|
+
publishableKey: 'your-journium-publishable-key'
|
|
28
38
|
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Track a Custom Event
|
|
42
|
+
Track user actions and business events with custom properties.
|
|
29
43
|
|
|
30
|
-
|
|
44
|
+
```javascript
|
|
31
45
|
journium.track('button_clicked', {
|
|
32
46
|
button_name: 'signup',
|
|
33
|
-
page: 'homepage'
|
|
47
|
+
page: 'homepage',
|
|
48
|
+
user_type: 'visitor'
|
|
34
49
|
});
|
|
50
|
+
```
|
|
35
51
|
|
|
36
|
-
|
|
37
|
-
|
|
52
|
+
### Identify a User
|
|
53
|
+
Identify users when they log in or sign up to connect their actions across sessions.
|
|
38
54
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
55
|
+
```javascript
|
|
56
|
+
journium.identify('user_12345', {
|
|
57
|
+
name: 'John Doe',
|
|
58
|
+
email: 'john@example.com',
|
|
59
|
+
plan: 'premium'
|
|
60
|
+
});
|
|
42
61
|
```
|
|
43
62
|
|
|
44
|
-
|
|
63
|
+
### Reset User Identity
|
|
64
|
+
Reset user identity when they log out to ensure privacy and accurate tracking.
|
|
45
65
|
|
|
46
|
-
|
|
66
|
+
```javascript
|
|
67
|
+
journium.reset();
|
|
68
|
+
```
|
|
47
69
|
|
|
48
|
-
|
|
70
|
+
## Advanced Setup
|
|
49
71
|
|
|
50
|
-
|
|
72
|
+
You can override default configurations:
|
|
51
73
|
|
|
52
74
|
```javascript
|
|
75
|
+
import { init } from '@journium/js';
|
|
76
|
+
|
|
53
77
|
const journium = init({
|
|
54
|
-
|
|
55
|
-
apiHost: 'https://
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
78
|
+
publishableKey: 'your-journium-publishable-key',
|
|
79
|
+
apiHost: 'https://your-custom-instance.com', // Optional: defaults to 'https://events.journium.app'
|
|
80
|
+
config: {
|
|
81
|
+
debug: true, // Enable debug logging
|
|
82
|
+
flushAt: 10, // Send events after N events
|
|
83
|
+
flushInterval: 5000, // Send events every N milliseconds
|
|
84
|
+
sessionTimeout: 1800000, // Session timeout (30 minutes)
|
|
85
|
+
autocapture: { // Configure automatic event capture
|
|
86
|
+
captureClicks: true, // Track click events
|
|
87
|
+
captureFormSubmits: true, // Track form submissions
|
|
88
|
+
captureFormChanges: false, // Track form field changes
|
|
89
|
+
ignoreClasses: ['no-track'], // CSS classes to ignore
|
|
90
|
+
ignoreElements: ['input[type="password"]'] // Elements to ignore
|
|
91
|
+
}
|
|
92
|
+
}
|
|
61
93
|
});
|
|
94
|
+
|
|
95
|
+
// Start automatic event capture
|
|
96
|
+
journium.startAutocapture();
|
|
62
97
|
```
|
|
63
98
|
|
|
64
|
-
|
|
99
|
+
## API Reference
|
|
65
100
|
|
|
66
|
-
|
|
101
|
+
### `init(config: JourniumConfig)`
|
|
102
|
+
Initialize the Journium SDK with your configuration.
|
|
67
103
|
|
|
104
|
+
```javascript
|
|
105
|
+
const journium = init({
|
|
106
|
+
publishableKey: 'your-journium-publishable-key',
|
|
107
|
+
apiHost: 'https://events.journium.app', // Optional
|
|
108
|
+
config: { /* optional local config */ }
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### `journium.track(eventName, properties?)`
|
|
68
113
|
Track custom events with optional properties.
|
|
69
114
|
|
|
70
115
|
```javascript
|
|
@@ -75,46 +120,29 @@ journium.track('feature_used');
|
|
|
75
120
|
journium.track('purchase_completed', {
|
|
76
121
|
product_id: 'prod_123',
|
|
77
122
|
amount: 29.99,
|
|
78
|
-
currency: 'USD'
|
|
79
|
-
category: 'digital',
|
|
80
|
-
plan: 'premium'
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// User action with context
|
|
84
|
-
journium.track('video_played', {
|
|
85
|
-
video_id: 'intro-2024',
|
|
86
|
-
video_length: 120,
|
|
87
|
-
quality: '1080p',
|
|
88
|
-
autoplay: false
|
|
123
|
+
currency: 'USD'
|
|
89
124
|
});
|
|
90
125
|
```
|
|
91
126
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
Identify a user when they log in or sign up. This method should be used instead of tracking user login as a custom event.
|
|
127
|
+
### `journium.identify(distinctId, attributes?)`
|
|
128
|
+
Identify a user when they log in or sign up.
|
|
95
129
|
|
|
96
130
|
```javascript
|
|
97
|
-
// When user logs in or signs up
|
|
98
131
|
journium.identify('user_12345', {
|
|
99
132
|
name: 'John Doe',
|
|
100
|
-
email: 'john@example.com'
|
|
133
|
+
email: 'john@example.com',
|
|
134
|
+
signup_date: '2024-01-15'
|
|
101
135
|
});
|
|
102
|
-
|
|
103
|
-
// Minimal identification (just user ID)
|
|
104
|
-
journium.identify('user_67890');
|
|
105
136
|
```
|
|
106
137
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
Reset user identity when they log out. This generates a new anonymous distinct ID and should be called on user logout.
|
|
138
|
+
### `journium.reset()`
|
|
139
|
+
Reset user identity when they log out.
|
|
110
140
|
|
|
111
141
|
```javascript
|
|
112
|
-
// When user logs out
|
|
113
142
|
journium.reset();
|
|
114
143
|
```
|
|
115
144
|
|
|
116
|
-
|
|
117
|
-
|
|
145
|
+
### `journium.capturePageview(properties?)`
|
|
118
146
|
Manually capture pageview events.
|
|
119
147
|
|
|
120
148
|
```javascript
|
|
@@ -124,243 +152,31 @@ journium.capturePageview();
|
|
|
124
152
|
// Pageview with custom properties
|
|
125
153
|
journium.capturePageview({
|
|
126
154
|
section: 'pricing',
|
|
127
|
-
experiment_variant: 'v2'
|
|
128
|
-
user_plan: 'free'
|
|
155
|
+
experiment_variant: 'v2'
|
|
129
156
|
});
|
|
130
157
|
```
|
|
131
158
|
|
|
132
|
-
###
|
|
133
|
-
|
|
134
|
-
#### `journium.startAutoCapture()` / `journium.stopAutoCapture()`
|
|
135
|
-
|
|
159
|
+
### `journium.startAutocapture()` / `journium.stopAutocapture()`
|
|
136
160
|
Control automatic event capture for clicks, pageviews, and form interactions.
|
|
137
161
|
|
|
138
|
-
**Note:** Autocapture is enabled by default. You can disable it entirely with `autocapture: false` in your config, or control it programmatically:
|
|
139
|
-
|
|
140
162
|
```javascript
|
|
141
|
-
// Start
|
|
142
|
-
journium.
|
|
163
|
+
// Start automatic capture
|
|
164
|
+
journium.startAutocapture();
|
|
143
165
|
|
|
144
166
|
// Stop automatic capture
|
|
145
|
-
journium.
|
|
146
|
-
|
|
147
|
-
// Or disable entirely in configuration:
|
|
148
|
-
const journium = init({
|
|
149
|
-
token: 'your-token',
|
|
150
|
-
apiHost: 'your-api.com',
|
|
151
|
-
autocapture: false // Disables all autocapture functionality
|
|
152
|
-
});
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
Configure what gets auto-captured:
|
|
156
|
-
|
|
157
|
-
```javascript
|
|
158
|
-
const journium = init({
|
|
159
|
-
token: 'your-token',
|
|
160
|
-
apiHost: 'https://your-api.com',
|
|
161
|
-
autocapture: {
|
|
162
|
-
captureClicks: true, // Track click events
|
|
163
|
-
captureFormSubmits: true, // Track form submissions
|
|
164
|
-
captureFormChanges: false, // Track form field changes
|
|
165
|
-
captureTextSelection: false, // Track text selections
|
|
166
|
-
captureContentText: true, // Include element text
|
|
167
|
-
ignoreClasses: ['no-track'], // CSS classes to ignore
|
|
168
|
-
ignoreElements: ['input[type="password"]'] // Elements to ignore
|
|
169
|
-
}
|
|
170
|
-
});
|
|
167
|
+
journium.stopAutocapture();
|
|
171
168
|
```
|
|
172
169
|
|
|
173
|
-
###
|
|
174
|
-
|
|
175
|
-
#### `journium.flush()`
|
|
176
|
-
|
|
170
|
+
### `journium.flush()`
|
|
177
171
|
Manually send queued events to the server.
|
|
178
172
|
|
|
179
173
|
```javascript
|
|
180
|
-
// Send all pending events immediately
|
|
181
174
|
await journium.flush();
|
|
182
175
|
```
|
|
183
176
|
|
|
184
|
-
|
|
185
|
-
|
|
177
|
+
### `journium.destroy()`
|
|
186
178
|
Clean up the SDK and send any remaining events.
|
|
187
179
|
|
|
188
180
|
```javascript
|
|
189
|
-
// Cleanup before page unload
|
|
190
181
|
journium.destroy();
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
## 🏗️ Event Properties
|
|
194
|
-
|
|
195
|
-
### Automatic Properties
|
|
196
|
-
|
|
197
|
-
Journium automatically includes these properties with every event:
|
|
198
|
-
|
|
199
|
-
- `$device_id` - Unique device identifier (persistent across user sessions)
|
|
200
|
-
- `$session_id` - Current session ID
|
|
201
|
-
- `distinct_id` - User identifier (anonymous until `identify()` is called)
|
|
202
|
-
- `$is_identified` - Whether the user has been identified (true/false)
|
|
203
|
-
- `$current_url` - Current page URL
|
|
204
|
-
- `$pathname` - URL pathname
|
|
205
|
-
- `$browser` - Browser name (Chrome, Firefox, etc.)
|
|
206
|
-
- `$os` - Operating system (Windows, macOS, etc.)
|
|
207
|
-
- `$device_type` - Device type (desktop, mobile, tablet)
|
|
208
|
-
- `$lib_version` - SDK version
|
|
209
|
-
- `$platform` - Always "web"
|
|
210
|
-
|
|
211
|
-
### Custom Properties
|
|
212
|
-
|
|
213
|
-
Add any custom properties to track additional context:
|
|
214
|
-
|
|
215
|
-
```javascript
|
|
216
|
-
journium.track('feature_used', {
|
|
217
|
-
// Your custom properties
|
|
218
|
-
feature_name: 'dark_mode',
|
|
219
|
-
user_plan: 'premium',
|
|
220
|
-
user_role: 'admin',
|
|
221
|
-
experiment_group: 'control',
|
|
222
|
-
|
|
223
|
-
// Nested objects work too
|
|
224
|
-
user_preferences: {
|
|
225
|
-
theme: 'dark',
|
|
226
|
-
language: 'en',
|
|
227
|
-
timezone: 'UTC'
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
## 🔧 Configuration Options
|
|
233
|
-
|
|
234
|
-
### Required Configuration
|
|
235
|
-
|
|
236
|
-
```javascript
|
|
237
|
-
{
|
|
238
|
-
token: 'your-journium-token', // Your project token from Journium
|
|
239
|
-
apiHost: 'https://api.journium.com' // Your Journium API endpoint
|
|
240
|
-
}
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
### Optional Configuration
|
|
244
|
-
|
|
245
|
-
```javascript
|
|
246
|
-
{
|
|
247
|
-
debug: false, // Enable console logging
|
|
248
|
-
flushAt: 20, // Send events after N events queued
|
|
249
|
-
flushInterval: 10000, // Send events every N milliseconds
|
|
250
|
-
sessionTimeout: 1800000, // Session timeout (30 minutes)
|
|
251
|
-
autocapture: true // Default: true - set false to disable auto-capture
|
|
252
|
-
}
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
### Advanced Auto-Capture Configuration
|
|
256
|
-
|
|
257
|
-
```javascript
|
|
258
|
-
{
|
|
259
|
-
autocapture: {
|
|
260
|
-
captureClicks: true, // Capture click events
|
|
261
|
-
captureFormSubmits: true, // Capture form submissions
|
|
262
|
-
captureFormChanges: false, // Capture form field changes
|
|
263
|
-
captureTextSelection: false, // Capture text selection events
|
|
264
|
-
captureContentText: true, // Include element text content
|
|
265
|
-
ignoreClasses: [ // CSS classes to ignore
|
|
266
|
-
'no-track',
|
|
267
|
-
'sensitive-data',
|
|
268
|
-
'admin-only'
|
|
269
|
-
],
|
|
270
|
-
ignoreElements: [ // CSS selectors to ignore
|
|
271
|
-
'input[type="password"]',
|
|
272
|
-
'.credit-card-input',
|
|
273
|
-
'[data-private]'
|
|
274
|
-
]
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
## 🔒 Privacy & Security
|
|
280
|
-
|
|
281
|
-
Journium is designed with privacy in mind:
|
|
282
|
-
|
|
283
|
-
- **No PII by default** - We don't automatically collect personally identifiable information
|
|
284
|
-
- **Configurable tracking** - Exclude sensitive elements and data
|
|
285
|
-
- **Secure transmission** - All data sent over HTTPS
|
|
286
|
-
- **Session-based** - Automatic session management without persistent user tracking
|
|
287
|
-
|
|
288
|
-
### Excluding Sensitive Data
|
|
289
|
-
|
|
290
|
-
```javascript
|
|
291
|
-
// Method 1: CSS classes
|
|
292
|
-
<button class="signup-btn no-track">Sign Up</button>
|
|
293
|
-
|
|
294
|
-
// Method 2: Configuration
|
|
295
|
-
const journium = init({
|
|
296
|
-
token: 'your-token',
|
|
297
|
-
apiHost: 'your-api.com',
|
|
298
|
-
autocapture: {
|
|
299
|
-
ignoreClasses: ['no-track', 'sensitive'],
|
|
300
|
-
ignoreElements: ['input[type="password"]', '.credit-card']
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
## 🌐 Browser Support
|
|
306
|
-
|
|
307
|
-
- ✅ **Chrome** 60+
|
|
308
|
-
- ✅ **Firefox** 55+
|
|
309
|
-
- ✅ **Safari** 12+
|
|
310
|
-
- ✅ **Edge** 79+
|
|
311
|
-
- ✅ **Mobile browsers** (iOS Safari, Chrome Mobile)
|
|
312
|
-
|
|
313
|
-
## 📝 TypeScript Support
|
|
314
|
-
|
|
315
|
-
Full TypeScript support with complete type definitions:
|
|
316
|
-
|
|
317
|
-
```typescript
|
|
318
|
-
import { init, JourniumConfig, Journium } from '@journium/js';
|
|
319
|
-
|
|
320
|
-
const config: JourniumConfig = {
|
|
321
|
-
token: 'your-token',
|
|
322
|
-
apiHost: 'https://api.journium.com',
|
|
323
|
-
debug: true
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
const journium: Journium = init(config);
|
|
327
|
-
|
|
328
|
-
// Type-safe event tracking
|
|
329
|
-
journium.track('user_action', {
|
|
330
|
-
action_type: 'click',
|
|
331
|
-
element_id: 'signup-button',
|
|
332
|
-
timestamp: new Date().toISOString()
|
|
333
|
-
});
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
## 🔗 Related Packages
|
|
337
|
-
|
|
338
|
-
Part of the Journium JavaScript SDK ecosystem:
|
|
339
|
-
|
|
340
|
-
- **[@journium/react](https://npmjs.com/package/@journium/react)** - React integration with hooks and providers
|
|
341
|
-
- **[@journium/nextjs](https://npmjs.com/package/@journium/nextjs)** - Next.js integration with SSR support
|
|
342
|
-
- **[@journium/node](https://npmjs.com/package/@journium/node)** - Node.js server-side tracking
|
|
343
|
-
- **[@journium/core](https://npmjs.com/package/@journium/core)** - Core utilities and types
|
|
344
|
-
|
|
345
|
-
## 📖 Documentation
|
|
346
|
-
|
|
347
|
-
For complete documentation, guides, and examples:
|
|
348
|
-
|
|
349
|
-
- **[Documentation](https://docs.journium.app)** - Complete guides and API reference
|
|
350
|
-
- **[Getting Started](https://docs.journium.app/getting-started)** - Quick setup guide
|
|
351
|
-
- **[Examples](https://docs.journium.app/examples)** - Code examples and patterns
|
|
352
|
-
|
|
353
|
-
## 🤝 Contributing
|
|
354
|
-
|
|
355
|
-
We welcome contributions! Please see our [Contributing Guide](https://github.com/journium/journium-js/blob/main/CONTRIBUTING.md).
|
|
356
|
-
|
|
357
|
-
## 📄 License
|
|
358
|
-
|
|
359
|
-
MIT License - see [LICENSE](https://github.com/journium/journium-js/blob/main/LICENSE) file for details.
|
|
360
|
-
|
|
361
|
-
## 🆘 Support
|
|
362
|
-
|
|
363
|
-
- **📚 Docs**: [docs.journium.app](https://docs.journium.app)
|
|
364
|
-
- **🐛 Issues**: [GitHub Issues](https://github.com/journium/journium-js/issues)
|
|
365
|
-
- **💬 Discussions**: [GitHub Discussions](https://github.com/journium/journium-js/discussions)
|
|
366
|
-
- **📧 Email**: support@journium.com
|
|
182
|
+
```
|
package/dist/client.d.ts
CHANGED
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,cAAc,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,cAAc,EAAqI,MAAM,gBAAgB,CAAC;AAElM,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,eAAe,CAAuB;IAC9C,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,UAAU,CAA+C;IACjE,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,eAAe,CAA0B;IACjD,OAAO,CAAC,gBAAgB,CAAU;gBAEtB,MAAM,EAAE,cAAc;IAsClC,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,cAAc;YA0BR,sBAAsB;YAOtB,yBAAyB;IAyCvC,OAAO,CAAC,eAAe;YAWT,UAAU;IA8BxB,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,IAAI;IAyBxE,KAAK,IAAI,IAAI;IAiBb,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,IAAI;IA4C1D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAmB5B,OAAO,IAAI,IAAI;CAOhB"}
|