@checkflow/sdk 1.0.1 → 1.0.2
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 +34 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +34 -7
- 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
|
/**
|
|
@@ -3606,6 +3603,8 @@ class AnalyticsTracker {
|
|
|
3606
3603
|
try {
|
|
3607
3604
|
// Flush any remaining interactions
|
|
3608
3605
|
await this.flushInteractions();
|
|
3606
|
+
// Save session recording if available
|
|
3607
|
+
await this.saveSessionRecording();
|
|
3609
3608
|
// Update session with end time
|
|
3610
3609
|
await this.updateSessionEnd();
|
|
3611
3610
|
// Remove event listeners
|
|
@@ -3626,6 +3625,34 @@ class AnalyticsTracker {
|
|
|
3626
3625
|
console.error('Error stopping analytics tracking:', error);
|
|
3627
3626
|
}
|
|
3628
3627
|
}
|
|
3628
|
+
async saveSessionRecording() {
|
|
3629
|
+
// Get session recording from global CheckFlow instance if available
|
|
3630
|
+
try {
|
|
3631
|
+
const checkflowInstance = window.checkflow;
|
|
3632
|
+
if (!checkflowInstance || !checkflowInstance.sessionRecording) {
|
|
3633
|
+
this.log('No session recording available');
|
|
3634
|
+
return;
|
|
3635
|
+
}
|
|
3636
|
+
const recordingData = checkflowInstance.sessionRecording.getRecordingData();
|
|
3637
|
+
if (!recordingData || recordingData.events.length === 0) {
|
|
3638
|
+
this.log('No recording events to save');
|
|
3639
|
+
return;
|
|
3640
|
+
}
|
|
3641
|
+
// Save recording to analytics backend
|
|
3642
|
+
await this.apiClient.saveSessionRecording({
|
|
3643
|
+
events: recordingData.events,
|
|
3644
|
+
sessionId: this.sessionId,
|
|
3645
|
+
durationMs: recordingData.duration * 1000
|
|
3646
|
+
});
|
|
3647
|
+
this.log('Session recording saved:', {
|
|
3648
|
+
eventCount: recordingData.events.length,
|
|
3649
|
+
duration: recordingData.duration
|
|
3650
|
+
});
|
|
3651
|
+
}
|
|
3652
|
+
catch (error) {
|
|
3653
|
+
console.error('Failed to save session recording:', error);
|
|
3654
|
+
}
|
|
3655
|
+
}
|
|
3629
3656
|
// ==================== Private Methods - Session Management ====================
|
|
3630
3657
|
async createSession() {
|
|
3631
3658
|
const sessionData = {
|