@crashsense/types 0.1.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/dist/index.d.mts +354 -0
- package/dist/index.d.ts +354 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +44 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
type CrashCategory = 'runtime_error' | 'memory_issue' | 'event_loop_blocking' | 'framework_react' | 'framework_vue' | 'network_induced' | 'iframe_overload' | 'rendering' | 'mobile_device' | 'resource_exhaustion' | 'browser_compatibility';
|
|
2
|
+
type CrashSeverity = 'critical' | 'error' | 'warning' | 'info';
|
|
3
|
+
interface StackFrame {
|
|
4
|
+
filename: string;
|
|
5
|
+
function: string;
|
|
6
|
+
lineno: number;
|
|
7
|
+
colno: number;
|
|
8
|
+
inApp: boolean;
|
|
9
|
+
context?: string[];
|
|
10
|
+
}
|
|
11
|
+
type BreadcrumbType = 'click' | 'navigation' | 'network' | 'console' | 'state' | 'custom';
|
|
12
|
+
interface Breadcrumb {
|
|
13
|
+
type: BreadcrumbType;
|
|
14
|
+
timestamp: number;
|
|
15
|
+
message: string;
|
|
16
|
+
data?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
type MemoryTrend = 'stable' | 'growing' | 'shrinking' | 'spike';
|
|
19
|
+
interface MemoryState {
|
|
20
|
+
usedJSHeapSize: number | null;
|
|
21
|
+
totalJSHeapSize: number | null;
|
|
22
|
+
heapSizeLimit: number | null;
|
|
23
|
+
trend: MemoryTrend;
|
|
24
|
+
utilizationPercent: number | null;
|
|
25
|
+
}
|
|
26
|
+
interface CpuState {
|
|
27
|
+
longTasksLast30s: number;
|
|
28
|
+
avgLongTaskDuration: number;
|
|
29
|
+
maxLongTaskDuration: number;
|
|
30
|
+
estimatedBlockingTime: number;
|
|
31
|
+
}
|
|
32
|
+
interface EventLoopState {
|
|
33
|
+
isBlocked: boolean;
|
|
34
|
+
blockDuration: number | null;
|
|
35
|
+
fps: number;
|
|
36
|
+
}
|
|
37
|
+
interface NetworkState {
|
|
38
|
+
pendingRequests: number;
|
|
39
|
+
failedRequestsLast60s: number;
|
|
40
|
+
avgLatencyLast60s: number;
|
|
41
|
+
connectionType: string | null;
|
|
42
|
+
isOnline: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface IframeState {
|
|
45
|
+
totalCount: number;
|
|
46
|
+
addedLast60s: number;
|
|
47
|
+
removedLast60s: number;
|
|
48
|
+
origins: string[];
|
|
49
|
+
crossOriginCount: number;
|
|
50
|
+
}
|
|
51
|
+
interface SystemState {
|
|
52
|
+
memory: MemoryState;
|
|
53
|
+
cpu: CpuState;
|
|
54
|
+
eventLoop: EventLoopState;
|
|
55
|
+
network: NetworkState;
|
|
56
|
+
iframe?: IframeState;
|
|
57
|
+
}
|
|
58
|
+
interface DeviceInfo {
|
|
59
|
+
userAgent: string;
|
|
60
|
+
platform: string;
|
|
61
|
+
vendor: string;
|
|
62
|
+
deviceMemory: number | null;
|
|
63
|
+
hardwareConcurrency: number | null;
|
|
64
|
+
viewport: {
|
|
65
|
+
width: number;
|
|
66
|
+
height: number;
|
|
67
|
+
};
|
|
68
|
+
devicePixelRatio: number;
|
|
69
|
+
touchSupport: boolean;
|
|
70
|
+
colorScheme: 'light' | 'dark';
|
|
71
|
+
reducedMotion: boolean;
|
|
72
|
+
language: string;
|
|
73
|
+
timezone: string;
|
|
74
|
+
}
|
|
75
|
+
interface FrameworkContext {
|
|
76
|
+
name: 'react' | 'vue' | 'vanilla' | string;
|
|
77
|
+
version: string;
|
|
78
|
+
adapter: string;
|
|
79
|
+
componentTree?: string[];
|
|
80
|
+
currentRoute?: string;
|
|
81
|
+
storeState?: Record<string, unknown>;
|
|
82
|
+
lifecycleStage?: string;
|
|
83
|
+
renderCount?: number;
|
|
84
|
+
}
|
|
85
|
+
interface ContributingFactor {
|
|
86
|
+
factor: string;
|
|
87
|
+
weight: number;
|
|
88
|
+
evidence: string;
|
|
89
|
+
}
|
|
90
|
+
interface CrashEvent {
|
|
91
|
+
id: string;
|
|
92
|
+
fingerprint: string;
|
|
93
|
+
timestamp: number;
|
|
94
|
+
sessionId: string;
|
|
95
|
+
category: CrashCategory;
|
|
96
|
+
subcategory: string;
|
|
97
|
+
severity: CrashSeverity;
|
|
98
|
+
confidence: number;
|
|
99
|
+
error: {
|
|
100
|
+
type: string;
|
|
101
|
+
message: string;
|
|
102
|
+
stack: StackFrame[];
|
|
103
|
+
raw: string;
|
|
104
|
+
};
|
|
105
|
+
system: SystemState;
|
|
106
|
+
device: DeviceInfo;
|
|
107
|
+
framework: FrameworkContext;
|
|
108
|
+
breadcrumbs: Breadcrumb[];
|
|
109
|
+
contributingFactors: ContributingFactor[];
|
|
110
|
+
meta: CrashEventMeta;
|
|
111
|
+
}
|
|
112
|
+
interface CrashEventMeta {
|
|
113
|
+
appId: string;
|
|
114
|
+
environment: string;
|
|
115
|
+
release?: string;
|
|
116
|
+
userId?: string;
|
|
117
|
+
tags: Record<string, string>;
|
|
118
|
+
sdkVersion: string;
|
|
119
|
+
}
|
|
120
|
+
interface RawCrashEvent {
|
|
121
|
+
id: string;
|
|
122
|
+
timestamp: number;
|
|
123
|
+
sessionId: string;
|
|
124
|
+
error: {
|
|
125
|
+
type: string;
|
|
126
|
+
message: string;
|
|
127
|
+
stack: StackFrame[];
|
|
128
|
+
raw: string;
|
|
129
|
+
};
|
|
130
|
+
system: Partial<SystemState>;
|
|
131
|
+
device: DeviceInfo;
|
|
132
|
+
framework: Partial<FrameworkContext>;
|
|
133
|
+
breadcrumbs: Breadcrumb[];
|
|
134
|
+
meta: CrashEventMeta;
|
|
135
|
+
}
|
|
136
|
+
interface CrashSenseConfig {
|
|
137
|
+
appId: string;
|
|
138
|
+
environment?: string;
|
|
139
|
+
release?: string;
|
|
140
|
+
sampleRate?: number;
|
|
141
|
+
maxEventsPerMinute?: number;
|
|
142
|
+
enableMemoryMonitoring?: boolean;
|
|
143
|
+
enableLongTaskMonitoring?: boolean;
|
|
144
|
+
enableNetworkMonitoring?: boolean;
|
|
145
|
+
enableIframeTracking?: boolean;
|
|
146
|
+
enablePreCrashWarning?: boolean;
|
|
147
|
+
preCrashMemoryThreshold?: number;
|
|
148
|
+
piiScrubbing?: boolean;
|
|
149
|
+
debug?: boolean;
|
|
150
|
+
onCrash?: (report: CrashReport) => void;
|
|
151
|
+
}
|
|
152
|
+
interface ResolvedConfig {
|
|
153
|
+
appId: string;
|
|
154
|
+
environment: string;
|
|
155
|
+
release: string;
|
|
156
|
+
sampleRate: number;
|
|
157
|
+
maxEventsPerMinute: number;
|
|
158
|
+
enableMemoryMonitoring: boolean;
|
|
159
|
+
enableLongTaskMonitoring: boolean;
|
|
160
|
+
enableNetworkMonitoring: boolean;
|
|
161
|
+
enableIframeTracking: boolean;
|
|
162
|
+
enablePreCrashWarning: boolean;
|
|
163
|
+
preCrashMemoryThreshold: number;
|
|
164
|
+
piiScrubbing: boolean;
|
|
165
|
+
debug: boolean;
|
|
166
|
+
onCrash: ((report: CrashReport) => void) | null;
|
|
167
|
+
}
|
|
168
|
+
interface CrashSensePlugin {
|
|
169
|
+
name: string;
|
|
170
|
+
setup(core: CrashSenseCore): void;
|
|
171
|
+
teardown(): void;
|
|
172
|
+
onCrashEvent?(event: CrashEvent): CrashEvent | null;
|
|
173
|
+
}
|
|
174
|
+
interface CrashSenseCore {
|
|
175
|
+
readonly config: ResolvedConfig;
|
|
176
|
+
readonly sessionId: string;
|
|
177
|
+
use(plugin: CrashSensePlugin): void;
|
|
178
|
+
captureException(error: unknown, context?: Record<string, unknown>): void;
|
|
179
|
+
captureMessage(message: string, severity?: CrashSeverity): void;
|
|
180
|
+
addBreadcrumb(breadcrumb: Omit<Breadcrumb, 'timestamp'>): void;
|
|
181
|
+
setUser(user: {
|
|
182
|
+
id: string;
|
|
183
|
+
[key: string]: unknown;
|
|
184
|
+
}): void;
|
|
185
|
+
setContext(key: string, value: Record<string, unknown>): void;
|
|
186
|
+
getSystemState(): SystemState;
|
|
187
|
+
getDeviceInfo(): DeviceInfo;
|
|
188
|
+
destroy(): void;
|
|
189
|
+
_reportRawEvent(event: RawCrashEvent): void;
|
|
190
|
+
_getEventBus(): EventBus;
|
|
191
|
+
}
|
|
192
|
+
type EventBusEventMap = {
|
|
193
|
+
'error': {
|
|
194
|
+
error: Error;
|
|
195
|
+
timestamp: number;
|
|
196
|
+
};
|
|
197
|
+
'unhandled_rejection': {
|
|
198
|
+
reason: unknown;
|
|
199
|
+
timestamp: number;
|
|
200
|
+
};
|
|
201
|
+
'memory_warning': {
|
|
202
|
+
utilization: number;
|
|
203
|
+
trend: MemoryTrend;
|
|
204
|
+
timestamp: number;
|
|
205
|
+
};
|
|
206
|
+
'long_task': {
|
|
207
|
+
duration: number;
|
|
208
|
+
startTime: number;
|
|
209
|
+
timestamp: number;
|
|
210
|
+
};
|
|
211
|
+
'network_failure': {
|
|
212
|
+
url: string;
|
|
213
|
+
status: number;
|
|
214
|
+
error: string;
|
|
215
|
+
timestamp: number;
|
|
216
|
+
};
|
|
217
|
+
'crash_detected': {
|
|
218
|
+
event: CrashEvent;
|
|
219
|
+
};
|
|
220
|
+
'iframe_added': {
|
|
221
|
+
src: string;
|
|
222
|
+
origin: string;
|
|
223
|
+
crossOrigin: boolean;
|
|
224
|
+
totalCount: number;
|
|
225
|
+
timestamp: number;
|
|
226
|
+
};
|
|
227
|
+
'iframe_removed': {
|
|
228
|
+
src: string;
|
|
229
|
+
totalCount: number;
|
|
230
|
+
timestamp: number;
|
|
231
|
+
};
|
|
232
|
+
'pre_crash_warning': {
|
|
233
|
+
level: PreCrashLevel;
|
|
234
|
+
memoryUtilization: number | null;
|
|
235
|
+
iframeCount: number;
|
|
236
|
+
reason: string;
|
|
237
|
+
timestamp: number;
|
|
238
|
+
};
|
|
239
|
+
'breadcrumb': Breadcrumb;
|
|
240
|
+
};
|
|
241
|
+
type PreCrashLevel = 'elevated' | 'critical' | 'imminent';
|
|
242
|
+
interface EventBus {
|
|
243
|
+
on<K extends keyof EventBusEventMap>(event: K, handler: (data: EventBusEventMap[K]) => void): void;
|
|
244
|
+
off<K extends keyof EventBusEventMap>(event: K, handler: (data: EventBusEventMap[K]) => void): void;
|
|
245
|
+
emit<K extends keyof EventBusEventMap>(event: K, data: EventBusEventMap[K]): void;
|
|
246
|
+
}
|
|
247
|
+
interface CrashReport {
|
|
248
|
+
event: CrashEvent;
|
|
249
|
+
analysis: CrashAnalysis | null;
|
|
250
|
+
timestamp: number;
|
|
251
|
+
}
|
|
252
|
+
interface CrashAnalysis {
|
|
253
|
+
rootCause: string;
|
|
254
|
+
explanation: string;
|
|
255
|
+
fix: {
|
|
256
|
+
description: string;
|
|
257
|
+
code: string;
|
|
258
|
+
filename: string;
|
|
259
|
+
} | null;
|
|
260
|
+
prevention: string[];
|
|
261
|
+
confidence: number;
|
|
262
|
+
alternativeCauses: Array<{
|
|
263
|
+
cause: string;
|
|
264
|
+
likelihood: number;
|
|
265
|
+
}>;
|
|
266
|
+
source: 'heuristic' | 'ai' | 'hybrid';
|
|
267
|
+
}
|
|
268
|
+
interface AIConfig {
|
|
269
|
+
endpoint: string;
|
|
270
|
+
apiKey: string;
|
|
271
|
+
model?: string;
|
|
272
|
+
maxTokens?: number;
|
|
273
|
+
temperature?: number;
|
|
274
|
+
timeout?: number;
|
|
275
|
+
retries?: number;
|
|
276
|
+
provider?: 'openai' | 'anthropic' | 'google' | 'custom';
|
|
277
|
+
}
|
|
278
|
+
interface AIPayload {
|
|
279
|
+
crash_summary: {
|
|
280
|
+
category: CrashCategory;
|
|
281
|
+
subcategory: string;
|
|
282
|
+
heuristic_confidence: number;
|
|
283
|
+
severity: CrashSeverity;
|
|
284
|
+
};
|
|
285
|
+
error: {
|
|
286
|
+
type: string;
|
|
287
|
+
message: string;
|
|
288
|
+
stack_top_5: string[];
|
|
289
|
+
user_code_frames: string[];
|
|
290
|
+
};
|
|
291
|
+
system_state: {
|
|
292
|
+
memory_utilization: string;
|
|
293
|
+
memory_trend: MemoryTrend;
|
|
294
|
+
long_tasks_last_30s: number;
|
|
295
|
+
fps_at_crash: number;
|
|
296
|
+
pending_network_requests: number;
|
|
297
|
+
failed_requests_last_60s: number;
|
|
298
|
+
};
|
|
299
|
+
device: {
|
|
300
|
+
platform: string;
|
|
301
|
+
memory: string;
|
|
302
|
+
viewport: string;
|
|
303
|
+
connection: string;
|
|
304
|
+
};
|
|
305
|
+
framework: {
|
|
306
|
+
name: string;
|
|
307
|
+
version: string;
|
|
308
|
+
lifecycle_stage: string;
|
|
309
|
+
component_path: string[];
|
|
310
|
+
render_count_since_nav: number;
|
|
311
|
+
};
|
|
312
|
+
breadcrumbs_last_5: Array<{
|
|
313
|
+
type: BreadcrumbType;
|
|
314
|
+
message: string;
|
|
315
|
+
time: string;
|
|
316
|
+
}>;
|
|
317
|
+
contributing_factors: Array<{
|
|
318
|
+
factor: string;
|
|
319
|
+
weight: number;
|
|
320
|
+
evidence: string;
|
|
321
|
+
}>;
|
|
322
|
+
}
|
|
323
|
+
interface AIResponse {
|
|
324
|
+
rootCause: string;
|
|
325
|
+
explanation: string;
|
|
326
|
+
fix: {
|
|
327
|
+
description: string;
|
|
328
|
+
code: string;
|
|
329
|
+
filename: string;
|
|
330
|
+
};
|
|
331
|
+
prevention: string[];
|
|
332
|
+
confidence: number;
|
|
333
|
+
alternativeCauses: Array<{
|
|
334
|
+
cause: string;
|
|
335
|
+
likelihood: number;
|
|
336
|
+
}>;
|
|
337
|
+
}
|
|
338
|
+
interface NetworkRequest {
|
|
339
|
+
url: string;
|
|
340
|
+
method: string;
|
|
341
|
+
status: number;
|
|
342
|
+
duration: number;
|
|
343
|
+
startTime: number;
|
|
344
|
+
error: string | null;
|
|
345
|
+
responseSize: number | null;
|
|
346
|
+
}
|
|
347
|
+
interface ClassificationResult {
|
|
348
|
+
category: CrashCategory;
|
|
349
|
+
subcategory: string;
|
|
350
|
+
confidence: number;
|
|
351
|
+
contributingFactors: ContributingFactor[];
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export type { AIConfig, AIPayload, AIResponse, Breadcrumb, BreadcrumbType, ClassificationResult, ContributingFactor, CpuState, CrashAnalysis, CrashCategory, CrashEvent, CrashEventMeta, CrashReport, CrashSenseConfig, CrashSenseCore, CrashSensePlugin, CrashSeverity, DeviceInfo, EventBus, EventBusEventMap, EventLoopState, FrameworkContext, IframeState, MemoryState, MemoryTrend, NetworkRequest, NetworkState, PreCrashLevel, RawCrashEvent, ResolvedConfig, StackFrame, SystemState };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
type CrashCategory = 'runtime_error' | 'memory_issue' | 'event_loop_blocking' | 'framework_react' | 'framework_vue' | 'network_induced' | 'iframe_overload' | 'rendering' | 'mobile_device' | 'resource_exhaustion' | 'browser_compatibility';
|
|
2
|
+
type CrashSeverity = 'critical' | 'error' | 'warning' | 'info';
|
|
3
|
+
interface StackFrame {
|
|
4
|
+
filename: string;
|
|
5
|
+
function: string;
|
|
6
|
+
lineno: number;
|
|
7
|
+
colno: number;
|
|
8
|
+
inApp: boolean;
|
|
9
|
+
context?: string[];
|
|
10
|
+
}
|
|
11
|
+
type BreadcrumbType = 'click' | 'navigation' | 'network' | 'console' | 'state' | 'custom';
|
|
12
|
+
interface Breadcrumb {
|
|
13
|
+
type: BreadcrumbType;
|
|
14
|
+
timestamp: number;
|
|
15
|
+
message: string;
|
|
16
|
+
data?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
type MemoryTrend = 'stable' | 'growing' | 'shrinking' | 'spike';
|
|
19
|
+
interface MemoryState {
|
|
20
|
+
usedJSHeapSize: number | null;
|
|
21
|
+
totalJSHeapSize: number | null;
|
|
22
|
+
heapSizeLimit: number | null;
|
|
23
|
+
trend: MemoryTrend;
|
|
24
|
+
utilizationPercent: number | null;
|
|
25
|
+
}
|
|
26
|
+
interface CpuState {
|
|
27
|
+
longTasksLast30s: number;
|
|
28
|
+
avgLongTaskDuration: number;
|
|
29
|
+
maxLongTaskDuration: number;
|
|
30
|
+
estimatedBlockingTime: number;
|
|
31
|
+
}
|
|
32
|
+
interface EventLoopState {
|
|
33
|
+
isBlocked: boolean;
|
|
34
|
+
blockDuration: number | null;
|
|
35
|
+
fps: number;
|
|
36
|
+
}
|
|
37
|
+
interface NetworkState {
|
|
38
|
+
pendingRequests: number;
|
|
39
|
+
failedRequestsLast60s: number;
|
|
40
|
+
avgLatencyLast60s: number;
|
|
41
|
+
connectionType: string | null;
|
|
42
|
+
isOnline: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface IframeState {
|
|
45
|
+
totalCount: number;
|
|
46
|
+
addedLast60s: number;
|
|
47
|
+
removedLast60s: number;
|
|
48
|
+
origins: string[];
|
|
49
|
+
crossOriginCount: number;
|
|
50
|
+
}
|
|
51
|
+
interface SystemState {
|
|
52
|
+
memory: MemoryState;
|
|
53
|
+
cpu: CpuState;
|
|
54
|
+
eventLoop: EventLoopState;
|
|
55
|
+
network: NetworkState;
|
|
56
|
+
iframe?: IframeState;
|
|
57
|
+
}
|
|
58
|
+
interface DeviceInfo {
|
|
59
|
+
userAgent: string;
|
|
60
|
+
platform: string;
|
|
61
|
+
vendor: string;
|
|
62
|
+
deviceMemory: number | null;
|
|
63
|
+
hardwareConcurrency: number | null;
|
|
64
|
+
viewport: {
|
|
65
|
+
width: number;
|
|
66
|
+
height: number;
|
|
67
|
+
};
|
|
68
|
+
devicePixelRatio: number;
|
|
69
|
+
touchSupport: boolean;
|
|
70
|
+
colorScheme: 'light' | 'dark';
|
|
71
|
+
reducedMotion: boolean;
|
|
72
|
+
language: string;
|
|
73
|
+
timezone: string;
|
|
74
|
+
}
|
|
75
|
+
interface FrameworkContext {
|
|
76
|
+
name: 'react' | 'vue' | 'vanilla' | string;
|
|
77
|
+
version: string;
|
|
78
|
+
adapter: string;
|
|
79
|
+
componentTree?: string[];
|
|
80
|
+
currentRoute?: string;
|
|
81
|
+
storeState?: Record<string, unknown>;
|
|
82
|
+
lifecycleStage?: string;
|
|
83
|
+
renderCount?: number;
|
|
84
|
+
}
|
|
85
|
+
interface ContributingFactor {
|
|
86
|
+
factor: string;
|
|
87
|
+
weight: number;
|
|
88
|
+
evidence: string;
|
|
89
|
+
}
|
|
90
|
+
interface CrashEvent {
|
|
91
|
+
id: string;
|
|
92
|
+
fingerprint: string;
|
|
93
|
+
timestamp: number;
|
|
94
|
+
sessionId: string;
|
|
95
|
+
category: CrashCategory;
|
|
96
|
+
subcategory: string;
|
|
97
|
+
severity: CrashSeverity;
|
|
98
|
+
confidence: number;
|
|
99
|
+
error: {
|
|
100
|
+
type: string;
|
|
101
|
+
message: string;
|
|
102
|
+
stack: StackFrame[];
|
|
103
|
+
raw: string;
|
|
104
|
+
};
|
|
105
|
+
system: SystemState;
|
|
106
|
+
device: DeviceInfo;
|
|
107
|
+
framework: FrameworkContext;
|
|
108
|
+
breadcrumbs: Breadcrumb[];
|
|
109
|
+
contributingFactors: ContributingFactor[];
|
|
110
|
+
meta: CrashEventMeta;
|
|
111
|
+
}
|
|
112
|
+
interface CrashEventMeta {
|
|
113
|
+
appId: string;
|
|
114
|
+
environment: string;
|
|
115
|
+
release?: string;
|
|
116
|
+
userId?: string;
|
|
117
|
+
tags: Record<string, string>;
|
|
118
|
+
sdkVersion: string;
|
|
119
|
+
}
|
|
120
|
+
interface RawCrashEvent {
|
|
121
|
+
id: string;
|
|
122
|
+
timestamp: number;
|
|
123
|
+
sessionId: string;
|
|
124
|
+
error: {
|
|
125
|
+
type: string;
|
|
126
|
+
message: string;
|
|
127
|
+
stack: StackFrame[];
|
|
128
|
+
raw: string;
|
|
129
|
+
};
|
|
130
|
+
system: Partial<SystemState>;
|
|
131
|
+
device: DeviceInfo;
|
|
132
|
+
framework: Partial<FrameworkContext>;
|
|
133
|
+
breadcrumbs: Breadcrumb[];
|
|
134
|
+
meta: CrashEventMeta;
|
|
135
|
+
}
|
|
136
|
+
interface CrashSenseConfig {
|
|
137
|
+
appId: string;
|
|
138
|
+
environment?: string;
|
|
139
|
+
release?: string;
|
|
140
|
+
sampleRate?: number;
|
|
141
|
+
maxEventsPerMinute?: number;
|
|
142
|
+
enableMemoryMonitoring?: boolean;
|
|
143
|
+
enableLongTaskMonitoring?: boolean;
|
|
144
|
+
enableNetworkMonitoring?: boolean;
|
|
145
|
+
enableIframeTracking?: boolean;
|
|
146
|
+
enablePreCrashWarning?: boolean;
|
|
147
|
+
preCrashMemoryThreshold?: number;
|
|
148
|
+
piiScrubbing?: boolean;
|
|
149
|
+
debug?: boolean;
|
|
150
|
+
onCrash?: (report: CrashReport) => void;
|
|
151
|
+
}
|
|
152
|
+
interface ResolvedConfig {
|
|
153
|
+
appId: string;
|
|
154
|
+
environment: string;
|
|
155
|
+
release: string;
|
|
156
|
+
sampleRate: number;
|
|
157
|
+
maxEventsPerMinute: number;
|
|
158
|
+
enableMemoryMonitoring: boolean;
|
|
159
|
+
enableLongTaskMonitoring: boolean;
|
|
160
|
+
enableNetworkMonitoring: boolean;
|
|
161
|
+
enableIframeTracking: boolean;
|
|
162
|
+
enablePreCrashWarning: boolean;
|
|
163
|
+
preCrashMemoryThreshold: number;
|
|
164
|
+
piiScrubbing: boolean;
|
|
165
|
+
debug: boolean;
|
|
166
|
+
onCrash: ((report: CrashReport) => void) | null;
|
|
167
|
+
}
|
|
168
|
+
interface CrashSensePlugin {
|
|
169
|
+
name: string;
|
|
170
|
+
setup(core: CrashSenseCore): void;
|
|
171
|
+
teardown(): void;
|
|
172
|
+
onCrashEvent?(event: CrashEvent): CrashEvent | null;
|
|
173
|
+
}
|
|
174
|
+
interface CrashSenseCore {
|
|
175
|
+
readonly config: ResolvedConfig;
|
|
176
|
+
readonly sessionId: string;
|
|
177
|
+
use(plugin: CrashSensePlugin): void;
|
|
178
|
+
captureException(error: unknown, context?: Record<string, unknown>): void;
|
|
179
|
+
captureMessage(message: string, severity?: CrashSeverity): void;
|
|
180
|
+
addBreadcrumb(breadcrumb: Omit<Breadcrumb, 'timestamp'>): void;
|
|
181
|
+
setUser(user: {
|
|
182
|
+
id: string;
|
|
183
|
+
[key: string]: unknown;
|
|
184
|
+
}): void;
|
|
185
|
+
setContext(key: string, value: Record<string, unknown>): void;
|
|
186
|
+
getSystemState(): SystemState;
|
|
187
|
+
getDeviceInfo(): DeviceInfo;
|
|
188
|
+
destroy(): void;
|
|
189
|
+
_reportRawEvent(event: RawCrashEvent): void;
|
|
190
|
+
_getEventBus(): EventBus;
|
|
191
|
+
}
|
|
192
|
+
type EventBusEventMap = {
|
|
193
|
+
'error': {
|
|
194
|
+
error: Error;
|
|
195
|
+
timestamp: number;
|
|
196
|
+
};
|
|
197
|
+
'unhandled_rejection': {
|
|
198
|
+
reason: unknown;
|
|
199
|
+
timestamp: number;
|
|
200
|
+
};
|
|
201
|
+
'memory_warning': {
|
|
202
|
+
utilization: number;
|
|
203
|
+
trend: MemoryTrend;
|
|
204
|
+
timestamp: number;
|
|
205
|
+
};
|
|
206
|
+
'long_task': {
|
|
207
|
+
duration: number;
|
|
208
|
+
startTime: number;
|
|
209
|
+
timestamp: number;
|
|
210
|
+
};
|
|
211
|
+
'network_failure': {
|
|
212
|
+
url: string;
|
|
213
|
+
status: number;
|
|
214
|
+
error: string;
|
|
215
|
+
timestamp: number;
|
|
216
|
+
};
|
|
217
|
+
'crash_detected': {
|
|
218
|
+
event: CrashEvent;
|
|
219
|
+
};
|
|
220
|
+
'iframe_added': {
|
|
221
|
+
src: string;
|
|
222
|
+
origin: string;
|
|
223
|
+
crossOrigin: boolean;
|
|
224
|
+
totalCount: number;
|
|
225
|
+
timestamp: number;
|
|
226
|
+
};
|
|
227
|
+
'iframe_removed': {
|
|
228
|
+
src: string;
|
|
229
|
+
totalCount: number;
|
|
230
|
+
timestamp: number;
|
|
231
|
+
};
|
|
232
|
+
'pre_crash_warning': {
|
|
233
|
+
level: PreCrashLevel;
|
|
234
|
+
memoryUtilization: number | null;
|
|
235
|
+
iframeCount: number;
|
|
236
|
+
reason: string;
|
|
237
|
+
timestamp: number;
|
|
238
|
+
};
|
|
239
|
+
'breadcrumb': Breadcrumb;
|
|
240
|
+
};
|
|
241
|
+
type PreCrashLevel = 'elevated' | 'critical' | 'imminent';
|
|
242
|
+
interface EventBus {
|
|
243
|
+
on<K extends keyof EventBusEventMap>(event: K, handler: (data: EventBusEventMap[K]) => void): void;
|
|
244
|
+
off<K extends keyof EventBusEventMap>(event: K, handler: (data: EventBusEventMap[K]) => void): void;
|
|
245
|
+
emit<K extends keyof EventBusEventMap>(event: K, data: EventBusEventMap[K]): void;
|
|
246
|
+
}
|
|
247
|
+
interface CrashReport {
|
|
248
|
+
event: CrashEvent;
|
|
249
|
+
analysis: CrashAnalysis | null;
|
|
250
|
+
timestamp: number;
|
|
251
|
+
}
|
|
252
|
+
interface CrashAnalysis {
|
|
253
|
+
rootCause: string;
|
|
254
|
+
explanation: string;
|
|
255
|
+
fix: {
|
|
256
|
+
description: string;
|
|
257
|
+
code: string;
|
|
258
|
+
filename: string;
|
|
259
|
+
} | null;
|
|
260
|
+
prevention: string[];
|
|
261
|
+
confidence: number;
|
|
262
|
+
alternativeCauses: Array<{
|
|
263
|
+
cause: string;
|
|
264
|
+
likelihood: number;
|
|
265
|
+
}>;
|
|
266
|
+
source: 'heuristic' | 'ai' | 'hybrid';
|
|
267
|
+
}
|
|
268
|
+
interface AIConfig {
|
|
269
|
+
endpoint: string;
|
|
270
|
+
apiKey: string;
|
|
271
|
+
model?: string;
|
|
272
|
+
maxTokens?: number;
|
|
273
|
+
temperature?: number;
|
|
274
|
+
timeout?: number;
|
|
275
|
+
retries?: number;
|
|
276
|
+
provider?: 'openai' | 'anthropic' | 'google' | 'custom';
|
|
277
|
+
}
|
|
278
|
+
interface AIPayload {
|
|
279
|
+
crash_summary: {
|
|
280
|
+
category: CrashCategory;
|
|
281
|
+
subcategory: string;
|
|
282
|
+
heuristic_confidence: number;
|
|
283
|
+
severity: CrashSeverity;
|
|
284
|
+
};
|
|
285
|
+
error: {
|
|
286
|
+
type: string;
|
|
287
|
+
message: string;
|
|
288
|
+
stack_top_5: string[];
|
|
289
|
+
user_code_frames: string[];
|
|
290
|
+
};
|
|
291
|
+
system_state: {
|
|
292
|
+
memory_utilization: string;
|
|
293
|
+
memory_trend: MemoryTrend;
|
|
294
|
+
long_tasks_last_30s: number;
|
|
295
|
+
fps_at_crash: number;
|
|
296
|
+
pending_network_requests: number;
|
|
297
|
+
failed_requests_last_60s: number;
|
|
298
|
+
};
|
|
299
|
+
device: {
|
|
300
|
+
platform: string;
|
|
301
|
+
memory: string;
|
|
302
|
+
viewport: string;
|
|
303
|
+
connection: string;
|
|
304
|
+
};
|
|
305
|
+
framework: {
|
|
306
|
+
name: string;
|
|
307
|
+
version: string;
|
|
308
|
+
lifecycle_stage: string;
|
|
309
|
+
component_path: string[];
|
|
310
|
+
render_count_since_nav: number;
|
|
311
|
+
};
|
|
312
|
+
breadcrumbs_last_5: Array<{
|
|
313
|
+
type: BreadcrumbType;
|
|
314
|
+
message: string;
|
|
315
|
+
time: string;
|
|
316
|
+
}>;
|
|
317
|
+
contributing_factors: Array<{
|
|
318
|
+
factor: string;
|
|
319
|
+
weight: number;
|
|
320
|
+
evidence: string;
|
|
321
|
+
}>;
|
|
322
|
+
}
|
|
323
|
+
interface AIResponse {
|
|
324
|
+
rootCause: string;
|
|
325
|
+
explanation: string;
|
|
326
|
+
fix: {
|
|
327
|
+
description: string;
|
|
328
|
+
code: string;
|
|
329
|
+
filename: string;
|
|
330
|
+
};
|
|
331
|
+
prevention: string[];
|
|
332
|
+
confidence: number;
|
|
333
|
+
alternativeCauses: Array<{
|
|
334
|
+
cause: string;
|
|
335
|
+
likelihood: number;
|
|
336
|
+
}>;
|
|
337
|
+
}
|
|
338
|
+
interface NetworkRequest {
|
|
339
|
+
url: string;
|
|
340
|
+
method: string;
|
|
341
|
+
status: number;
|
|
342
|
+
duration: number;
|
|
343
|
+
startTime: number;
|
|
344
|
+
error: string | null;
|
|
345
|
+
responseSize: number | null;
|
|
346
|
+
}
|
|
347
|
+
interface ClassificationResult {
|
|
348
|
+
category: CrashCategory;
|
|
349
|
+
subcategory: string;
|
|
350
|
+
confidence: number;
|
|
351
|
+
contributingFactors: ContributingFactor[];
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export type { AIConfig, AIPayload, AIResponse, Breadcrumb, BreadcrumbType, ClassificationResult, ContributingFactor, CpuState, CrashAnalysis, CrashCategory, CrashEvent, CrashEventMeta, CrashReport, CrashSenseConfig, CrashSenseCore, CrashSensePlugin, CrashSeverity, DeviceInfo, EventBus, EventBusEventMap, EventLoopState, FrameworkContext, IframeState, MemoryState, MemoryTrend, NetworkRequest, NetworkState, PreCrashLevel, RawCrashEvent, ResolvedConfig, StackFrame, SystemState };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@crashsense/types",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared TypeScript type definitions for CrashSense",
|
|
5
|
+
"author": "hoainho <nhoxtvt@gmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/hoainho/crashsense.git",
|
|
10
|
+
"directory": "packages/types"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/hoainho/crashsense/tree/main/packages/types",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/hoainho/crashsense/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"crashsense",
|
|
18
|
+
"crash-detection",
|
|
19
|
+
"error-monitoring",
|
|
20
|
+
"typescript",
|
|
21
|
+
"types"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"module": "./dist/index.mjs",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.mjs",
|
|
33
|
+
"require": "./dist/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsup",
|
|
41
|
+
"dev": "tsup --watch"
|
|
42
|
+
},
|
|
43
|
+
"sideEffects": false
|
|
44
|
+
}
|