rozmova-analytics 1.0.23 → 1.0.25

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 CHANGED
@@ -33,60 +33,72 @@ import {
33
33
  setUser,
34
34
  trackEvent,
35
35
  setLocale,
36
- } from 'rozmova-analytics';
36
+ } from "rozmova-analytics";
37
37
 
38
38
  // Initialize the library
39
- init('en', 'web');
39
+ init({ locale: "en", platform: "web", isClearly: true });
40
40
 
41
41
  // Set user
42
- setUser('user-id-123', { email: 'user@example.com', name: 'John Doe' });
42
+ setUser("user-id-123", { email: "user@example.com", name: "John Doe" });
43
43
 
44
44
  // Track an event
45
- trackEvent('button_click', { button_name: 'Sign Up' });
45
+ trackEvent("button_click", { button_name: "Sign Up" });
46
46
  ```
47
47
 
48
48
  Or use in browser:
49
49
 
50
50
  ```javascript
51
-
52
51
  // Initialize the library
53
- window.Analytics.init('en', 'web');
52
+ window.Analytics.init({ locale: "en", platform: "web" });
54
53
 
55
54
  // Set user
56
- window.Analytics.setUser('user-id-123', { email: 'user@example.com', name: 'John Doe' });
55
+ window.Analytics.setUser("user-id-123", {
56
+ email: "user@example.com",
57
+ name: "John Doe",
58
+ });
57
59
 
58
60
  // Track an event
59
- window.Analytics.trackEvent('button_click', { button_name: 'Sign Up' });
61
+ window.Analytics.trackEvent("button_click", { button_name: "Sign Up" });
60
62
  ```
61
63
 
62
64
  ## API
63
65
 
64
- ### `init(locale?: string, platform?: string)`
66
+ ### `init(initParams:{locale?: string, platform?: string})`
67
+
65
68
  Initializes the analytics library, setting up Mixpanel and Google Analytics integrations. Optionally, set a locale and platform.
66
69
 
67
70
  ### `generateUserId()`
71
+
68
72
  Generates a unique user ID, stores it in cookies and localStorage, and returns the ID.
69
73
 
70
74
  ### `getUserId()`
75
+
71
76
  Retrieves the user ID from cookies, localStorage, or URL query parameters. If not found, generates a new one.
72
77
 
73
78
  ### `getCommonParams()`
79
+
74
80
  Returns an object with common analytics parameters such as device, browser, referrer, and UTM parameters.
75
81
 
76
82
  ### `setLocale(newLocale: string)`
83
+
77
84
  Sets the locale for analytics data.
78
85
 
79
86
  ### `setUser(userId: string, userParams: { email: string; name: string })`
87
+
80
88
  Associates a user with the provided user ID and sets user properties in Mixpanel and Google Analytics.
81
89
 
82
90
  ### `resetUser()`
91
+
83
92
  Resets the current user, generating a new user ID and reinitializing the library.
84
93
 
85
94
  ### `trackEvent(eventName: string, properties?: EventParams)`
95
+
86
96
  Tracks an event with the specified name and optional properties.
87
97
 
88
98
  ## Browser Support
99
+
89
100
  The package works on modern browsers and supports the following:
101
+
90
102
  - Chrome
91
103
  - Firefox
92
104
  - Safari
@@ -95,24 +107,25 @@ The package works on modern browsers and supports the following:
95
107
  ## Example Integration
96
108
 
97
109
  ```javascript
98
- import { init, trackEvent, setUser, resetUser } from 'rozmova-analytics';
110
+ import { init, trackEvent, setUser, resetUser } from "rozmova-analytics";
99
111
 
100
112
  // Initialize analytics
101
- init('en', 'ios');
113
+ init({ locale: "en", platform: "ios", isClearly: true });
102
114
 
103
115
  // Track a page view event
104
- trackEvent('page_view', { page: 'Home' });
116
+ trackEvent("page_view", { page: "Home" });
105
117
 
106
118
  // Set user details
107
- setUser('user-456', { email: 'user456@example.com', name: 'Jane Doe' });
119
+ setUser("user-456", { email: "user456@example.com", name: "Jane Doe" });
108
120
 
109
121
  // Reset the user
110
122
  resetUser();
111
123
  ```
112
124
 
113
125
  ## Contributing
126
+
114
127
  Contributions are welcome! Please fork the repository and create a pull request with your changes.
115
128
 
116
129
  ## License
117
- This project is licensed under the MIT License.
118
130
 
131
+ This project is licensed under the MIT License.
@@ -0,0 +1 @@
1
+ export declare const initCookieConsentBanner: (lng: string, isClearly: boolean) => void;
package/dist/helpers.d.ts CHANGED
@@ -10,5 +10,4 @@ export declare const getReferrer: () => string | null;
10
10
  export declare function getSearchQueryFromReferrer(): string | null;
11
11
  export declare const getGAClientId: () => string;
12
12
  export declare function getGASessionId(): string | null;
13
- export declare const isClearly: () => boolean;
14
- export declare const getLocaleFromURL: () => string;
13
+ export declare const getLocaleFromURL: (isClearly?: boolean) => string;
package/dist/index.d.ts CHANGED
@@ -4,7 +4,11 @@ declare class Analytics {
4
4
  private locale;
5
5
  private platform;
6
6
  private dataLayer;
7
- init(locale?: string, platform?: string): void;
7
+ init({ locale, platform, isClearly, }?: {
8
+ locale?: string;
9
+ platform?: string;
10
+ isClearly?: boolean;
11
+ }): void;
8
12
  trackEvent(eventName: string, properties?: EventParams): void;
9
13
  setUser(userId: string, userParams: {
10
14
  email: string;