clarity-analytics-sdk 1.0.3 → 1.0.5
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/package.json +2 -4
- package/src/index.js +7 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clarity-analytics-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "A lightweight JavaScript SDK for tracking events and analytics with Clarity Analytics",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,9 +29,7 @@
|
|
|
29
29
|
"getUserId",
|
|
30
30
|
"initSDK"
|
|
31
31
|
],
|
|
32
|
-
"ignore": [
|
|
33
|
-
"src/staging.js"
|
|
34
|
-
]
|
|
32
|
+
"ignore": []
|
|
35
33
|
},
|
|
36
34
|
"devDependencies": {
|
|
37
35
|
"standard": "^17.1.2",
|
package/src/index.js
CHANGED
|
@@ -17,12 +17,13 @@
|
|
|
17
17
|
}
|
|
18
18
|
// Configuration
|
|
19
19
|
this.config = {
|
|
20
|
-
apiUrl: '
|
|
21
|
-
fetchUserIdUrl: '
|
|
20
|
+
apiUrl: 'https://apps.helo.ai/api/v1/sdk/clarity/events/publish-event',
|
|
21
|
+
fetchUserIdUrl: 'https://apps.helo.ai/api/v1/sdk/clarity/projects?id=',
|
|
22
22
|
projectId: config.projectId,
|
|
23
23
|
projectName: config.projectName || '',
|
|
24
24
|
apiKey: config.apiKey || null,
|
|
25
25
|
userId: null, // Will be fetched from backend
|
|
26
|
+
systemUserId: null, // Will be fetched from backend API
|
|
26
27
|
sessionId: config.sessionId || this._generateSessionId(),
|
|
27
28
|
debug: config.debug || false,
|
|
28
29
|
retryAttempts: config.retryAttempts || 3,
|
|
@@ -57,6 +58,7 @@
|
|
|
57
58
|
|
|
58
59
|
this.config.userId = userId
|
|
59
60
|
this.config.ipaddress = ipaddress
|
|
61
|
+
this.config.systemUserId = userId || '' // Set to empty string if not provided
|
|
60
62
|
this._isInitialized = true
|
|
61
63
|
|
|
62
64
|
// Auto-collect page view if enabled
|
|
@@ -178,14 +180,9 @@
|
|
|
178
180
|
const requestId = this._generateRequestId()
|
|
179
181
|
const userId = data.customId || this.config.userId
|
|
180
182
|
|
|
181
|
-
//
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (userId && !userId.startsWith('user_')) {
|
|
186
|
-
// If it's a real user ID provided by the application
|
|
187
|
-
systemUserId = userId
|
|
188
|
-
}
|
|
183
|
+
// system_user_id comes from API response only, default to empty string if not available
|
|
184
|
+
const systemUserId = this.config.systemUserId || ''
|
|
185
|
+
const finalUserId = userId
|
|
189
186
|
|
|
190
187
|
// Build flat event payload (matching staging.js structure)
|
|
191
188
|
return {
|