@base44/sdk 0.8.8 → 0.8.9

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 ANALYTICS_CONFIG_URL_PARAM_KEY = "analytics-disable";
5
+ export declare const ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY = "analytics-enable";
6
6
  export declare const ANALYTICS_SESSION_ID_LOCAL_STORAGE_KEY = "base44_analytics_session_id";
7
7
  export interface AnalyticsModuleArgs {
8
8
  axiosClient: AxiosInstance;
@@ -1,10 +1,11 @@
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 ANALYTICS_CONFIG_URL_PARAM_KEY = "analytics-disable";
4
+ export const ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY = "analytics-enable";
5
5
  export const ANALYTICS_SESSION_ID_LOCAL_STORAGE_KEY = "base44_analytics_session_id";
6
6
  const defaultConfiguration = {
7
- enabled: true,
7
+ // default to disabled //
8
+ enabled: false,
8
9
  maxQueueSize: 1000,
9
10
  throttleTime: 1000,
10
11
  batchSize: 30,
@@ -44,6 +45,7 @@ export const createAnalyticsModule = ({ axiosClient, serverUrl, appId, userAuthM
44
45
  data: { events },
45
46
  });
46
47
  };
48
+ // currently disabled, until fully tested //
47
49
  const beaconRequest = async (events) => {
48
50
  const beaconPayload = JSON.stringify({ events });
49
51
  try {
@@ -59,9 +61,12 @@ export const createAnalyticsModule = ({ axiosClient, serverUrl, appId, userAuthM
59
61
  const flush = async (eventsData) => {
60
62
  const sessionContext_ = await getSessionContext(userAuthModule);
61
63
  const events = eventsData.map(transformEventDataToApiRequestData(sessionContext_));
62
- if (!(await beaconRequest(events))) {
64
+ try {
63
65
  return batchRequestFallback(events);
64
66
  }
67
+ catch (_a) {
68
+ // do nothing
69
+ }
65
70
  };
66
71
  const startProcessing = () => {
67
72
  startAnalyticsProcessor(flush, {
@@ -196,18 +201,18 @@ export function getAnalyticsConfigFromUrlParams() {
196
201
  if (typeof window === "undefined")
197
202
  return undefined;
198
203
  const urlParams = new URLSearchParams(window.location.search);
199
- const analyticsDisable = urlParams.get(ANALYTICS_CONFIG_URL_PARAM_KEY);
204
+ const analyticsEnable = urlParams.get(ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY);
200
205
  // if the url param is not set, return undefined //
201
- if (analyticsDisable == null || !analyticsDisable.length)
206
+ if (analyticsEnable == null || !analyticsEnable.length)
202
207
  return undefined;
203
208
  // remove the url param from the url //
204
209
  const newUrlParams = new URLSearchParams(window.location.search);
205
- newUrlParams.delete(ANALYTICS_CONFIG_URL_PARAM_KEY);
210
+ newUrlParams.delete(ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY);
206
211
  const newUrl = window.location.pathname +
207
212
  (newUrlParams.toString() ? "?" + newUrlParams.toString() : "");
208
213
  window.history.replaceState({}, "", newUrl);
209
214
  // return the config object //
210
- return analyticsDisable === "true" ? { enabled: false } : undefined;
215
+ return { enabled: analyticsEnable === "true" };
211
216
  }
212
217
  export function getAnalyticsSessionId() {
213
218
  if (typeof window === "undefined") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44/sdk",
3
- "version": "0.8.8",
3
+ "version": "0.8.9",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",