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/dist/esm/index.js
CHANGED
|
@@ -4197,28 +4197,39 @@ class HumanBehaviorAPI {
|
|
|
4197
4197
|
entryURL = window.location.href;
|
|
4198
4198
|
referrer = document.referrer;
|
|
4199
4199
|
}
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4200
|
+
console.log('API init called with:', { sessionId, userId, entryURL, referrer, baseUrl: this.baseUrl });
|
|
4201
|
+
try {
|
|
4202
|
+
const response = yield fetch(`${this.baseUrl}/api/ingestion/init`, {
|
|
4203
|
+
method: 'POST',
|
|
4204
|
+
headers: {
|
|
4205
|
+
'Content-Type': 'application/json',
|
|
4206
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
4207
|
+
'Referer': referrer || ''
|
|
4208
|
+
},
|
|
4209
|
+
body: JSON.stringify({
|
|
4210
|
+
sessionId: sessionId,
|
|
4211
|
+
endUserId: userId,
|
|
4212
|
+
entryURL: entryURL,
|
|
4213
|
+
referrer: referrer
|
|
4214
|
+
})
|
|
4215
|
+
});
|
|
4216
|
+
console.log('API init response status:', response.status);
|
|
4217
|
+
if (!response.ok) {
|
|
4218
|
+
const errorText = yield response.text();
|
|
4219
|
+
console.error('API init failed:', response.status, errorText);
|
|
4220
|
+
throw new Error(`Failed to initialize ingestion: ${response.statusText} - ${errorText}`);
|
|
4221
|
+
}
|
|
4222
|
+
const responseJson = yield response.json();
|
|
4223
|
+
console.log('API init success:', responseJson);
|
|
4224
|
+
return {
|
|
4225
|
+
sessionId: responseJson.sessionId,
|
|
4226
|
+
endUserId: responseJson.endUserId
|
|
4227
|
+
};
|
|
4228
|
+
}
|
|
4229
|
+
catch (error) {
|
|
4230
|
+
console.error('API init error:', error);
|
|
4231
|
+
throw error;
|
|
4216
4232
|
}
|
|
4217
|
-
const responseJson = yield response.json();
|
|
4218
|
-
return {
|
|
4219
|
-
sessionId: responseJson.sessionId,
|
|
4220
|
-
endUserId: responseJson.endUserId
|
|
4221
|
-
};
|
|
4222
4233
|
});
|
|
4223
4234
|
}
|
|
4224
4235
|
sendEvents(events, sessionId, userId) {
|
|
@@ -4898,7 +4909,8 @@ class HumanBehaviorTracker {
|
|
|
4898
4909
|
throw new Error('Human Behavior API Key is required');
|
|
4899
4910
|
}
|
|
4900
4911
|
// Initialize API
|
|
4901
|
-
const defaultIngestionUrl = 'http://3.137.217.33:3000'; // AWS Development Server
|
|
4912
|
+
//const defaultIngestionUrl = 'http://3.137.217.33:3000'; // AWS Development Server
|
|
4913
|
+
const defaultIngestionUrl = 'http://ingestion-server-alb-1823866402.us-east-2.elb.amazonaws.com'; // ALB
|
|
4902
4914
|
this.api = new HumanBehaviorAPI({
|
|
4903
4915
|
apiKey: apiKey,
|
|
4904
4916
|
ingestionUrl: ingestionUrl || defaultIngestionUrl
|