humanbehavior-js 0.4.6 → 0.4.8

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 (58) hide show
  1. package/dist/cjs/angular/index.cjs +52 -7
  2. package/dist/cjs/angular/index.cjs.map +1 -1
  3. package/dist/cjs/index.cjs +52 -7
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/install-wizard.cjs +4 -2
  6. package/dist/cjs/install-wizard.cjs.map +1 -1
  7. package/dist/cjs/react/index.cjs +52 -7
  8. package/dist/cjs/react/index.cjs.map +1 -1
  9. package/dist/cjs/remix/index.cjs +52 -7
  10. package/dist/cjs/remix/index.cjs.map +1 -1
  11. package/dist/cjs/svelte/index.cjs +52 -7
  12. package/dist/cjs/svelte/index.cjs.map +1 -1
  13. package/dist/cjs/vue/index.cjs +52 -7
  14. package/dist/cjs/vue/index.cjs.map +1 -1
  15. package/dist/cjs/wizard/index.cjs +3208 -0
  16. package/dist/cjs/wizard/index.cjs.map +1 -0
  17. package/dist/cli/ai-auto-install.js +2024 -0
  18. package/dist/cli/ai-auto-install.js.map +1 -0
  19. package/dist/cli/auto-install.js +4 -2
  20. package/dist/cli/auto-install.js.map +1 -1
  21. package/dist/esm/angular/index.js +52 -7
  22. package/dist/esm/angular/index.js.map +1 -1
  23. package/dist/esm/index.js +52 -7
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/install-wizard.js +4 -2
  26. package/dist/esm/install-wizard.js.map +1 -1
  27. package/dist/esm/react/index.js +52 -7
  28. package/dist/esm/react/index.js.map +1 -1
  29. package/dist/esm/remix/index.js +52 -7
  30. package/dist/esm/remix/index.js.map +1 -1
  31. package/dist/esm/svelte/index.js +52 -7
  32. package/dist/esm/svelte/index.js.map +1 -1
  33. package/dist/esm/vue/index.js +52 -7
  34. package/dist/esm/vue/index.js.map +1 -1
  35. package/dist/esm/wizard/index.js +3178 -0
  36. package/dist/esm/wizard/index.js.map +1 -0
  37. package/dist/index.min.js +1 -1
  38. package/dist/index.min.js.map +1 -1
  39. package/dist/types/angular/index.d.ts +7 -0
  40. package/dist/types/index.d.ts +7 -0
  41. package/dist/types/install-wizard.d.ts +8 -8
  42. package/dist/types/react/index.d.ts +7 -0
  43. package/dist/types/remix/index.d.ts +7 -0
  44. package/dist/types/svelte/index.d.ts +7 -0
  45. package/dist/types/wizard/index.d.ts +489 -0
  46. package/package.json +14 -8
  47. package/rollup.config.js +65 -3
  48. package/src/react/AutoInstallWizard.tsx +1 -1
  49. package/src/tracker.ts +59 -8
  50. package/src/wizard/README.md +114 -0
  51. package/src/wizard/ai/ai-install-wizard.ts +894 -0
  52. package/src/wizard/ai/manual-framework-wizard.ts +236 -0
  53. package/src/wizard/cli/ai-auto-install.ts +369 -0
  54. package/src/{cli → wizard/cli}/auto-install.ts +1 -1
  55. package/src/{install-wizard.ts → wizard/core/install-wizard.ts} +12 -10
  56. package/src/wizard/index.ts +23 -0
  57. package/src/wizard/services/centralized-ai-service.ts +668 -0
  58. package/src/wizard/services/remote-ai-service.ts +224 -0
@@ -13226,6 +13226,8 @@ class HumanBehaviorTracker {
13226
13226
  this._connectionBlocked = false;
13227
13227
  this.recordInstance = null;
13228
13228
  this.sessionStartTime = Date.now();
13229
+ this.rrwebRecord = null;
13230
+ this.fullSnapshotTimeout = null;
13229
13231
  if (!apiKey) {
13230
13232
  throw new Error('Human Behavior API Key is required');
13231
13233
  }
@@ -13333,6 +13335,8 @@ class HumanBehaviorTracker {
13333
13335
  this.originalPushState.apply(history, args);
13334
13336
  // Track navigation event
13335
13337
  this.trackNavigationEvent('pushState', this.previousUrl, this.currentUrl);
13338
+ // Take FullSnapshot on navigation
13339
+ this.takeFullSnapshot();
13336
13340
  };
13337
13341
  // Override replaceState to capture programmatic navigation
13338
13342
  history.replaceState = (...args) => {
@@ -13342,12 +13346,16 @@ class HumanBehaviorTracker {
13342
13346
  this.originalReplaceState.apply(history, args);
13343
13347
  // Track navigation event
13344
13348
  this.trackNavigationEvent('replaceState', this.previousUrl, this.currentUrl);
13349
+ // Take FullSnapshot on navigation
13350
+ this.takeFullSnapshot();
13345
13351
  };
13346
13352
  // Listen for popstate events (back/forward navigation)
13347
13353
  const popstateListener = () => {
13348
13354
  this.previousUrl = this.currentUrl;
13349
13355
  this.currentUrl = window.location.href;
13350
13356
  this.trackNavigationEvent('popstate', this.previousUrl, this.currentUrl);
13357
+ // Take FullSnapshot on navigation
13358
+ this.takeFullSnapshot();
13351
13359
  };
13352
13360
  window.addEventListener('popstate', popstateListener);
13353
13361
  this.navigationListeners.push(() => {
@@ -13775,13 +13783,14 @@ class HumanBehaviorTracker {
13775
13783
  this.flushInterval = window.setInterval(() => {
13776
13784
  this.flush();
13777
13785
  }, this.FLUSH_INTERVAL_MS);
13778
- // Enable console tracking
13779
- this.enableConsoleTracking();
13786
+ // Disable console tracking to reduce event pollution
13787
+ // this.enableConsoleTracking();
13780
13788
  // ✅ DOM READY DETECTION
13781
13789
  // Wait for DOM to be ready before starting recording
13782
13790
  const startRecording = () => {
13783
13791
  logDebug('🎯 DOM ready, starting session recording');
13784
13792
  // ✅ HUMANBEHAVIOR RRWEB CONFIGURATION
13793
+ this.rrwebRecord = record;
13785
13794
  const recordInstance = record({
13786
13795
  emit: (event) => {
13787
13796
  // ✅ DIRECT EVENT HANDLING - Let rrweb handle events natively
@@ -13803,12 +13812,11 @@ class HumanBehaviorTracker {
13803
13812
  recordCrossOriginIframes: false, // HumanBehavior default
13804
13813
  // ✅ CANVAS RECORDING - Disabled to prevent large data URIs
13805
13814
  recordCanvas: false, // Disabled to prevent large data URIs
13806
- // ✅ FULLSNAPSHOT GENERATION - Use reasonable intervals
13807
- // checkoutEveryNms: 300000, // Take FullSnapshot every 5 minutes
13808
- // checkoutEveryNth: 1000, // Take FullSnapshot every 1000 events
13815
+ // ✅ FULLSNAPSHOT GENERATION - No periodic snapshots to avoid animation issues
13816
+ // Rely on initial FullSnapshot + navigation-triggered ones only
13809
13817
  });
13810
- // Store the record instance for cleanup
13811
- this.recordInstance = recordInstance;
13818
+ // Store the record instance for cleanup
13819
+ this.recordInstance = recordInstance || null;
13812
13820
  };
13813
13821
  // ✅ DOM READY DETECTION
13814
13822
  logDebug(`🎯 DOM ready state: ${document.readyState}`);
@@ -13827,6 +13835,37 @@ class HumanBehaviorTracker {
13827
13835
  }
13828
13836
  });
13829
13837
  }
13838
+ /**
13839
+ * Manually trigger a FullSnapshot (for navigation events)
13840
+ * Delays snapshot to avoid capturing mid-animation states
13841
+ */
13842
+ takeFullSnapshot() {
13843
+ // Clear any existing timeout to avoid multiple snapshots
13844
+ if (this.fullSnapshotTimeout) {
13845
+ clearTimeout(this.fullSnapshotTimeout);
13846
+ }
13847
+ // Delay FullSnapshot to let animations settle
13848
+ this.fullSnapshotTimeout = window.setTimeout(() => {
13849
+ try {
13850
+ // Wait for any pending animations/transitions to complete
13851
+ requestAnimationFrame(() => {
13852
+ requestAnimationFrame(() => {
13853
+ // Access takeFullSnapshot from the rrweb record function
13854
+ if (this.rrwebRecord && typeof this.rrwebRecord.takeFullSnapshot === 'function') {
13855
+ this.rrwebRecord.takeFullSnapshot();
13856
+ logDebug('✅ FullSnapshot taken for navigation (delayed for animations)');
13857
+ }
13858
+ else {
13859
+ logWarn('⚠️ takeFullSnapshot not available on record function');
13860
+ }
13861
+ });
13862
+ });
13863
+ }
13864
+ catch (error) {
13865
+ logError('❌ Failed to take FullSnapshot for navigation:', error);
13866
+ }
13867
+ }, 1000); // Wait 1 second for animations to settle
13868
+ }
13830
13869
  stop() {
13831
13870
  return __awaiter(this, void 0, void 0, function* () {
13832
13871
  yield this.ensureInitialized();
@@ -13841,6 +13880,12 @@ class HumanBehaviorTracker {
13841
13880
  this.recordInstance();
13842
13881
  this.recordInstance = null;
13843
13882
  }
13883
+ // Clear any pending FullSnapshot timeouts
13884
+ if (this.fullSnapshotTimeout) {
13885
+ clearTimeout(this.fullSnapshotTimeout);
13886
+ this.fullSnapshotTimeout = null;
13887
+ }
13888
+ this.rrwebRecord = null;
13844
13889
  // Disable console tracking
13845
13890
  this.disableConsoleTracking();
13846
13891
  // Cleanup navigation tracking