@checkflow/sdk 1.0.1 → 1.0.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/analytics-tracker.d.ts +1 -0
- package/dist/api-client.d.ts +3 -5
- package/dist/index.esm.js +85 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +85 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -240,16 +240,13 @@ class APIClient {
|
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
242
|
/**
|
|
243
|
-
* Save session recording to backend
|
|
244
|
-
*
|
|
243
|
+
* Save session recording to analytics backend
|
|
244
|
+
* Recordings are now part of analytics sessions (independent from feedbacks)
|
|
245
245
|
*/
|
|
246
246
|
async saveSessionRecording(recording) {
|
|
247
|
-
return this.request('POST',
|
|
247
|
+
return this.request('POST', `/api/v1/analytics/sessions/${recording.sessionId}/recording`, {
|
|
248
248
|
events: recording.events,
|
|
249
|
-
|
|
250
|
-
start_url: recording.startUrl,
|
|
251
|
-
end_url: recording.endUrl,
|
|
252
|
-
duration_seconds: recording.durationSeconds,
|
|
249
|
+
duration_ms: recording.durationMs || 0,
|
|
253
250
|
});
|
|
254
251
|
}
|
|
255
252
|
/**
|
|
@@ -2711,6 +2708,10 @@ class SessionRecording {
|
|
|
2711
2708
|
start() {
|
|
2712
2709
|
if (this.isRecording || !this.config.enabled)
|
|
2713
2710
|
return;
|
|
2711
|
+
console.log(' [SessionRecording] Starting session recording...', {
|
|
2712
|
+
sessionId: this.sessionId,
|
|
2713
|
+
config: this.config
|
|
2714
|
+
});
|
|
2714
2715
|
this.isRecording = true;
|
|
2715
2716
|
this.startTime = Date.now();
|
|
2716
2717
|
this.events = [];
|
|
@@ -2719,20 +2720,25 @@ class SessionRecording {
|
|
|
2719
2720
|
// Setup event listeners
|
|
2720
2721
|
if (this.config.recordMouse) {
|
|
2721
2722
|
this.setupMouseTracking();
|
|
2723
|
+
console.log(' [SessionRecording] Mouse tracking enabled');
|
|
2722
2724
|
}
|
|
2723
2725
|
if (this.config.recordScroll) {
|
|
2724
2726
|
this.setupScrollTracking();
|
|
2727
|
+
console.log(' [SessionRecording] Scroll tracking enabled');
|
|
2725
2728
|
}
|
|
2726
2729
|
if (this.config.recordInput) {
|
|
2727
2730
|
this.setupInputTracking();
|
|
2731
|
+
console.log(' [SessionRecording] Input tracking enabled');
|
|
2728
2732
|
}
|
|
2729
2733
|
if (this.config.recordMutations) {
|
|
2730
2734
|
this.setupMutationObserver();
|
|
2735
|
+
console.log(' [SessionRecording] Mutation observer enabled');
|
|
2731
2736
|
}
|
|
2732
2737
|
// Track navigation
|
|
2733
2738
|
this.setupNavigationTracking();
|
|
2734
2739
|
// Track resize
|
|
2735
2740
|
this.setupResizeTracking();
|
|
2741
|
+
console.log(' [SessionRecording] Session recording started successfully');
|
|
2736
2742
|
// Auto-stop after max duration
|
|
2737
2743
|
setTimeout(() => {
|
|
2738
2744
|
if (this.isRecording) {
|
|
@@ -2788,13 +2794,29 @@ class SessionRecording {
|
|
|
2788
2794
|
* Get recording data for submission
|
|
2789
2795
|
*/
|
|
2790
2796
|
getRecordingData() {
|
|
2791
|
-
|
|
2797
|
+
console.log('🎥 [SessionRecording] getRecordingData called:', {
|
|
2798
|
+
eventCount: this.events.length,
|
|
2799
|
+
sessionId: this.sessionId,
|
|
2800
|
+
duration: this.getDuration(),
|
|
2801
|
+
isRecording: this.isRecording,
|
|
2802
|
+
startTime: this.startTime
|
|
2803
|
+
});
|
|
2804
|
+
if (this.events.length === 0) {
|
|
2805
|
+
console.warn('🎥 [SessionRecording] No events to return');
|
|
2792
2806
|
return null;
|
|
2793
|
-
|
|
2807
|
+
}
|
|
2808
|
+
const data = {
|
|
2794
2809
|
events: [...this.events],
|
|
2795
2810
|
sessionId: this.sessionId,
|
|
2796
2811
|
duration: this.getDuration(),
|
|
2797
2812
|
};
|
|
2813
|
+
console.log('🎥 [SessionRecording] Returning recording data:', {
|
|
2814
|
+
eventCount: data.events.length,
|
|
2815
|
+
duration: data.duration,
|
|
2816
|
+
firstEventType: data.events[0]?.type,
|
|
2817
|
+
lastEventType: data.events[data.events.length - 1]?.type
|
|
2818
|
+
});
|
|
2819
|
+
return data;
|
|
2798
2820
|
}
|
|
2799
2821
|
addEvent(type, data) {
|
|
2800
2822
|
// Sample rate filtering
|
|
@@ -3606,6 +3628,8 @@ class AnalyticsTracker {
|
|
|
3606
3628
|
try {
|
|
3607
3629
|
// Flush any remaining interactions
|
|
3608
3630
|
await this.flushInteractions();
|
|
3631
|
+
// Save session recording if available
|
|
3632
|
+
await this.saveSessionRecording();
|
|
3609
3633
|
// Update session with end time
|
|
3610
3634
|
await this.updateSessionEnd();
|
|
3611
3635
|
// Remove event listeners
|
|
@@ -3626,6 +3650,56 @@ class AnalyticsTracker {
|
|
|
3626
3650
|
console.error('Error stopping analytics tracking:', error);
|
|
3627
3651
|
}
|
|
3628
3652
|
}
|
|
3653
|
+
async saveSessionRecording() {
|
|
3654
|
+
// Get session recording from global CheckFlow instance if available
|
|
3655
|
+
try {
|
|
3656
|
+
console.log('🎬 [AnalyticsTracker] Starting saveSessionRecording for session:', this.sessionId);
|
|
3657
|
+
const checkflowInstance = window.checkflow;
|
|
3658
|
+
console.log('🎬 [AnalyticsTracker] CheckFlow instance found:', !!checkflowInstance);
|
|
3659
|
+
console.log('🎬 [AnalyticsTracker] SessionRecording instance found:', !!checkflowInstance?.sessionRecording);
|
|
3660
|
+
if (!checkflowInstance || !checkflowInstance.sessionRecording) {
|
|
3661
|
+
console.warn('🎬 [AnalyticsTracker] No session recording available - instance missing');
|
|
3662
|
+
this.log('No session recording available');
|
|
3663
|
+
return;
|
|
3664
|
+
}
|
|
3665
|
+
const recordingData = checkflowInstance.sessionRecording.getRecordingData();
|
|
3666
|
+
console.log('🎬 [AnalyticsTracker] Recording data retrieved:', {
|
|
3667
|
+
hasData: !!recordingData,
|
|
3668
|
+
eventCount: recordingData?.events?.length || 0,
|
|
3669
|
+
duration: recordingData?.duration || 0,
|
|
3670
|
+
sessionId: recordingData?.sessionId
|
|
3671
|
+
});
|
|
3672
|
+
if (!recordingData || recordingData.events.length === 0) {
|
|
3673
|
+
console.warn('🎬 [AnalyticsTracker] No recording events to save - events array empty');
|
|
3674
|
+
this.log('No recording events to save');
|
|
3675
|
+
return;
|
|
3676
|
+
}
|
|
3677
|
+
// Save recording to analytics backend
|
|
3678
|
+
console.log('🎬 [AnalyticsTracker] Saving recording to backend...', {
|
|
3679
|
+
sessionId: this.sessionId,
|
|
3680
|
+
eventCount: recordingData.events.length,
|
|
3681
|
+
durationMs: recordingData.duration * 1000
|
|
3682
|
+
});
|
|
3683
|
+
const result = await this.apiClient.saveSessionRecording({
|
|
3684
|
+
events: recordingData.events,
|
|
3685
|
+
sessionId: this.sessionId,
|
|
3686
|
+
durationMs: recordingData.duration * 1000
|
|
3687
|
+
});
|
|
3688
|
+
console.log('🎬 [AnalyticsTracker] Session recording saved successfully:', result);
|
|
3689
|
+
this.log('Session recording saved:', {
|
|
3690
|
+
eventCount: recordingData.events.length,
|
|
3691
|
+
duration: recordingData.duration
|
|
3692
|
+
});
|
|
3693
|
+
}
|
|
3694
|
+
catch (error) {
|
|
3695
|
+
console.error('🎬 [AnalyticsTracker] Failed to save session recording:', error);
|
|
3696
|
+
console.error('🎬 [AnalyticsTracker] Error details:', {
|
|
3697
|
+
message: error instanceof Error ? error.message : String(error),
|
|
3698
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
3699
|
+
sessionId: this.sessionId
|
|
3700
|
+
});
|
|
3701
|
+
}
|
|
3702
|
+
}
|
|
3629
3703
|
// ==================== Private Methods - Session Management ====================
|
|
3630
3704
|
async createSession() {
|
|
3631
3705
|
const sessionData = {
|
|
@@ -4048,6 +4122,8 @@ class CheckFlow {
|
|
|
4048
4122
|
}
|
|
4049
4123
|
// Store as singleton
|
|
4050
4124
|
CheckFlow.instance = this;
|
|
4125
|
+
// Expose globally for analytics tracker access
|
|
4126
|
+
window.checkflow = this;
|
|
4051
4127
|
}
|
|
4052
4128
|
/**
|
|
4053
4129
|
* Initialize the SDK
|