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 CHANGED
@@ -4201,28 +4201,39 @@ class HumanBehaviorAPI {
4201
4201
  entryURL = window.location.href;
4202
4202
  referrer = document.referrer;
4203
4203
  }
4204
- const response = yield fetch(`${this.baseUrl}/api/ingestion/init`, {
4205
- method: 'POST',
4206
- headers: {
4207
- 'Content-Type': 'application/json',
4208
- 'Authorization': `Bearer ${this.apiKey}`,
4209
- 'Referer': referrer || ''
4210
- },
4211
- body: JSON.stringify({
4212
- sessionId: sessionId,
4213
- endUserId: userId,
4214
- entryURL: entryURL,
4215
- referrer: referrer
4216
- })
4217
- });
4218
- if (!response.ok) {
4219
- throw new Error(`Failed to initialize ingestion: ${response.statusText}`);
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