@tracelog/lib 0.2.2 → 0.3.0

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/README.md CHANGED
@@ -107,6 +107,12 @@ await tracelog.init({
107
107
 
108
108
  ## Configuration
109
109
 
110
+ **Disabling TraceLog:**
111
+ ```typescript
112
+ // Set this flag before initialization to disable TraceLog completely
113
+ window.__traceLogDisabled = true;
114
+ ```
115
+
110
116
  **Environment-based settings:**
111
117
  - Use `samplingRate: 0.1` to reduce data volume in high-traffic applications
112
118
  - Configure `sessionTimeout` to match your application's user session length
@@ -2399,30 +2399,32 @@ let g = null, C = !1, q = !1;
2399
2399
  const sr = async (r) => {
2400
2400
  if (typeof window > "u" || typeof document > "u")
2401
2401
  throw new Error("This library can only be used in a browser environment");
2402
- if (g) {
2403
- a.debug("API", "Library already initialized, skipping duplicate initialization");
2404
- return;
2405
- }
2406
- if (C)
2407
- throw a.warn("API", "Initialization already in progress"), new Error("Initialization already in progress");
2408
- C = !0;
2409
- try {
2410
- a.info("API", "Initializing TraceLog", { projectId: r.id });
2411
- const e = Lt(r), t = new nr();
2402
+ if (!window.__traceLogDisabled) {
2403
+ if (g) {
2404
+ a.debug("API", "Library already initialized, skipping duplicate initialization");
2405
+ return;
2406
+ }
2407
+ if (C)
2408
+ throw a.warn("API", "Initialization already in progress"), new Error("Initialization already in progress");
2409
+ C = !0;
2412
2410
  try {
2413
- await t.init(e), g = t, a.info("API", "TraceLog initialized successfully", { projectId: e.id });
2414
- } catch (n) {
2411
+ a.info("API", "Initializing TraceLog", { projectId: r.id });
2412
+ const e = Lt(r), t = new nr();
2415
2413
  try {
2416
- await t.destroy(!0);
2417
- } catch (s) {
2418
- a.warn("API", "Failed to cleanup partially initialized app", { cleanupError: s });
2414
+ await t.init(e), g = t, a.info("API", "TraceLog initialized successfully", { projectId: e.id });
2415
+ } catch (n) {
2416
+ try {
2417
+ await t.destroy(!0);
2418
+ } catch (s) {
2419
+ a.warn("API", "Failed to cleanup partially initialized app", { cleanupError: s });
2420
+ }
2421
+ throw n;
2419
2422
  }
2420
- throw n;
2423
+ } catch (e) {
2424
+ throw g = null, a.error("API", "Initialization failed", { error: e }), e;
2425
+ } finally {
2426
+ C = !1;
2421
2427
  }
2422
- } catch (e) {
2423
- throw g = null, a.error("API", "Initialization failed", { error: e }), e;
2424
- } finally {
2425
- C = !1;
2426
2428
  }
2427
2429
  }, ir = (r, e) => {
2428
2430
  if (!g)
package/dist/cjs/api.js CHANGED
@@ -21,6 +21,10 @@ const init = async (appConfig) => {
21
21
  if (typeof window === 'undefined' || typeof document === 'undefined') {
22
22
  throw new Error('This library can only be used in a browser environment');
23
23
  }
24
+ // Check if TraceLog is disabled
25
+ if (window.__traceLogDisabled) {
26
+ return;
27
+ }
24
28
  // Already initialized - safe to return
25
29
  if (app) {
26
30
  utils_1.debugLog.debug('API', 'Library already initialized, skipping duplicate initialization');
@@ -1,6 +1,11 @@
1
1
  import { TraceLogTestBridge } from './test-bridge.types';
2
2
  declare global {
3
3
  interface Window {
4
+ /**
5
+ * Flag to disable TraceLog initialization
6
+ * Set to true to prevent the library from running
7
+ */
8
+ __traceLogDisabled?: boolean;
4
9
  /**
5
10
  * Testing bridge for E2E tests
6
11
  * Only available when NODE_ENV=dev
package/dist/esm/api.js CHANGED
@@ -18,6 +18,10 @@ export const init = async (appConfig) => {
18
18
  if (typeof window === 'undefined' || typeof document === 'undefined') {
19
19
  throw new Error('This library can only be used in a browser environment');
20
20
  }
21
+ // Check if TraceLog is disabled
22
+ if (window.__traceLogDisabled) {
23
+ return;
24
+ }
21
25
  // Already initialized - safe to return
22
26
  if (app) {
23
27
  debugLog.debug('API', 'Library already initialized, skipping duplicate initialization');
@@ -1,6 +1,11 @@
1
1
  import { TraceLogTestBridge } from './test-bridge.types';
2
2
  declare global {
3
3
  interface Window {
4
+ /**
5
+ * Flag to disable TraceLog initialization
6
+ * Set to true to prevent the library from running
7
+ */
8
+ __traceLogDisabled?: boolean;
4
9
  /**
5
10
  * Testing bridge for E2E tests
6
11
  * Only available when NODE_ENV=dev
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tracelog/lib",
3
3
  "description": "JavaScript library for web analytics and real-time event tracking",
4
4
  "license": "MIT",
5
- "version": "0.2.2",
5
+ "version": "0.3.0",
6
6
  "main": "./dist/cjs/public-api.js",
7
7
  "module": "./dist/esm/public-api.js",
8
8
  "types": "./dist/esm/public-api.d.ts",