@base44-preview/sdk 0.8.6-pr.57.5bc7e40 → 0.8.6-pr.57.6db0afd
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.
|
@@ -2,7 +2,7 @@ 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
|
|
5
|
+
export declare const ANALYTICS_CONFIG_WINDOW_KEY = "base44_analytics_config";
|
|
6
6
|
export declare const ANALYTICS_SESSION_ID_LOCAL_STORAGE_KEY = "base44_analytics_session_id";
|
|
7
7
|
export interface AnalyticsModuleArgs {
|
|
8
8
|
axiosClient: AxiosInstance;
|
|
@@ -14,5 +14,5 @@ export declare const createAnalyticsModule: ({ axiosClient, serverUrl, appId, us
|
|
|
14
14
|
track: (params: TrackEventParams) => void;
|
|
15
15
|
cleanup: () => void;
|
|
16
16
|
};
|
|
17
|
-
export declare function
|
|
17
|
+
export declare function getAnalyticsModuleOptionsFromWindow(): AnalyticsModuleOptions | undefined;
|
|
18
18
|
export declare function getAnalyticsSessionId(): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getSharedInstance } from "../utils/sharedInstance";
|
|
2
2
|
import { generateUuid } from "../utils/common";
|
|
3
3
|
export const USER_HEARTBEAT_EVENT_NAME = "__user_heartbeat_event__";
|
|
4
|
-
export const
|
|
4
|
+
export const ANALYTICS_CONFIG_WINDOW_KEY = "base44_analytics_config";
|
|
5
5
|
export const ANALYTICS_SESSION_ID_LOCAL_STORAGE_KEY = "base44_analytics_session_id";
|
|
6
6
|
const defaultConfiguration = {
|
|
7
7
|
enabled: true,
|
|
@@ -22,7 +22,7 @@ const analyticsSharedState = getSharedInstance(ANALYTICS_SHARED_STATE_NAME, () =
|
|
|
22
22
|
sessionContext: null,
|
|
23
23
|
config: {
|
|
24
24
|
...defaultConfiguration,
|
|
25
|
-
...
|
|
25
|
+
...getAnalyticsModuleOptionsFromWindow(),
|
|
26
26
|
},
|
|
27
27
|
}));
|
|
28
28
|
export const createAnalyticsModule = ({ axiosClient, serverUrl, appId, userAuthModule, }) => {
|
|
@@ -189,18 +189,10 @@ async function getSessionContext(userAuthModule) {
|
|
|
189
189
|
}
|
|
190
190
|
return analyticsSharedState.sessionContext;
|
|
191
191
|
}
|
|
192
|
-
export function
|
|
192
|
+
export function getAnalyticsModuleOptionsFromWindow() {
|
|
193
193
|
if (typeof window === "undefined")
|
|
194
194
|
return undefined;
|
|
195
|
-
|
|
196
|
-
const jsonString = localStorage.getItem(ANALYTICS_CONFIG_LOCAL_STORAGE_KEY);
|
|
197
|
-
if (!jsonString)
|
|
198
|
-
return undefined;
|
|
199
|
-
return JSON.parse(jsonString);
|
|
200
|
-
}
|
|
201
|
-
catch (_a) {
|
|
202
|
-
return undefined;
|
|
203
|
-
}
|
|
195
|
+
return window[ANALYTICS_CONFIG_WINDOW_KEY];
|
|
204
196
|
}
|
|
205
197
|
export function getAnalyticsSessionId() {
|
|
206
198
|
if (typeof window === "undefined") {
|