humanbehavior-js 0.0.7 → 0.0.8

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/esm/index.js CHANGED
@@ -4073,15 +4073,25 @@ class HumanBehaviorAPI {
4073
4073
  }
4074
4074
  init(sessionId, userId) {
4075
4075
  return __awaiter$1(this, void 0, void 0, function* () {
4076
+ // Get current page URL and referrer if in browser environment
4077
+ let entryURL = null;
4078
+ let referrer = null;
4079
+ if (typeof window !== 'undefined') {
4080
+ entryURL = window.location.href;
4081
+ referrer = document.referrer;
4082
+ }
4076
4083
  const response = yield fetch(`${this.baseUrl}/api/ingestion/init`, {
4077
4084
  method: 'POST',
4078
4085
  headers: {
4079
4086
  'Content-Type': 'application/json',
4080
- 'Authorization': `Bearer ${this.apiKey}`
4087
+ 'Authorization': `Bearer ${this.apiKey}`,
4088
+ 'Referer': referrer || ''
4081
4089
  },
4082
4090
  body: JSON.stringify({
4083
4091
  sessionId: sessionId,
4084
- endUserId: userId
4092
+ endUserId: userId,
4093
+ entryURL: entryURL,
4094
+ referrer: referrer
4085
4095
  })
4086
4096
  });
4087
4097
  if (!response.ok) {
@@ -4784,12 +4794,19 @@ class HumanBehaviorTracker {
4784
4794
  if (!apiKey) {
4785
4795
  throw new Error('Human Behavior API Key is required');
4786
4796
  }
4787
- if (!ingestionUrl) {
4788
- throw new Error('Human Behavior Ingestion URL is required');
4789
- }
4797
+ // ========================================
4798
+ // DEVELOPER: Choose your ingestion server
4799
+ // ========================================
4800
+ // Uncomment ONE of the following lines to select your server:
4801
+ // AWS Development Server
4802
+ const defaultIngestionUrl = 'http://3.137.217.33:3000';
4803
+ // Vercel Production Server
4804
+ // const defaultIngestionUrl = 'https://ingestion-server.vercel.app';
4805
+ // Local Development Server
4806
+ // const defaultIngestionUrl = 'http://localhost:3000';
4790
4807
  this.api = new HumanBehaviorAPI({
4791
4808
  apiKey: apiKey,
4792
- ingestionUrl: ingestionUrl
4809
+ ingestionUrl: ingestionUrl || defaultIngestionUrl
4793
4810
  });
4794
4811
  this.apiKey = apiKey;
4795
4812
  this.redactionManager = new RedactionManager();