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.
@@ -324,7 +324,8 @@ interface ServerSideUserData {
324
324
  * Identify user from server-side (NextAuth, Firebase, etc.)
325
325
  * Use this in your auth events to track users immediately on sign-in
326
326
  */
327
- declare function identifyUser(userData: ServerSideUserData, apiKey: string): Promise<{
327
+ declare function identifyUser(userId: string, // Separate userId parameter (should be stable unique identifier)
328
+ userData: ServerSideUserData, apiKey: string): Promise<{
328
329
  success: boolean;
329
330
  error?: string;
330
331
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "humanbehavior-js",
3
- "version": "0.2.9",
3
+ "version": "0.3.0",
4
4
  "description": "SDK for HumanBehavior session and event recording",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
package/src/server.ts CHANGED
@@ -15,6 +15,7 @@ export interface ServerSideUserData {
15
15
  * Use this in your auth events to track users immediately on sign-in
16
16
  */
17
17
  export async function identifyUser(
18
+ userId: string, // Separate userId parameter (should be stable unique identifier)
18
19
  userData: ServerSideUserData,
19
20
  apiKey: string
20
21
  ): Promise<{ success: boolean; error?: string }> {
@@ -26,8 +27,9 @@ export async function identifyUser(
26
27
  'Authorization': `Bearer ${apiKey}`
27
28
  },
28
29
  body: JSON.stringify({
29
- userId: userData.email,
30
- userAttributes: userData,
30
+ userId: userId, // Use stable unique identifier
31
+ userAttributes: userData, // Email and other data go here
32
+ sessionId: 'server-side-identification', // Dummy sessionId for server-side requests
31
33
  posthogName: userData.email || userData.name || null // Update posthogName with email
32
34
  })
33
35
  });