humanbehavior-js 0.3.4 → 0.3.5

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/esm/index.js CHANGED
@@ -5938,57 +5938,6 @@ if (isBrowser) {
5938
5938
  window.HumanBehaviorTracker = HumanBehaviorTracker;
5939
5939
  }
5940
5940
 
5941
- /**
5942
- * Server-side utilities for HumanBehavior SDK
5943
- */
5944
- /**
5945
- * Identify user from server-side (NextAuth, Firebase, etc.)
5946
- * Use this in your auth events to track users immediately on sign-in
5947
- */
5948
- function identifyUser(userId, // Separate userId parameter (should be stable unique identifier)
5949
- userData, apiKey) {
5950
- return __awaiter$1(this, void 0, void 0, function* () {
5951
- try {
5952
- const response = yield fetch('https://ingest.humanbehavior.co/api/ingestion/user', {
5953
- method: 'POST',
5954
- headers: {
5955
- 'Content-Type': 'application/json',
5956
- 'Authorization': `Bearer ${apiKey}`
5957
- },
5958
- body: JSON.stringify({
5959
- userId: userId, // Use stable unique identifier
5960
- userAttributes: userData, // Email and other data go here
5961
- sessionId: 'server-side-identification', // Dummy sessionId for server-side requests
5962
- posthogName: userData.email || userData.name || null // Update posthogName with email
5963
- })
5964
- });
5965
- if (!response.ok) {
5966
- const errorText = yield response.text();
5967
- return {
5968
- success: false,
5969
- error: `Failed to identify user: ${response.status} ${response.statusText} - ${errorText}`
5970
- };
5971
- }
5972
- const result = yield response.json();
5973
- // If server found existing user, return the actual userId
5974
- if (result.actualUserId && result.actualUserId !== userId) {
5975
- console.log(`🔄 Server found existing user: ${result.actualUserId} (sent: ${userId})`);
5976
- return {
5977
- success: true,
5978
- actualUserId: result.actualUserId
5979
- };
5980
- }
5981
- return { success: true };
5982
- }
5983
- catch (error) {
5984
- return {
5985
- success: false,
5986
- error: error instanceof Error ? error.message : 'Unknown error'
5987
- };
5988
- }
5989
- });
5990
- }
5991
-
5992
5941
  /**
5993
5942
  * Main entry point for the HumanBehavior SDK
5994
5943
  */
@@ -5997,5 +5946,5 @@ if (typeof window !== 'undefined') {
5997
5946
  window.HumanBehaviorTracker = HumanBehaviorTracker;
5998
5947
  }
5999
5948
 
6000
- export { HumanBehaviorAPI, HumanBehaviorTracker, LogLevel, MAX_CHUNK_SIZE_BYTES, RedactionManager, HumanBehaviorTracker as default, identifyUser, isChunkSizeExceeded, logDebug, logError, logInfo, logWarn, logger, redactionManager, splitLargeEvent, validateSingleEventSize };
5949
+ export { HumanBehaviorAPI, HumanBehaviorTracker, LogLevel, MAX_CHUNK_SIZE_BYTES, RedactionManager, HumanBehaviorTracker as default, isChunkSizeExceeded, logDebug, logError, logInfo, logWarn, logger, redactionManager, splitLargeEvent, validateSingleEventSize };
6001
5950
  //# sourceMappingURL=index.js.map