@checkflow/sdk 1.1.0 → 1.1.1

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.
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Optimized Session Recorder - Inspired by Mixpanel/LogRocket
3
+ *
4
+ * Features from refactorisation.md:
5
+ * - Adaptive sampling (10-100ms based on activity)
6
+ * - Event batching (50 events per batch)
7
+ * - Compression before sending
8
+ * - Circular buffer for performance
9
+ * - Intelligent event filtering
10
+ */
11
+ import type { eventWithTime } from '@rrweb/types';
12
+ export interface OptimizedRecorderConfig {
13
+ samplingRate: number;
14
+ eventBatchSize: number;
15
+ maxSessionLength: number;
16
+ quality: 'low' | 'medium' | 'high';
17
+ compression: boolean;
18
+ adaptiveSampling: boolean;
19
+ onBatchReady?: (batch: EventBatch) => void;
20
+ onError?: (error: Error) => void;
21
+ }
22
+ export interface EventBatch {
23
+ sessionId: string;
24
+ events: eventWithTime[];
25
+ chunkIndex: number;
26
+ compressed?: boolean;
27
+ compressedData?: string;
28
+ timestamp: number;
29
+ }
30
+ export declare class OptimizedRecorder {
31
+ private config;
32
+ private eventBuffer;
33
+ private bufferIndex;
34
+ private sessionId;
35
+ private stopRecording?;
36
+ private batchTimer?;
37
+ private activityMetrics;
38
+ private startTime;
39
+ private chunkIndex;
40
+ private isRecording;
41
+ constructor(sessionId: string, config?: Partial<OptimizedRecorderConfig>);
42
+ /**
43
+ * Start recording with optimized settings
44
+ */
45
+ start(): void;
46
+ /**
47
+ * Stop recording and flush remaining events
48
+ */
49
+ stop(): void;
50
+ /**
51
+ * Handle incoming event from rrweb
52
+ */
53
+ private handleEvent;
54
+ /**
55
+ * Flush current batch of events
56
+ */
57
+ private flushBatch;
58
+ /**
59
+ * Start periodic batch flushing
60
+ */
61
+ private startBatchTimer;
62
+ /**
63
+ * Update activity metrics based on event
64
+ */
65
+ private updateActivityMetrics;
66
+ /**
67
+ * Calculate activity level (0-1)
68
+ */
69
+ private calculateActivityLevel;
70
+ /**
71
+ * Adjust sampling rate based on activity
72
+ */
73
+ private adjustSamplingRate;
74
+ /**
75
+ * Get sampling configuration based on quality
76
+ */
77
+ private getSamplingConfig;
78
+ /**
79
+ * Get slimDOM options based on quality
80
+ */
81
+ private getSlimDOMOptions;
82
+ /**
83
+ * Get current recording stats
84
+ */
85
+ getStats(): {
86
+ isRecording: boolean;
87
+ sessionId: string;
88
+ duration: number;
89
+ bufferedEvents: number;
90
+ chunksSent: number;
91
+ activityLevel: number;
92
+ currentSamplingRate: number;
93
+ };
94
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkflow/sdk",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "description": "CheckFlow SDK for capturing user feedback with context",
6
6
  "main": "dist/index.js",
@@ -37,6 +37,7 @@
37
37
  "@rollup/plugin-typescript": "^11.1.5",
38
38
  "@types/jest": "^29.5.11",
39
39
  "@types/node": "^20.10.5",
40
+ "@types/pako": "^2.0.4",
40
41
  "@types/react": "^18.3.27",
41
42
  "@types/react-dom": "^18.3.7",
42
43
  "@typescript-eslint/eslint-plugin": "^6.15.0",
@@ -53,6 +54,7 @@
53
54
  },
54
55
  "dependencies": {
55
56
  "html2canvas": "^1.4.1",
57
+ "pako": "^2.1.0",
56
58
  "rrweb": "^2.0.0-alpha.17"
57
59
  },
58
60
  "peerDependencies": {