@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
|
@@ -72,6 +72,7 @@ export declare class AnalyticsTracker {
|
|
|
72
72
|
constructor(apiClient: APIClient, options?: Partial<AnalyticsOptions>);
|
|
73
73
|
startTracking(): Promise<void>;
|
|
74
74
|
stopTracking(): Promise<void>;
|
|
75
|
+
private saveSessionRecording;
|
|
75
76
|
private createSession;
|
|
76
77
|
private updateSessionEnd;
|
|
77
78
|
private setupEventListeners;
|
package/dist/api-client.d.ts
CHANGED
|
@@ -45,15 +45,13 @@ export declare class APIClient {
|
|
|
45
45
|
*/
|
|
46
46
|
uploadScreenshotOnly(screenshotBase64: string, url: string): Promise<APIResponse>;
|
|
47
47
|
/**
|
|
48
|
-
* Save session recording to backend
|
|
49
|
-
*
|
|
48
|
+
* Save session recording to analytics backend
|
|
49
|
+
* Recordings are now part of analytics sessions (independent from feedbacks)
|
|
50
50
|
*/
|
|
51
51
|
saveSessionRecording(recording: {
|
|
52
52
|
events: any[];
|
|
53
53
|
sessionId: string;
|
|
54
|
-
|
|
55
|
-
endUrl?: string;
|
|
56
|
-
durationSeconds: number;
|
|
54
|
+
durationMs?: number;
|
|
57
55
|
}): Promise<APIResponse>;
|
|
58
56
|
/**
|
|
59
57
|
* Report an error to the backend
|
package/dist/index.esm.js
CHANGED
|
@@ -236,16 +236,13 @@ class APIClient {
|
|
|
236
236
|
});
|
|
237
237
|
}
|
|
238
238
|
/**
|
|
239
|
-
* Save session recording to backend
|
|
240
|
-
*
|
|
239
|
+
* Save session recording to analytics backend
|
|
240
|
+
* Recordings are now part of analytics sessions (independent from feedbacks)
|
|
241
241
|
*/
|
|
242
242
|
async saveSessionRecording(recording) {
|
|
243
|
-
return this.request('POST',
|
|
243
|
+
return this.request('POST', `/api/v1/analytics/sessions/${recording.sessionId}/recording`, {
|
|
244
244
|
events: recording.events,
|
|
245
|
-
|
|
246
|
-
start_url: recording.startUrl,
|
|
247
|
-
end_url: recording.endUrl,
|
|
248
|
-
duration_seconds: recording.durationSeconds,
|
|
245
|
+
duration_ms: recording.durationMs || 0,
|
|
249
246
|
});
|
|
250
247
|
}
|
|
251
248
|
/**
|
|
@@ -3602,6 +3599,8 @@ class AnalyticsTracker {
|
|
|
3602
3599
|
try {
|
|
3603
3600
|
// Flush any remaining interactions
|
|
3604
3601
|
await this.flushInteractions();
|
|
3602
|
+
// Save session recording if available
|
|
3603
|
+
await this.saveSessionRecording();
|
|
3605
3604
|
// Update session with end time
|
|
3606
3605
|
await this.updateSessionEnd();
|
|
3607
3606
|
// Remove event listeners
|
|
@@ -3622,6 +3621,34 @@ class AnalyticsTracker {
|
|
|
3622
3621
|
console.error('Error stopping analytics tracking:', error);
|
|
3623
3622
|
}
|
|
3624
3623
|
}
|
|
3624
|
+
async saveSessionRecording() {
|
|
3625
|
+
// Get session recording from global CheckFlow instance if available
|
|
3626
|
+
try {
|
|
3627
|
+
const checkflowInstance = window.checkflow;
|
|
3628
|
+
if (!checkflowInstance || !checkflowInstance.sessionRecording) {
|
|
3629
|
+
this.log('No session recording available');
|
|
3630
|
+
return;
|
|
3631
|
+
}
|
|
3632
|
+
const recordingData = checkflowInstance.sessionRecording.getRecordingData();
|
|
3633
|
+
if (!recordingData || recordingData.events.length === 0) {
|
|
3634
|
+
this.log('No recording events to save');
|
|
3635
|
+
return;
|
|
3636
|
+
}
|
|
3637
|
+
// Save recording to analytics backend
|
|
3638
|
+
await this.apiClient.saveSessionRecording({
|
|
3639
|
+
events: recordingData.events,
|
|
3640
|
+
sessionId: this.sessionId,
|
|
3641
|
+
durationMs: recordingData.duration * 1000
|
|
3642
|
+
});
|
|
3643
|
+
this.log('Session recording saved:', {
|
|
3644
|
+
eventCount: recordingData.events.length,
|
|
3645
|
+
duration: recordingData.duration
|
|
3646
|
+
});
|
|
3647
|
+
}
|
|
3648
|
+
catch (error) {
|
|
3649
|
+
console.error('Failed to save session recording:', error);
|
|
3650
|
+
}
|
|
3651
|
+
}
|
|
3625
3652
|
// ==================== Private Methods - Session Management ====================
|
|
3626
3653
|
async createSession() {
|
|
3627
3654
|
const sessionData = {
|