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