humanbehavior-js 0.2.2 → 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.
Files changed (22) hide show
  1. package/dist/cjs/index.js +14 -22
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/esm/index.js +14 -22
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/index.min.js +2 -2
  6. package/dist/index.min.js.map +1 -1
  7. package/dist/types/index.d.ts +5 -6
  8. package/package.json +1 -1
  9. package/src/tracker.ts +15 -22
  10. package/.rollup.cache/Users/hudsonch/Desktop/HumanBehaviorInternship/humanbehavior-js/dist/.tsbuildinfo +0 -1
  11. package/.rollup.cache/Users/hudsonch/Desktop/HumanBehaviorInternship/humanbehavior-js/dist/api.js +0 -312
  12. package/.rollup.cache/Users/hudsonch/Desktop/HumanBehaviorInternship/humanbehavior-js/dist/api.js.map +0 -1
  13. package/.rollup.cache/Users/hudsonch/Desktop/HumanBehaviorInternship/humanbehavior-js/dist/index.js +0 -19
  14. package/.rollup.cache/Users/hudsonch/Desktop/HumanBehaviorInternship/humanbehavior-js/dist/index.js.map +0 -1
  15. package/.rollup.cache/Users/hudsonch/Desktop/HumanBehaviorInternship/humanbehavior-js/dist/react/index.js +0 -222
  16. package/.rollup.cache/Users/hudsonch/Desktop/HumanBehaviorInternship/humanbehavior-js/dist/react/index.js.map +0 -1
  17. package/.rollup.cache/Users/hudsonch/Desktop/HumanBehaviorInternship/humanbehavior-js/dist/redact.js +0 -416
  18. package/.rollup.cache/Users/hudsonch/Desktop/HumanBehaviorInternship/humanbehavior-js/dist/redact.js.map +0 -1
  19. package/.rollup.cache/Users/hudsonch/Desktop/HumanBehaviorInternship/humanbehavior-js/dist/tracker.js +0 -950
  20. package/.rollup.cache/Users/hudsonch/Desktop/HumanBehaviorInternship/humanbehavior-js/dist/tracker.js.map +0 -1
  21. package/.rollup.cache/Users/hudsonch/Desktop/HumanBehaviorInternship/humanbehavior-js/dist/utils/logger.js +0 -117
  22. package/.rollup.cache/Users/hudsonch/Desktop/HumanBehaviorInternship/humanbehavior-js/dist/utils/logger.js.map +0 -1
package/dist/esm/index.js CHANGED
@@ -5474,34 +5474,26 @@ class HumanBehaviorTracker {
5474
5474
  logError('Failed to read logs:', e);
5475
5475
  }
5476
5476
  }
5477
- addUserInfo(_a) {
5478
- return __awaiter$1(this, arguments, void 0, function* ({ userId, userProperties }) {
5479
- yield this.ensureInitialized();
5480
- if (!this.endUserId) {
5481
- throw new Error('Cannot add user info before tracker initialization');
5482
- }
5483
- this.userProperties = userProperties;
5484
- yield this.api.sendUserData(this.endUserId, userProperties, this.sessionId);
5485
- if (userId) {
5486
- this.endUserId = userId;
5487
- }
5488
- });
5489
- }
5490
5477
  /**
5491
5478
  * Add user identification information to the tracker
5492
- * @param authFields Array of field names to check for existing users (e.g., ['email', 'phoneNumber'])
5479
+ * If userId is not provided, will use userProperties.email as the userId (if present)
5493
5480
  */
5494
- auth(id) {
5495
- return __awaiter$1(this, void 0, void 0, function* () {
5481
+ addUserInfo(_a) {
5482
+ return __awaiter$1(this, arguments, void 0, function* ({ userId, userProperties }) {
5496
5483
  yield this.ensureInitialized();
5497
- if (!this.endUserId) {
5498
- throw new Error('Cannot authenticate before tracker initialization');
5484
+ // Determine the userId to use
5485
+ const resolvedUserId = userId || userProperties.email;
5486
+ if (!resolvedUserId) {
5487
+ return this.endUserId || '';
5499
5488
  }
5500
- const response = yield this.api.sendUserAuth(this.endUserId, { id }, this.sessionId, ["id"]);
5501
- if (response && response.userId && response.userId !== this.endUserId) {
5502
- this.endUserId = response.userId;
5503
- this.setCookie(`human_behavior_end_user_id_${this.apiKey}`, response.userId, 365);
5489
+ this.userProperties = userProperties;
5490
+ yield this.api.sendUserData(resolvedUserId, userProperties, this.sessionId);
5491
+ // Update endUserId and cookie if changed
5492
+ if (resolvedUserId !== this.endUserId) {
5493
+ this.endUserId = resolvedUserId;
5494
+ this.setCookie(`human_behavior_end_user_id_${this.apiKey}`, resolvedUserId, 365);
5504
5495
  }
5496
+ return this.endUserId || '';
5505
5497
  });
5506
5498
  }
5507
5499
  start() {