@checkflow/sdk 1.0.2 → 1.0.4

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/index.esm.js CHANGED
@@ -2704,6 +2704,10 @@ class SessionRecording {
2704
2704
  start() {
2705
2705
  if (this.isRecording || !this.config.enabled)
2706
2706
  return;
2707
+ console.log(' [SessionRecording] Starting session recording...', {
2708
+ sessionId: this.sessionId,
2709
+ config: this.config
2710
+ });
2707
2711
  this.isRecording = true;
2708
2712
  this.startTime = Date.now();
2709
2713
  this.events = [];
@@ -2712,20 +2716,25 @@ class SessionRecording {
2712
2716
  // Setup event listeners
2713
2717
  if (this.config.recordMouse) {
2714
2718
  this.setupMouseTracking();
2719
+ console.log(' [SessionRecording] Mouse tracking enabled');
2715
2720
  }
2716
2721
  if (this.config.recordScroll) {
2717
2722
  this.setupScrollTracking();
2723
+ console.log(' [SessionRecording] Scroll tracking enabled');
2718
2724
  }
2719
2725
  if (this.config.recordInput) {
2720
2726
  this.setupInputTracking();
2727
+ console.log(' [SessionRecording] Input tracking enabled');
2721
2728
  }
2722
2729
  if (this.config.recordMutations) {
2723
2730
  this.setupMutationObserver();
2731
+ console.log(' [SessionRecording] Mutation observer enabled');
2724
2732
  }
2725
2733
  // Track navigation
2726
2734
  this.setupNavigationTracking();
2727
2735
  // Track resize
2728
2736
  this.setupResizeTracking();
2737
+ console.log(' [SessionRecording] Session recording started successfully');
2729
2738
  // Auto-stop after max duration
2730
2739
  setTimeout(() => {
2731
2740
  if (this.isRecording) {
@@ -2781,13 +2790,29 @@ class SessionRecording {
2781
2790
  * Get recording data for submission
2782
2791
  */
2783
2792
  getRecordingData() {
2784
- if (this.events.length === 0)
2793
+ console.log('🎥 [SessionRecording] getRecordingData called:', {
2794
+ eventCount: this.events.length,
2795
+ sessionId: this.sessionId,
2796
+ duration: this.getDuration(),
2797
+ isRecording: this.isRecording,
2798
+ startTime: this.startTime
2799
+ });
2800
+ if (this.events.length === 0) {
2801
+ console.warn('🎥 [SessionRecording] No events to return');
2785
2802
  return null;
2786
- return {
2803
+ }
2804
+ const data = {
2787
2805
  events: [...this.events],
2788
2806
  sessionId: this.sessionId,
2789
2807
  duration: this.getDuration(),
2790
2808
  };
2809
+ console.log('🎥 [SessionRecording] Returning recording data:', {
2810
+ eventCount: data.events.length,
2811
+ duration: data.duration,
2812
+ firstEventType: data.events[0]?.type,
2813
+ lastEventType: data.events[data.events.length - 1]?.type
2814
+ });
2815
+ return data;
2791
2816
  }
2792
2817
  addEvent(type, data) {
2793
2818
  // Sample rate filtering
@@ -3624,29 +3649,51 @@ class AnalyticsTracker {
3624
3649
  async saveSessionRecording() {
3625
3650
  // Get session recording from global CheckFlow instance if available
3626
3651
  try {
3652
+ console.log('🎬 [AnalyticsTracker] Starting saveSessionRecording for session:', this.sessionId);
3627
3653
  const checkflowInstance = window.checkflow;
3654
+ console.log('🎬 [AnalyticsTracker] CheckFlow instance found:', !!checkflowInstance);
3655
+ console.log('🎬 [AnalyticsTracker] SessionRecording instance found:', !!checkflowInstance?.sessionRecording);
3628
3656
  if (!checkflowInstance || !checkflowInstance.sessionRecording) {
3657
+ console.warn('🎬 [AnalyticsTracker] No session recording available - instance missing');
3629
3658
  this.log('No session recording available');
3630
3659
  return;
3631
3660
  }
3632
3661
  const recordingData = checkflowInstance.sessionRecording.getRecordingData();
3662
+ console.log('🎬 [AnalyticsTracker] Recording data retrieved:', {
3663
+ hasData: !!recordingData,
3664
+ eventCount: recordingData?.events?.length || 0,
3665
+ duration: recordingData?.duration || 0,
3666
+ sessionId: recordingData?.sessionId
3667
+ });
3633
3668
  if (!recordingData || recordingData.events.length === 0) {
3669
+ console.warn('🎬 [AnalyticsTracker] No recording events to save - events array empty');
3634
3670
  this.log('No recording events to save');
3635
3671
  return;
3636
3672
  }
3637
3673
  // Save recording to analytics backend
3638
- await this.apiClient.saveSessionRecording({
3674
+ console.log('🎬 [AnalyticsTracker] Saving recording to backend...', {
3675
+ sessionId: this.sessionId,
3676
+ eventCount: recordingData.events.length,
3677
+ durationMs: recordingData.duration * 1000
3678
+ });
3679
+ const result = await this.apiClient.saveSessionRecording({
3639
3680
  events: recordingData.events,
3640
3681
  sessionId: this.sessionId,
3641
3682
  durationMs: recordingData.duration * 1000
3642
3683
  });
3684
+ console.log('🎬 [AnalyticsTracker] Session recording saved successfully:', result);
3643
3685
  this.log('Session recording saved:', {
3644
3686
  eventCount: recordingData.events.length,
3645
3687
  duration: recordingData.duration
3646
3688
  });
3647
3689
  }
3648
3690
  catch (error) {
3649
- console.error('Failed to save session recording:', error);
3691
+ console.error('🎬 [AnalyticsTracker] Failed to save session recording:', error);
3692
+ console.error('🎬 [AnalyticsTracker] Error details:', {
3693
+ message: error instanceof Error ? error.message : String(error),
3694
+ stack: error instanceof Error ? error.stack : undefined,
3695
+ sessionId: this.sessionId
3696
+ });
3650
3697
  }
3651
3698
  }
3652
3699
  // ==================== Private Methods - Session Management ====================
@@ -3927,7 +3974,7 @@ class AnalyticsTracker {
3927
3974
  if (element.id) {
3928
3975
  return `#${element.id}`;
3929
3976
  }
3930
- if (element.className) {
3977
+ if (element.className && typeof element.className === 'string') {
3931
3978
  const classes = element.className.trim().split(/\s+/);
3932
3979
  return `${element.tagName.toLowerCase()}.${classes.join('.')}`;
3933
3980
  }
@@ -4071,6 +4118,8 @@ class CheckFlow {
4071
4118
  }
4072
4119
  // Store as singleton
4073
4120
  CheckFlow.instance = this;
4121
+ // Expose globally for analytics tracker access
4122
+ window.checkflow = this;
4074
4123
  }
4075
4124
  /**
4076
4125
  * Initialize the SDK