humanbehavior-js 0.3.1 → 0.3.2
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 +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react/index.js +5 -5
- package/dist/cjs/react/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react/index.js +5 -5
- package/dist/esm/react/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 +1 -1
- package/dist/types/react/index.d.ts +1 -1
- package/package.json +5 -2
- package/rollup.config.js +3 -3
- package/src/react/index.tsx +8 -8
- package/src/tracker.ts +1 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -193,7 +193,7 @@ declare class HumanBehaviorTracker {
|
|
|
193
193
|
* Add user identification information to the tracker
|
|
194
194
|
* If userId is not provided, will use userProperties.email as the userId (if present)
|
|
195
195
|
*/
|
|
196
|
-
|
|
196
|
+
identifyUser({ userId, userProperties }: {
|
|
197
197
|
userId?: string;
|
|
198
198
|
userProperties: Record<string, any>;
|
|
199
199
|
}): Promise<string>;
|
|
@@ -20,7 +20,7 @@ declare const useRedaction: () => {
|
|
|
20
20
|
getRedactedFields: () => string[];
|
|
21
21
|
};
|
|
22
22
|
declare const useUserTracking: () => {
|
|
23
|
-
|
|
23
|
+
identifyUser: ({ userId, userProperties }: {
|
|
24
24
|
userId?: string;
|
|
25
25
|
userProperties: Record<string, any>;
|
|
26
26
|
}) => Promise<{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "humanbehavior-js",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "SDK for HumanBehavior session and event recording",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -31,10 +31,13 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@types/react": "^19.0.12",
|
|
33
33
|
"humanbehavior-js": "^0.0.9",
|
|
34
|
-
"react": "^19.0.0",
|
|
35
34
|
"rrweb": "^2.0.0-alpha.4",
|
|
36
35
|
"uuid": "^11.1.0"
|
|
37
36
|
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"react": ">=16.8.0",
|
|
39
|
+
"react-dom": ">=16.8.0"
|
|
40
|
+
},
|
|
38
41
|
"devDependencies": {
|
|
39
42
|
"@rollup/plugin-commonjs": "^28.0.3",
|
|
40
43
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
package/rollup.config.js
CHANGED
|
@@ -4,8 +4,8 @@ import commonjs from '@rollup/plugin-commonjs';
|
|
|
4
4
|
import terser from '@rollup/plugin-terser';
|
|
5
5
|
import dts from 'rollup-plugin-dts';
|
|
6
6
|
|
|
7
|
-
//
|
|
8
|
-
const external = ['react', 'react-dom'];
|
|
7
|
+
// React should be external since it's typically provided by the host application
|
|
8
|
+
const external = ['react', 'react-dom', 'react/jsx-runtime'];
|
|
9
9
|
|
|
10
10
|
// Global variables for UMD build
|
|
11
11
|
const globals = {
|
|
@@ -81,7 +81,7 @@ export default [
|
|
|
81
81
|
declaration: false
|
|
82
82
|
})
|
|
83
83
|
],
|
|
84
|
-
external: [...external, '..']
|
|
84
|
+
external: [...external, '..'] // Externalize React and the main SDK
|
|
85
85
|
},
|
|
86
86
|
|
|
87
87
|
// Type definition bundles - generate these separately
|
package/src/react/index.tsx
CHANGED
|
@@ -8,7 +8,7 @@ const isBrowser = () => typeof window !== 'undefined';
|
|
|
8
8
|
// Define the public interface that components will interact with
|
|
9
9
|
interface HumanBehaviorInterface {
|
|
10
10
|
addEvent: (event: any) => void;
|
|
11
|
-
|
|
11
|
+
identifyUser: ({ userId, userProperties }: { userId?: string, userProperties: Record<string, any> }) => Promise<string>;
|
|
12
12
|
start: () => void;
|
|
13
13
|
stop: () => void;
|
|
14
14
|
logout: () => void;
|
|
@@ -125,7 +125,7 @@ export const HumanBehaviorProvider = ({ apiKey, client, children, options }: Hum
|
|
|
125
125
|
if (event.type === 'identify') {
|
|
126
126
|
logDebug('Processing queued identify event', event);
|
|
127
127
|
try {
|
|
128
|
-
await tracker.
|
|
128
|
+
await tracker.identifyUser({ userId: event.userId, userProperties: event.userProperties });
|
|
129
129
|
} catch (error) {
|
|
130
130
|
logError('Failed to process queued user info:', error);
|
|
131
131
|
}
|
|
@@ -169,7 +169,7 @@ export const HumanBehaviorProvider = ({ apiKey, client, children, options }: Hum
|
|
|
169
169
|
// Default implementation for when tracker is not available
|
|
170
170
|
const defaultImplementation: HumanBehaviorInterface = {
|
|
171
171
|
addEvent: () => {},
|
|
172
|
-
|
|
172
|
+
identifyUser: async ({ userId, userProperties }: { userId?: string, userProperties: Record<string, any> }) => {
|
|
173
173
|
return userId || '';
|
|
174
174
|
},
|
|
175
175
|
start: () => {},
|
|
@@ -183,7 +183,7 @@ const createQueuingImplementation = (queueEvent: (event: any) => void): HumanBeh
|
|
|
183
183
|
addEvent: (event: any) => {
|
|
184
184
|
queueEvent(event);
|
|
185
185
|
},
|
|
186
|
-
|
|
186
|
+
identifyUser: async ({ userId, userProperties }: { userId?: string, userProperties: Record<string, any> }) => {
|
|
187
187
|
queueEvent({
|
|
188
188
|
type: 'identify',
|
|
189
189
|
userId,
|
|
@@ -240,18 +240,18 @@ export const useRedaction = () => {
|
|
|
240
240
|
export const useUserTracking = () => {
|
|
241
241
|
const tracker = useHumanBehavior();
|
|
242
242
|
|
|
243
|
-
const
|
|
243
|
+
const identifyUser = useCallback(async ({ userId, userProperties }: { userId?: string, userProperties: Record<string, any> }) => {
|
|
244
244
|
try {
|
|
245
|
-
await tracker.
|
|
245
|
+
await tracker.identifyUser({ userId, userProperties });
|
|
246
246
|
return { success: true };
|
|
247
247
|
} catch (error) {
|
|
248
|
-
logError('Failed to
|
|
248
|
+
logError('Failed to identify user:', error);
|
|
249
249
|
return { success: false, error };
|
|
250
250
|
}
|
|
251
251
|
}, [tracker]);
|
|
252
252
|
|
|
253
253
|
return {
|
|
254
|
-
|
|
254
|
+
identifyUser
|
|
255
255
|
};
|
|
256
256
|
};
|
|
257
257
|
|
package/src/tracker.ts
CHANGED
|
@@ -724,7 +724,7 @@ export class HumanBehaviorTracker {
|
|
|
724
724
|
* Add user identification information to the tracker
|
|
725
725
|
* If userId is not provided, will use userProperties.email as the userId (if present)
|
|
726
726
|
*/
|
|
727
|
-
public async
|
|
727
|
+
public async identifyUser(
|
|
728
728
|
{ userId, userProperties }: { userId?: string, userProperties: Record<string, any> }
|
|
729
729
|
): Promise<string> {
|
|
730
730
|
await this.ensureInitialized();
|