@tracelog/lib 2.2.1 → 2.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.
@@ -557,7 +557,7 @@ var LONG_TASK_THROTTLE_MS = 1e3;
557
557
  var MAX_NAVIGATION_HISTORY = 50;
558
558
 
559
559
  // package.json
560
- var version = "2.2.0";
560
+ var version = "2.2.1";
561
561
 
562
562
  // src/constants/version.constants.ts
563
563
  var LIB_VERSION = version;
@@ -848,7 +848,6 @@ var sanitizeString = (value) => {
848
848
  }
849
849
  });
850
850
  }
851
- sanitized = sanitized.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#x27;").replaceAll("/", "&#x2F;");
852
851
  const result = sanitized.trim();
853
852
  return result;
854
853
  };
@@ -6122,7 +6121,7 @@ var App = class extends StateManager {
6122
6121
  */
6123
6122
  async init(config = {}) {
6124
6123
  if (this.isInitialized) {
6125
- return;
6124
+ return { sessionId: this.get("sessionId") ?? "" };
6126
6125
  }
6127
6126
  this.managers.storage = new StorageManager();
6128
6127
  try {
@@ -6140,6 +6139,7 @@ var App = class extends StateManager {
6140
6139
  log("warn", "Failed to recover persisted events", { error });
6141
6140
  });
6142
6141
  this.isInitialized = true;
6142
+ return { sessionId: this.get("sessionId") ?? "" };
6143
6143
  } catch (error) {
6144
6144
  this.destroy(true);
6145
6145
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -6299,6 +6299,15 @@ var App = class extends StateManager {
6299
6299
  getEventManager() {
6300
6300
  return this.managers.event;
6301
6301
  }
6302
+ /**
6303
+ * Returns the current session ID.
6304
+ *
6305
+ * @returns The session ID string, or null if not yet initialized
6306
+ * @internal Used by api.getSessionId()
6307
+ */
6308
+ getSessionId() {
6309
+ return this.get("sessionId");
6310
+ }
6302
6311
  /**
6303
6312
  * Validates metadata object structure and values.
6304
6313
  *
@@ -6411,17 +6420,17 @@ var isInitializing = false;
6411
6420
  var isDestroying = false;
6412
6421
  var init = async (config) => {
6413
6422
  if (typeof window === "undefined" || typeof document === "undefined") {
6414
- return;
6423
+ return { sessionId: "" };
6415
6424
  }
6416
6425
  isDestroying = false;
6417
6426
  if (window.__traceLogDisabled === true) {
6418
- return;
6427
+ return { sessionId: "" };
6419
6428
  }
6420
6429
  if (app) {
6421
- return;
6430
+ return { sessionId: app.getSessionId() ?? "" };
6422
6431
  }
6423
6432
  if (isInitializing) {
6424
- return;
6433
+ return { sessionId: "" };
6425
6434
  }
6426
6435
  isInitializing = true;
6427
6436
  try {
@@ -6450,8 +6459,9 @@ var init = async (config) => {
6450
6459
  reject(new Error(`[TraceLog] Initialization timeout after ${INITIALIZATION_TIMEOUT_MS}ms`));
6451
6460
  }, INITIALIZATION_TIMEOUT_MS);
6452
6461
  });
6453
- await Promise.race([initPromise, timeoutPromise]);
6462
+ const result = await Promise.race([initPromise, timeoutPromise]);
6454
6463
  app = instance;
6464
+ return result;
6455
6465
  } catch (error) {
6456
6466
  try {
6457
6467
  instance.destroy(true);
@@ -6577,6 +6587,15 @@ var isInitialized = () => {
6577
6587
  }
6578
6588
  return app !== null;
6579
6589
  };
6590
+ var getSessionId = () => {
6591
+ if (typeof window === "undefined" || typeof document === "undefined") {
6592
+ return null;
6593
+ }
6594
+ if (!app) {
6595
+ return null;
6596
+ }
6597
+ return app.getSessionId();
6598
+ };
6580
6599
  var destroy = () => {
6581
6600
  if (typeof window === "undefined" || typeof document === "undefined") {
6582
6601
  return;
@@ -6650,6 +6669,7 @@ var tracelog = {
6650
6669
  setCustomHeaders,
6651
6670
  removeCustomHeaders,
6652
6671
  isInitialized,
6672
+ getSessionId,
6653
6673
  destroy,
6654
6674
  setQaMode: setQaMode2,
6655
6675
  updateGlobalMetadata,