humanbehavior-js 0.2.8 → 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/cjs/index.js +5 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +5 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/package.json +1 -1
- package/src/server.ts +4 -3
package/dist/types/index.d.ts
CHANGED
|
@@ -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(
|
|
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
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,9 +27,9 @@ export async function identifyUser(
|
|
|
26
27
|
'Authorization': `Bearer ${apiKey}`
|
|
27
28
|
},
|
|
28
29
|
body: JSON.stringify({
|
|
29
|
-
userId:
|
|
30
|
-
userAttributes: userData,
|
|
31
|
-
sessionId:
|
|
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
|
|
32
33
|
posthogName: userData.email || userData.name || null // Update posthogName with email
|
|
33
34
|
})
|
|
34
35
|
});
|