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/dist/cjs/index.js +34 -22
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +34 -22
- package/dist/esm/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +33 -21
- package/src/tracker.ts +2 -1
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -41,29 +41,41 @@ export class HumanBehaviorAPI {
|
|
|
41
41
|
referrer = document.referrer;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
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
|
-
|
|
60
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|