writetrack 0.5.0 → 0.6.0

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.
@@ -2,7 +2,15 @@ import { K as KeystrokeEvent, C as ClipboardEvent, U as UndoRedoEvent, S as Sele
2
2
  export { D as DataQualityMetrics, M as ModifierState, b as SessionMetadata } from './index-ChEZuqzG.js';
3
3
  import { WriteTrackSink } from './pipes.js';
4
4
  export { DatadogClient, DatadogOptions, OTelSpan, OTelTracer, OpenTelemetryOptions, SegmentClient, SegmentOptions, WebhookOptions, datadog, opentelemetry, segment, webhook } from './pipes.js';
5
- import { S as SessionAnalysis, a as SessionReport, I as IndicatorOutput } from './analysis-types-CDTIp-v7.js';
5
+ import { S as SessionAnalysis, a as SessionReport, I as IndicatorOutput } from './analysis-types-Crmvzq7z.js';
6
+
7
+ interface PersistedSessionInfo {
8
+ contentId: string;
9
+ fieldId: string;
10
+ keystrokeCount: number;
11
+ lastSavedAt: number;
12
+ sessionId: string;
13
+ }
6
14
 
7
15
  interface WriteTrackOptions {
8
16
  target: HTMLElement;
@@ -17,6 +25,11 @@ interface WriteTrackOptions {
17
25
  wasmUrl?: string;
18
26
  /** Enable IndexedDB session persistence and auto-resume. Requires contentId. */
19
27
  persist?: boolean;
28
+ /** Custom cursor position provider. Called on every keydown/keyup to get the current
29
+ * cursor offset. Use this when the target is a rich text editor with its own document
30
+ * model (e.g., ProseMirror, Quill, CKEditor). If not provided, falls back to
31
+ * selectionStart (input/textarea) or Range-based offset (contenteditable). */
32
+ cursorPositionProvider?: () => number;
20
33
  }
21
34
  declare class WriteTrack {
22
35
  /** @internal */ keystrokeEvents: KeystrokeEvent[];
@@ -46,6 +59,7 @@ declare class WriteTrack {
46
59
  /** @internal */ readonly persist: boolean;
47
60
  private _analysis;
48
61
  private _persist;
62
+ private readonly cursorPositionProvider?;
49
63
  private _sinks;
50
64
  private _listeners;
51
65
  /**
@@ -61,6 +75,7 @@ declare class WriteTrack {
61
75
  */
62
76
  private setupTargetObserver;
63
77
  private isRecordingEnabled;
78
+ private getCursorPosition;
64
79
  private recordKeydown;
65
80
  private recordKeyup;
66
81
  private recordMouseActivity;
@@ -132,6 +147,16 @@ declare class WriteTrack {
132
147
  getSessionReport(): Promise<SessionReport>;
133
148
  getText(): string;
134
149
  getData(): WriteTrackDataSchema;
150
+ /**
151
+ * List all persisted sessions with summary metadata.
152
+ */
153
+ static listPersistedSessions(): Promise<PersistedSessionInfo[]>;
154
+ /**
155
+ * Delete persisted session data by contentId.
156
+ * If fieldId is provided, deletes only that specific session.
157
+ * If fieldId is omitted, deletes all sessions for the contentId.
158
+ */
159
+ static deletePersistedSession(contentId: string, fieldId?: string): Promise<void>;
135
160
  }
136
161
 
137
162
  /**
@@ -154,6 +179,12 @@ declare function formatIndicator(indicator: IndicatorOutput): string;
154
179
  * and returns a full SessionAnalysis without needing a DOM element.
155
180
  */
156
181
 
182
+ interface AnalyzeEventsOptions {
183
+ /** Custom URL/path for the WASM binary */
184
+ wasmUrl?: string;
185
+ /** License key for WASM verification */
186
+ licenseKey?: string;
187
+ }
157
188
  /**
158
189
  * Analyze a WriteTrackDataSchema object without needing a live DOM element.
159
190
  *
@@ -161,10 +192,9 @@ declare function formatIndicator(indicator: IndicatorOutput): string;
161
192
  * Returns null if WASM loading fails or input is invalid.
162
193
  *
163
194
  * @param rawEventData - Output of WriteTrack.getData() (WriteTrackDataSchema format)
164
- * @param wasmUrl - Optional custom URL/path for the WASM binary
165
- * @param licenseKey - Optional license key for WASM verification
195
+ * @param options - Optional configuration (wasmUrl, licenseKey)
166
196
  */
167
- declare function analyzeEvents(rawEventData: unknown, wasmUrl?: string, licenseKey?: string): Promise<SessionAnalysis | null>;
197
+ declare function analyzeEvents(rawEventData: unknown, options?: AnalyzeEventsOptions): Promise<SessionAnalysis | null>;
168
198
 
169
199
  /**
170
200
  * Utility functions for timing and statistical calculations
@@ -174,4 +204,4 @@ declare function analyzeEvents(rawEventData: unknown, wasmUrl?: string, licenseK
174
204
  */
175
205
  declare function getHighResolutionTime(): number;
176
206
 
177
- export { ClipboardEvent, CompositionEvent, IndicatorOutput, KeystrokeEvent, ProgrammaticInsertionEvent, SelectionEvent, SessionAnalysis, SessionReport, UndoRedoEvent, WriteTrack, WriteTrackDataSchema, type WriteTrackOptions, WriteTrackSink, analyzeEvents, WriteTrack as default, formatIndicator, getHighResolutionTime };
207
+ export { type AnalyzeEventsOptions, ClipboardEvent, CompositionEvent, IndicatorOutput, KeystrokeEvent, type PersistedSessionInfo, ProgrammaticInsertionEvent, SelectionEvent, SessionAnalysis, SessionReport, UndoRedoEvent, WriteTrack, WriteTrackDataSchema, type WriteTrackOptions, WriteTrackSink, analyzeEvents, WriteTrack as default, formatIndicator, getHighResolutionTime };