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/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(
|
|
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,9 +5955,9 @@ function identifyUser(userData, apiKey) {
|
|
|
5954
5955
|
'Authorization': `Bearer ${apiKey}`
|
|
5955
5956
|
},
|
|
5956
5957
|
body: JSON.stringify({
|
|
5957
|
-
userId:
|
|
5958
|
-
userAttributes: userData,
|
|
5959
|
-
sessionId:
|
|
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
|
|
5960
5961
|
posthogName: userData.email || userData.name || null // Update posthogName with email
|
|
5961
5962
|
})
|
|
5962
5963
|
});
|