@usero/sdk 1.1.11 → 1.1.13

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.
@@ -37,6 +37,7 @@ interface PluginContext {
37
37
  logger: PluginLogger;
38
38
  resolveUser?: () => void;
39
39
  getSdkSessionId?: () => string;
40
+ reseatSdkSessionId?: (id: string) => void;
40
41
  getAnonymousId?: () => string;
41
42
  getUserId?: () => string | null;
42
43
  getReplayStartMs?: () => number | null;
@@ -92,6 +93,7 @@ interface RecorderStore {
92
93
  tasksPanelOpen: boolean;
93
94
  outsidePointerHandler: ((event: PointerEvent) => void) | null;
94
95
  keydownHandler: ((event: KeyboardEvent) => void) | null;
96
+ keyboardWatcherCleanup: (() => void) | null;
95
97
  hasMicPermission: boolean;
96
98
  micAcquiring: boolean;
97
99
  micFailReason: 'blocked' | 'not-found' | 'unsupported' | null;
@@ -104,29 +106,78 @@ interface RecorderStore {
104
106
  } | null;
105
107
  muteToastShown: boolean;
106
108
  muteToastTimers: number[];
109
+ resumeToastTimers: number[];
107
110
  notes: InFlightNote[];
108
111
  notesPopoverOpen: boolean;
109
112
  notePopoverAtMs: number | null;
110
113
  endNote: string;
111
114
  finishFlowRan: boolean;
115
+ sessionClosed: boolean;
116
+ onSessionClosed: (() => void) | null;
117
+ paused: boolean;
118
+ resumed: boolean;
119
+ sdkSessionId: string | null;
112
120
  replayOffsetAtStartMs: number | null;
113
121
  }
114
- declare function getTestSlug(queryParam: string): string | null;
122
+ interface ActiveSessionState {
123
+ slug: string;
124
+ sessionId: string;
125
+ nextChunkIndex: number;
126
+ startedAt: number;
127
+ status: 'active' | 'paused';
128
+ sdkSessionId?: string;
129
+ pausedAt?: number;
130
+ }
131
+ type AdoptResult = {
132
+ kind: 'ok';
133
+ sessionId: string;
134
+ clientId: string;
135
+ tasks: UserTestTask[];
136
+ } | {
137
+ kind: 'closed';
138
+ } | {
139
+ kind: 'error';
140
+ };
141
+
115
142
  declare function isMediaRecorderSupported(): boolean;
116
143
  declare function pickMimeType(): string | undefined;
117
- declare function micChipState(store: RecorderStore): 'recording' | 'muted' | 'none' | 'connecting' | 'silent' | 'inactive';
144
+ type ChunkResponseClass = 'ok' | 'closed' | 'retry' | 'fatal';
145
+ declare function classifyChunkResponse(status: number, body: unknown): ChunkResponseClass;
146
+ declare function handleSessionClosed(store: RecorderStore): void;
118
147
  declare function rmsDbFromSamples(samples: Float32Array | number[]): number;
119
148
  declare function isStreamSilent(input: number | Float32Array | number[]): boolean;
149
+
150
+ declare function parseActiveSession(raw: unknown): ActiveSessionState | null;
151
+ declare function readActiveSession(): ActiveSessionState | null;
152
+ declare function clearActiveSession(): void;
153
+ declare function persistActiveSession(store: RecorderStore, status: 'active' | 'paused'): void;
154
+ declare function getTestSlug(queryParam: string): string | null;
155
+ declare function adoptSession(apiUrl: string, sessionId: string): Promise<AdoptResult>;
156
+
157
+ declare function computeKeyboardInset(innerHeight: number, viewportHeight: number, viewportOffsetTop: number): number;
158
+ declare function micChipState(store: RecorderStore): 'recording' | 'muted' | 'none' | 'connecting' | 'silent' | 'inactive';
159
+
120
160
  declare function userTest(options?: UserTestOptions): UseroPlugin;
121
161
  declare const __test__: {
122
162
  getTestSlug: typeof getTestSlug;
123
163
  pickMimeType: typeof pickMimeType;
124
164
  isMediaRecorderSupported: typeof isMediaRecorderSupported;
165
+ classifyChunkResponse: typeof classifyChunkResponse;
166
+ handleSessionClosed: typeof handleSessionClosed;
125
167
  micChipState: typeof micChipState;
168
+ computeKeyboardInset: typeof computeKeyboardInset;
126
169
  isStreamSilent: typeof isStreamSilent;
127
170
  rmsDbFromSamples: typeof rmsDbFromSamples;
128
171
  SILENCE_RMS_DB_THRESHOLD: number;
129
172
  SILENCE_FLOOR_DB: number;
173
+ parseActiveSession: typeof parseActiveSession;
174
+ readActiveSession: typeof readActiveSession;
175
+ clearActiveSession: typeof clearActiveSession;
176
+ persistActiveSession: typeof persistActiveSession;
177
+ adoptSession: typeof adoptSession;
178
+ ACTIVE_SESSION_MAX_AGE_MS: number;
179
+ RESUME_MAX_IDLE_MS: number;
180
+ ACTIVE_SESSION_STORAGE_KEY: string;
130
181
  };
131
182
 
132
183
  export { type UserTestOptions, __test__, isStreamSilent, rmsDbFromSamples, userTest };
@@ -37,6 +37,7 @@ interface PluginContext {
37
37
  logger: PluginLogger;
38
38
  resolveUser?: () => void;
39
39
  getSdkSessionId?: () => string;
40
+ reseatSdkSessionId?: (id: string) => void;
40
41
  getAnonymousId?: () => string;
41
42
  getUserId?: () => string | null;
42
43
  getReplayStartMs?: () => number | null;
@@ -92,6 +93,7 @@ interface RecorderStore {
92
93
  tasksPanelOpen: boolean;
93
94
  outsidePointerHandler: ((event: PointerEvent) => void) | null;
94
95
  keydownHandler: ((event: KeyboardEvent) => void) | null;
96
+ keyboardWatcherCleanup: (() => void) | null;
95
97
  hasMicPermission: boolean;
96
98
  micAcquiring: boolean;
97
99
  micFailReason: 'blocked' | 'not-found' | 'unsupported' | null;
@@ -104,29 +106,78 @@ interface RecorderStore {
104
106
  } | null;
105
107
  muteToastShown: boolean;
106
108
  muteToastTimers: number[];
109
+ resumeToastTimers: number[];
107
110
  notes: InFlightNote[];
108
111
  notesPopoverOpen: boolean;
109
112
  notePopoverAtMs: number | null;
110
113
  endNote: string;
111
114
  finishFlowRan: boolean;
115
+ sessionClosed: boolean;
116
+ onSessionClosed: (() => void) | null;
117
+ paused: boolean;
118
+ resumed: boolean;
119
+ sdkSessionId: string | null;
112
120
  replayOffsetAtStartMs: number | null;
113
121
  }
114
- declare function getTestSlug(queryParam: string): string | null;
122
+ interface ActiveSessionState {
123
+ slug: string;
124
+ sessionId: string;
125
+ nextChunkIndex: number;
126
+ startedAt: number;
127
+ status: 'active' | 'paused';
128
+ sdkSessionId?: string;
129
+ pausedAt?: number;
130
+ }
131
+ type AdoptResult = {
132
+ kind: 'ok';
133
+ sessionId: string;
134
+ clientId: string;
135
+ tasks: UserTestTask[];
136
+ } | {
137
+ kind: 'closed';
138
+ } | {
139
+ kind: 'error';
140
+ };
141
+
115
142
  declare function isMediaRecorderSupported(): boolean;
116
143
  declare function pickMimeType(): string | undefined;
117
- declare function micChipState(store: RecorderStore): 'recording' | 'muted' | 'none' | 'connecting' | 'silent' | 'inactive';
144
+ type ChunkResponseClass = 'ok' | 'closed' | 'retry' | 'fatal';
145
+ declare function classifyChunkResponse(status: number, body: unknown): ChunkResponseClass;
146
+ declare function handleSessionClosed(store: RecorderStore): void;
118
147
  declare function rmsDbFromSamples(samples: Float32Array | number[]): number;
119
148
  declare function isStreamSilent(input: number | Float32Array | number[]): boolean;
149
+
150
+ declare function parseActiveSession(raw: unknown): ActiveSessionState | null;
151
+ declare function readActiveSession(): ActiveSessionState | null;
152
+ declare function clearActiveSession(): void;
153
+ declare function persistActiveSession(store: RecorderStore, status: 'active' | 'paused'): void;
154
+ declare function getTestSlug(queryParam: string): string | null;
155
+ declare function adoptSession(apiUrl: string, sessionId: string): Promise<AdoptResult>;
156
+
157
+ declare function computeKeyboardInset(innerHeight: number, viewportHeight: number, viewportOffsetTop: number): number;
158
+ declare function micChipState(store: RecorderStore): 'recording' | 'muted' | 'none' | 'connecting' | 'silent' | 'inactive';
159
+
120
160
  declare function userTest(options?: UserTestOptions): UseroPlugin;
121
161
  declare const __test__: {
122
162
  getTestSlug: typeof getTestSlug;
123
163
  pickMimeType: typeof pickMimeType;
124
164
  isMediaRecorderSupported: typeof isMediaRecorderSupported;
165
+ classifyChunkResponse: typeof classifyChunkResponse;
166
+ handleSessionClosed: typeof handleSessionClosed;
125
167
  micChipState: typeof micChipState;
168
+ computeKeyboardInset: typeof computeKeyboardInset;
126
169
  isStreamSilent: typeof isStreamSilent;
127
170
  rmsDbFromSamples: typeof rmsDbFromSamples;
128
171
  SILENCE_RMS_DB_THRESHOLD: number;
129
172
  SILENCE_FLOOR_DB: number;
173
+ parseActiveSession: typeof parseActiveSession;
174
+ readActiveSession: typeof readActiveSession;
175
+ clearActiveSession: typeof clearActiveSession;
176
+ persistActiveSession: typeof persistActiveSession;
177
+ adoptSession: typeof adoptSession;
178
+ ACTIVE_SESSION_MAX_AGE_MS: number;
179
+ RESUME_MAX_IDLE_MS: number;
180
+ ACTIVE_SESSION_STORAGE_KEY: string;
130
181
  };
131
182
 
132
183
  export { type UserTestOptions, __test__, isStreamSilent, rmsDbFromSamples, userTest };