@shiva004/surveys 0.11.1 → 0.11.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.
@@ -1,17 +1,75 @@
1
1
  import React from 'react';
2
2
  import 'rrweb/dist/rrweb.min.css';
3
3
  import './rrw.css';
4
+ type LogEventType = 'session_start' | 'session_resume' | 'session_stop' | 'click' | 'route' | 'api' | 'error' | 'promise_rejection' | 'tab_visibility' | 'network' | 'console_error' | 'console_warn' | 'resource_error' | 'submit' | 'change' | 'page_view' | 'page_unload' | 'dblclick' | 'rage_click' | 'contextmenu' | 'key' | 'clipboard' | 'scroll' | 'resize' | 'focus' | 'long_task' | 'csp_violation';
5
+ export interface LogEvent {
6
+ sessionId: string;
7
+ type: LogEventType;
8
+ localTime: string;
9
+ localISO: string;
10
+ utcISO: string;
11
+ epochMs: number;
12
+ videoOffsetMs: number;
13
+ route: string;
14
+ module: string;
15
+ detail: Record<string, unknown>;
16
+ }
17
+ export interface RrEvent {
18
+ type: number;
19
+ data: unknown;
20
+ timestamp: number;
21
+ }
22
+ export interface RecordingSummary {
23
+ sessionId: string;
24
+ startedAt: number;
25
+ endedAt: number;
26
+ durationMs: number;
27
+ timezone: string;
28
+ eventCount: number;
29
+ interrupted?: boolean;
30
+ }
31
+ export interface FinishedRecording {
32
+ rr: RrEvent[];
33
+ summary: RecordingSummary;
34
+ events: LogEvent[];
35
+ recovered: boolean;
36
+ }
4
37
  /** 2026-11-09 14:32:05.123 (UTC+05:30) */
5
38
  export declare const formatLocalTime: (value?: Date | number) => string;
6
39
  /** 2026-11-09T14:32:05.123+05:30 (ISO format in LOCAL time) */
7
40
  export declare const toLocalISO: (value?: Date | number) => string;
8
41
  export declare const formatDisplayTime: (value: Date | number) => string;
9
42
  type ModuleMap = Record<string, string> | ((pathname: string) => string);
43
+ export declare const downloadLogJson: (f: FinishedRecording) => void;
44
+ export declare const downloadReplayJson: (f: FinishedRecording) => void;
45
+ /** Live info about the recording that is running right now (null when none). Used by the All Sessions table. */
46
+ export declare const getLiveInfo: () => {
47
+ sessionId: string;
48
+ startedAt: number;
49
+ } | null;
50
+ /** Snapshot of everything recorded so far in the running session, without stopping it. */
51
+ export declare const loadLiveRecording: () => Promise<FinishedRecording | null>;
52
+ export declare const ReplayPlayer: React.FC<{
53
+ recording: FinishedRecording;
54
+ onClose: () => void;
55
+ }>;
10
56
  export interface RouteRecorderWatcherProps {
11
57
  /** Recording stops automatically after this many minutes (default 30). Protects browser storage. */
12
58
  maxDurationMinutes?: number;
13
59
  /** Route prefix -> module name map, or a function. Default: first URL segment. */
14
60
  moduleMap?: ModuleMap;
61
+ /** Start recording by itself as soon as the app opens (default true). A reload continues the same session. false = never record. */
62
+ autoStart?: boolean;
63
+ /** When a session ends (Stop, time limit, or recovered after a closed tab) download its replay + log files automatically (default false). */
64
+ autoDownload?: boolean;
65
+ /** POST every finished session here as JSON { summary, events, rrwebEvents } (optional backend save). */
66
+ saveUrl?: string;
67
+ /** Called with every finished session (optional; use it to upload anywhere). */
68
+ onSave?: (rec: {
69
+ summary: RecordingSummary;
70
+ events: LogEvent[];
71
+ rrwebEvents: unknown[];
72
+ }) => void | Promise<void>;
15
73
  }
16
74
  export declare const RouteRecorderWatcher: React.FC<RouteRecorderWatcherProps>;
17
75
  export {};
@@ -0,0 +1,22 @@
1
+ export interface RecordingSummary {
2
+ sessionId: string;
3
+ startedAt: number;
4
+ endedAt: number;
5
+ durationMs: number;
6
+ timezone: string;
7
+ eventCount: number;
8
+ interrupted?: boolean;
9
+ errors: number;
10
+ pages: number;
11
+ clicks: number;
12
+ rageClicks?: number;
13
+ }
14
+ export declare const saveRecording: (summary: RecordingSummary, rr: unknown[], events: unknown[]) => Promise<void>;
15
+ export declare const listRecordings: () => Promise<RecordingSummary[]>;
16
+ export declare const getRecordingData: (id: string) => Promise<{
17
+ rr: unknown[];
18
+ events: unknown[];
19
+ } | null>;
20
+ export declare const deleteRecording: (id: string, announce?: boolean) => Promise<void>;
21
+ /** Live list of archived recordings for React components. */
22
+ export declare const useRecordings: () => RecordingSummary[];
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import './recording.css';
3
+ export declare const RecordingApp: React.FC;
@@ -0,0 +1,18 @@
1
+ export interface FieldOption {
2
+ key: string;
3
+ label: string;
4
+ kind: string;
5
+ isPassword: boolean;
6
+ }
7
+ export declare const FIELD_SELECTOR = "input, select, textarea";
8
+ export declare const friendlyKind: (k: string) => string;
9
+ export declare const isPasswordField: (el: Element) => boolean;
10
+ export declare const isSkippedField: (el: Element) => boolean;
11
+ /** Human-readable name: aria-label > <label for> > wrapping <label> > placeholder > name > id */
12
+ export declare const labelTextFor: (el: Element) => string;
13
+ /** Stable key. Empty string = cannot be identified (stays masked). */
14
+ export declare const fieldKeyFor: (el: Element) => string;
15
+ /** Every identifiable field currently rendered on the page (recorder's own UI is excluded). */
16
+ export declare const scanFields: (root?: ParentNode) => FieldOption[];
17
+ export declare const loadVisible: () => string[];
18
+ export declare const saveVisible: (keys: string[]) => void;
@@ -0,0 +1,54 @@
1
+ export type RecEvent = {
2
+ t: number;
3
+ k: 'v';
4
+ key: string;
5
+ v?: string | boolean;
6
+ n?: number;
7
+ } | {
8
+ t: number;
9
+ k: 'f' | 'b';
10
+ key: string;
11
+ } | {
12
+ t: number;
13
+ k: 'm' | 'c';
14
+ x: number;
15
+ y: number;
16
+ } | {
17
+ t: number;
18
+ k: 's';
19
+ y: number;
20
+ } | {
21
+ t: number;
22
+ k: 't';
23
+ key: string;
24
+ y: number;
25
+ };
26
+ export interface RecordingItem {
27
+ id: string;
28
+ name: string;
29
+ startedAt: number;
30
+ durationMs: number;
31
+ html: string;
32
+ width: number;
33
+ height: number;
34
+ vh: number;
35
+ events: RecEvent[];
36
+ visibleFields: string[];
37
+ clicks: number;
38
+ inputs: number;
39
+ }
40
+ type Status = 'idle' | 'recording';
41
+ interface Snap {
42
+ status: Status;
43
+ elapsedMs: number;
44
+ items: RecordingItem[];
45
+ error: string;
46
+ }
47
+ export declare const useRecording: () => Snap;
48
+ export declare const dots: (n: number) => string;
49
+ /** Starts recording ONLY this form. Nothing else on the page is recorded, no browser popup. */
50
+ export declare function startRecording(form: HTMLElement | null, visibleKeys: string[], visibleLabels: string[]): void;
51
+ export declare function stopRecording(): void;
52
+ export declare const deleteRecording: (id: string) => void;
53
+ export declare const clearError: () => void;
54
+ export {};
@@ -26,6 +26,10 @@ export interface Session {
26
26
  errors: number;
27
27
  /** Seconds from session start. */
28
28
  timeline: SessionEvent[];
29
+ /** Set when a screen recording exists for this session (Replay plays it). */
30
+ recordingId?: string;
31
+ /** True while that recording is still running. */
32
+ live?: boolean;
29
33
  }
30
34
  export interface SessionsConfig {
31
35
  environment?: string;
@@ -43,10 +47,13 @@ interface State {
43
47
  export declare const configureSessions: (c?: SessionsConfig) => void;
44
48
  export declare const getSessionsEnvironment: (override?: string) => string;
45
49
  export declare const useSessions: () => Session[];
50
+ /** This browser's own tracked session (null until its first event). */
51
+ export declare const getLocalSession: () => Session | null;
46
52
  /** Connection status and the time of the last update. */
47
53
  export declare const useSessionsStatus: () => State;
48
54
  /** Replace the sessions that come from your backend. The local browser session is kept. */
49
55
  export declare const setSessions: (remote: Session[]) => void;
56
+ export declare const detectPlatform: () => Pick<Session, "browser" | "os" | "device">;
50
57
  /** Build this browser's session from captured events (including those already captured). Safe to call twice. */
51
58
  export declare const startLocalSession: () => (() => void);
52
59
  /** Turn one JSON object from a backend into a Session (camelCase or snake_case fields). Returns null without an id. */