humanbehavior-js 0.1.3 → 0.1.5
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 +35 -22
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +35 -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 +13 -1
- package/src/tracker.ts +3 -1
package/dist/cjs/index.js
CHANGED
|
@@ -4201,28 +4201,39 @@ class HumanBehaviorAPI {
|
|
|
4201
4201
|
entryURL = window.location.href;
|
|
4202
4202
|
referrer = document.referrer;
|
|
4203
4203
|
}
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4204
|
+
console.log('API init called with:', { sessionId, userId, entryURL, referrer, baseUrl: this.baseUrl });
|
|
4205
|
+
try {
|
|
4206
|
+
const response = yield fetch(`${this.baseUrl}/api/ingestion/init`, {
|
|
4207
|
+
method: 'POST',
|
|
4208
|
+
headers: {
|
|
4209
|
+
'Content-Type': 'application/json',
|
|
4210
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
4211
|
+
'Referer': referrer || ''
|
|
4212
|
+
},
|
|
4213
|
+
body: JSON.stringify({
|
|
4214
|
+
sessionId: sessionId,
|
|
4215
|
+
endUserId: userId,
|
|
4216
|
+
entryURL: entryURL,
|
|
4217
|
+
referrer: referrer
|
|
4218
|
+
})
|
|
4219
|
+
});
|
|
4220
|
+
console.log('API init response status:', response.status);
|
|
4221
|
+
if (!response.ok) {
|
|
4222
|
+
const errorText = yield response.text();
|
|
4223
|
+
console.error('API init failed:', response.status, errorText);
|
|
4224
|
+
throw new Error(`Failed to initialize ingestion: ${response.statusText} - ${errorText}`);
|
|
4225
|
+
}
|
|
4226
|
+
const responseJson = yield response.json();
|
|
4227
|
+
console.log('API init success:', responseJson);
|
|
4228
|
+
return {
|
|
4229
|
+
sessionId: responseJson.sessionId,
|
|
4230
|
+
endUserId: responseJson.endUserId
|
|
4231
|
+
};
|
|
4232
|
+
}
|
|
4233
|
+
catch (error) {
|
|
4234
|
+
console.error('API init error:', error);
|
|
4235
|
+
throw error;
|
|
4220
4236
|
}
|
|
4221
|
-
const responseJson = yield response.json();
|
|
4222
|
-
return {
|
|
4223
|
-
sessionId: responseJson.sessionId,
|
|
4224
|
-
endUserId: responseJson.endUserId
|
|
4225
|
-
};
|
|
4226
4237
|
});
|
|
4227
4238
|
}
|
|
4228
4239
|
sendEvents(events, sessionId, userId) {
|
|
@@ -4902,7 +4913,9 @@ class HumanBehaviorTracker {
|
|
|
4902
4913
|
throw new Error('Human Behavior API Key is required');
|
|
4903
4914
|
}
|
|
4904
4915
|
// Initialize API
|
|
4905
|
-
const defaultIngestionUrl = 'http://3.137.217.33:3000'; // AWS Development Server
|
|
4916
|
+
//const defaultIngestionUrl = 'http://3.137.217.33:3000'; // AWS Development Server
|
|
4917
|
+
//const defaultIngestionUrl = 'http://ingestion-server-alb-1823866402.us-east-2.elb.amazonaws.com'; // ALB
|
|
4918
|
+
const defaultIngestionUrl = 'https://ingest.humanbehavior.co'; // HTTPS ALB
|
|
4906
4919
|
this.api = new HumanBehaviorAPI({
|
|
4907
4920
|
apiKey: apiKey,
|
|
4908
4921
|
ingestionUrl: ingestionUrl || defaultIngestionUrl
|