@base44-preview/sdk 0.8.12-pr.65.5df0d45 → 0.8.12-pr.65.a665dc3

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 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.
@@ -2,7 +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_REFERRER_EVENT_NAME = "__referrer_event__";
5
+ export declare const ANALYTICS_INITIALIZTION_EVENT_NAME = "__initialization_event__";
6
+ export declare const ANALYTICS_SESSION_DURATION_EVENT_NAME = "__session_duration_event__";
6
7
  export declare const ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY = "analytics-enable";
7
8
  export declare const ANALYTICS_SESSION_ID_LOCAL_STORAGE_KEY = "base44_analytics_session_id";
8
9
  export interface AnalyticsModuleArgs {
@@ -1,7 +1,8 @@
1
1
  import { getSharedInstance } from "../utils/sharedInstance.js";
2
2
  import { generateUuid } from "../utils/common.js";
3
3
  export const USER_HEARTBEAT_EVENT_NAME = "__user_heartbeat_event__";
4
- export const ANALYTICS_REFERRER_EVENT_NAME = "__referrer_event__";
4
+ export const ANALYTICS_INITIALIZTION_EVENT_NAME = "__initialization_event__";
5
+ export const ANALYTICS_SESSION_DURATION_EVENT_NAME = "__session_duration_event__";
5
6
  export const ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY = "analytics-enable";
6
7
  export const ANALYTICS_SESSION_ID_LOCAL_STORAGE_KEY = "base44_analytics_session_id";
7
8
  const defaultConfiguration = {
@@ -21,8 +22,9 @@ const analyticsSharedState = getSharedInstance(ANALYTICS_SHARED_STATE_NAME, () =
21
22
  requestsQueue: [],
22
23
  isProcessing: false,
23
24
  isHeartBeatProcessing: false,
24
- wasReferrerTracked: false,
25
+ wasInitializationTracked: false,
25
26
  sessionContext: null,
27
+ sessionStartTime: null,
26
28
  config: {
27
29
  ...defaultConfiguration,
28
30
  ...getAnalyticsConfigFromUrlParams(),
@@ -97,10 +99,12 @@ export const createAnalyticsModule = ({ axiosClient, serverUrl, appId, userAuthM
97
99
  batchSize,
98
100
  });
99
101
  clearHeartBeatProcessor = startHeartBeatProcessor(track);
102
+ setSessionDurationTimerStart();
100
103
  };
101
104
  const onDocHidden = () => {
102
105
  stopAnalyticsProcessor();
103
106
  clearHeartBeatProcessor === null || clearHeartBeatProcessor === void 0 ? void 0 : clearHeartBeatProcessor();
107
+ trackSessionDurationEvent(track);
104
108
  // flush entire queue on visibility change and hope for the best //
105
109
  const eventsData = analyticsSharedState.requestsQueue.splice(0);
106
110
  flush(eventsData, { isBeacon: true });
@@ -127,7 +131,7 @@ export const createAnalyticsModule = ({ axiosClient, serverUrl, appId, userAuthM
127
131
  // start the heart beat processor //
128
132
  clearHeartBeatProcessor = startHeartBeatProcessor(track);
129
133
  // track the referrer event //
130
- trackReferrerEvent(track);
134
+ trackInitializationEvent(track);
131
135
  // start the visibility change listener //
132
136
  if (typeof window !== "undefined") {
133
137
  window.addEventListener("visibilitychange", onVisibilityChange);
@@ -170,14 +174,36 @@ function startHeartBeatProcessor(track) {
170
174
  analyticsSharedState.isHeartBeatProcessing = false;
171
175
  };
172
176
  }
173
- function trackReferrerEvent(track) {
174
- if (typeof window === "undefined" || analyticsSharedState.wasReferrerTracked)
177
+ function trackInitializationEvent(track) {
178
+ if (typeof window === "undefined" ||
179
+ analyticsSharedState.wasInitializationTracked)
175
180
  return;
176
- analyticsSharedState.wasReferrerTracked = true;
177
- const referrer = document === null || document === void 0 ? void 0 : document.referrer;
178
- if (!referrer)
181
+ analyticsSharedState.wasInitializationTracked = true;
182
+ track({
183
+ eventName: ANALYTICS_INITIALIZTION_EVENT_NAME,
184
+ properties: {
185
+ referrer: document === null || document === void 0 ? void 0 : document.referrer,
186
+ },
187
+ });
188
+ }
189
+ function setSessionDurationTimerStart() {
190
+ if (typeof window === "undefined" ||
191
+ analyticsSharedState.sessionStartTime !== null) {
192
+ return;
193
+ }
194
+ analyticsSharedState.sessionStartTime = new Date().toISOString();
195
+ }
196
+ function trackSessionDurationEvent(track) {
197
+ if (typeof window === "undefined" ||
198
+ analyticsSharedState.sessionStartTime === null)
179
199
  return;
180
- track({ eventName: ANALYTICS_REFERRER_EVENT_NAME, properties: { referrer } });
200
+ const sessionDuration = new Date().getTime() -
201
+ new Date(analyticsSharedState.sessionStartTime).getTime();
202
+ analyticsSharedState.sessionStartTime = null;
203
+ track({
204
+ eventName: ANALYTICS_SESSION_DURATION_EVENT_NAME,
205
+ properties: { sessionDuration },
206
+ });
181
207
  }
182
208
  function getEventIntrinsicData() {
183
209
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.12-pr.65.5df0d45",
3
+ "version": "0.8.12-pr.65.a665dc3",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -55,10 +55,10 @@
55
55
  "license": "MIT",
56
56
  "repository": {
57
57
  "type": "git",
58
- "url": "git+https://github.com/base44/sdk.git"
58
+ "url": "git+https://github.com/base44/javascript-sdk.git"
59
59
  },
60
60
  "bugs": {
61
- "url": "https://github.com/base44/sdk/issues"
61
+ "url": "https://github.com/base44/javascript-sdk/issues"
62
62
  },
63
- "homepage": "https://github.com/base44/sdk#readme"
63
+ "homepage": "https://github.com/base44/javascript-sdk#readme"
64
64
  }