@base44-preview/sdk 0.8.6-pr.57.346f67a → 0.8.6-pr.57.5d40d85

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/dist/client.js CHANGED
@@ -124,6 +124,7 @@ export function createClient(config) {
124
124
  userAuthModule,
125
125
  }),
126
126
  cleanup: () => {
127
+ userModules.analytics.cleanup();
127
128
  if (socket) {
128
129
  socket.disconnect();
129
130
  }
@@ -6,6 +6,7 @@ import type { ConnectorsModule } from "./modules/connectors.types.js";
6
6
  import type { FunctionsModule } from "./modules/functions.types.js";
7
7
  import type { AgentsModule } from "./modules/agents.types.js";
8
8
  import type { AppLogsModule } from "./modules/app-logs.types.js";
9
+ import type { AnalyticsModule } from "./modules/analytics.types.js";
9
10
  /**
10
11
  * Options for creating a Base44 client.
11
12
  */
@@ -82,6 +83,8 @@ export interface Base44Client {
82
83
  agents: AgentsModule;
83
84
  /** {@link AppLogsModule | App logs module} for tracking app usage. */
84
85
  appLogs: AppLogsModule;
86
+ /** {@link AnalyticsModule | Analytics module} for tracking app usage. */
87
+ analytics: AnalyticsModule;
85
88
  /** Cleanup function to disconnect WebSocket connections. Call when you're done with the client. */
86
89
  cleanup: () => void;
87
90
  /**
@@ -9,5 +9,6 @@ export interface AnalyticsModuleArgs {
9
9
  }
10
10
  export declare const createAnalyticsModule: ({ axiosClient, serverUrl, appId, userAuthModule, }: AnalyticsModuleArgs) => {
11
11
  track: (params: TrackEventParams) => void;
12
+ cleanup: () => void;
12
13
  };
13
14
  export declare function getAnalyticsModuleOptionsFromUrlParams(): AnalyticsModuleOptions | undefined;
@@ -61,7 +61,7 @@ export const createAnalyticsModule = ({ axiosClient, serverUrl, appId, userAuthM
61
61
  }
62
62
  };
63
63
  const onDocHidden = () => {
64
- analyticsSharedState.isProcessing = false;
64
+ stopAnalyticsProcessor();
65
65
  // flush entire queue on visibility change and hope for the best //
66
66
  const eventsData = analyticsSharedState.requestsQueue.splice(0);
67
67
  flush(eventsData);
@@ -92,10 +92,20 @@ export const createAnalyticsModule = ({ axiosClient, serverUrl, appId, userAuthM
92
92
  batchSize,
93
93
  });
94
94
  }
95
+ const cleanup = () => {
96
+ if (typeof window === "undefined")
97
+ return;
98
+ window.removeEventListener("visibilitychange", onVisibilityChange);
99
+ stopAnalyticsProcessor();
100
+ };
95
101
  return {
96
102
  track,
103
+ cleanup,
97
104
  };
98
105
  };
106
+ function stopAnalyticsProcessor() {
107
+ analyticsSharedState.isProcessing = false;
108
+ }
99
109
  async function startAnalyticsProcessor(handleTrack, options) {
100
110
  if (analyticsSharedState.isProcessing) {
101
111
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.6-pr.57.346f67a",
3
+ "version": "0.8.6-pr.57.5d40d85",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",