@uncaughtdev/core 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.
@@ -0,0 +1,164 @@
1
+ /** How captured events are delivered. */
2
+ type TransportMode = 'remote' | 'local' | 'console';
3
+ /** Severity levels mirroring syslog. */
4
+ type SeverityLevel = 'fatal' | 'error' | 'warning' | 'info' | 'debug';
5
+ /**
6
+ * Configuration object passed to `initUncaught()`.
7
+ */
8
+ interface UncaughtConfig {
9
+ /** Project key used for authentication with the remote endpoint. */
10
+ projectKey?: string;
11
+ /** Remote ingestion endpoint URL. Required when transport is 'remote'. */
12
+ endpoint?: string;
13
+ /** Deployment environment label (e.g. "production", "staging"). */
14
+ environment?: string;
15
+ /** Release / version identifier. */
16
+ release?: string;
17
+ /** When true, the SDK logs internal debug information to the console. */
18
+ debug?: boolean;
19
+ /** Master kill-switch. When false the SDK is completely inert. Defaults to true. */
20
+ enabled?: boolean;
21
+ /** Maximum number of breadcrumbs retained in the ring buffer. Defaults to 20. */
22
+ maxBreadcrumbs?: number;
23
+ /** Rate-limit: max events accepted per 60-second sliding window. Defaults to 30. */
24
+ maxEventsPerMinute?: number;
25
+ /**
26
+ * Lifecycle hook invoked just before an event is sent.
27
+ * Return `null` to discard the event.
28
+ */
29
+ beforeSend?: (event: UncaughtEvent) => UncaughtEvent | null;
30
+ /** Additional key patterns to redact during sanitization. */
31
+ sanitizeKeys?: string[];
32
+ /**
33
+ * An array of strings or RegExp patterns. If the error message matches any
34
+ * of these the event is silently dropped.
35
+ */
36
+ ignoreErrors?: Array<string | RegExp>;
37
+ /** Transport strategy. Defaults to 'local'. */
38
+ transport?: TransportMode;
39
+ /**
40
+ * Directory used by the local-file transport.
41
+ * Defaults to `process.cwd() + '/.uncaught'`.
42
+ */
43
+ localOutputDir?: string;
44
+ }
45
+ /** Structured representation of a captured error. */
46
+ interface ErrorInfo {
47
+ message: string;
48
+ type: string;
49
+ stack?: string;
50
+ componentStack?: string;
51
+ raw?: unknown;
52
+ }
53
+ /** Contextual HTTP request information attached to an event. */
54
+ interface RequestInfo {
55
+ method?: string;
56
+ url?: string;
57
+ headers?: Record<string, string>;
58
+ body?: unknown;
59
+ query?: Record<string, string>;
60
+ }
61
+ /** Information about a failed external operation (DB, auth, API, etc.). */
62
+ interface OperationInfo {
63
+ provider: string;
64
+ type: string;
65
+ method: string;
66
+ params?: Record<string, unknown>;
67
+ errorCode?: string;
68
+ errorDetails?: string;
69
+ }
70
+ /** User context attached to events. */
71
+ interface UserInfo {
72
+ id?: string;
73
+ email?: string;
74
+ username?: string;
75
+ [key: string]: unknown;
76
+ }
77
+ /** SDK metadata shipped with every event. */
78
+ interface SdkInfo {
79
+ name: string;
80
+ version: string;
81
+ }
82
+ /**
83
+ * The canonical event payload sent to transports.
84
+ */
85
+ interface UncaughtEvent {
86
+ eventId: string;
87
+ timestamp: string;
88
+ projectKey?: string;
89
+ level: SeverityLevel;
90
+ fingerprint: string;
91
+ error: ErrorInfo;
92
+ breadcrumbs: Breadcrumb[];
93
+ request?: RequestInfo;
94
+ operation?: OperationInfo;
95
+ environment?: EnvironmentInfo;
96
+ user?: UserInfo;
97
+ fixPrompt: string;
98
+ sdk: SdkInfo;
99
+ }
100
+ /** Breadcrumb categories. */
101
+ type BreadcrumbType = 'click' | 'navigation' | 'api_call' | 'db_query' | 'auth' | 'console' | 'custom';
102
+ /** A single breadcrumb entry. */
103
+ interface Breadcrumb {
104
+ type: BreadcrumbType;
105
+ category: string;
106
+ message: string;
107
+ timestamp: string;
108
+ data?: Record<string, unknown>;
109
+ level?: SeverityLevel;
110
+ }
111
+ /** Public interface of the breadcrumb ring-buffer store. */
112
+ interface BreadcrumbStore {
113
+ /** Append a breadcrumb (auto-timestamps). */
114
+ add(crumb: Omit<Breadcrumb, 'timestamp'>): void;
115
+ /** Return all stored breadcrumbs in chronological order (copies). */
116
+ getAll(): Breadcrumb[];
117
+ /** Return the most recent `n` breadcrumbs (copies). */
118
+ getLast(n: number): Breadcrumb[];
119
+ /** Empty the buffer. */
120
+ clear(): void;
121
+ }
122
+ /** Detected runtime / platform information. */
123
+ interface EnvironmentInfo {
124
+ framework?: string;
125
+ frameworkVersion?: string;
126
+ runtime?: string;
127
+ runtimeVersion?: string;
128
+ platform?: string;
129
+ os?: string;
130
+ browser?: string;
131
+ browserVersion?: string;
132
+ deviceType?: string;
133
+ locale?: string;
134
+ timezone?: string;
135
+ url?: string;
136
+ }
137
+ /** Options used to configure a remote transport. */
138
+ interface TransportOptions {
139
+ endpoint: string;
140
+ projectKey: string;
141
+ maxRetries?: number;
142
+ batchSize?: number;
143
+ flushIntervalMs?: number;
144
+ }
145
+ /** A transport implementation capable of delivering events. */
146
+ interface Transport {
147
+ send(event: UncaughtEvent): void;
148
+ flush(): Promise<void>;
149
+ }
150
+ type IssueStatus = 'open' | 'resolved' | 'ignored';
151
+ interface IssueEntry {
152
+ fingerprint: string;
153
+ title: string;
154
+ errorType: string;
155
+ count: number;
156
+ affectedUsers: string[];
157
+ firstSeen: string;
158
+ lastSeen: string;
159
+ status: IssueStatus;
160
+ fixPromptFile: string;
161
+ latestEventFile: string;
162
+ }
163
+
164
+ export type { Breadcrumb as B, EnvironmentInfo as E, IssueEntry as I, OperationInfo as O, RequestInfo as R, SeverityLevel as S, Transport as T, UncaughtEvent as U, UncaughtConfig as a, UserInfo as b, BreadcrumbStore as c, BreadcrumbType as d, ErrorInfo as e, IssueStatus as f, SdkInfo as g, TransportMode as h, TransportOptions as i };
@@ -0,0 +1,164 @@
1
+ /** How captured events are delivered. */
2
+ type TransportMode = 'remote' | 'local' | 'console';
3
+ /** Severity levels mirroring syslog. */
4
+ type SeverityLevel = 'fatal' | 'error' | 'warning' | 'info' | 'debug';
5
+ /**
6
+ * Configuration object passed to `initUncaught()`.
7
+ */
8
+ interface UncaughtConfig {
9
+ /** Project key used for authentication with the remote endpoint. */
10
+ projectKey?: string;
11
+ /** Remote ingestion endpoint URL. Required when transport is 'remote'. */
12
+ endpoint?: string;
13
+ /** Deployment environment label (e.g. "production", "staging"). */
14
+ environment?: string;
15
+ /** Release / version identifier. */
16
+ release?: string;
17
+ /** When true, the SDK logs internal debug information to the console. */
18
+ debug?: boolean;
19
+ /** Master kill-switch. When false the SDK is completely inert. Defaults to true. */
20
+ enabled?: boolean;
21
+ /** Maximum number of breadcrumbs retained in the ring buffer. Defaults to 20. */
22
+ maxBreadcrumbs?: number;
23
+ /** Rate-limit: max events accepted per 60-second sliding window. Defaults to 30. */
24
+ maxEventsPerMinute?: number;
25
+ /**
26
+ * Lifecycle hook invoked just before an event is sent.
27
+ * Return `null` to discard the event.
28
+ */
29
+ beforeSend?: (event: UncaughtEvent) => UncaughtEvent | null;
30
+ /** Additional key patterns to redact during sanitization. */
31
+ sanitizeKeys?: string[];
32
+ /**
33
+ * An array of strings or RegExp patterns. If the error message matches any
34
+ * of these the event is silently dropped.
35
+ */
36
+ ignoreErrors?: Array<string | RegExp>;
37
+ /** Transport strategy. Defaults to 'local'. */
38
+ transport?: TransportMode;
39
+ /**
40
+ * Directory used by the local-file transport.
41
+ * Defaults to `process.cwd() + '/.uncaught'`.
42
+ */
43
+ localOutputDir?: string;
44
+ }
45
+ /** Structured representation of a captured error. */
46
+ interface ErrorInfo {
47
+ message: string;
48
+ type: string;
49
+ stack?: string;
50
+ componentStack?: string;
51
+ raw?: unknown;
52
+ }
53
+ /** Contextual HTTP request information attached to an event. */
54
+ interface RequestInfo {
55
+ method?: string;
56
+ url?: string;
57
+ headers?: Record<string, string>;
58
+ body?: unknown;
59
+ query?: Record<string, string>;
60
+ }
61
+ /** Information about a failed external operation (DB, auth, API, etc.). */
62
+ interface OperationInfo {
63
+ provider: string;
64
+ type: string;
65
+ method: string;
66
+ params?: Record<string, unknown>;
67
+ errorCode?: string;
68
+ errorDetails?: string;
69
+ }
70
+ /** User context attached to events. */
71
+ interface UserInfo {
72
+ id?: string;
73
+ email?: string;
74
+ username?: string;
75
+ [key: string]: unknown;
76
+ }
77
+ /** SDK metadata shipped with every event. */
78
+ interface SdkInfo {
79
+ name: string;
80
+ version: string;
81
+ }
82
+ /**
83
+ * The canonical event payload sent to transports.
84
+ */
85
+ interface UncaughtEvent {
86
+ eventId: string;
87
+ timestamp: string;
88
+ projectKey?: string;
89
+ level: SeverityLevel;
90
+ fingerprint: string;
91
+ error: ErrorInfo;
92
+ breadcrumbs: Breadcrumb[];
93
+ request?: RequestInfo;
94
+ operation?: OperationInfo;
95
+ environment?: EnvironmentInfo;
96
+ user?: UserInfo;
97
+ fixPrompt: string;
98
+ sdk: SdkInfo;
99
+ }
100
+ /** Breadcrumb categories. */
101
+ type BreadcrumbType = 'click' | 'navigation' | 'api_call' | 'db_query' | 'auth' | 'console' | 'custom';
102
+ /** A single breadcrumb entry. */
103
+ interface Breadcrumb {
104
+ type: BreadcrumbType;
105
+ category: string;
106
+ message: string;
107
+ timestamp: string;
108
+ data?: Record<string, unknown>;
109
+ level?: SeverityLevel;
110
+ }
111
+ /** Public interface of the breadcrumb ring-buffer store. */
112
+ interface BreadcrumbStore {
113
+ /** Append a breadcrumb (auto-timestamps). */
114
+ add(crumb: Omit<Breadcrumb, 'timestamp'>): void;
115
+ /** Return all stored breadcrumbs in chronological order (copies). */
116
+ getAll(): Breadcrumb[];
117
+ /** Return the most recent `n` breadcrumbs (copies). */
118
+ getLast(n: number): Breadcrumb[];
119
+ /** Empty the buffer. */
120
+ clear(): void;
121
+ }
122
+ /** Detected runtime / platform information. */
123
+ interface EnvironmentInfo {
124
+ framework?: string;
125
+ frameworkVersion?: string;
126
+ runtime?: string;
127
+ runtimeVersion?: string;
128
+ platform?: string;
129
+ os?: string;
130
+ browser?: string;
131
+ browserVersion?: string;
132
+ deviceType?: string;
133
+ locale?: string;
134
+ timezone?: string;
135
+ url?: string;
136
+ }
137
+ /** Options used to configure a remote transport. */
138
+ interface TransportOptions {
139
+ endpoint: string;
140
+ projectKey: string;
141
+ maxRetries?: number;
142
+ batchSize?: number;
143
+ flushIntervalMs?: number;
144
+ }
145
+ /** A transport implementation capable of delivering events. */
146
+ interface Transport {
147
+ send(event: UncaughtEvent): void;
148
+ flush(): Promise<void>;
149
+ }
150
+ type IssueStatus = 'open' | 'resolved' | 'ignored';
151
+ interface IssueEntry {
152
+ fingerprint: string;
153
+ title: string;
154
+ errorType: string;
155
+ count: number;
156
+ affectedUsers: string[];
157
+ firstSeen: string;
158
+ lastSeen: string;
159
+ status: IssueStatus;
160
+ fixPromptFile: string;
161
+ latestEventFile: string;
162
+ }
163
+
164
+ export type { Breadcrumb as B, EnvironmentInfo as E, IssueEntry as I, OperationInfo as O, RequestInfo as R, SeverityLevel as S, Transport as T, UncaughtEvent as U, UncaughtConfig as a, UserInfo as b, BreadcrumbStore as c, BreadcrumbType as d, ErrorInfo as e, IssueStatus as f, SdkInfo as g, TransportMode as h, TransportOptions as i };
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@uncaughtdev/core",
3
+ "version": "0.1.0",
4
+ "description": "Core engine for Uncaught error monitoring — transport, breadcrumbs, and fix prompt generation",
5
+ "license": "MIT",
6
+ "author": "Uncaught",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/AjeeshDevops/uncaught.git",
10
+ "directory": "packages/core"
11
+ },
12
+ "homepage": "https://github.com/AjeeshDevops/uncaught#readme",
13
+ "keywords": [
14
+ "error",
15
+ "monitoring",
16
+ "debugging",
17
+ "error-tracking",
18
+ "developer-tools",
19
+ "vibe-coding",
20
+ "ai-debugging"
21
+ ],
22
+ "main": "./dist/index.js",
23
+ "module": "./dist/index.mjs",
24
+ "types": "./dist/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.mjs",
29
+ "require": "./dist/index.js"
30
+ },
31
+ "./local-api-handler": {
32
+ "types": "./dist/local-api-handler.d.ts",
33
+ "import": "./dist/local-api-handler.mjs",
34
+ "require": "./dist/local-api-handler.js"
35
+ },
36
+ "./local-api-handler/pages": {
37
+ "types": "./dist/local-api-handler-pages.d.ts",
38
+ "import": "./dist/local-api-handler-pages.mjs",
39
+ "require": "./dist/local-api-handler-pages.js"
40
+ }
41
+ },
42
+ "bin": {
43
+ "uncaught": "./dist/local-viewer.js"
44
+ },
45
+ "sideEffects": false,
46
+ "files": [
47
+ "dist"
48
+ ],
49
+ "devDependencies": {
50
+ "@types/node": "^25.3.3",
51
+ "tsup": "^8.0.0",
52
+ "typescript": "^5.4.0",
53
+ "vitest": "^1.6.0"
54
+ },
55
+ "scripts": {
56
+ "build": "tsup",
57
+ "dev": "tsup --watch",
58
+ "test": "vitest run",
59
+ "lint": "eslint src/",
60
+ "typecheck": "tsc --noEmit",
61
+ "clean": "rm -rf dist"
62
+ }
63
+ }