@usero/sdk 1.1.10 → 1.1.12

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;
@@ -104,29 +105,76 @@ interface RecorderStore {
104
105
  } | null;
105
106
  muteToastShown: boolean;
106
107
  muteToastTimers: number[];
108
+ resumeToastTimers: number[];
107
109
  notes: InFlightNote[];
108
110
  notesPopoverOpen: boolean;
109
111
  notePopoverAtMs: number | null;
110
112
  endNote: string;
111
113
  finishFlowRan: boolean;
114
+ sessionClosed: boolean;
115
+ onSessionClosed: (() => void) | null;
116
+ paused: boolean;
117
+ resumed: boolean;
118
+ sdkSessionId: string | null;
112
119
  replayOffsetAtStartMs: number | null;
113
120
  }
114
- declare function getTestSlug(queryParam: string): string | null;
121
+ interface ActiveSessionState {
122
+ slug: string;
123
+ sessionId: string;
124
+ nextChunkIndex: number;
125
+ startedAt: number;
126
+ status: 'active' | 'paused';
127
+ sdkSessionId?: string;
128
+ pausedAt?: number;
129
+ }
130
+ type AdoptResult = {
131
+ kind: 'ok';
132
+ sessionId: string;
133
+ clientId: string;
134
+ tasks: UserTestTask[];
135
+ } | {
136
+ kind: 'closed';
137
+ } | {
138
+ kind: 'error';
139
+ };
140
+
115
141
  declare function isMediaRecorderSupported(): boolean;
116
142
  declare function pickMimeType(): string | undefined;
117
- declare function micChipState(store: RecorderStore): 'recording' | 'muted' | 'none' | 'connecting' | 'silent' | 'inactive';
143
+ type ChunkResponseClass = 'ok' | 'closed' | 'retry' | 'fatal';
144
+ declare function classifyChunkResponse(status: number, body: unknown): ChunkResponseClass;
145
+ declare function handleSessionClosed(store: RecorderStore): void;
118
146
  declare function rmsDbFromSamples(samples: Float32Array | number[]): number;
119
147
  declare function isStreamSilent(input: number | Float32Array | number[]): boolean;
148
+
149
+ declare function parseActiveSession(raw: unknown): ActiveSessionState | null;
150
+ declare function readActiveSession(): ActiveSessionState | null;
151
+ declare function clearActiveSession(): void;
152
+ declare function persistActiveSession(store: RecorderStore, status: 'active' | 'paused'): void;
153
+ declare function getTestSlug(queryParam: string): string | null;
154
+ declare function adoptSession(apiUrl: string, sessionId: string): Promise<AdoptResult>;
155
+
156
+ declare function micChipState(store: RecorderStore): 'recording' | 'muted' | 'none' | 'connecting' | 'silent' | 'inactive';
157
+
120
158
  declare function userTest(options?: UserTestOptions): UseroPlugin;
121
159
  declare const __test__: {
122
160
  getTestSlug: typeof getTestSlug;
123
161
  pickMimeType: typeof pickMimeType;
124
162
  isMediaRecorderSupported: typeof isMediaRecorderSupported;
163
+ classifyChunkResponse: typeof classifyChunkResponse;
164
+ handleSessionClosed: typeof handleSessionClosed;
125
165
  micChipState: typeof micChipState;
126
166
  isStreamSilent: typeof isStreamSilent;
127
167
  rmsDbFromSamples: typeof rmsDbFromSamples;
128
168
  SILENCE_RMS_DB_THRESHOLD: number;
129
169
  SILENCE_FLOOR_DB: number;
170
+ parseActiveSession: typeof parseActiveSession;
171
+ readActiveSession: typeof readActiveSession;
172
+ clearActiveSession: typeof clearActiveSession;
173
+ persistActiveSession: typeof persistActiveSession;
174
+ adoptSession: typeof adoptSession;
175
+ ACTIVE_SESSION_MAX_AGE_MS: number;
176
+ RESUME_MAX_IDLE_MS: number;
177
+ ACTIVE_SESSION_STORAGE_KEY: string;
130
178
  };
131
179
 
132
180
  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;
@@ -104,29 +105,76 @@ interface RecorderStore {
104
105
  } | null;
105
106
  muteToastShown: boolean;
106
107
  muteToastTimers: number[];
108
+ resumeToastTimers: number[];
107
109
  notes: InFlightNote[];
108
110
  notesPopoverOpen: boolean;
109
111
  notePopoverAtMs: number | null;
110
112
  endNote: string;
111
113
  finishFlowRan: boolean;
114
+ sessionClosed: boolean;
115
+ onSessionClosed: (() => void) | null;
116
+ paused: boolean;
117
+ resumed: boolean;
118
+ sdkSessionId: string | null;
112
119
  replayOffsetAtStartMs: number | null;
113
120
  }
114
- declare function getTestSlug(queryParam: string): string | null;
121
+ interface ActiveSessionState {
122
+ slug: string;
123
+ sessionId: string;
124
+ nextChunkIndex: number;
125
+ startedAt: number;
126
+ status: 'active' | 'paused';
127
+ sdkSessionId?: string;
128
+ pausedAt?: number;
129
+ }
130
+ type AdoptResult = {
131
+ kind: 'ok';
132
+ sessionId: string;
133
+ clientId: string;
134
+ tasks: UserTestTask[];
135
+ } | {
136
+ kind: 'closed';
137
+ } | {
138
+ kind: 'error';
139
+ };
140
+
115
141
  declare function isMediaRecorderSupported(): boolean;
116
142
  declare function pickMimeType(): string | undefined;
117
- declare function micChipState(store: RecorderStore): 'recording' | 'muted' | 'none' | 'connecting' | 'silent' | 'inactive';
143
+ type ChunkResponseClass = 'ok' | 'closed' | 'retry' | 'fatal';
144
+ declare function classifyChunkResponse(status: number, body: unknown): ChunkResponseClass;
145
+ declare function handleSessionClosed(store: RecorderStore): void;
118
146
  declare function rmsDbFromSamples(samples: Float32Array | number[]): number;
119
147
  declare function isStreamSilent(input: number | Float32Array | number[]): boolean;
148
+
149
+ declare function parseActiveSession(raw: unknown): ActiveSessionState | null;
150
+ declare function readActiveSession(): ActiveSessionState | null;
151
+ declare function clearActiveSession(): void;
152
+ declare function persistActiveSession(store: RecorderStore, status: 'active' | 'paused'): void;
153
+ declare function getTestSlug(queryParam: string): string | null;
154
+ declare function adoptSession(apiUrl: string, sessionId: string): Promise<AdoptResult>;
155
+
156
+ declare function micChipState(store: RecorderStore): 'recording' | 'muted' | 'none' | 'connecting' | 'silent' | 'inactive';
157
+
120
158
  declare function userTest(options?: UserTestOptions): UseroPlugin;
121
159
  declare const __test__: {
122
160
  getTestSlug: typeof getTestSlug;
123
161
  pickMimeType: typeof pickMimeType;
124
162
  isMediaRecorderSupported: typeof isMediaRecorderSupported;
163
+ classifyChunkResponse: typeof classifyChunkResponse;
164
+ handleSessionClosed: typeof handleSessionClosed;
125
165
  micChipState: typeof micChipState;
126
166
  isStreamSilent: typeof isStreamSilent;
127
167
  rmsDbFromSamples: typeof rmsDbFromSamples;
128
168
  SILENCE_RMS_DB_THRESHOLD: number;
129
169
  SILENCE_FLOOR_DB: number;
170
+ parseActiveSession: typeof parseActiveSession;
171
+ readActiveSession: typeof readActiveSession;
172
+ clearActiveSession: typeof clearActiveSession;
173
+ persistActiveSession: typeof persistActiveSession;
174
+ adoptSession: typeof adoptSession;
175
+ ACTIVE_SESSION_MAX_AGE_MS: number;
176
+ RESUME_MAX_IDLE_MS: number;
177
+ ACTIVE_SESSION_STORAGE_KEY: string;
130
178
  };
131
179
 
132
180
  export { type UserTestOptions, __test__, isStreamSilent, rmsDbFromSamples, userTest };