@logspace/sdk 1.0.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.
- package/index.d.ts +6 -0
- package/logspace.esm.js +15848 -0
- package/logspace.esm.js.map +1 -0
- package/logspace.iife.js +2 -0
- package/logspace.iife.js.map +1 -0
- package/logspace.umd.js +2 -0
- package/logspace.umd.js.map +1 -0
- package/package.json +44 -0
- package/sdk/capture/base.d.ts +45 -0
- package/sdk/capture/console.d.ts +5 -0
- package/sdk/capture/errors.d.ts +5 -0
- package/sdk/capture/index.d.ts +16 -0
- package/sdk/capture/interactions.d.ts +5 -0
- package/sdk/capture/network.d.ts +5 -0
- package/sdk/capture/performance.d.ts +5 -0
- package/sdk/capture/resources.d.ts +5 -0
- package/sdk/capture/rrweb.d.ts +101 -0
- package/sdk/capture/spa-navigation.d.ts +5 -0
- package/sdk/capture/sse.d.ts +5 -0
- package/sdk/capture/storage.d.ts +5 -0
- package/sdk/capture/websocket.d.ts +5 -0
- package/sdk/core/console-api.d.ts +26 -0
- package/sdk/core/multi-tab.d.ts +176 -0
- package/sdk/index.d.ts +69 -0
- package/sdk/storage/indexed-db.d.ts +72 -0
- package/sdk/types.d.ts +411 -0
- package/shared/browser-detection.d.ts +38 -0
- package/shared/displayMediaCapture.d.ts +23 -0
- package/shared/export.d.ts +15 -0
- package/shared/log-optimizer.d.ts +47 -0
- package/shared/types.d.ts +356 -0
- package/shared/utils.d.ts +45 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
export interface RecordingSession {
|
|
2
|
+
id: string;
|
|
3
|
+
startTime: number;
|
|
4
|
+
endTime?: number;
|
|
5
|
+
duration: number;
|
|
6
|
+
tabs: TabRecording[];
|
|
7
|
+
settings: RecordingSettings;
|
|
8
|
+
status: 'active' | 'paused' | 'stopped';
|
|
9
|
+
totalSize: number;
|
|
10
|
+
stats: SessionStats;
|
|
11
|
+
cspBlocked?: boolean;
|
|
12
|
+
title?: string;
|
|
13
|
+
comment?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface TabRecording {
|
|
16
|
+
tabId: number;
|
|
17
|
+
url: string;
|
|
18
|
+
title: string;
|
|
19
|
+
logs?: LogEntry[];
|
|
20
|
+
interactions?: InteractionLog[];
|
|
21
|
+
pageMetrics: PageMetrics;
|
|
22
|
+
startTime: number;
|
|
23
|
+
endTime?: number;
|
|
24
|
+
}
|
|
25
|
+
export type LogType = 'network' | 'console' | 'error' | 'interaction' | 'performance' | 'annotation' | 'websocket' | 'sse' | 'storage';
|
|
26
|
+
export interface LogEntry {
|
|
27
|
+
id: string;
|
|
28
|
+
timestamp: number;
|
|
29
|
+
type: LogType;
|
|
30
|
+
tabId: number;
|
|
31
|
+
tabUrl: string;
|
|
32
|
+
data: any;
|
|
33
|
+
severity?: 'info' | 'warn' | 'error';
|
|
34
|
+
}
|
|
35
|
+
export interface NetworkLog extends LogEntry {
|
|
36
|
+
type: 'network';
|
|
37
|
+
data: {
|
|
38
|
+
method: string;
|
|
39
|
+
url: string;
|
|
40
|
+
status: number;
|
|
41
|
+
statusText?: string;
|
|
42
|
+
requestHeaders: Record<string, string>;
|
|
43
|
+
responseHeaders: Record<string, string>;
|
|
44
|
+
requestBody?: string;
|
|
45
|
+
responseBody?: string;
|
|
46
|
+
contentType?: string;
|
|
47
|
+
contentLength?: number;
|
|
48
|
+
duration: number;
|
|
49
|
+
timestamp: number;
|
|
50
|
+
initiator?: string;
|
|
51
|
+
error?: string;
|
|
52
|
+
isWebSocketUpgrade?: boolean;
|
|
53
|
+
isSSEStream?: boolean;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export interface ConsoleLog extends LogEntry {
|
|
57
|
+
type: 'console';
|
|
58
|
+
data: {
|
|
59
|
+
level: 'log' | 'info' | 'warn' | 'error' | 'debug';
|
|
60
|
+
args: string[];
|
|
61
|
+
stackTrace?: string;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export interface ErrorLog extends LogEntry {
|
|
65
|
+
type: 'error';
|
|
66
|
+
data: {
|
|
67
|
+
message: string;
|
|
68
|
+
stack: string;
|
|
69
|
+
context: Record<string, any>;
|
|
70
|
+
isUncaught: boolean;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export interface InteractionLog extends LogEntry {
|
|
74
|
+
type: 'interaction';
|
|
75
|
+
data: {
|
|
76
|
+
eventType: 'click' | 'input' | 'change' | 'scroll' | 'submit';
|
|
77
|
+
element: {
|
|
78
|
+
selector: string;
|
|
79
|
+
tagName: string;
|
|
80
|
+
text?: string;
|
|
81
|
+
};
|
|
82
|
+
coordinates?: {
|
|
83
|
+
x: number;
|
|
84
|
+
y: number;
|
|
85
|
+
};
|
|
86
|
+
value?: string;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export interface PerformanceLog extends LogEntry {
|
|
90
|
+
type: 'performance';
|
|
91
|
+
data: {
|
|
92
|
+
metric: string;
|
|
93
|
+
value?: number;
|
|
94
|
+
rating?: 'good' | 'needs-improvement' | 'poor';
|
|
95
|
+
vitals?: {
|
|
96
|
+
LCP?: {
|
|
97
|
+
value: number;
|
|
98
|
+
rating: string;
|
|
99
|
+
};
|
|
100
|
+
FID?: {
|
|
101
|
+
value: number;
|
|
102
|
+
rating: string;
|
|
103
|
+
};
|
|
104
|
+
CLS?: {
|
|
105
|
+
value: number;
|
|
106
|
+
rating: string;
|
|
107
|
+
};
|
|
108
|
+
FCP?: {
|
|
109
|
+
value: number;
|
|
110
|
+
rating: string;
|
|
111
|
+
};
|
|
112
|
+
TTFB?: {
|
|
113
|
+
value: number;
|
|
114
|
+
rating: string;
|
|
115
|
+
};
|
|
116
|
+
INP?: {
|
|
117
|
+
value: number;
|
|
118
|
+
rating: string;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
timing?: {
|
|
122
|
+
ttfb?: number;
|
|
123
|
+
dnsLookup?: number;
|
|
124
|
+
tcpConnection?: number;
|
|
125
|
+
domContentLoaded?: number;
|
|
126
|
+
pageLoad?: number;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export type AnnotationType = 'success' | 'issue' | 'important' | 'note' | 'draw';
|
|
131
|
+
export interface AnnotationLog extends LogEntry {
|
|
132
|
+
type: 'annotation';
|
|
133
|
+
data: {
|
|
134
|
+
text: string;
|
|
135
|
+
annotationType: AnnotationType;
|
|
136
|
+
coordinates?: {
|
|
137
|
+
x: number;
|
|
138
|
+
y: number;
|
|
139
|
+
};
|
|
140
|
+
drawing?: {
|
|
141
|
+
strokes: Array<{
|
|
142
|
+
points: Array<{
|
|
143
|
+
x: number;
|
|
144
|
+
y: number;
|
|
145
|
+
}>;
|
|
146
|
+
color: string;
|
|
147
|
+
width: number;
|
|
148
|
+
}>;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
export interface DrawingAnnotation {
|
|
153
|
+
id: string;
|
|
154
|
+
sessionId: string;
|
|
155
|
+
timestamp: number;
|
|
156
|
+
strokes: Array<{
|
|
157
|
+
points: Array<{
|
|
158
|
+
x: number;
|
|
159
|
+
y: number;
|
|
160
|
+
}>;
|
|
161
|
+
color: string;
|
|
162
|
+
width: number;
|
|
163
|
+
}>;
|
|
164
|
+
}
|
|
165
|
+
export interface WebSocketLog extends LogEntry {
|
|
166
|
+
type: 'websocket';
|
|
167
|
+
data: {
|
|
168
|
+
url: string;
|
|
169
|
+
event: 'open' | 'message' | 'error' | 'close';
|
|
170
|
+
direction?: 'sent' | 'received';
|
|
171
|
+
message?: string;
|
|
172
|
+
messageSize?: number;
|
|
173
|
+
isBinary?: boolean;
|
|
174
|
+
code?: number;
|
|
175
|
+
reason?: string;
|
|
176
|
+
readyState?: number;
|
|
177
|
+
timestamp: number;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
export interface SSELog extends LogEntry {
|
|
181
|
+
type: 'sse';
|
|
182
|
+
data: {
|
|
183
|
+
url: string;
|
|
184
|
+
event: 'open' | 'message' | 'error';
|
|
185
|
+
eventType?: string;
|
|
186
|
+
message?: string;
|
|
187
|
+
messageSize?: number;
|
|
188
|
+
lastEventId?: string;
|
|
189
|
+
readyState?: number;
|
|
190
|
+
timestamp: number;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
export interface StorageLog extends LogEntry {
|
|
194
|
+
type: 'storage';
|
|
195
|
+
data: {
|
|
196
|
+
storageType: 'localStorage' | 'sessionStorage' | 'indexedDB';
|
|
197
|
+
operation: 'setItem' | 'getItem' | 'removeItem' | 'clear';
|
|
198
|
+
key?: string;
|
|
199
|
+
value?: string;
|
|
200
|
+
oldValue?: string;
|
|
201
|
+
valueSize?: number;
|
|
202
|
+
dbName?: string;
|
|
203
|
+
storeName?: string;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
export type CaptureMode = 'auto' | 'fullscreen' | 'custom';
|
|
207
|
+
export type LogSeverity = 'log' | 'info' | 'warn' | 'error' | 'debug' | 'trace';
|
|
208
|
+
export interface RecordingSettings {
|
|
209
|
+
captureVideo: boolean;
|
|
210
|
+
captureMode: CaptureMode;
|
|
211
|
+
captureNetwork: boolean;
|
|
212
|
+
captureConsole: boolean;
|
|
213
|
+
captureStorage: boolean;
|
|
214
|
+
captureResources: boolean;
|
|
215
|
+
captureInteractions: boolean;
|
|
216
|
+
capturePerformance: boolean;
|
|
217
|
+
captureWebSocket: boolean;
|
|
218
|
+
captureSSE: boolean;
|
|
219
|
+
captureAnnotations: boolean;
|
|
220
|
+
showAnnotationButton: boolean;
|
|
221
|
+
annotationButtonPosition: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
222
|
+
showSpaceIndicator: boolean;
|
|
223
|
+
videoQuality: 'low' | 'medium' | 'high';
|
|
224
|
+
videoCodec: 'vp8' | 'vp9' | 'h264';
|
|
225
|
+
frameRate: number;
|
|
226
|
+
audioEnabled: boolean;
|
|
227
|
+
captureMicrophone: boolean;
|
|
228
|
+
captureSystemAudio: boolean;
|
|
229
|
+
captureWebcam: boolean;
|
|
230
|
+
webcamPosition: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
231
|
+
webcamSize: 'small' | 'medium' | 'large';
|
|
232
|
+
showCountdown: boolean;
|
|
233
|
+
excludeDomains: string[];
|
|
234
|
+
maskSensitiveData: boolean;
|
|
235
|
+
logLevels: LogSeverity[];
|
|
236
|
+
}
|
|
237
|
+
export declare const DEFAULT_SETTINGS: RecordingSettings;
|
|
238
|
+
export interface SessionStats {
|
|
239
|
+
logCount: number;
|
|
240
|
+
networkLogCount: number;
|
|
241
|
+
consoleLogCount: number;
|
|
242
|
+
errorCount: number;
|
|
243
|
+
storageLogCount: number;
|
|
244
|
+
interactionLogCount: number;
|
|
245
|
+
performanceLogCount: number;
|
|
246
|
+
annotationCount: number;
|
|
247
|
+
tabCount: number;
|
|
248
|
+
}
|
|
249
|
+
export interface PageMetrics {
|
|
250
|
+
loadTime: number;
|
|
251
|
+
domContentLoaded: number;
|
|
252
|
+
firstContentfulPaint?: number;
|
|
253
|
+
largestContentfulPaint?: number;
|
|
254
|
+
cumulativeLayoutShift?: number;
|
|
255
|
+
firstInputDelay?: number;
|
|
256
|
+
}
|
|
257
|
+
export interface TabContext {
|
|
258
|
+
tabId: number;
|
|
259
|
+
url: string;
|
|
260
|
+
title: string;
|
|
261
|
+
startTime: number;
|
|
262
|
+
endTime?: number;
|
|
263
|
+
}
|
|
264
|
+
export interface TimelineEvent {
|
|
265
|
+
timestamp: number;
|
|
266
|
+
type: 'tab_open' | 'tab_close' | 'navigation' | 'error' | 'interaction';
|
|
267
|
+
tabId: number;
|
|
268
|
+
description: string;
|
|
269
|
+
}
|
|
270
|
+
export interface AggregatedLogs {
|
|
271
|
+
sessionId: string;
|
|
272
|
+
logs: LogEntry[];
|
|
273
|
+
tabContexts: Map<number, TabContext>;
|
|
274
|
+
timelineEvents: TimelineEvent[];
|
|
275
|
+
}
|
|
276
|
+
export interface ExportData {
|
|
277
|
+
sessionId: string;
|
|
278
|
+
startTime: number;
|
|
279
|
+
duration: number;
|
|
280
|
+
tabs: ExportedTab[];
|
|
281
|
+
metadata: Record<string, any>;
|
|
282
|
+
}
|
|
283
|
+
export interface ExportedTab {
|
|
284
|
+
tabId: number;
|
|
285
|
+
url: string;
|
|
286
|
+
logs: LogEntry[];
|
|
287
|
+
interactions: InteractionLog[];
|
|
288
|
+
pageMetrics: PageMetrics;
|
|
289
|
+
}
|
|
290
|
+
export declare enum MessageType {
|
|
291
|
+
START_RECORDING = "START_RECORDING",
|
|
292
|
+
STOP_RECORDING = "STOP_RECORDING",
|
|
293
|
+
DISCARD_RECORDING = "DISCARD_RECORDING",
|
|
294
|
+
PAUSE_RECORDING = "PAUSE_RECORDING",
|
|
295
|
+
RESUME_RECORDING = "RESUME_RECORDING",
|
|
296
|
+
LOG_ENTRY = "LOG_ENTRY",
|
|
297
|
+
GET_STATUS = "GET_STATUS",
|
|
298
|
+
REGISTER_TAB = "REGISTER_TAB",
|
|
299
|
+
UNREGISTER_TAB = "UNREGISTER_TAB",
|
|
300
|
+
CSP_DETECTED = "CSP_DETECTED",// CSP blocked script injection
|
|
301
|
+
FETCH_ASSIGNED_LOGS = "FETCH_ASSIGNED_LOGS"
|
|
302
|
+
}
|
|
303
|
+
export interface Message {
|
|
304
|
+
type: MessageType;
|
|
305
|
+
payload?: any;
|
|
306
|
+
}
|
|
307
|
+
export interface StartRecordingMessage extends Message {
|
|
308
|
+
type: MessageType.START_RECORDING;
|
|
309
|
+
payload: {
|
|
310
|
+
settings: RecordingSettings;
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
export interface LogEntryMessage extends Message {
|
|
314
|
+
type: MessageType.LOG_ENTRY;
|
|
315
|
+
payload: {
|
|
316
|
+
sessionId: string;
|
|
317
|
+
tabId: number;
|
|
318
|
+
log: LogEntry;
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
export interface StatusResponse {
|
|
322
|
+
isRecording: boolean;
|
|
323
|
+
session: RecordingSession | null;
|
|
324
|
+
error?: string;
|
|
325
|
+
auth?: AuthState;
|
|
326
|
+
}
|
|
327
|
+
export interface CspDetectedMessage extends Message {
|
|
328
|
+
type: MessageType.CSP_DETECTED;
|
|
329
|
+
payload: {
|
|
330
|
+
url: string;
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
export interface AuthState {
|
|
334
|
+
authenticated: boolean;
|
|
335
|
+
serverUrl: string | null;
|
|
336
|
+
token?: string | null;
|
|
337
|
+
refreshToken?: string | null;
|
|
338
|
+
expiresAt?: number | null;
|
|
339
|
+
user?: {
|
|
340
|
+
id?: string;
|
|
341
|
+
email?: string;
|
|
342
|
+
name?: string;
|
|
343
|
+
} | null;
|
|
344
|
+
}
|
|
345
|
+
export interface AuthPollingState {
|
|
346
|
+
deviceCode: string;
|
|
347
|
+
serverUrl: string;
|
|
348
|
+
startTime: number;
|
|
349
|
+
expiresAt: number;
|
|
350
|
+
interval: number;
|
|
351
|
+
}
|
|
352
|
+
export declare enum AuthMessageType {
|
|
353
|
+
LOGIN_START = "LOGIN_START",
|
|
354
|
+
LOGOUT = "LOGOUT",
|
|
355
|
+
VALIDATE_AUTH = "VALIDATE_AUTH"
|
|
356
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { LogSeverity } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Generate a unique ID
|
|
4
|
+
*/
|
|
5
|
+
export declare function generateId(): string;
|
|
6
|
+
/**
|
|
7
|
+
* Format timestamp to readable string
|
|
8
|
+
*/
|
|
9
|
+
export declare function formatTimestamp(timestamp: number): string;
|
|
10
|
+
/**
|
|
11
|
+
* Format duration from milliseconds to readable string
|
|
12
|
+
*/
|
|
13
|
+
export declare function formatDuration(ms: number): string;
|
|
14
|
+
/**
|
|
15
|
+
* Format bytes to readable size
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatBytes(bytes: number): string;
|
|
18
|
+
/**
|
|
19
|
+
* Get CSS selector for an element
|
|
20
|
+
*/
|
|
21
|
+
export declare function getSelector(element: Element): string;
|
|
22
|
+
/**
|
|
23
|
+
* Safely serialize value to string
|
|
24
|
+
*/
|
|
25
|
+
export declare function safeStringify(value: any): string;
|
|
26
|
+
/**
|
|
27
|
+
* Mask sensitive data in strings for privacy protection
|
|
28
|
+
*/
|
|
29
|
+
export declare function maskSensitiveData(text: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Mask sensitive data in HTTP headers for privacy protection
|
|
32
|
+
*/
|
|
33
|
+
export declare function maskHeaders(headers: Record<string, string>): Record<string, string>;
|
|
34
|
+
/**
|
|
35
|
+
* Check if a URL matches any of the excluded domain patterns
|
|
36
|
+
* Supports regex patterns for flexible matching
|
|
37
|
+
*/
|
|
38
|
+
export declare function isUrlExcluded(url: string, excludePatterns: string[]): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Check if a log should be captured based on its severity level
|
|
41
|
+
* @param logSeverity The severity of the log
|
|
42
|
+
* @param enabledLevels Array of enabled log levels
|
|
43
|
+
* @returns true if log should be captured, false otherwise
|
|
44
|
+
*/
|
|
45
|
+
export declare function shouldCaptureBySeverity(logSeverity: LogSeverity | undefined, enabledLevels: LogSeverity[]): boolean;
|