@base44/sdk 0.8.11 → 0.8.13
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/LICENSE +21 -0
- package/dist/modules/agents.types.d.ts +2 -2
- package/dist/modules/analytics.d.ts +2 -0
- package/dist/modules/analytics.js +42 -2
- package/package.json +8 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 base44
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import { RoomsSocket } from "../utils/socket-utils";
|
|
3
|
-
import { ModelFilterParams } from "../types";
|
|
2
|
+
import { RoomsSocket } from "../utils/socket-utils.js";
|
|
3
|
+
import { ModelFilterParams } from "../types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Reasoning information for an agent message.
|
|
6
6
|
*
|
|
@@ -2,6 +2,8 @@ import { AxiosInstance } from "axios";
|
|
|
2
2
|
import { TrackEventParams, AnalyticsModuleOptions } from "./analytics.types";
|
|
3
3
|
import type { AuthModule } from "./auth.types";
|
|
4
4
|
export declare const USER_HEARTBEAT_EVENT_NAME = "__user_heartbeat_event__";
|
|
5
|
+
export declare const ANALYTICS_INITIALIZATION_EVENT_NAME = "__initialization_event__";
|
|
6
|
+
export declare const ANALYTICS_SESSION_DURATION_EVENT_NAME = "__session_duration_event__";
|
|
5
7
|
export declare const ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY = "analytics-enable";
|
|
6
8
|
export declare const ANALYTICS_SESSION_ID_LOCAL_STORAGE_KEY = "base44_analytics_session_id";
|
|
7
9
|
export interface AnalyticsModuleArgs {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { getSharedInstance } from "../utils/sharedInstance";
|
|
2
|
-
import { generateUuid } from "../utils/common";
|
|
1
|
+
import { getSharedInstance } from "../utils/sharedInstance.js";
|
|
2
|
+
import { generateUuid } from "../utils/common.js";
|
|
3
3
|
export const USER_HEARTBEAT_EVENT_NAME = "__user_heartbeat_event__";
|
|
4
|
+
export const ANALYTICS_INITIALIZATION_EVENT_NAME = "__initialization_event__";
|
|
5
|
+
export const ANALYTICS_SESSION_DURATION_EVENT_NAME = "__session_duration_event__";
|
|
4
6
|
export const ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY = "analytics-enable";
|
|
5
7
|
export const ANALYTICS_SESSION_ID_LOCAL_STORAGE_KEY = "base44_analytics_session_id";
|
|
6
8
|
const defaultConfiguration = {
|
|
@@ -20,7 +22,9 @@ const analyticsSharedState = getSharedInstance(ANALYTICS_SHARED_STATE_NAME, () =
|
|
|
20
22
|
requestsQueue: [],
|
|
21
23
|
isProcessing: false,
|
|
22
24
|
isHeartBeatProcessing: false,
|
|
25
|
+
wasInitializationTracked: false,
|
|
23
26
|
sessionContext: null,
|
|
27
|
+
sessionStartTime: null,
|
|
24
28
|
config: {
|
|
25
29
|
...defaultConfiguration,
|
|
26
30
|
...getAnalyticsConfigFromUrlParams(),
|
|
@@ -95,10 +99,12 @@ export const createAnalyticsModule = ({ axiosClient, serverUrl, appId, userAuthM
|
|
|
95
99
|
batchSize,
|
|
96
100
|
});
|
|
97
101
|
clearHeartBeatProcessor = startHeartBeatProcessor(track);
|
|
102
|
+
setSessionDurationTimerStart();
|
|
98
103
|
};
|
|
99
104
|
const onDocHidden = () => {
|
|
100
105
|
stopAnalyticsProcessor();
|
|
101
106
|
clearHeartBeatProcessor === null || clearHeartBeatProcessor === void 0 ? void 0 : clearHeartBeatProcessor();
|
|
107
|
+
trackSessionDurationEvent(track);
|
|
102
108
|
// flush entire queue on visibility change and hope for the best //
|
|
103
109
|
const eventsData = analyticsSharedState.requestsQueue.splice(0);
|
|
104
110
|
flush(eventsData, { isBeacon: true });
|
|
@@ -124,6 +130,8 @@ export const createAnalyticsModule = ({ axiosClient, serverUrl, appId, userAuthM
|
|
|
124
130
|
startProcessing();
|
|
125
131
|
// start the heart beat processor //
|
|
126
132
|
clearHeartBeatProcessor = startHeartBeatProcessor(track);
|
|
133
|
+
// track the referrer event //
|
|
134
|
+
trackInitializationEvent(track);
|
|
127
135
|
// start the visibility change listener //
|
|
128
136
|
if (typeof window !== "undefined") {
|
|
129
137
|
window.addEventListener("visibilitychange", onVisibilityChange);
|
|
@@ -166,6 +174,38 @@ function startHeartBeatProcessor(track) {
|
|
|
166
174
|
analyticsSharedState.isHeartBeatProcessing = false;
|
|
167
175
|
};
|
|
168
176
|
}
|
|
177
|
+
function trackInitializationEvent(track) {
|
|
178
|
+
if (typeof window === "undefined" ||
|
|
179
|
+
analyticsSharedState.wasInitializationTracked) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
analyticsSharedState.wasInitializationTracked = true;
|
|
183
|
+
track({
|
|
184
|
+
eventName: ANALYTICS_INITIALIZATION_EVENT_NAME,
|
|
185
|
+
properties: {
|
|
186
|
+
referrer: document === null || document === void 0 ? void 0 : document.referrer,
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function setSessionDurationTimerStart() {
|
|
191
|
+
if (typeof window === "undefined" ||
|
|
192
|
+
analyticsSharedState.sessionStartTime !== null) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
analyticsSharedState.sessionStartTime = new Date().toISOString();
|
|
196
|
+
}
|
|
197
|
+
function trackSessionDurationEvent(track) {
|
|
198
|
+
if (typeof window === "undefined" ||
|
|
199
|
+
analyticsSharedState.sessionStartTime === null)
|
|
200
|
+
return;
|
|
201
|
+
const sessionDuration = new Date().getTime() -
|
|
202
|
+
new Date(analyticsSharedState.sessionStartTime).getTime();
|
|
203
|
+
analyticsSharedState.sessionStartTime = null;
|
|
204
|
+
track({
|
|
205
|
+
eventName: ANALYTICS_SESSION_DURATION_EVENT_NAME,
|
|
206
|
+
properties: { sessionDuration },
|
|
207
|
+
});
|
|
208
|
+
}
|
|
169
209
|
function getEventIntrinsicData() {
|
|
170
210
|
return {
|
|
171
211
|
timestamp: new Date().toISOString(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@base44/sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.13",
|
|
4
4
|
"description": "JavaScript SDK for Base44 API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,15 +32,18 @@
|
|
|
32
32
|
"@types/hast": "^3.0.4",
|
|
33
33
|
"@types/node": "^25.0.1",
|
|
34
34
|
"@types/unist": "^3.0.3",
|
|
35
|
+
"@typescript-eslint/parser": "^8.51.0",
|
|
35
36
|
"@vitest/coverage-istanbul": "^1.0.0",
|
|
36
37
|
"@vitest/coverage-v8": "^1.0.0",
|
|
37
38
|
"@vitest/ui": "^1.0.0",
|
|
38
39
|
"dotenv": "^16.3.1",
|
|
39
|
-
"eslint": "^
|
|
40
|
+
"eslint": "^9.39.2",
|
|
41
|
+
"eslint-plugin-import": "^2.32.0",
|
|
40
42
|
"nock": "^13.4.0",
|
|
41
43
|
"typedoc": "^0.28.14",
|
|
42
44
|
"typedoc-plugin-markdown": "^4.9.0",
|
|
43
45
|
"typescript": "^5.3.2",
|
|
46
|
+
"typescript-eslint": "^8.51.0",
|
|
44
47
|
"vitest": "^1.6.1"
|
|
45
48
|
},
|
|
46
49
|
"keywords": [
|
|
@@ -52,11 +55,10 @@
|
|
|
52
55
|
"license": "MIT",
|
|
53
56
|
"repository": {
|
|
54
57
|
"type": "git",
|
|
55
|
-
"url": "git+https://github.com/base44/sdk.git"
|
|
58
|
+
"url": "git+https://github.com/base44/javascript-sdk.git"
|
|
56
59
|
},
|
|
57
60
|
"bugs": {
|
|
58
|
-
"url": "https://github.com/base44/sdk/issues"
|
|
61
|
+
"url": "https://github.com/base44/javascript-sdk/issues"
|
|
59
62
|
},
|
|
60
|
-
"homepage": "https://github.com/base44/sdk#readme"
|
|
61
|
-
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
63
|
+
"homepage": "https://github.com/base44/javascript-sdk#readme"
|
|
62
64
|
}
|