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/cjs/index.js CHANGED
@@ -5478,34 +5478,26 @@ class HumanBehaviorTracker {
5478
5478
  logError('Failed to read logs:', e);
5479
5479
  }
5480
5480
  }
5481
- addUserInfo(_a) {
5482
- return __awaiter$1(this, arguments, void 0, function* ({ userId, userProperties }) {
5483
- yield this.ensureInitialized();
5484
- if (!this.endUserId) {
5485
- throw new Error('Cannot add user info before tracker initialization');
5486
- }
5487
- this.userProperties = userProperties;
5488
- yield this.api.sendUserData(this.endUserId, userProperties, this.sessionId);
5489
- if (userId) {
5490
- this.endUserId = userId;
5491
- }
5492
- });
5493
- }
5494
5481
  /**
5495
5482
  * Add user identification information to the tracker
5496
- * @param authFields Array of field names to check for existing users (e.g., ['email', 'phoneNumber'])
5483
+ * If userId is not provided, will use userProperties.email as the userId (if present)
5497
5484
  */
5498
- auth(id) {
5499
- return __awaiter$1(this, void 0, void 0, function* () {
5485
+ addUserInfo(_a) {
5486
+ return __awaiter$1(this, arguments, void 0, function* ({ userId, userProperties }) {
5500
5487
  yield this.ensureInitialized();
5501
- if (!this.endUserId) {
5502
- throw new Error('Cannot authenticate before tracker initialization');
5488
+ // Determine the userId to use
5489
+ const resolvedUserId = userId || userProperties.email;
5490
+ if (!resolvedUserId) {
5491
+ return this.endUserId || '';
5503
5492
  }
5504
- const response = yield this.api.sendUserAuth(this.endUserId, { id }, this.sessionId, ["id"]);
5505
- if (response && response.userId && response.userId !== this.endUserId) {
5506
- this.endUserId = response.userId;
5507
- this.setCookie(`human_behavior_end_user_id_${this.apiKey}`, response.userId, 365);
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);
5508
5499
  }
5500
+ return this.endUserId || '';
5509
5501
  });
5510
5502
  }
5511
5503
  start() {