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