@tracelog/lib 2.2.1-rc.82.7 → 2.2.1

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.
@@ -62,21 +62,6 @@ type MetadataNestedObject = Record<string, MetadataNestedValue>;
62
62
  * ```
63
63
  */
64
64
  type MetadataType = MetadataPrimitive | string[] | MetadataNestedObject | MetadataNestedObject[];
65
- /**
66
- * Result returned by tracelog.init()
67
- *
68
- * Contains the session identifier generated during initialization.
69
- * The sessionId is empty string in edge cases (SSR, disabled, race condition).
70
- *
71
- * @example
72
- * ```typescript
73
- * const { sessionId } = await tracelog.init();
74
- * console.log('Session started:', sessionId);
75
- * ```
76
- */
77
- interface InitResult {
78
- sessionId: string;
79
- }
80
65
 
81
66
  /**
82
67
  * Element configuration for viewport tracking with optional identifiers
@@ -2302,7 +2287,7 @@ type CustomHeadersProvider = () => Record<string, string>;
2302
2287
  */
2303
2288
  interface TraceLogTestBridge {
2304
2289
  readonly initialized: boolean;
2305
- init(config?: Config): Promise<InitResult>;
2290
+ init(config?: Config): Promise<void>;
2306
2291
  destroy(force?: boolean): void;
2307
2292
  sendCustomEvent(name: string, data?: Record<string, unknown> | Record<string, unknown>[]): void;
2308
2293
  event(name: string, metadata?: Record<string, unknown> | Record<string, unknown>[]): void;
@@ -2489,7 +2474,7 @@ declare const DEFAULT_WEB_VITALS_MODE: WebVitalsMode;
2489
2474
  declare const getWebVitalsThresholds: (mode?: WebVitalsMode) => Record<WebVitalType, number>;
2490
2475
 
2491
2476
  declare const tracelog: {
2492
- init: (config?: Config) => Promise<InitResult>;
2477
+ init: (config?: Config) => Promise<void>;
2493
2478
  event: (name: string, metadata?: Record<string, MetadataType> | Record<string, MetadataType>[]) => void;
2494
2479
  on: <K extends keyof EmitterMap>(event: K, callback: EmitterCallback<EmitterMap[K]>) => void;
2495
2480
  off: <K extends keyof EmitterMap>(event: K, callback: EmitterCallback<EmitterMap[K]>) => void;
@@ -2498,11 +2483,10 @@ declare const tracelog: {
2498
2483
  setCustomHeaders: (provider: CustomHeadersProvider) => void;
2499
2484
  removeCustomHeaders: () => void;
2500
2485
  isInitialized: () => boolean;
2501
- getSessionId: () => string | null;
2502
2486
  destroy: () => void;
2503
2487
  setQaMode: (enabled: boolean) => void;
2504
2488
  updateGlobalMetadata: (metadata: Record<string, MetadataType>) => void;
2505
2489
  mergeGlobalMetadata: (metadata: Record<string, MetadataType>) => void;
2506
2490
  };
2507
2491
 
2508
- export { AppConfigValidationError, type BeforeBatchTransformer, type BeforeSendTransformer, type ClickCoordinates, type ClickData, type ClickTrackingElementData, type Config, type CustomEventData, type CustomHeadersProvider, DEFAULT_SESSION_TIMEOUT, DEFAULT_WEB_VITALS_MODE, type DeviceInfo, DeviceType, type EmitterCallback, EmitterEvent, type EmitterMap, type ErrorData, ErrorType, type EventData, EventType, type EventTypeName, type EventsQueue, type InitResult, InitializationTimeoutError, IntegrationValidationError, MAX_ARRAY_LENGTH, MAX_CUSTOM_EVENT_ARRAY_SIZE, MAX_CUSTOM_EVENT_KEYS, MAX_CUSTOM_EVENT_NAME_LENGTH, MAX_CUSTOM_EVENT_STRING_SIZE, MAX_NESTED_OBJECT_KEYS, MAX_STRING_LENGTH, MAX_STRING_LENGTH_IN_ARRAY, type MetadataType, Mode, PII_PATTERNS, type PageViewData, PermanentError, type PersistedEventsQueue, type PrimaryScrollEvent, SamplingRateValidationError, type ScrollData, ScrollDirection, type SecondaryScrollEvent, type SessionEventCounts, SessionTimeoutValidationError, SpecialApiUrl, type State, type TraceLogTestBridge, TraceLogValidationError, type TransformerHook, type TransformerMap, type UTM, type ViewportConfig, type ViewportElement, type ViewportEventData, WEB_VITALS_GOOD_THRESHOLDS, WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS, WEB_VITALS_POOR_THRESHOLDS, type WebVitalType, type WebVitalsData, type WebVitalsMode, getWebVitalsThresholds, isPrimaryScrollEvent, isSecondaryScrollEvent, tracelog };
2492
+ export { AppConfigValidationError, type BeforeBatchTransformer, type BeforeSendTransformer, type ClickCoordinates, type ClickData, type ClickTrackingElementData, type Config, type CustomEventData, type CustomHeadersProvider, DEFAULT_SESSION_TIMEOUT, DEFAULT_WEB_VITALS_MODE, type DeviceInfo, DeviceType, type EmitterCallback, EmitterEvent, type EmitterMap, type ErrorData, ErrorType, type EventData, EventType, type EventTypeName, type EventsQueue, InitializationTimeoutError, IntegrationValidationError, MAX_ARRAY_LENGTH, MAX_CUSTOM_EVENT_ARRAY_SIZE, MAX_CUSTOM_EVENT_KEYS, MAX_CUSTOM_EVENT_NAME_LENGTH, MAX_CUSTOM_EVENT_STRING_SIZE, MAX_NESTED_OBJECT_KEYS, MAX_STRING_LENGTH, MAX_STRING_LENGTH_IN_ARRAY, type MetadataType, Mode, PII_PATTERNS, type PageViewData, PermanentError, type PersistedEventsQueue, type PrimaryScrollEvent, SamplingRateValidationError, type ScrollData, ScrollDirection, type SecondaryScrollEvent, type SessionEventCounts, SessionTimeoutValidationError, SpecialApiUrl, type State, type TraceLogTestBridge, TraceLogValidationError, type TransformerHook, type TransformerMap, type UTM, type ViewportConfig, type ViewportElement, type ViewportEventData, WEB_VITALS_GOOD_THRESHOLDS, WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS, WEB_VITALS_POOR_THRESHOLDS, type WebVitalType, type WebVitalsData, type WebVitalsMode, getWebVitalsThresholds, isPrimaryScrollEvent, isSecondaryScrollEvent, tracelog };
@@ -62,21 +62,6 @@ type MetadataNestedObject = Record<string, MetadataNestedValue>;
62
62
  * ```
63
63
  */
64
64
  type MetadataType = MetadataPrimitive | string[] | MetadataNestedObject | MetadataNestedObject[];
65
- /**
66
- * Result returned by tracelog.init()
67
- *
68
- * Contains the session identifier generated during initialization.
69
- * The sessionId is empty string in edge cases (SSR, disabled, race condition).
70
- *
71
- * @example
72
- * ```typescript
73
- * const { sessionId } = await tracelog.init();
74
- * console.log('Session started:', sessionId);
75
- * ```
76
- */
77
- interface InitResult {
78
- sessionId: string;
79
- }
80
65
 
81
66
  /**
82
67
  * Element configuration for viewport tracking with optional identifiers
@@ -2302,7 +2287,7 @@ type CustomHeadersProvider = () => Record<string, string>;
2302
2287
  */
2303
2288
  interface TraceLogTestBridge {
2304
2289
  readonly initialized: boolean;
2305
- init(config?: Config): Promise<InitResult>;
2290
+ init(config?: Config): Promise<void>;
2306
2291
  destroy(force?: boolean): void;
2307
2292
  sendCustomEvent(name: string, data?: Record<string, unknown> | Record<string, unknown>[]): void;
2308
2293
  event(name: string, metadata?: Record<string, unknown> | Record<string, unknown>[]): void;
@@ -2489,7 +2474,7 @@ declare const DEFAULT_WEB_VITALS_MODE: WebVitalsMode;
2489
2474
  declare const getWebVitalsThresholds: (mode?: WebVitalsMode) => Record<WebVitalType, number>;
2490
2475
 
2491
2476
  declare const tracelog: {
2492
- init: (config?: Config) => Promise<InitResult>;
2477
+ init: (config?: Config) => Promise<void>;
2493
2478
  event: (name: string, metadata?: Record<string, MetadataType> | Record<string, MetadataType>[]) => void;
2494
2479
  on: <K extends keyof EmitterMap>(event: K, callback: EmitterCallback<EmitterMap[K]>) => void;
2495
2480
  off: <K extends keyof EmitterMap>(event: K, callback: EmitterCallback<EmitterMap[K]>) => void;
@@ -2498,11 +2483,10 @@ declare const tracelog: {
2498
2483
  setCustomHeaders: (provider: CustomHeadersProvider) => void;
2499
2484
  removeCustomHeaders: () => void;
2500
2485
  isInitialized: () => boolean;
2501
- getSessionId: () => string | null;
2502
2486
  destroy: () => void;
2503
2487
  setQaMode: (enabled: boolean) => void;
2504
2488
  updateGlobalMetadata: (metadata: Record<string, MetadataType>) => void;
2505
2489
  mergeGlobalMetadata: (metadata: Record<string, MetadataType>) => void;
2506
2490
  };
2507
2491
 
2508
- export { AppConfigValidationError, type BeforeBatchTransformer, type BeforeSendTransformer, type ClickCoordinates, type ClickData, type ClickTrackingElementData, type Config, type CustomEventData, type CustomHeadersProvider, DEFAULT_SESSION_TIMEOUT, DEFAULT_WEB_VITALS_MODE, type DeviceInfo, DeviceType, type EmitterCallback, EmitterEvent, type EmitterMap, type ErrorData, ErrorType, type EventData, EventType, type EventTypeName, type EventsQueue, type InitResult, InitializationTimeoutError, IntegrationValidationError, MAX_ARRAY_LENGTH, MAX_CUSTOM_EVENT_ARRAY_SIZE, MAX_CUSTOM_EVENT_KEYS, MAX_CUSTOM_EVENT_NAME_LENGTH, MAX_CUSTOM_EVENT_STRING_SIZE, MAX_NESTED_OBJECT_KEYS, MAX_STRING_LENGTH, MAX_STRING_LENGTH_IN_ARRAY, type MetadataType, Mode, PII_PATTERNS, type PageViewData, PermanentError, type PersistedEventsQueue, type PrimaryScrollEvent, SamplingRateValidationError, type ScrollData, ScrollDirection, type SecondaryScrollEvent, type SessionEventCounts, SessionTimeoutValidationError, SpecialApiUrl, type State, type TraceLogTestBridge, TraceLogValidationError, type TransformerHook, type TransformerMap, type UTM, type ViewportConfig, type ViewportElement, type ViewportEventData, WEB_VITALS_GOOD_THRESHOLDS, WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS, WEB_VITALS_POOR_THRESHOLDS, type WebVitalType, type WebVitalsData, type WebVitalsMode, getWebVitalsThresholds, isPrimaryScrollEvent, isSecondaryScrollEvent, tracelog };
2492
+ export { AppConfigValidationError, type BeforeBatchTransformer, type BeforeSendTransformer, type ClickCoordinates, type ClickData, type ClickTrackingElementData, type Config, type CustomEventData, type CustomHeadersProvider, DEFAULT_SESSION_TIMEOUT, DEFAULT_WEB_VITALS_MODE, type DeviceInfo, DeviceType, type EmitterCallback, EmitterEvent, type EmitterMap, type ErrorData, ErrorType, type EventData, EventType, type EventTypeName, type EventsQueue, InitializationTimeoutError, IntegrationValidationError, MAX_ARRAY_LENGTH, MAX_CUSTOM_EVENT_ARRAY_SIZE, MAX_CUSTOM_EVENT_KEYS, MAX_CUSTOM_EVENT_NAME_LENGTH, MAX_CUSTOM_EVENT_STRING_SIZE, MAX_NESTED_OBJECT_KEYS, MAX_STRING_LENGTH, MAX_STRING_LENGTH_IN_ARRAY, type MetadataType, Mode, PII_PATTERNS, type PageViewData, PermanentError, type PersistedEventsQueue, type PrimaryScrollEvent, SamplingRateValidationError, type ScrollData, ScrollDirection, type SecondaryScrollEvent, type SessionEventCounts, SessionTimeoutValidationError, SpecialApiUrl, type State, type TraceLogTestBridge, TraceLogValidationError, type TransformerHook, type TransformerMap, type UTM, type ViewportConfig, type ViewportElement, type ViewportEventData, WEB_VITALS_GOOD_THRESHOLDS, WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS, WEB_VITALS_POOR_THRESHOLDS, type WebVitalType, type WebVitalsData, type WebVitalsMode, getWebVitalsThresholds, isPrimaryScrollEvent, isSecondaryScrollEvent, tracelog };
@@ -555,7 +555,7 @@ var LONG_TASK_THROTTLE_MS = 1e3;
555
555
  var MAX_NAVIGATION_HISTORY = 50;
556
556
 
557
557
  // package.json
558
- var version = "2.2.1";
558
+ var version = "2.2.0";
559
559
 
560
560
  // src/constants/version.constants.ts
561
561
  var LIB_VERSION = version;
@@ -846,6 +846,7 @@ var sanitizeString = (value) => {
846
846
  }
847
847
  });
848
848
  }
849
+ sanitized = sanitized.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#x27;").replaceAll("/", "&#x2F;");
849
850
  const result = sanitized.trim();
850
851
  return result;
851
852
  };
@@ -6119,7 +6120,7 @@ var App = class extends StateManager {
6119
6120
  */
6120
6121
  async init(config = {}) {
6121
6122
  if (this.isInitialized) {
6122
- return { sessionId: this.get("sessionId") ?? "" };
6123
+ return;
6123
6124
  }
6124
6125
  this.managers.storage = new StorageManager();
6125
6126
  try {
@@ -6137,7 +6138,6 @@ var App = class extends StateManager {
6137
6138
  log("warn", "Failed to recover persisted events", { error });
6138
6139
  });
6139
6140
  this.isInitialized = true;
6140
- return { sessionId: this.get("sessionId") ?? "" };
6141
6141
  } catch (error) {
6142
6142
  this.destroy(true);
6143
6143
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -6297,15 +6297,6 @@ var App = class extends StateManager {
6297
6297
  getEventManager() {
6298
6298
  return this.managers.event;
6299
6299
  }
6300
- /**
6301
- * Returns the current session ID.
6302
- *
6303
- * @returns The session ID string, or null if not yet initialized
6304
- * @internal Used by api.getSessionId()
6305
- */
6306
- getSessionId() {
6307
- return this.get("sessionId");
6308
- }
6309
6300
  /**
6310
6301
  * Validates metadata object structure and values.
6311
6302
  *
@@ -6418,17 +6409,17 @@ var isInitializing = false;
6418
6409
  var isDestroying = false;
6419
6410
  var init = async (config) => {
6420
6411
  if (typeof window === "undefined" || typeof document === "undefined") {
6421
- return { sessionId: "" };
6412
+ return;
6422
6413
  }
6423
6414
  isDestroying = false;
6424
6415
  if (window.__traceLogDisabled === true) {
6425
- return { sessionId: "" };
6416
+ return;
6426
6417
  }
6427
6418
  if (app) {
6428
- return { sessionId: app.getSessionId() ?? "" };
6419
+ return;
6429
6420
  }
6430
6421
  if (isInitializing) {
6431
- return { sessionId: "" };
6422
+ return;
6432
6423
  }
6433
6424
  isInitializing = true;
6434
6425
  try {
@@ -6457,9 +6448,8 @@ var init = async (config) => {
6457
6448
  reject(new Error(`[TraceLog] Initialization timeout after ${INITIALIZATION_TIMEOUT_MS}ms`));
6458
6449
  }, INITIALIZATION_TIMEOUT_MS);
6459
6450
  });
6460
- const result = await Promise.race([initPromise, timeoutPromise]);
6451
+ await Promise.race([initPromise, timeoutPromise]);
6461
6452
  app = instance;
6462
- return result;
6463
6453
  } catch (error) {
6464
6454
  try {
6465
6455
  instance.destroy(true);
@@ -6585,15 +6575,6 @@ var isInitialized = () => {
6585
6575
  }
6586
6576
  return app !== null;
6587
6577
  };
6588
- var getSessionId = () => {
6589
- if (typeof window === "undefined" || typeof document === "undefined") {
6590
- return null;
6591
- }
6592
- if (!app) {
6593
- return null;
6594
- }
6595
- return app.getSessionId();
6596
- };
6597
6578
  var destroy = () => {
6598
6579
  if (typeof window === "undefined" || typeof document === "undefined") {
6599
6580
  return;
@@ -6667,7 +6648,6 @@ var tracelog = {
6667
6648
  setCustomHeaders,
6668
6649
  removeCustomHeaders,
6669
6650
  isInitialized,
6670
- getSessionId,
6671
6651
  destroy,
6672
6652
  setQaMode: setQaMode2,
6673
6653
  updateGlobalMetadata,