humanbehavior-js 0.3.4 → 0.3.6

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/dist/cjs/index.js CHANGED
@@ -5529,7 +5529,7 @@ class HumanBehaviorTracker {
5529
5529
  * If userId is not provided, will use userProperties.email as the userId (if present)
5530
5530
  */
5531
5531
  identifyUser(_a) {
5532
- return __awaiter$1(this, arguments, void 0, function* ({ userId, userProperties }) {
5532
+ return __awaiter$1(this, arguments, void 0, function* ({ userProperties }) {
5533
5533
  yield this.ensureInitialized();
5534
5534
  // Keep the original endUserId (UUID) - don't change it
5535
5535
  const originalEndUserId = this.endUserId;
@@ -5942,57 +5942,6 @@ if (isBrowser) {
5942
5942
  window.HumanBehaviorTracker = HumanBehaviorTracker;
5943
5943
  }
5944
5944
 
5945
- /**
5946
- * Server-side utilities for HumanBehavior SDK
5947
- */
5948
- /**
5949
- * Identify user from server-side (NextAuth, Firebase, etc.)
5950
- * Use this in your auth events to track users immediately on sign-in
5951
- */
5952
- function identifyUser(userId, // Separate userId parameter (should be stable unique identifier)
5953
- userData, apiKey) {
5954
- return __awaiter$1(this, void 0, void 0, function* () {
5955
- try {
5956
- const response = yield fetch('https://ingest.humanbehavior.co/api/ingestion/user', {
5957
- method: 'POST',
5958
- headers: {
5959
- 'Content-Type': 'application/json',
5960
- 'Authorization': `Bearer ${apiKey}`
5961
- },
5962
- body: JSON.stringify({
5963
- userId: userId, // Use stable unique identifier
5964
- userAttributes: userData, // Email and other data go here
5965
- sessionId: 'server-side-identification', // Dummy sessionId for server-side requests
5966
- posthogName: userData.email || userData.name || null // Update posthogName with email
5967
- })
5968
- });
5969
- if (!response.ok) {
5970
- const errorText = yield response.text();
5971
- return {
5972
- success: false,
5973
- error: `Failed to identify user: ${response.status} ${response.statusText} - ${errorText}`
5974
- };
5975
- }
5976
- const result = yield response.json();
5977
- // If server found existing user, return the actual userId
5978
- if (result.actualUserId && result.actualUserId !== userId) {
5979
- console.log(`🔄 Server found existing user: ${result.actualUserId} (sent: ${userId})`);
5980
- return {
5981
- success: true,
5982
- actualUserId: result.actualUserId
5983
- };
5984
- }
5985
- return { success: true };
5986
- }
5987
- catch (error) {
5988
- return {
5989
- success: false,
5990
- error: error instanceof Error ? error.message : 'Unknown error'
5991
- };
5992
- }
5993
- });
5994
- }
5995
-
5996
5945
  /**
5997
5946
  * Main entry point for the HumanBehavior SDK
5998
5947
  */
@@ -6006,7 +5955,6 @@ exports.HumanBehaviorTracker = HumanBehaviorTracker;
6006
5955
  exports.MAX_CHUNK_SIZE_BYTES = MAX_CHUNK_SIZE_BYTES;
6007
5956
  exports.RedactionManager = RedactionManager;
6008
5957
  exports.default = HumanBehaviorTracker;
6009
- exports.identifyUser = identifyUser;
6010
5958
  exports.isChunkSizeExceeded = isChunkSizeExceeded;
6011
5959
  exports.logDebug = logDebug;
6012
5960
  exports.logError = logError;