humanbehavior-js 0.0.4 → 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/cjs/index.js +8 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +8 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/types/index.d.ts +3 -2
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -4102,7 +4102,6 @@ function v1Bytes(rnds, msecs, nsecs, clockseq, node, buf, offset = 0) {
|
|
|
4102
4102
|
return buf;
|
|
4103
4103
|
}
|
|
4104
4104
|
|
|
4105
|
-
var INGESTION_URL = process.env.HUMAN_BEHAVIOR_INGESTION_URL; // for development
|
|
4106
4105
|
var MAX_CHUNK_SIZE_BYTES = 1024 * 1024 * 10; // 10MB chunk size
|
|
4107
4106
|
function isChunkSizeExceeded(currentChunk, newEvent, sessionId) {
|
|
4108
4107
|
var nextChunkSize = new TextEncoder().encode(JSON.stringify({
|
|
@@ -4122,12 +4121,9 @@ function validateSingleEventSize(event, sessionId) {
|
|
|
4122
4121
|
}
|
|
4123
4122
|
var HumanBehaviorAPI = /** @class */ (function () {
|
|
4124
4123
|
function HumanBehaviorAPI(_a) {
|
|
4125
|
-
var apiKey = _a.apiKey;
|
|
4124
|
+
var apiKey = _a.apiKey, ingestionUrl = _a.ingestionUrl;
|
|
4126
4125
|
this.apiKey = apiKey;
|
|
4127
|
-
|
|
4128
|
-
throw new Error('HUMAN_BEHAVIOR_INGESTION_URL is not set');
|
|
4129
|
-
}
|
|
4130
|
-
this.baseUrl = INGESTION_URL;
|
|
4126
|
+
this.baseUrl = ingestionUrl;
|
|
4131
4127
|
}
|
|
4132
4128
|
HumanBehaviorAPI.prototype.init = function (sessionId, userId) {
|
|
4133
4129
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
@@ -4479,7 +4475,7 @@ var HumanBehaviorAPI = /** @class */ (function () {
|
|
|
4479
4475
|
// Check if we're in a browser environment
|
|
4480
4476
|
var isBrowser = typeof window !== 'undefined';
|
|
4481
4477
|
var HumanBehaviorTracker = /** @class */ (function () {
|
|
4482
|
-
function HumanBehaviorTracker(apiKey) {
|
|
4478
|
+
function HumanBehaviorTracker(apiKey, ingestionUrl) {
|
|
4483
4479
|
this.eventIngestionQueue = [];
|
|
4484
4480
|
this.queueSizeBytes = 0;
|
|
4485
4481
|
this.rejectedEvents = [];
|
|
@@ -4492,10 +4488,14 @@ var HumanBehaviorTracker = /** @class */ (function () {
|
|
|
4492
4488
|
this.initialized = false;
|
|
4493
4489
|
this.initializationPromise = null;
|
|
4494
4490
|
if (!apiKey) {
|
|
4495
|
-
throw new Error('Human Behavior
|
|
4491
|
+
throw new Error('Human Behavior API Key is required');
|
|
4492
|
+
}
|
|
4493
|
+
if (!ingestionUrl) {
|
|
4494
|
+
throw new Error('Human Behavior Ingestion URL is required');
|
|
4496
4495
|
}
|
|
4497
4496
|
this.api = new HumanBehaviorAPI({
|
|
4498
4497
|
apiKey: apiKey,
|
|
4498
|
+
ingestionUrl: ingestionUrl
|
|
4499
4499
|
});
|
|
4500
4500
|
this.apiKey = apiKey;
|
|
4501
4501
|
// Check for existing session ID and last activity time in localStorage
|