humanbehavior-js 0.1.3 → 0.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "humanbehavior-js",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "SDK for HumanBehavior session and event recording",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
package/src/api.ts CHANGED
@@ -41,29 +41,41 @@ export class HumanBehaviorAPI {
41
41
  referrer = document.referrer;
42
42
  }
43
43
 
44
- const response = await fetch(`${this.baseUrl}/api/ingestion/init`, {
45
- method: 'POST',
46
- headers: {
47
- 'Content-Type': 'application/json',
48
- 'Authorization': `Bearer ${this.apiKey}`,
49
- 'Referer': referrer || ''
50
- },
51
- body: JSON.stringify({
52
- sessionId: sessionId,
53
- endUserId: userId,
54
- entryURL: entryURL,
55
- referrer: referrer
56
- })
57
- });
44
+ console.log('API init called with:', { sessionId, userId, entryURL, referrer, baseUrl: this.baseUrl });
58
45
 
59
- if (!response.ok) {
60
- throw new Error(`Failed to initialize ingestion: ${response.statusText}`);
61
- }
46
+ try {
47
+ const response = await fetch(`${this.baseUrl}/api/ingestion/init`, {
48
+ method: 'POST',
49
+ headers: {
50
+ 'Content-Type': 'application/json',
51
+ 'Authorization': `Bearer ${this.apiKey}`,
52
+ 'Referer': referrer || ''
53
+ },
54
+ body: JSON.stringify({
55
+ sessionId: sessionId,
56
+ endUserId: userId,
57
+ entryURL: entryURL,
58
+ referrer: referrer
59
+ })
60
+ });
61
+
62
+ console.log('API init response status:', response.status);
62
63
 
63
- const responseJson = await response.json();
64
- return {
65
- sessionId: responseJson.sessionId,
66
- endUserId: responseJson.endUserId
64
+ if (!response.ok) {
65
+ const errorText = await response.text();
66
+ console.error('API init failed:', response.status, errorText);
67
+ throw new Error(`Failed to initialize ingestion: ${response.statusText} - ${errorText}`);
68
+ }
69
+
70
+ const responseJson = await response.json();
71
+ console.log('API init success:', responseJson);
72
+ return {
73
+ sessionId: responseJson.sessionId,
74
+ endUserId: responseJson.endUserId
75
+ }
76
+ } catch (error) {
77
+ console.error('API init error:', error);
78
+ throw error;
67
79
  }
68
80
  }
69
81
 
package/src/tracker.ts CHANGED
@@ -114,7 +114,8 @@ export class HumanBehaviorTracker {
114
114
  }
115
115
 
116
116
  // Initialize API
117
- const defaultIngestionUrl = 'http://3.137.217.33:3000'; // AWS Development Server
117
+ //const defaultIngestionUrl = 'http://3.137.217.33:3000'; // AWS Development Server
118
+ const defaultIngestionUrl = 'http://ingestion-server-alb-1823866402.us-east-2.elb.amazonaws.com'; // ALB
118
119
  this.api = new HumanBehaviorAPI({
119
120
  apiKey: apiKey,
120
121
  ingestionUrl: ingestionUrl || defaultIngestionUrl