humanbehavior-js 0.4.8 → 0.4.10

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.
@@ -12449,7 +12449,7 @@ class HumanBehaviorAPI {
12449
12449
  entryURL = window.location.href;
12450
12450
  referrer = document.referrer;
12451
12451
  }
12452
- console.log('API init called with:', { sessionId, userId, entryURL, referrer, baseUrl: this.baseUrl });
12452
+ logInfo('API init called with:', { sessionId, userId, entryURL, referrer, baseUrl: this.baseUrl });
12453
12453
  try {
12454
12454
  const response = yield fetch(`${this.baseUrl}/api/ingestion/init`, {
12455
12455
  method: 'POST',
@@ -12465,21 +12465,21 @@ class HumanBehaviorAPI {
12465
12465
  referrer: referrer
12466
12466
  })
12467
12467
  });
12468
- console.log('API init response status:', response.status);
12468
+ logInfo('API init response status:', response.status);
12469
12469
  if (!response.ok) {
12470
12470
  const errorText = yield response.text();
12471
- console.error('API init failed:', response.status, errorText);
12471
+ logError('API init failed:', response.status, errorText);
12472
12472
  throw new Error(`Failed to initialize ingestion: ${response.statusText} - ${errorText}`);
12473
12473
  }
12474
12474
  const responseJson = yield response.json();
12475
- console.log('API init success:', responseJson);
12475
+ logInfo('API init success:', responseJson);
12476
12476
  return {
12477
12477
  sessionId: responseJson.sessionId,
12478
12478
  endUserId: responseJson.endUserId
12479
12479
  };
12480
12480
  }
12481
12481
  catch (error) {
12482
- console.error('API init error:', error);
12482
+ logError('API init error:', error);
12483
12483
  throw error;
12484
12484
  }
12485
12485
  });
@@ -12582,7 +12582,7 @@ class HumanBehaviorAPI {
12582
12582
  sessionId: sessionId,
12583
12583
  posthogName: userData.email || userData.name || null // Update user name with email
12584
12584
  };
12585
- console.log('Sending user data to server:', payload);
12585
+ logDebug('Sending user data to server:', payload);
12586
12586
  const response = yield fetch(`${this.baseUrl}/api/ingestion/user`, {
12587
12587
  method: 'POST',
12588
12588
  headers: {
@@ -12595,7 +12595,7 @@ class HumanBehaviorAPI {
12595
12595
  throw new Error(`Failed to send user data: ${response.statusText} with API key: ${this.apiKey}`);
12596
12596
  }
12597
12597
  const result = yield response.json();
12598
- console.log('Server response:', result);
12598
+ logDebug('Server response:', result);
12599
12599
  return result;
12600
12600
  }
12601
12601
  catch (error) {
@@ -13746,7 +13746,7 @@ class HumanBehaviorTracker {
13746
13746
  viewLogs() {
13747
13747
  try {
13748
13748
  const logs = logger.getLogs();
13749
- console.log('HumanBehavior Logs:', logs);
13749
+ logInfo('HumanBehavior Logs:', logs);
13750
13750
  logger.clearLogs(); // Clear logs after viewing
13751
13751
  }
13752
13752
  catch (e) {
@@ -13764,6 +13764,7 @@ class HumanBehaviorTracker {
13764
13764
  const originalEndUserId = this.endUserId;
13765
13765
  // Store user properties
13766
13766
  this.userProperties = userProperties;
13767
+ logDebug('Identifying user:', { userProperties, originalEndUserId, sessionId: this.sessionId });
13767
13768
  // Send user data with the original endUserId
13768
13769
  yield this.api.sendUserData(originalEndUserId, userProperties, this.sessionId);
13769
13770
  // Don't update endUserId - keep it as the original UUID