humanbehavior-js 0.2.9 → 0.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.
package/dist/esm/index.js CHANGED
@@ -5944,7 +5944,8 @@ if (isBrowser) {
5944
5944
  * Identify user from server-side (NextAuth, Firebase, etc.)
5945
5945
  * Use this in your auth events to track users immediately on sign-in
5946
5946
  */
5947
- function identifyUser(userData, apiKey) {
5947
+ function identifyUser(userId, // Separate userId parameter (should be stable unique identifier)
5948
+ userData, apiKey) {
5948
5949
  return __awaiter$1(this, void 0, void 0, function* () {
5949
5950
  try {
5950
5951
  const response = yield fetch('https://ingest.humanbehavior.co/api/ingestion/user', {
@@ -5954,8 +5955,9 @@ function identifyUser(userData, apiKey) {
5954
5955
  'Authorization': `Bearer ${apiKey}`
5955
5956
  },
5956
5957
  body: JSON.stringify({
5957
- userId: userData.email,
5958
- userAttributes: userData,
5958
+ userId: userId, // Use stable unique identifier
5959
+ userAttributes: userData, // Email and other data go here
5960
+ sessionId: 'server-side-identification', // Dummy sessionId for server-side requests
5959
5961
  posthogName: userData.email || userData.name || null // Update posthogName with email
5960
5962
  })
5961
5963
  });