@techts/sdk 3.0.2
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/README.md +62 -0
- package/dist/index.d.mts +118 -0
- package/dist/index.d.ts +118 -0
- package/dist/index.js +708 -0
- package/dist/index.mjs +683 -0
- package/package.json +24 -0
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @techts/sdk
|
|
2
|
+
|
|
3
|
+
Deep frontend capture SDK for [debugger.help](https://debugger.help). Automatically captures console output, unhandled errors, network requests, Web Vitals, long tasks, and more.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @techts/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { DebuggerSDK } from '@techts/sdk';
|
|
15
|
+
|
|
16
|
+
const dbg = new DebuggerSDK({
|
|
17
|
+
apiKey: 'YOUR_API_KEY',
|
|
18
|
+
ingestUrl: 'YOUR_INGEST_URL',
|
|
19
|
+
source: 'my-frontend',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Everything is automatic. Manual API:
|
|
23
|
+
dbg.log('info', 'User clicked generate', { userId: '123' });
|
|
24
|
+
dbg.captureError(new Error('something broke'));
|
|
25
|
+
dbg.metric({ custom: { renderTime: 42 } });
|
|
26
|
+
dbg.inspect({ userState: { loggedIn: true } });
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## What it captures automatically
|
|
30
|
+
|
|
31
|
+
- Console output (log, warn, error, debug, info, trace, assert)
|
|
32
|
+
- Unhandled exceptions and promise rejections
|
|
33
|
+
- Failed and slow network requests (fetch + XMLHttpRequest)
|
|
34
|
+
- Resource loading failures (images, scripts, stylesheets, fonts)
|
|
35
|
+
- Web Vitals (LCP, FID, CLS, TTFB, FCP, INP)
|
|
36
|
+
- JS heap memory usage
|
|
37
|
+
- Long tasks (>50ms)
|
|
38
|
+
- Navigation and route changes
|
|
39
|
+
- Visibility changes (tab hidden/visible)
|
|
40
|
+
- WebSocket errors
|
|
41
|
+
- CSP violations
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
| Option | Default | Description |
|
|
46
|
+
|--------|---------|-------------|
|
|
47
|
+
| `apiKey` | required | Your debugger.help API key |
|
|
48
|
+
| `ingestUrl` | required | Your ingest endpoint URL |
|
|
49
|
+
| `source` | required | Name for this data source |
|
|
50
|
+
| `batchInterval` | `2000` | Ms between batch sends |
|
|
51
|
+
| `maxBatchSize` | `50` | Max items per batch |
|
|
52
|
+
| `captureConsole` | `true` | Capture console output |
|
|
53
|
+
| `captureErrors` | `true` | Capture unhandled errors |
|
|
54
|
+
| `captureNetwork` | `true` | Intercept fetch/XHR |
|
|
55
|
+
| `captureWebVitals` | `true` | Track Web Vitals |
|
|
56
|
+
| `captureLongTasks` | `true` | Track long tasks |
|
|
57
|
+
| `slowRequestThresholdMs` | `3000` | Threshold for slow request warnings |
|
|
58
|
+
| `metricsInterval` | `30000` | Ms between metric snapshots |
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* debugger.help SDK v3 — Ultimate Deep Frontend Capture
|
|
3
|
+
*
|
|
4
|
+
* Captures EVERYTHING from your web app:
|
|
5
|
+
* - Console output (log, warn, error, debug, info, trace, assert)
|
|
6
|
+
* - Unhandled exceptions & unhandled promise rejections
|
|
7
|
+
* - Failed & slow network requests (fetch + XMLHttpRequest)
|
|
8
|
+
* - Resource loading failures (images, scripts, stylesheets, fonts)
|
|
9
|
+
* - Performance: Web Vitals (LCP, FID, CLS, TTFB, FCP, INP)
|
|
10
|
+
* - JS heap memory usage
|
|
11
|
+
* - Long tasks (>50ms) via PerformanceObserver
|
|
12
|
+
* - React error boundaries (manual integration)
|
|
13
|
+
* - User navigation / route changes (popstate, pushState, replaceState)
|
|
14
|
+
* - Visibility changes (tab hidden/visible)
|
|
15
|
+
* - WebSocket errors
|
|
16
|
+
* - CSP violations
|
|
17
|
+
* - DOM mutation counts (optional)
|
|
18
|
+
*
|
|
19
|
+
* Usage:
|
|
20
|
+
* import { DebuggerSDK } from './debugger-sdk';
|
|
21
|
+
*
|
|
22
|
+
* const dbg = new DebuggerSDK({
|
|
23
|
+
* apiKey: 'sk_your_api_key',
|
|
24
|
+
* ingestUrl: 'https://your-project.supabase.co/functions/v1/ingest',
|
|
25
|
+
* source: 'my-frontend',
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // Everything is automatic. Manual API:
|
|
29
|
+
* dbg.log('info', 'User clicked generate', { userId: '123' });
|
|
30
|
+
* dbg.captureError(new Error('something broke'));
|
|
31
|
+
* dbg.metric({ custom: { renderTime: 42 } });
|
|
32
|
+
* dbg.inspect({ userState: { loggedIn: true } });
|
|
33
|
+
* dbg.captureImageGenResult(jobId, model, params, result, error, durationMs);
|
|
34
|
+
*/
|
|
35
|
+
interface DebuggerConfig {
|
|
36
|
+
apiKey: string;
|
|
37
|
+
ingestUrl: string;
|
|
38
|
+
source: string;
|
|
39
|
+
platform?: string;
|
|
40
|
+
version?: string;
|
|
41
|
+
batchInterval?: number;
|
|
42
|
+
maxBatchSize?: number;
|
|
43
|
+
captureConsole?: boolean;
|
|
44
|
+
captureErrors?: boolean;
|
|
45
|
+
captureNetwork?: boolean;
|
|
46
|
+
captureResources?: boolean;
|
|
47
|
+
captureWebVitals?: boolean;
|
|
48
|
+
captureLongTasks?: boolean;
|
|
49
|
+
captureNavigation?: boolean;
|
|
50
|
+
captureVisibility?: boolean;
|
|
51
|
+
captureCSP?: boolean;
|
|
52
|
+
captureWebSockets?: boolean;
|
|
53
|
+
slowRequestThresholdMs?: number;
|
|
54
|
+
metricsInterval?: number;
|
|
55
|
+
sessionId?: string;
|
|
56
|
+
userId?: string;
|
|
57
|
+
}
|
|
58
|
+
type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'critical';
|
|
59
|
+
declare class DebuggerSDK {
|
|
60
|
+
private config;
|
|
61
|
+
private queue;
|
|
62
|
+
private batchTimer;
|
|
63
|
+
private metricsTimer;
|
|
64
|
+
private sessionId;
|
|
65
|
+
private pageLoadTime;
|
|
66
|
+
private navigationCount;
|
|
67
|
+
private errorCount;
|
|
68
|
+
private networkFailCount;
|
|
69
|
+
private longTaskCount;
|
|
70
|
+
private originalConsole;
|
|
71
|
+
private originalFetch;
|
|
72
|
+
private originalXhrOpen;
|
|
73
|
+
private originalXhrSend;
|
|
74
|
+
private originalWsConstructor;
|
|
75
|
+
constructor(config: DebuggerConfig);
|
|
76
|
+
log(level: LogLevel, message: string, context?: Record<string, unknown>): void;
|
|
77
|
+
debug(msg: string, ctx?: Record<string, unknown>): void;
|
|
78
|
+
info(msg: string, ctx?: Record<string, unknown>): void;
|
|
79
|
+
warn(msg: string, ctx?: Record<string, unknown>): void;
|
|
80
|
+
error(msg: string, ctx?: Record<string, unknown>): void;
|
|
81
|
+
critical(msg: string, ctx?: Record<string, unknown>): void;
|
|
82
|
+
captureError(err: Error, context?: Record<string, unknown>): void;
|
|
83
|
+
/**
|
|
84
|
+
* Capture React error boundary errors.
|
|
85
|
+
* Call from componentDidCatch or ErrorBoundary fallback.
|
|
86
|
+
*/
|
|
87
|
+
captureReactError(error: Error, errorInfo: {
|
|
88
|
+
componentStack?: string;
|
|
89
|
+
}): void;
|
|
90
|
+
metric(data: Record<string, unknown>): void;
|
|
91
|
+
inspect(variables: Record<string, unknown>): void;
|
|
92
|
+
heartbeat(): void;
|
|
93
|
+
setUserId(userId: string): void;
|
|
94
|
+
/**
|
|
95
|
+
* Track image generation results from the frontend
|
|
96
|
+
*/
|
|
97
|
+
captureImageGenResult(jobId: string, model: string, params: Record<string, unknown>, result?: Record<string, unknown>, error?: string, durationMs?: number): void;
|
|
98
|
+
private interceptConsole;
|
|
99
|
+
private captureGlobalErrors;
|
|
100
|
+
private captureResourceErrors;
|
|
101
|
+
private interceptNetwork;
|
|
102
|
+
private interceptFetch;
|
|
103
|
+
private interceptXHR;
|
|
104
|
+
private captureWebVitals;
|
|
105
|
+
private captureLongTasks;
|
|
106
|
+
private captureNavigation;
|
|
107
|
+
private captureVisibilityChanges;
|
|
108
|
+
private captureCSPViolations;
|
|
109
|
+
private interceptWebSockets;
|
|
110
|
+
private collectBrowserMetrics;
|
|
111
|
+
private enqueue;
|
|
112
|
+
flush(): Promise<void>;
|
|
113
|
+
private generateSessionId;
|
|
114
|
+
private sanitizeHeaders;
|
|
115
|
+
destroy(): void;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { type DebuggerConfig, DebuggerSDK };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* debugger.help SDK v3 — Ultimate Deep Frontend Capture
|
|
3
|
+
*
|
|
4
|
+
* Captures EVERYTHING from your web app:
|
|
5
|
+
* - Console output (log, warn, error, debug, info, trace, assert)
|
|
6
|
+
* - Unhandled exceptions & unhandled promise rejections
|
|
7
|
+
* - Failed & slow network requests (fetch + XMLHttpRequest)
|
|
8
|
+
* - Resource loading failures (images, scripts, stylesheets, fonts)
|
|
9
|
+
* - Performance: Web Vitals (LCP, FID, CLS, TTFB, FCP, INP)
|
|
10
|
+
* - JS heap memory usage
|
|
11
|
+
* - Long tasks (>50ms) via PerformanceObserver
|
|
12
|
+
* - React error boundaries (manual integration)
|
|
13
|
+
* - User navigation / route changes (popstate, pushState, replaceState)
|
|
14
|
+
* - Visibility changes (tab hidden/visible)
|
|
15
|
+
* - WebSocket errors
|
|
16
|
+
* - CSP violations
|
|
17
|
+
* - DOM mutation counts (optional)
|
|
18
|
+
*
|
|
19
|
+
* Usage:
|
|
20
|
+
* import { DebuggerSDK } from './debugger-sdk';
|
|
21
|
+
*
|
|
22
|
+
* const dbg = new DebuggerSDK({
|
|
23
|
+
* apiKey: 'sk_your_api_key',
|
|
24
|
+
* ingestUrl: 'https://your-project.supabase.co/functions/v1/ingest',
|
|
25
|
+
* source: 'my-frontend',
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // Everything is automatic. Manual API:
|
|
29
|
+
* dbg.log('info', 'User clicked generate', { userId: '123' });
|
|
30
|
+
* dbg.captureError(new Error('something broke'));
|
|
31
|
+
* dbg.metric({ custom: { renderTime: 42 } });
|
|
32
|
+
* dbg.inspect({ userState: { loggedIn: true } });
|
|
33
|
+
* dbg.captureImageGenResult(jobId, model, params, result, error, durationMs);
|
|
34
|
+
*/
|
|
35
|
+
interface DebuggerConfig {
|
|
36
|
+
apiKey: string;
|
|
37
|
+
ingestUrl: string;
|
|
38
|
+
source: string;
|
|
39
|
+
platform?: string;
|
|
40
|
+
version?: string;
|
|
41
|
+
batchInterval?: number;
|
|
42
|
+
maxBatchSize?: number;
|
|
43
|
+
captureConsole?: boolean;
|
|
44
|
+
captureErrors?: boolean;
|
|
45
|
+
captureNetwork?: boolean;
|
|
46
|
+
captureResources?: boolean;
|
|
47
|
+
captureWebVitals?: boolean;
|
|
48
|
+
captureLongTasks?: boolean;
|
|
49
|
+
captureNavigation?: boolean;
|
|
50
|
+
captureVisibility?: boolean;
|
|
51
|
+
captureCSP?: boolean;
|
|
52
|
+
captureWebSockets?: boolean;
|
|
53
|
+
slowRequestThresholdMs?: number;
|
|
54
|
+
metricsInterval?: number;
|
|
55
|
+
sessionId?: string;
|
|
56
|
+
userId?: string;
|
|
57
|
+
}
|
|
58
|
+
type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'critical';
|
|
59
|
+
declare class DebuggerSDK {
|
|
60
|
+
private config;
|
|
61
|
+
private queue;
|
|
62
|
+
private batchTimer;
|
|
63
|
+
private metricsTimer;
|
|
64
|
+
private sessionId;
|
|
65
|
+
private pageLoadTime;
|
|
66
|
+
private navigationCount;
|
|
67
|
+
private errorCount;
|
|
68
|
+
private networkFailCount;
|
|
69
|
+
private longTaskCount;
|
|
70
|
+
private originalConsole;
|
|
71
|
+
private originalFetch;
|
|
72
|
+
private originalXhrOpen;
|
|
73
|
+
private originalXhrSend;
|
|
74
|
+
private originalWsConstructor;
|
|
75
|
+
constructor(config: DebuggerConfig);
|
|
76
|
+
log(level: LogLevel, message: string, context?: Record<string, unknown>): void;
|
|
77
|
+
debug(msg: string, ctx?: Record<string, unknown>): void;
|
|
78
|
+
info(msg: string, ctx?: Record<string, unknown>): void;
|
|
79
|
+
warn(msg: string, ctx?: Record<string, unknown>): void;
|
|
80
|
+
error(msg: string, ctx?: Record<string, unknown>): void;
|
|
81
|
+
critical(msg: string, ctx?: Record<string, unknown>): void;
|
|
82
|
+
captureError(err: Error, context?: Record<string, unknown>): void;
|
|
83
|
+
/**
|
|
84
|
+
* Capture React error boundary errors.
|
|
85
|
+
* Call from componentDidCatch or ErrorBoundary fallback.
|
|
86
|
+
*/
|
|
87
|
+
captureReactError(error: Error, errorInfo: {
|
|
88
|
+
componentStack?: string;
|
|
89
|
+
}): void;
|
|
90
|
+
metric(data: Record<string, unknown>): void;
|
|
91
|
+
inspect(variables: Record<string, unknown>): void;
|
|
92
|
+
heartbeat(): void;
|
|
93
|
+
setUserId(userId: string): void;
|
|
94
|
+
/**
|
|
95
|
+
* Track image generation results from the frontend
|
|
96
|
+
*/
|
|
97
|
+
captureImageGenResult(jobId: string, model: string, params: Record<string, unknown>, result?: Record<string, unknown>, error?: string, durationMs?: number): void;
|
|
98
|
+
private interceptConsole;
|
|
99
|
+
private captureGlobalErrors;
|
|
100
|
+
private captureResourceErrors;
|
|
101
|
+
private interceptNetwork;
|
|
102
|
+
private interceptFetch;
|
|
103
|
+
private interceptXHR;
|
|
104
|
+
private captureWebVitals;
|
|
105
|
+
private captureLongTasks;
|
|
106
|
+
private captureNavigation;
|
|
107
|
+
private captureVisibilityChanges;
|
|
108
|
+
private captureCSPViolations;
|
|
109
|
+
private interceptWebSockets;
|
|
110
|
+
private collectBrowserMetrics;
|
|
111
|
+
private enqueue;
|
|
112
|
+
flush(): Promise<void>;
|
|
113
|
+
private generateSessionId;
|
|
114
|
+
private sanitizeHeaders;
|
|
115
|
+
destroy(): void;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { type DebuggerConfig, DebuggerSDK };
|