humanbehavior-js 0.2.1 → 0.2.3
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 +16 -28
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react/index.js +26 -451
- package/dist/cjs/react/index.js.map +1 -1
- package/dist/esm/index.js +16 -28
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react/index.js +5 -430
- package/dist/esm/react/index.js.map +1 -1
- package/dist/index.min.js +15 -1
- package/dist/index.min.js.map +1 -1
- package/dist/types/index.d.ts +5 -10
- package/dist/types/react/index.d.ts +2 -3
- package/package.json +10 -32
- package/rollup.config.js +106 -0
- package/simple-demo.html +26 -0
- package/simple-spa.html +658 -0
- package/src/index.ts +2 -2
- package/src/tracker.ts +15 -22
- package/tsconfig.json +24 -0
- package/dist/.tsbuildinfo +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -3234,17 +3234,13 @@ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector, mir
|
|
|
3234
3234
|
};
|
|
3235
3235
|
}
|
|
3236
3236
|
|
|
3237
|
-
function commonjsRequire(path) {
|
|
3238
|
-
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
3239
|
-
}
|
|
3240
|
-
|
|
3241
3237
|
var WorkerClass = null;
|
|
3242
3238
|
|
|
3243
3239
|
try {
|
|
3244
3240
|
var WorkerThreads =
|
|
3245
|
-
typeof module !== 'undefined' && typeof
|
|
3241
|
+
typeof module !== 'undefined' && typeof module.require === 'function' && module.require('worker_threads') ||
|
|
3246
3242
|
typeof __non_webpack_require__ === 'function' && __non_webpack_require__('worker_threads') ||
|
|
3247
|
-
typeof
|
|
3243
|
+
typeof require === 'function' && require('worker_threads');
|
|
3248
3244
|
WorkerClass = WorkerThreads.Worker;
|
|
3249
3245
|
} catch(e) {} // eslint-disable-line
|
|
3250
3246
|
|
|
@@ -5482,34 +5478,26 @@ class HumanBehaviorTracker {
|
|
|
5482
5478
|
logError('Failed to read logs:', e);
|
|
5483
5479
|
}
|
|
5484
5480
|
}
|
|
5485
|
-
addUserInfo(_a) {
|
|
5486
|
-
return __awaiter$1(this, arguments, void 0, function* ({ userId, userProperties }) {
|
|
5487
|
-
yield this.ensureInitialized();
|
|
5488
|
-
if (!this.endUserId) {
|
|
5489
|
-
throw new Error('Cannot add user info before tracker initialization');
|
|
5490
|
-
}
|
|
5491
|
-
this.userProperties = userProperties;
|
|
5492
|
-
yield this.api.sendUserData(this.endUserId, userProperties, this.sessionId);
|
|
5493
|
-
if (userId) {
|
|
5494
|
-
this.endUserId = userId;
|
|
5495
|
-
}
|
|
5496
|
-
});
|
|
5497
|
-
}
|
|
5498
5481
|
/**
|
|
5499
5482
|
* Add user identification information to the tracker
|
|
5500
|
-
*
|
|
5483
|
+
* If userId is not provided, will use userProperties.email as the userId (if present)
|
|
5501
5484
|
*/
|
|
5502
|
-
|
|
5503
|
-
return __awaiter$1(this,
|
|
5485
|
+
addUserInfo(_a) {
|
|
5486
|
+
return __awaiter$1(this, arguments, void 0, function* ({ userId, userProperties }) {
|
|
5504
5487
|
yield this.ensureInitialized();
|
|
5505
|
-
|
|
5506
|
-
|
|
5488
|
+
// Determine the userId to use
|
|
5489
|
+
const resolvedUserId = userId || userProperties.email;
|
|
5490
|
+
if (!resolvedUserId) {
|
|
5491
|
+
return this.endUserId || '';
|
|
5507
5492
|
}
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5493
|
+
this.userProperties = userProperties;
|
|
5494
|
+
yield this.api.sendUserData(resolvedUserId, userProperties, this.sessionId);
|
|
5495
|
+
// Update endUserId and cookie if changed
|
|
5496
|
+
if (resolvedUserId !== this.endUserId) {
|
|
5497
|
+
this.endUserId = resolvedUserId;
|
|
5498
|
+
this.setCookie(`human_behavior_end_user_id_${this.apiKey}`, resolvedUserId, 365);
|
|
5512
5499
|
}
|
|
5500
|
+
return this.endUserId || '';
|
|
5513
5501
|
});
|
|
5514
5502
|
}
|
|
5515
5503
|
start() {
|