@reservamos/browser-analytics 0.1.3 → 0.1.4-alpha.2
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/CHANGELOG.md +14 -0
- package/README.md +23 -11
- package/dist/browser-analytics.cjs +3 -3
- package/dist/browser-analytics.d.ts +80 -13
- package/dist/browser-analytics.esm.js +12231 -12316
- package/dist/browser-analytics.iife.js +24 -24
- package/package.json +1 -1
- package/src/constants/ProductTypes.ts +6 -0
- package/src/events/identify/identify.ts +81 -0
- package/src/events/identify/identifySchema.ts +15 -0
- package/src/events/identify/index.ts +3 -0
- package/src/events/search/index.ts +7 -0
- package/src/events/search/searchSchema.ts +44 -0
- package/src/events/search/trackSearch.ts +14 -0
- package/src/events/test/index.ts +3 -0
- package/src/events/{trackTest.ts → test/trackTest.ts} +4 -2
- package/src/index.ts +13 -8
- package/src/init.ts +6 -8
- package/src/{fingerprint.ts → services/fingerprint.ts} +11 -3
- package/src/services/mixpanel.ts +89 -0
- package/src/services/validator.ts +138 -0
- package/src/track.ts +7 -13
- package/src/util/dateValidation.ts +26 -0
- package/src/util/userFingerprintValidation.ts +9 -0
- package/src/events/event_schema/PaymentFailedEventSchema.ts +0 -247
- package/src/events/event_schema/PurchaseCompleteEventSchema.ts +0 -62
- package/src/events/event_schema/validationSchema.ts +0 -135
- package/src/mixpanel.ts +0 -36
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
- Breaking Change: Import individual init, track and identify functions is no longer available.
|
|
6
|
+
- Breaking Change: The track events are now under the `track` property. So `analytics.trackEventName` now becomes `analytics.track.eventName`.
|
|
7
|
+
- Implement new folder structure.
|
|
8
|
+
- Add services
|
|
9
|
+
- Add a folder per event
|
|
10
|
+
- Refactor mixpanel, fingerprint and validator to become services
|
|
11
|
+
|
|
12
|
+
## 0.1.3
|
|
13
|
+
|
|
14
|
+
- Added publish action
|
|
15
|
+
|
|
3
16
|
## 0.1.1
|
|
17
|
+
|
|
4
18
|
- Added `zod` dependency to validate schema formats
|
|
5
19
|
|
|
6
20
|
## 0.1.0
|
package/README.md
CHANGED
|
@@ -16,20 +16,14 @@ This library is a lightweight and optimized solution for tracking user events an
|
|
|
16
16
|
To install the library, use npm or yarn
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
npm install reservamos
|
|
19
|
+
npm install @reservamos/browser-analytics
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## Usage
|
|
23
23
|
|
|
24
24
|
```typescript
|
|
25
|
-
// Import the tracker
|
|
26
|
-
import
|
|
27
|
-
|
|
28
|
-
// Also import the InitConfig interface if you want to use type safety
|
|
29
|
-
// import tracker, { InitConfig } from "@reservamos/browser-analytics";
|
|
30
|
-
|
|
31
|
-
// You can also import only the functions you need
|
|
32
|
-
// import { init, track, identify } from "@reservamos/browser-analytics";
|
|
25
|
+
// Import the tracker and the InitConfig interface if you want to use type safety
|
|
26
|
+
import analytics, { InitConfig } from '@reservamos/browser-analytics';
|
|
33
27
|
|
|
34
28
|
// Define the configuration for the tracker
|
|
35
29
|
const config: InitConfig = {
|
|
@@ -39,13 +33,31 @@ const config: InitConfig = {
|
|
|
39
33
|
};
|
|
40
34
|
|
|
41
35
|
// Initialize the tracker with the config
|
|
42
|
-
|
|
36
|
+
analytics.init(config);
|
|
43
37
|
|
|
44
38
|
// Listen for the "Tracker Ready" event
|
|
45
39
|
window.addEventListener('Tracker Ready', () => {
|
|
46
40
|
console.log('Tracker Ready');
|
|
47
41
|
|
|
48
42
|
// Track a test event
|
|
49
|
-
|
|
43
|
+
analytics.track.test();
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Identifying Users
|
|
48
|
+
|
|
49
|
+
The `identify` method accepts a main identifier and an object containing user information. The object has four predefined fields: `email`, `firstName`, `lastName`, and `phone`. In addition to these, you can include any custom fields to store additional user-specific information as needed.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import analytics from '@reservamos/browser-analytics';
|
|
53
|
+
|
|
54
|
+
// Identify the user with the main identifier and additional information
|
|
55
|
+
|
|
56
|
+
analytics.identify('main-identifier', {
|
|
57
|
+
email: 'example',
|
|
58
|
+
firstName: 'John',
|
|
59
|
+
lastName: 'Doe',
|
|
60
|
+
phone: '123456789',
|
|
61
|
+
salesforceId: '123456789',
|
|
50
62
|
});
|
|
51
63
|
```
|