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.
- package/dist/cjs/index.js +9 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/server.ts +12 -1
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
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 {
|