humanbehavior-js 0.3.0 → 0.3.1

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.
@@ -328,6 +328,7 @@ declare function identifyUser(userId: string, // Separate userId parameter (shou
328
328
  userData: ServerSideUserData, apiKey: string): Promise<{
329
329
  success: boolean;
330
330
  error?: string;
331
+ actualUserId?: string;
331
332
  }>;
332
333
 
333
334
  declare enum LogLevel {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "humanbehavior-js",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
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
@@ -18,7 +18,7 @@ export async function identifyUser(
18
18
  userId: string, // Separate userId parameter (should be stable unique identifier)
19
19
  userData: ServerSideUserData,
20
20
  apiKey: string
21
- ): Promise<{ success: boolean; error?: string }> {
21
+ ): Promise<{ success: boolean; error?: string; actualUserId?: string }> {
22
22
  try {
23
23
  const response = await fetch('https://ingest.humanbehavior.co/api/ingestion/user', {
24
24
  method: 'POST',
@@ -42,6 +42,17 @@ export async function identifyUser(
42
42
  };
43
43
  }
44
44
 
45
+ const result = await response.json();
46
+
47
+ // If server found existing user, return the actual userId
48
+ if (result.actualUserId && result.actualUserId !== userId) {
49
+ console.log(`🔄 Server found existing user: ${result.actualUserId} (sent: ${userId})`);
50
+ return {
51
+ success: true,
52
+ actualUserId: result.actualUserId
53
+ };
54
+ }
55
+
45
56
  return { success: true };
46
57
  } catch (error) {
47
58
  return {