@journium/react 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/dist/context.d.ts +0 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/hooks.d.ts +0 -2
- package/dist/hooks.d.ts.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +112 -134
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +112 -134
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/readme.md +141 -340
package/readme.md
CHANGED
|
@@ -8,17 +8,27 @@
|
|
|
8
8
|
|
|
9
9
|
The official React SDK for Journium providing hooks, providers, and components for seamless analytics integration in React applications.
|
|
10
10
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
### Installation
|
|
11
|
+
## Installation
|
|
14
12
|
|
|
13
|
+
### npm
|
|
15
14
|
```bash
|
|
16
15
|
npm install @journium/react
|
|
17
16
|
```
|
|
18
17
|
|
|
19
|
-
###
|
|
18
|
+
### pnpm
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add @journium/react
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### yarn
|
|
24
|
+
```bash
|
|
25
|
+
yarn add @journium/react
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Basic Setup
|
|
20
29
|
|
|
21
|
-
|
|
30
|
+
### Initialize Journium
|
|
31
|
+
Wrap your app with the `JourniumProvider` to enable analytics throughout your React application.
|
|
22
32
|
|
|
23
33
|
```jsx
|
|
24
34
|
import React from 'react';
|
|
@@ -29,13 +39,8 @@ function Root() {
|
|
|
29
39
|
return (
|
|
30
40
|
<JourniumProvider
|
|
31
41
|
config={{
|
|
32
|
-
|
|
33
|
-
apiHost: "https://your-journium-instance.com",
|
|
34
|
-
debug: true, // Optional: Enable debug logging
|
|
35
|
-
flushAt: 5, // Optional: Send events after 5 events
|
|
36
|
-
flushInterval: 10000 // Optional: Send events every 10 seconds
|
|
42
|
+
publishableKey: 'your-journium-publishable-key'
|
|
37
43
|
}}
|
|
38
|
-
autoCapture={true} // Enables auto-pageview and click tracking
|
|
39
44
|
>
|
|
40
45
|
<App />
|
|
41
46
|
</JourniumProvider>
|
|
@@ -45,9 +50,8 @@ function Root() {
|
|
|
45
50
|
export default Root;
|
|
46
51
|
```
|
|
47
52
|
|
|
48
|
-
### Track Custom
|
|
49
|
-
|
|
50
|
-
Use the `useTrackEvent` hook to track custom events:
|
|
53
|
+
### Track a Custom Event
|
|
54
|
+
Use the `useTrackEvent` hook to track custom events from any component.
|
|
51
55
|
|
|
52
56
|
```jsx
|
|
53
57
|
import React from 'react';
|
|
@@ -62,75 +66,29 @@ function SignupButton() {
|
|
|
62
66
|
source: 'landing_page',
|
|
63
67
|
plan: 'free'
|
|
64
68
|
});
|
|
65
|
-
// Your signup logic
|
|
66
69
|
};
|
|
67
70
|
|
|
68
71
|
return <button onClick={handleSignup}>Sign Up</button>;
|
|
69
72
|
}
|
|
70
73
|
```
|
|
71
74
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
### useTrackEvent - Track Custom Events
|
|
75
|
-
|
|
76
|
-
The primary hook for tracking custom business events:
|
|
77
|
-
|
|
78
|
-
```jsx
|
|
79
|
-
import { useTrackEvent } from '@journium/react';
|
|
80
|
-
|
|
81
|
-
function EcommerceComponent() {
|
|
82
|
-
const trackEvent = useTrackEvent();
|
|
83
|
-
|
|
84
|
-
const handlePurchase = () => {
|
|
85
|
-
trackEvent('purchase_completed', {
|
|
86
|
-
product_id: 'prod_123',
|
|
87
|
-
price: 29.99,
|
|
88
|
-
currency: 'USD',
|
|
89
|
-
category: 'electronics'
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const handleAddToCart = () => {
|
|
94
|
-
trackEvent('product_added_to_cart', {
|
|
95
|
-
product_id: 'prod_123',
|
|
96
|
-
quantity: 1,
|
|
97
|
-
source: 'product_page'
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<div>
|
|
103
|
-
<button onClick={handleAddToCart}>Add to Cart</button>
|
|
104
|
-
<button onClick={handlePurchase}>Buy Now</button>
|
|
105
|
-
</div>
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### useIdentify - User Identification
|
|
111
|
-
|
|
112
|
-
Use this hook to identify users when they log in or sign up. This should be used instead of tracking user login as a custom event.
|
|
75
|
+
### Identify a User
|
|
76
|
+
Use the `useIdentify` hook to identify users when they log in or sign up.
|
|
113
77
|
|
|
114
78
|
```jsx
|
|
79
|
+
import React from 'react';
|
|
115
80
|
import { useIdentify } from '@journium/react';
|
|
116
81
|
|
|
117
82
|
function LoginForm() {
|
|
118
83
|
const identify = useIdentify();
|
|
119
84
|
|
|
120
85
|
const handleLogin = async (email, password) => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
email: user.email,
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
// Redirect to dashboard or show success
|
|
131
|
-
} catch (error) {
|
|
132
|
-
// Handle login error
|
|
133
|
-
}
|
|
86
|
+
const user = await loginUser(email, password);
|
|
87
|
+
|
|
88
|
+
identify(user.id, {
|
|
89
|
+
name: user.name,
|
|
90
|
+
email: user.email
|
|
91
|
+
});
|
|
134
92
|
};
|
|
135
93
|
|
|
136
94
|
return (
|
|
@@ -141,275 +99,192 @@ function LoginForm() {
|
|
|
141
99
|
}
|
|
142
100
|
```
|
|
143
101
|
|
|
144
|
-
###
|
|
145
|
-
|
|
146
|
-
Use this hook to reset user identity when they log out:
|
|
102
|
+
### Reset User Identity
|
|
103
|
+
Use the `useReset` hook to reset user identity when they log out.
|
|
147
104
|
|
|
148
105
|
```jsx
|
|
106
|
+
import React from 'react';
|
|
149
107
|
import { useReset } from '@journium/react';
|
|
150
108
|
|
|
151
109
|
function LogoutButton() {
|
|
152
110
|
const reset = useReset();
|
|
153
111
|
|
|
154
112
|
const handleLogout = async () => {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
// Reset user identity after successful logout
|
|
159
|
-
reset();
|
|
160
|
-
|
|
161
|
-
// Redirect to home or login page
|
|
162
|
-
} catch (error) {
|
|
163
|
-
// Handle logout error
|
|
164
|
-
}
|
|
113
|
+
await logoutUser();
|
|
114
|
+
reset();
|
|
165
115
|
};
|
|
166
116
|
|
|
167
117
|
return <button onClick={handleLogout}>Log Out</button>;
|
|
168
118
|
}
|
|
169
119
|
```
|
|
170
120
|
|
|
171
|
-
|
|
121
|
+
## Advanced Setup
|
|
172
122
|
|
|
173
|
-
|
|
123
|
+
You can override default configurations and control autocapture:
|
|
174
124
|
|
|
175
125
|
```jsx
|
|
176
|
-
import
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const trackPageview = useTrackPageview();
|
|
180
|
-
|
|
181
|
-
const handleSpecialPageview = () => {
|
|
182
|
-
trackPageview({
|
|
183
|
-
page_type: 'modal',
|
|
184
|
-
content_type: 'pricing_calculator',
|
|
185
|
-
user_segment: 'premium'
|
|
186
|
-
});
|
|
187
|
-
};
|
|
126
|
+
import React from 'react';
|
|
127
|
+
import { JourniumProvider } from '@journium/react';
|
|
128
|
+
import App from './App';
|
|
188
129
|
|
|
130
|
+
function Root() {
|
|
189
131
|
return (
|
|
190
|
-
<
|
|
191
|
-
|
|
192
|
-
|
|
132
|
+
<JourniumProvider
|
|
133
|
+
config={{
|
|
134
|
+
publishableKey: 'your-journium-publishable-key',
|
|
135
|
+
apiHost: 'https://your-custom-instance.com', // Optional: defaults to 'https://events.journium.app'
|
|
136
|
+
config: {
|
|
137
|
+
debug: true, // Enable debug logging
|
|
138
|
+
flushAt: 5, // Send events after N events
|
|
139
|
+
flushInterval: 10000, // Send events every N milliseconds
|
|
140
|
+
sessionTimeout: 1800000, // Session timeout (30 minutes)
|
|
141
|
+
autocapture: { // Configure automatic event capture
|
|
142
|
+
captureClicks: true, // Track click events
|
|
143
|
+
captureFormSubmits: true, // Track form submissions
|
|
144
|
+
captureFormChanges: false, // Track form field changes
|
|
145
|
+
ignoreClasses: ['no-track', 'sensitive'], // CSS classes to ignore
|
|
146
|
+
ignoreElements: ['input[type="password"]'] // Elements to ignore
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
<App />
|
|
152
|
+
</JourniumProvider>
|
|
193
153
|
);
|
|
194
154
|
}
|
|
155
|
+
|
|
156
|
+
export default Root;
|
|
195
157
|
```
|
|
196
158
|
|
|
197
|
-
|
|
159
|
+
## API Reference
|
|
198
160
|
|
|
199
|
-
|
|
161
|
+
### `<JourniumProvider>`
|
|
162
|
+
Provider component to initialize Journium throughout your React app.
|
|
200
163
|
|
|
201
164
|
```jsx
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
return <div>Product {productId}</div>;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function BlogPost({ postId }) {
|
|
216
|
-
// Track pageview for blog posts
|
|
217
|
-
useAutoTrackPageview([postId], {
|
|
218
|
-
page_type: 'blog_post',
|
|
219
|
-
post_id: postId,
|
|
220
|
-
content_type: 'article'
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
return <article>Blog post content</article>;
|
|
224
|
-
}
|
|
165
|
+
<JourniumProvider
|
|
166
|
+
config={{
|
|
167
|
+
publishableKey: 'your-journium-publishable-key',
|
|
168
|
+
apiHost: 'https://events.journium.app', // Optional
|
|
169
|
+
config: { /* optional local config */ }
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
<App />
|
|
173
|
+
</JourniumProvider>
|
|
225
174
|
```
|
|
226
175
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
### Form Tracking
|
|
230
|
-
|
|
231
|
-
Track form interactions and submissions:
|
|
176
|
+
### `useTrackEvent()`
|
|
177
|
+
Hook for tracking custom events with optional properties.
|
|
232
178
|
|
|
233
179
|
```jsx
|
|
234
180
|
import { useTrackEvent } from '@journium/react';
|
|
235
181
|
|
|
236
|
-
function
|
|
182
|
+
function Component() {
|
|
237
183
|
const trackEvent = useTrackEvent();
|
|
238
184
|
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
form_type: 'lead_generation',
|
|
245
|
-
fields_completed: ['name', 'email', 'company']
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
// Submit form logic
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
const handleFieldChange = (fieldName) => {
|
|
252
|
-
trackEvent('form_field_completed', {
|
|
253
|
-
form_name: 'contact',
|
|
254
|
-
field_name: fieldName
|
|
185
|
+
const handlePurchase = () => {
|
|
186
|
+
trackEvent('purchase_completed', {
|
|
187
|
+
product_id: 'prod_123',
|
|
188
|
+
price: 29.99,
|
|
189
|
+
currency: 'USD'
|
|
255
190
|
});
|
|
256
191
|
};
|
|
257
192
|
|
|
258
|
-
return
|
|
259
|
-
<form onSubmit={handleSubmit}>
|
|
260
|
-
<input
|
|
261
|
-
name="email"
|
|
262
|
-
onChange={() => handleFieldChange('email')}
|
|
263
|
-
placeholder="Email"
|
|
264
|
-
/>
|
|
265
|
-
<input
|
|
266
|
-
name="company"
|
|
267
|
-
onChange={() => handleFieldChange('company')}
|
|
268
|
-
placeholder="Company"
|
|
269
|
-
/>
|
|
270
|
-
<button type="submit">Send Message</button>
|
|
271
|
-
</form>
|
|
272
|
-
);
|
|
193
|
+
return <button onClick={handlePurchase}>Buy Now</button>;
|
|
273
194
|
}
|
|
274
195
|
```
|
|
275
196
|
|
|
276
|
-
###
|
|
277
|
-
|
|
278
|
-
Track multi-step user flows:
|
|
197
|
+
### `useIdentify()`
|
|
198
|
+
Hook for identifying users on login or signup.
|
|
279
199
|
|
|
280
200
|
```jsx
|
|
281
|
-
import {
|
|
282
|
-
|
|
283
|
-
function OnboardingFlow({ step }) {
|
|
284
|
-
const trackEvent = useTrackEvent();
|
|
285
|
-
const trackPageview = useTrackPageview();
|
|
286
|
-
|
|
287
|
-
useEffect(() => {
|
|
288
|
-
// Track onboarding step pageview
|
|
289
|
-
trackPageview({
|
|
290
|
-
page_type: 'onboarding',
|
|
291
|
-
step: step,
|
|
292
|
-
flow: 'user_setup'
|
|
293
|
-
});
|
|
294
|
-
}, [step, trackPageview]);
|
|
201
|
+
import { useIdentify } from '@journium/react';
|
|
295
202
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
step: step,
|
|
299
|
-
time_spent: Date.now() - stepStartTime,
|
|
300
|
-
completed_successfully: true
|
|
301
|
-
});
|
|
302
|
-
};
|
|
203
|
+
function Component() {
|
|
204
|
+
const identify = useIdentify();
|
|
303
205
|
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
step: step,
|
|
307
|
-
reason: 'user_choice'
|
|
308
|
-
});
|
|
206
|
+
const handleLogin = (userId, userAttributes) => {
|
|
207
|
+
identify(userId, userAttributes);
|
|
309
208
|
};
|
|
310
209
|
|
|
311
|
-
return
|
|
312
|
-
<div>
|
|
313
|
-
<h2>Step {step}</h2>
|
|
314
|
-
<button onClick={handleStepComplete}>Complete Step</button>
|
|
315
|
-
<button onClick={handleSkipStep}>Skip</button>
|
|
316
|
-
</div>
|
|
317
|
-
);
|
|
210
|
+
return <LoginForm onLogin={handleLogin} />;
|
|
318
211
|
}
|
|
319
212
|
```
|
|
320
213
|
|
|
321
|
-
###
|
|
322
|
-
|
|
323
|
-
Create reusable tracking patterns:
|
|
214
|
+
### `useReset()`
|
|
215
|
+
Hook for resetting user identity on logout.
|
|
324
216
|
|
|
325
217
|
```jsx
|
|
326
|
-
import {
|
|
327
|
-
|
|
328
|
-
// Custom hook for feature tracking
|
|
329
|
-
function useFeatureTracking() {
|
|
330
|
-
const trackEvent = useTrackEvent();
|
|
218
|
+
import { useReset } from '@journium/react';
|
|
331
219
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
feature_name: featureName,
|
|
335
|
-
timestamp: new Date().toISOString(),
|
|
336
|
-
...context
|
|
337
|
-
});
|
|
338
|
-
};
|
|
220
|
+
function Component() {
|
|
221
|
+
const reset = useReset();
|
|
339
222
|
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
feature_name: featureName,
|
|
343
|
-
discovery_method: discoveryMethod
|
|
344
|
-
});
|
|
223
|
+
const handleLogout = () => {
|
|
224
|
+
reset();
|
|
345
225
|
};
|
|
346
226
|
|
|
347
|
-
return {
|
|
227
|
+
return <button onClick={handleLogout}>Logout</button>;
|
|
348
228
|
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### `useTrackPageview()`
|
|
232
|
+
Hook for manual pageview tracking.
|
|
349
233
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
234
|
+
```jsx
|
|
235
|
+
import { useTrackPageview } from '@journium/react';
|
|
236
|
+
|
|
237
|
+
function Component() {
|
|
238
|
+
const trackPageview = useTrackPageview();
|
|
353
239
|
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
240
|
+
const handleSpecialPageview = () => {
|
|
241
|
+
trackPageview({
|
|
242
|
+
page_type: 'modal',
|
|
243
|
+
content_type: 'pricing_calculator'
|
|
358
244
|
});
|
|
359
245
|
};
|
|
360
246
|
|
|
361
|
-
return
|
|
362
|
-
<div>
|
|
363
|
-
<button onClick={handleFeatureClick}>
|
|
364
|
-
Use Advanced Search
|
|
365
|
-
</button>
|
|
366
|
-
</div>
|
|
367
|
-
);
|
|
247
|
+
return <button onClick={handleSpecialPageview}>Track Modal View</button>;
|
|
368
248
|
}
|
|
369
249
|
```
|
|
370
250
|
|
|
371
|
-
|
|
251
|
+
### `useAutoTrackPageview()`
|
|
252
|
+
Hook for automatic pageview tracking when components mount or dependencies change.
|
|
372
253
|
|
|
373
|
-
|
|
254
|
+
```jsx
|
|
255
|
+
import { useAutoTrackPageview } from '@journium/react';
|
|
374
256
|
|
|
375
|
-
|
|
257
|
+
function ProductPage({ productId, category }) {
|
|
258
|
+
// Tracks pageview when component mounts or productId changes
|
|
259
|
+
useAutoTrackPageview([productId], {
|
|
260
|
+
page_type: 'product_detail',
|
|
261
|
+
product_id: productId,
|
|
262
|
+
category: category
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
return <div>Product {productId}</div>;
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### `useAutocapture()`
|
|
270
|
+
Hook for controlling automatic event capture.
|
|
376
271
|
|
|
377
272
|
```jsx
|
|
378
|
-
import { useState, useEffect } from 'react';
|
|
379
273
|
import { useAutocapture } from '@journium/react';
|
|
380
274
|
|
|
381
275
|
function ConsentBanner() {
|
|
382
276
|
const { startAutocapture, stopAutocapture } = useAutocapture();
|
|
383
|
-
const [hasConsent, setHasConsent] = useState(null);
|
|
384
|
-
|
|
385
|
-
useEffect(() => {
|
|
386
|
-
const savedConsent = localStorage.getItem('tracking_consent');
|
|
387
|
-
if (savedConsent === 'true') {
|
|
388
|
-
setHasConsent(true);
|
|
389
|
-
startAutocapture();
|
|
390
|
-
} else if (savedConsent === 'false') {
|
|
391
|
-
setHasConsent(false);
|
|
392
|
-
stopAutocapture();
|
|
393
|
-
}
|
|
394
|
-
}, [startAutocapture, stopAutocapture]);
|
|
395
277
|
|
|
396
278
|
const handleAccept = () => {
|
|
397
|
-
setHasConsent(true);
|
|
398
|
-
localStorage.setItem('tracking_consent', 'true');
|
|
399
279
|
startAutocapture();
|
|
400
280
|
};
|
|
401
281
|
|
|
402
282
|
const handleDecline = () => {
|
|
403
|
-
setHasConsent(false);
|
|
404
|
-
localStorage.setItem('tracking_consent', 'false');
|
|
405
283
|
stopAutocapture();
|
|
406
284
|
};
|
|
407
285
|
|
|
408
|
-
if (hasConsent !== null) return null;
|
|
409
|
-
|
|
410
286
|
return (
|
|
411
|
-
<div
|
|
412
|
-
<p>We use analytics to improve your experience.</p>
|
|
287
|
+
<div>
|
|
413
288
|
<button onClick={handleAccept}>Accept</button>
|
|
414
289
|
<button onClick={handleDecline}>Decline</button>
|
|
415
290
|
</div>
|
|
@@ -417,94 +292,20 @@ function ConsentBanner() {
|
|
|
417
292
|
}
|
|
418
293
|
```
|
|
419
294
|
|
|
420
|
-
###
|
|
421
|
-
|
|
422
|
-
Configure autocapture to ignore sensitive elements:
|
|
295
|
+
### `useJournium()`
|
|
296
|
+
Hook for direct access to the Journium instance for advanced use cases.
|
|
423
297
|
|
|
424
298
|
```jsx
|
|
425
|
-
|
|
426
|
-
config={{
|
|
427
|
-
token: "your-token",
|
|
428
|
-
apiHost: "https://api.journium.com",
|
|
429
|
-
autocapture: {
|
|
430
|
-
captureClicks: true,
|
|
431
|
-
captureFormSubmits: true,
|
|
432
|
-
captureFormChanges: false,
|
|
433
|
-
ignoreClasses: ['no-track', 'sensitive', 'pii'],
|
|
434
|
-
ignoreElements: ['input[type="password"]', '.credit-card']
|
|
435
|
-
}
|
|
436
|
-
}}
|
|
437
|
-
>
|
|
438
|
-
<App />
|
|
439
|
-
</JourniumProvider>
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
## 📱 TypeScript Support
|
|
443
|
-
|
|
444
|
-
Full TypeScript support with complete type definitions:
|
|
299
|
+
import { useJournium } from '@journium/react';
|
|
445
300
|
|
|
446
|
-
|
|
447
|
-
|
|
301
|
+
function Component() {
|
|
302
|
+
const { journium } = useJournium();
|
|
448
303
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
price: number;
|
|
453
|
-
currency: string;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
function TypedComponent() {
|
|
457
|
-
const trackEvent = useTrackEvent();
|
|
458
|
-
|
|
459
|
-
const handlePurchase = (productData: PurchaseEventProperties) => {
|
|
460
|
-
// Fully typed event tracking
|
|
461
|
-
trackEvent('product_purchased', productData);
|
|
304
|
+
const handleAdvancedTracking = () => {
|
|
305
|
+
journium?.track('custom_event', { advanced: true });
|
|
306
|
+
journium?.flush();
|
|
462
307
|
};
|
|
463
308
|
|
|
464
|
-
return <button onClick={
|
|
309
|
+
return <button onClick={handleAdvancedTracking}>Advanced Track</button>;
|
|
465
310
|
}
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
## 🔗 Available Hooks
|
|
469
|
-
|
|
470
|
-
| Hook | Purpose | Usage |
|
|
471
|
-
|------|---------|-------|
|
|
472
|
-
| `useTrackEvent()` | Track custom events | `trackEvent('event_name', properties)` |
|
|
473
|
-
| `useIdentify()` | Identify users on login/signup | `identify(distinctId, attributes)` |
|
|
474
|
-
| `useReset()` | Reset user identity on logout | `reset()` |
|
|
475
|
-
| `useTrackPageview()` | Manual pageview tracking | `trackPageview(properties)` |
|
|
476
|
-
| `useAutoTrackPageview(deps, props)` | Automatic pageview on mount | Auto-tracks when deps change |
|
|
477
|
-
| `useAutocapture()` | Control autocapture | `{ startAutocapture, stopAutocapture }` |
|
|
478
|
-
| `useJournium()` | Direct Journium instance access | Advanced use cases only |
|
|
479
|
-
|
|
480
|
-
## 🔗 Related Packages
|
|
481
|
-
|
|
482
|
-
Part of the Journium JavaScript SDK ecosystem:
|
|
483
|
-
|
|
484
|
-
- **[journium-js](https://npmjs.com/package/journium-js)** - Core JavaScript SDK for web browsers
|
|
485
|
-
- **[@journium/nextjs](https://npmjs.com/package/@journium/nextjs)** - Next.js integration with SSR support
|
|
486
|
-
- **[@journium/node](https://npmjs.com/package/@journium/node)** - Node.js server-side tracking
|
|
487
|
-
- **[@journium/core](https://npmjs.com/package/@journium/core)** - Core utilities and types
|
|
488
|
-
|
|
489
|
-
## 📖 Documentation
|
|
490
|
-
|
|
491
|
-
For complete documentation, guides, and examples:
|
|
492
|
-
|
|
493
|
-
- **[Documentation](https://docs.journium.app)** - Complete guides and API reference
|
|
494
|
-
- **[React Guide](https://docs.journium.app/react)** - React-specific documentation
|
|
495
|
-
- **[Examples](https://docs.journium.app/examples/react)** - React code examples and patterns
|
|
496
|
-
|
|
497
|
-
## 🤝 Contributing
|
|
498
|
-
|
|
499
|
-
We welcome contributions! Please see our [Contributing Guide](https://github.com/journium/journium-js/blob/main/CONTRIBUTING.md).
|
|
500
|
-
|
|
501
|
-
## 📄 License
|
|
502
|
-
|
|
503
|
-
MIT License - see [LICENSE](https://github.com/journium/journium-js/blob/main/LICENSE) file for details.
|
|
504
|
-
|
|
505
|
-
## 🆘 Support
|
|
506
|
-
|
|
507
|
-
- **📚 Docs**: [docs.journium.app](https://docs.journium.app)
|
|
508
|
-
- **🐛 Issues**: [GitHub Issues](https://github.com/journium/journium-js/issues)
|
|
509
|
-
- **💬 Discussions**: [GitHub Discussions](https://github.com/journium/journium-js/discussions)
|
|
510
|
-
- **📧 Email**: support@journium.com
|
|
311
|
+
```
|