@base44-preview/sdk 0.8.7-pr.59.f0df0c6 → 0.8.8-pr.60.dc14a43

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,14 +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);
200
- if (analyticsDisable == null || !analyticsDisable.length)
204
+ const analyticsEnable = urlParams.get(ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY);
205
+ // if the url param is not set, return undefined //
206
+ if (analyticsEnable == null || !analyticsEnable.length)
201
207
  return undefined;
208
+ // remove the url param from the url //
202
209
  const newUrlParams = new URLSearchParams(window.location.search);
203
- newUrlParams.delete(ANALYTICS_CONFIG_URL_PARAM_KEY);
204
- const newUrl = `${window.location.pathname}?${newUrlParams.toString()}`;
205
- window.history.replaceState({}, document.title, newUrl);
206
- return analyticsDisable === "true" ? { enabled: false } : undefined;
210
+ newUrlParams.delete(ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY);
211
+ const newUrl = window.location.pathname +
212
+ (newUrlParams.toString() ? "?" + newUrlParams.toString() : "");
213
+ window.history.replaceState({}, "", newUrl);
214
+ // return the config object //
215
+ return { enabled: analyticsEnable === "true" };
207
216
  }
208
217
  export function getAnalyticsSessionId() {
209
218
  if (typeof window === "undefined") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.7-pr.59.f0df0c6",
3
+ "version": "0.8.8-pr.60.dc14a43",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",