humanbehavior-js 0.1.5 → 0.1.7
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 +12 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react/index.js +1 -1
- package/dist/cjs/react/index.js.map +1 -1
- package/dist/esm/index.js +12 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react/index.js +1 -1
- package/dist/esm/react/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 -1
- package/package.json +1 -1
- package/src/api.ts +14 -6
- package/src/react/index.tsx +1 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -275,7 +275,7 @@ declare class HumanBehaviorAPI {
|
|
|
275
275
|
sendEventsChunked(events: any[], sessionId: string): Promise<any[]>;
|
|
276
276
|
sendUserData(userId: string, userData: Record<string, any>, sessionId: string): Promise<any>;
|
|
277
277
|
sendUserAuth(userId: string, userData: Record<string, any>, sessionId: string, authFields: string[]): Promise<any>;
|
|
278
|
-
sendBeaconEvents(events: any[], sessionId: string):
|
|
278
|
+
sendBeaconEvents(events: any[], sessionId: string): boolean;
|
|
279
279
|
sendCustomEvent(sessionId: string, eventName: string, eventProperties?: Record<string, any>): Promise<any>;
|
|
280
280
|
sendCustomEventBatch(sessionId: string, events: Array<{
|
|
281
281
|
eventName: string;
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -220,16 +220,24 @@ export class HumanBehaviorAPI {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
public sendBeaconEvents(events: any[], sessionId: string) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
223
|
+
// Create JSON payload that matches the server's expected format
|
|
224
|
+
const payload = {
|
|
225
|
+
sessionId: sessionId,
|
|
226
|
+
events: events,
|
|
227
|
+
endUserId: null // Beacon doesn't have user context
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
// Convert to Blob for sendBeacon
|
|
231
|
+
const blob = new Blob([JSON.stringify(payload)], {
|
|
232
|
+
type: 'application/json'
|
|
233
|
+
});
|
|
228
234
|
|
|
229
235
|
const success = navigator.sendBeacon(
|
|
230
236
|
`${this.baseUrl}/api/ingestion/events`,
|
|
231
|
-
|
|
237
|
+
blob
|
|
232
238
|
);
|
|
239
|
+
|
|
240
|
+
return success;
|
|
233
241
|
}
|
|
234
242
|
|
|
235
243
|
async sendCustomEvent(sessionId: string, eventName: string, eventProperties?: Record<string, any>) {
|
package/src/react/index.tsx
CHANGED
|
@@ -108,7 +108,7 @@ export const HumanBehaviorProvider = ({ apiKey, client, children, options }: Hum
|
|
|
108
108
|
// Create new tracker instance with the validated apiKey
|
|
109
109
|
const tracker = new HumanBehaviorTracker(
|
|
110
110
|
apiKeyRef.current.trim(),
|
|
111
|
-
|
|
111
|
+
'https://ingest.humanbehavior.co'
|
|
112
112
|
);
|
|
113
113
|
setHumanBehavior(tracker);
|
|
114
114
|
|