humanbehavior-js 0.0.3 → 0.0.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/esm/index.js CHANGED
@@ -4098,7 +4098,6 @@ function v1Bytes(rnds, msecs, nsecs, clockseq, node, buf, offset = 0) {
4098
4098
  return buf;
4099
4099
  }
4100
4100
 
4101
- var INGESTION_URL = process.env.HUMAN_BEHAVIOR_INGESTION_URL; // for development
4102
4101
  var MAX_CHUNK_SIZE_BYTES = 1024 * 1024 * 10; // 10MB chunk size
4103
4102
  function isChunkSizeExceeded(currentChunk, newEvent, sessionId) {
4104
4103
  var nextChunkSize = new TextEncoder().encode(JSON.stringify({
@@ -4118,12 +4117,9 @@ function validateSingleEventSize(event, sessionId) {
4118
4117
  }
4119
4118
  var HumanBehaviorAPI = /** @class */ (function () {
4120
4119
  function HumanBehaviorAPI(_a) {
4121
- var apiKey = _a.apiKey;
4120
+ var apiKey = _a.apiKey, ingestionUrl = _a.ingestionUrl;
4122
4121
  this.apiKey = apiKey;
4123
- if (!INGESTION_URL) {
4124
- throw new Error('HUMAN_BEHAVIOR_INGESTION_URL is not set');
4125
- }
4126
- this.baseUrl = INGESTION_URL;
4122
+ this.baseUrl = ingestionUrl;
4127
4123
  }
4128
4124
  HumanBehaviorAPI.prototype.init = function (sessionId, userId) {
4129
4125
  return __awaiter$1(this, void 0, void 0, function () {
@@ -4475,7 +4471,7 @@ var HumanBehaviorAPI = /** @class */ (function () {
4475
4471
  // Check if we're in a browser environment
4476
4472
  var isBrowser = typeof window !== 'undefined';
4477
4473
  var HumanBehaviorTracker = /** @class */ (function () {
4478
- function HumanBehaviorTracker(apiKey) {
4474
+ function HumanBehaviorTracker(apiKey, ingestionUrl) {
4479
4475
  this.eventIngestionQueue = [];
4480
4476
  this.queueSizeBytes = 0;
4481
4477
  this.rejectedEvents = [];
@@ -4488,10 +4484,14 @@ var HumanBehaviorTracker = /** @class */ (function () {
4488
4484
  this.initialized = false;
4489
4485
  this.initializationPromise = null;
4490
4486
  if (!apiKey) {
4491
- throw new Error('Human Behavior apiKey is required');
4487
+ throw new Error('Human Behavior API Key is required');
4488
+ }
4489
+ if (!ingestionUrl) {
4490
+ throw new Error('Human Behavior Ingestion URL is required');
4492
4491
  }
4493
4492
  this.api = new HumanBehaviorAPI({
4494
4493
  apiKey: apiKey,
4494
+ ingestionUrl: ingestionUrl
4495
4495
  });
4496
4496
  this.apiKey = apiKey;
4497
4497
  // Check for existing session ID and last activity time in localStorage