@catdoes/watch 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/README.md +181 -0
- package/dist/index.d.mts +486 -0
- package/dist/index.d.ts +486 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/react.d.mts +56 -0
- package/dist/react.d.ts +56 -0
- package/dist/react.js +1 -0
- package/dist/react.mjs +1 -0
- package/package.json +74 -0
package/README.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# @catdoes/watch
|
|
2
|
+
|
|
3
|
+
Error tracking and monitoring SDK for React Native and Expo apps.
|
|
4
|
+
|
|
5
|
+
**CatDoes Watch** provides real-time error tracking, crash reporting, and debugging tools for your mobile applications built with React Native and Expo.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 🚨 **Automatic Error Capture** - Catches unhandled errors and promise rejections
|
|
10
|
+
- 🎯 **React Error Boundary** - Integrated error boundary component
|
|
11
|
+
- 📍 **Breadcrumbs** - Track user actions leading up to errors
|
|
12
|
+
- 📱 **Cross-Platform** - Works on iOS, Android, and Web
|
|
13
|
+
- 🔄 **Offline Support** - Queues events when offline, sends when reconnected
|
|
14
|
+
- ⚡ **Lightweight** - Minimal impact on app performance
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @catdoes/watch
|
|
20
|
+
# or
|
|
21
|
+
yarn add @catdoes/watch
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Peer Dependencies
|
|
25
|
+
|
|
26
|
+
Make sure you have these peer dependencies installed:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx expo install @react-native-async-storage/async-storage expo-crypto
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### 1. Initialize the SDK
|
|
35
|
+
|
|
36
|
+
In your app's entry point (e.g., `_layout.tsx` for Expo Router):
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { Watch, setupGlobalHandlers } from "@catdoes/watch";
|
|
40
|
+
|
|
41
|
+
// Initialize Watch with your API key
|
|
42
|
+
const watchClient = Watch.init({
|
|
43
|
+
apiKey: process.env.EXPO_PUBLIC_CATDOES_WATCH_KEY || "",
|
|
44
|
+
debug: __DEV__, // Enable debug logging in development
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Set up global error handlers
|
|
48
|
+
if (watchClient) {
|
|
49
|
+
setupGlobalHandlers(watchClient);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 2. Wrap Your App with Error Boundary
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { ErrorBoundary } from "@/components/ErrorBoundary";
|
|
57
|
+
|
|
58
|
+
export default function RootLayout() {
|
|
59
|
+
return (
|
|
60
|
+
<ErrorBoundary>
|
|
61
|
+
{/* Your app content */}
|
|
62
|
+
</ErrorBoundary>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 3. Capture Errors Manually (Optional)
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { Watch } from "@catdoes/watch";
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
await riskyOperation();
|
|
74
|
+
} catch (error) {
|
|
75
|
+
Watch.captureError(error as Error, {
|
|
76
|
+
context: "riskyOperation",
|
|
77
|
+
userId: currentUser.id,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## API Reference
|
|
83
|
+
|
|
84
|
+
### `Watch.init(config)`
|
|
85
|
+
|
|
86
|
+
Initializes the Watch client.
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
interface WatchConfig {
|
|
90
|
+
apiKey: string; // Your CatDoes Watch API key
|
|
91
|
+
endpoint?: string; // Custom endpoint (default: CatDoes servers)
|
|
92
|
+
environment?: "development" | "production";
|
|
93
|
+
captureConsoleErrors?: boolean; // Capture console.error (default: false)
|
|
94
|
+
maxBreadcrumbs?: number; // Max breadcrumbs to store (default: 20)
|
|
95
|
+
debug?: boolean; // Enable debug logging
|
|
96
|
+
beforeSend?: (event) => event | null; // Modify or drop events
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### `Watch.captureError(error, extra?)`
|
|
101
|
+
|
|
102
|
+
Manually capture an error.
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
Watch.captureError(new Error("Something went wrong"), {
|
|
106
|
+
userId: "123",
|
|
107
|
+
action: "checkout",
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### `Watch.captureMessage(message, level?)`
|
|
112
|
+
|
|
113
|
+
Capture a message as an error.
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
Watch.captureMessage("User attempted invalid action", "warning");
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### `Watch.addBreadcrumb(breadcrumb)`
|
|
120
|
+
|
|
121
|
+
Add a breadcrumb for context.
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
Watch.addBreadcrumb({
|
|
125
|
+
type: "navigation",
|
|
126
|
+
message: "User navigated to Settings",
|
|
127
|
+
data: { screen: "Settings" },
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### `Watch.setContext(key, value)`
|
|
132
|
+
|
|
133
|
+
Set context that will be attached to all future events.
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
Watch.setContext("appVersion", "1.2.3");
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### `Watch.setUser(user)`
|
|
140
|
+
|
|
141
|
+
Set user information for error correlation.
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
Watch.setUser({
|
|
145
|
+
id: "user123",
|
|
146
|
+
email: "user@example.com",
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### `Watch.flush()`
|
|
151
|
+
|
|
152
|
+
Force flush all queued events to the server.
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
await Watch.flush();
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Breadcrumb Types
|
|
159
|
+
|
|
160
|
+
- `navigation` - Route/screen changes
|
|
161
|
+
- `ui` - User interactions (taps, swipes)
|
|
162
|
+
- `http` - Network requests
|
|
163
|
+
- `console` - Console logs
|
|
164
|
+
- `custom` - Custom events
|
|
165
|
+
|
|
166
|
+
## Environment Variables
|
|
167
|
+
|
|
168
|
+
Set your API key in your environment:
|
|
169
|
+
|
|
170
|
+
```env
|
|
171
|
+
EXPO_PUBLIC_CATDOES_WATCH_KEY=your_api_key_here
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Support
|
|
175
|
+
|
|
176
|
+
- Documentation: https://catdoes.watch/docs
|
|
177
|
+
- Support: support@catdoes.com
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
Proprietary - All rights reserved by CatDoes.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
export { WatchErrorBoundary, WatchErrorBoundaryProps, withWatchErrorBoundary } from './react.mjs';
|
|
2
|
+
import 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* CatDoes Watch SDK - Type Definitions
|
|
6
|
+
*
|
|
7
|
+
* These types define the structure of error events, configuration,
|
|
8
|
+
* and other data used by the Watch SDK.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Configuration options for initializing the Watch client.
|
|
12
|
+
*/
|
|
13
|
+
interface WatchConfig {
|
|
14
|
+
/**
|
|
15
|
+
* The API key for authenticating with CatDoes Watch.
|
|
16
|
+
* Format: cd_watch_xxxxx
|
|
17
|
+
*/
|
|
18
|
+
apiKey: string;
|
|
19
|
+
/**
|
|
20
|
+
* The endpoint URL for the ingestion API.
|
|
21
|
+
* @default "https://app.catdoes.com/api/watch/ingest"
|
|
22
|
+
*/
|
|
23
|
+
endpoint?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The environment to report errors for.
|
|
26
|
+
* Auto-detected from __DEV__ if not specified.
|
|
27
|
+
* @default Auto-detected
|
|
28
|
+
*/
|
|
29
|
+
environment?: "development" | "production";
|
|
30
|
+
/**
|
|
31
|
+
* Whether to capture console.error calls as errors.
|
|
32
|
+
* This can be noisy and is disabled by default.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
captureConsoleErrors?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Maximum number of breadcrumbs to store.
|
|
38
|
+
* @default 20
|
|
39
|
+
*/
|
|
40
|
+
maxBreadcrumbs?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Maximum number of events to buffer before flushing.
|
|
43
|
+
* @default 10
|
|
44
|
+
*/
|
|
45
|
+
maxBufferSize?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Interval in milliseconds between automatic flushes.
|
|
48
|
+
* @default 5000
|
|
49
|
+
*/
|
|
50
|
+
flushInterval?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Callback invoked before sending an event.
|
|
53
|
+
* Return null to drop the event, or modify and return it.
|
|
54
|
+
*/
|
|
55
|
+
beforeSend?: (event: WatchEvent) => WatchEvent | null;
|
|
56
|
+
/**
|
|
57
|
+
* Enable debug logging to console.
|
|
58
|
+
* @default false
|
|
59
|
+
*/
|
|
60
|
+
debug?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Initial context to attach to all events.
|
|
63
|
+
*/
|
|
64
|
+
initialContext?: Record<string, unknown>;
|
|
65
|
+
/**
|
|
66
|
+
* Time window in milliseconds to consider errors as duplicates.
|
|
67
|
+
* Errors with the same key occurring within this window will be deduplicated.
|
|
68
|
+
* @default 5000
|
|
69
|
+
*/
|
|
70
|
+
dedupWindowMs?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Maximum number of recent error keys to keep in memory for deduplication.
|
|
73
|
+
* When exceeded, the oldest keys will be evicted.
|
|
74
|
+
* @default 500
|
|
75
|
+
*/
|
|
76
|
+
dedupMaxEntries?: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Required configuration with defaults applied.
|
|
80
|
+
*/
|
|
81
|
+
interface WatchConfigResolved {
|
|
82
|
+
apiKey: string;
|
|
83
|
+
endpoint: string;
|
|
84
|
+
environment: "development" | "production";
|
|
85
|
+
captureConsoleErrors: boolean;
|
|
86
|
+
maxBreadcrumbs: number;
|
|
87
|
+
maxBufferSize: number;
|
|
88
|
+
flushInterval: number;
|
|
89
|
+
beforeSend: (event: WatchEvent) => WatchEvent | null;
|
|
90
|
+
debug: boolean;
|
|
91
|
+
dedupWindowMs: number;
|
|
92
|
+
dedupMaxEntries: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Device and environment information collected automatically.
|
|
96
|
+
*/
|
|
97
|
+
interface DeviceInfo {
|
|
98
|
+
deviceModel?: string;
|
|
99
|
+
deviceName?: string;
|
|
100
|
+
deviceType?: string;
|
|
101
|
+
brand?: string;
|
|
102
|
+
manufacturer?: string;
|
|
103
|
+
modelName?: string;
|
|
104
|
+
isDevice?: boolean;
|
|
105
|
+
isEmulator?: boolean;
|
|
106
|
+
isTablet?: boolean;
|
|
107
|
+
osName?: string;
|
|
108
|
+
osVersion?: string;
|
|
109
|
+
osBuildId?: string;
|
|
110
|
+
platformApiLevel?: number;
|
|
111
|
+
appVersion?: string;
|
|
112
|
+
appBuildNumber?: string;
|
|
113
|
+
appName?: string;
|
|
114
|
+
bundleId?: string;
|
|
115
|
+
runtimeVersion?: string;
|
|
116
|
+
expoVersion?: string;
|
|
117
|
+
nativeAppVersion?: string;
|
|
118
|
+
nativeBuildVersion?: string;
|
|
119
|
+
screenWidth?: number;
|
|
120
|
+
screenHeight?: number;
|
|
121
|
+
screenScale?: number;
|
|
122
|
+
locale?: string;
|
|
123
|
+
timezone?: string;
|
|
124
|
+
networkType?: string;
|
|
125
|
+
isConnected?: boolean;
|
|
126
|
+
browserName?: string;
|
|
127
|
+
browserVersion?: string;
|
|
128
|
+
userAgent?: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* A breadcrumb representing an action or event before an error.
|
|
132
|
+
*/
|
|
133
|
+
interface Breadcrumb {
|
|
134
|
+
/**
|
|
135
|
+
* The type of breadcrumb.
|
|
136
|
+
*/
|
|
137
|
+
type: "navigation" | "ui" | "http" | "console" | "custom";
|
|
138
|
+
/**
|
|
139
|
+
* A human-readable message describing the breadcrumb.
|
|
140
|
+
*/
|
|
141
|
+
message: string;
|
|
142
|
+
/**
|
|
143
|
+
* ISO 8601 timestamp of when the breadcrumb was created.
|
|
144
|
+
*/
|
|
145
|
+
timestamp: string;
|
|
146
|
+
/**
|
|
147
|
+
* Additional data associated with the breadcrumb.
|
|
148
|
+
*/
|
|
149
|
+
data?: Record<string, unknown>;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* An error event to be sent to CatDoes Watch.
|
|
153
|
+
*/
|
|
154
|
+
interface WatchEvent {
|
|
155
|
+
/**
|
|
156
|
+
* The error message.
|
|
157
|
+
*/
|
|
158
|
+
message: string;
|
|
159
|
+
/**
|
|
160
|
+
* The stack trace of the error.
|
|
161
|
+
*/
|
|
162
|
+
stack?: string;
|
|
163
|
+
/**
|
|
164
|
+
* React component stack trace.
|
|
165
|
+
*/
|
|
166
|
+
componentStack?: string;
|
|
167
|
+
/**
|
|
168
|
+
* The filename where the error occurred.
|
|
169
|
+
*/
|
|
170
|
+
filename?: string;
|
|
171
|
+
/**
|
|
172
|
+
* The line number where the error occurred.
|
|
173
|
+
*/
|
|
174
|
+
lineno?: number;
|
|
175
|
+
/**
|
|
176
|
+
* The column number where the error occurred.
|
|
177
|
+
*/
|
|
178
|
+
colno?: number;
|
|
179
|
+
/**
|
|
180
|
+
* ISO 8601 timestamp of when the error occurred.
|
|
181
|
+
*/
|
|
182
|
+
timestamp: string;
|
|
183
|
+
/**
|
|
184
|
+
* The environment where the error occurred.
|
|
185
|
+
*/
|
|
186
|
+
environment: "development" | "production";
|
|
187
|
+
/**
|
|
188
|
+
* The platform where the error occurred.
|
|
189
|
+
*/
|
|
190
|
+
platform: "ios" | "android" | "web";
|
|
191
|
+
/**
|
|
192
|
+
* A unique identifier for the current session.
|
|
193
|
+
*/
|
|
194
|
+
sessionId: string;
|
|
195
|
+
/**
|
|
196
|
+
* Device and environment information.
|
|
197
|
+
*/
|
|
198
|
+
deviceInfo?: DeviceInfo;
|
|
199
|
+
/**
|
|
200
|
+
* Additional context data.
|
|
201
|
+
*/
|
|
202
|
+
extra?: Record<string, unknown>;
|
|
203
|
+
/**
|
|
204
|
+
* Breadcrumbs leading up to the error.
|
|
205
|
+
*/
|
|
206
|
+
breadcrumbs?: Breadcrumb[];
|
|
207
|
+
/**
|
|
208
|
+
* SDK version for debugging. Helps correlate reports across SDK releases.
|
|
209
|
+
*/
|
|
210
|
+
sdkVersion?: string;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Input for adding a breadcrumb (timestamp is auto-generated).
|
|
214
|
+
*/
|
|
215
|
+
type BreadcrumbInput = Omit<Breadcrumb, "timestamp">;
|
|
216
|
+
/**
|
|
217
|
+
* Response from the ingestion API.
|
|
218
|
+
*/
|
|
219
|
+
interface IngestResponse {
|
|
220
|
+
accepted?: number;
|
|
221
|
+
filtered?: boolean;
|
|
222
|
+
error?: string;
|
|
223
|
+
retryAfter?: number;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* CatDoes Watch SDK - Transport Layer
|
|
228
|
+
*
|
|
229
|
+
* Handles HTTP communication with the CatDoes Watch ingestion API.
|
|
230
|
+
* Features:
|
|
231
|
+
* - Batching: Groups multiple events into single requests
|
|
232
|
+
* - Retry with exponential backoff on failures
|
|
233
|
+
* - Respects rate limiting (429 responses)
|
|
234
|
+
* - Silent failures (never throws to avoid breaking the app)
|
|
235
|
+
*/
|
|
236
|
+
|
|
237
|
+
interface FlushOptions {
|
|
238
|
+
/**
|
|
239
|
+
* Hint browsers to allow the request to outlive the page lifecycle.
|
|
240
|
+
*/
|
|
241
|
+
keepalive?: boolean;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* CatDoes Watch SDK - Main Client
|
|
246
|
+
*
|
|
247
|
+
* The primary interface for the CatDoes Watch error tracking SDK.
|
|
248
|
+
* Implements a singleton pattern for ease of use.
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* The main CatDoes Watch client class.
|
|
253
|
+
*/
|
|
254
|
+
declare class WatchClient {
|
|
255
|
+
private static instance;
|
|
256
|
+
private config;
|
|
257
|
+
private transport;
|
|
258
|
+
private breadcrumbs;
|
|
259
|
+
private context;
|
|
260
|
+
private user;
|
|
261
|
+
private isInitialized;
|
|
262
|
+
private recentErrors;
|
|
263
|
+
private recentErrorsCleanupTimer;
|
|
264
|
+
private constructor();
|
|
265
|
+
/**
|
|
266
|
+
* Initializes the Watch client with the given configuration.
|
|
267
|
+
*/
|
|
268
|
+
static init(config: WatchConfig): WatchClient;
|
|
269
|
+
/**
|
|
270
|
+
* Gets the existing Watch client instance, or null if not initialized.
|
|
271
|
+
*/
|
|
272
|
+
static getInstance(): WatchClient | null;
|
|
273
|
+
/**
|
|
274
|
+
* Captures an error and sends it to CatDoes Watch.
|
|
275
|
+
*/
|
|
276
|
+
captureError(error: Error, extra?: Record<string, unknown>): void;
|
|
277
|
+
/**
|
|
278
|
+
* Captures a message as an error.
|
|
279
|
+
*/
|
|
280
|
+
captureMessage(message: string, level?: "info" | "warning" | "error"): void;
|
|
281
|
+
/**
|
|
282
|
+
* Adds a breadcrumb to the trail.
|
|
283
|
+
*/
|
|
284
|
+
addBreadcrumb(breadcrumb: BreadcrumbInput): void;
|
|
285
|
+
/**
|
|
286
|
+
* Sets a context value that will be attached to all future events.
|
|
287
|
+
*/
|
|
288
|
+
setContext(key: string, value: unknown): void;
|
|
289
|
+
/**
|
|
290
|
+
* Clears a context value.
|
|
291
|
+
*/
|
|
292
|
+
clearContext(key: string): void;
|
|
293
|
+
/**
|
|
294
|
+
* Sets user information to attach to events.
|
|
295
|
+
*/
|
|
296
|
+
setUser(user: {
|
|
297
|
+
id?: string;
|
|
298
|
+
[key: string]: unknown;
|
|
299
|
+
} | null): void;
|
|
300
|
+
/**
|
|
301
|
+
* Flushes all queued events immediately.
|
|
302
|
+
*/
|
|
303
|
+
flush(options?: FlushOptions): Promise<void>;
|
|
304
|
+
/**
|
|
305
|
+
* Gets the current configuration.
|
|
306
|
+
*/
|
|
307
|
+
getConfig(): Readonly<WatchConfigResolved>;
|
|
308
|
+
/**
|
|
309
|
+
* Checks if the client is initialized and ready to capture events.
|
|
310
|
+
*/
|
|
311
|
+
get initialized(): boolean;
|
|
312
|
+
private buildEvent;
|
|
313
|
+
private shouldCapture;
|
|
314
|
+
private ensureStack;
|
|
315
|
+
private getErrorKey;
|
|
316
|
+
private markErrorAsSeen;
|
|
317
|
+
private hasSeenErrorRecently;
|
|
318
|
+
private scheduleRecentErrorsCleanup;
|
|
319
|
+
private pruneRecentErrors;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Static interface for convenience methods.
|
|
323
|
+
*/
|
|
324
|
+
declare const Watch: {
|
|
325
|
+
init(config: WatchConfig): WatchClient;
|
|
326
|
+
getInstance(): WatchClient | null;
|
|
327
|
+
captureError(error: Error, extra?: Record<string, unknown>): void;
|
|
328
|
+
captureMessage(message: string, level?: "info" | "warning" | "error"): void;
|
|
329
|
+
addBreadcrumb(breadcrumb: BreadcrumbInput): void;
|
|
330
|
+
setContext(key: string, value: unknown): void;
|
|
331
|
+
setUser(user: {
|
|
332
|
+
id?: string;
|
|
333
|
+
[key: string]: unknown;
|
|
334
|
+
} | null): void;
|
|
335
|
+
flush(options?: FlushOptions): Promise<void>;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* CatDoes Watch SDK - Global Error Handlers
|
|
340
|
+
*
|
|
341
|
+
* Sets up global error handlers to automatically capture unhandled errors.
|
|
342
|
+
* Supports both web (window.onerror) and React Native (ErrorUtils).
|
|
343
|
+
*/
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Sets up global error handlers for the given Watch client.
|
|
347
|
+
*/
|
|
348
|
+
declare function setupGlobalHandlers(client: WatchClient): void;
|
|
349
|
+
/**
|
|
350
|
+
* Sets up console.error interception (optional, can be noisy).
|
|
351
|
+
*/
|
|
352
|
+
declare function setupConsoleErrorCapture(client: WatchClient): void;
|
|
353
|
+
/**
|
|
354
|
+
* Removes all installed global handlers.
|
|
355
|
+
*/
|
|
356
|
+
declare function removeGlobalHandlers(): void;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* CatDoes Watch SDK - Session Management
|
|
360
|
+
*
|
|
361
|
+
* Generates and manages a unique session ID for the current app session.
|
|
362
|
+
* The session ID is used to group errors from the same user session.
|
|
363
|
+
*/
|
|
364
|
+
/**
|
|
365
|
+
* Gets the current session ID, generating one if it doesn't exist.
|
|
366
|
+
* The session ID persists for the lifetime of the app process.
|
|
367
|
+
*/
|
|
368
|
+
declare function getSessionId(): string;
|
|
369
|
+
/**
|
|
370
|
+
* Resets the session ID, forcing a new one to be generated.
|
|
371
|
+
* This can be called when a user logs out or the app wants to start fresh.
|
|
372
|
+
*/
|
|
373
|
+
declare function resetSession(): void;
|
|
374
|
+
/**
|
|
375
|
+
* Sets a specific session ID (useful for testing or migration).
|
|
376
|
+
*/
|
|
377
|
+
declare function setSessionId(sessionId: string): void;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* CatDoes Watch SDK - Context Collection
|
|
381
|
+
*
|
|
382
|
+
* Collects device and environment information to attach to error events.
|
|
383
|
+
* Uses Expo and React Native APIs where available.
|
|
384
|
+
*/
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Gets the current platform: 'ios', 'android', or 'web'.
|
|
388
|
+
*/
|
|
389
|
+
declare function getPlatform(): "ios" | "android" | "web";
|
|
390
|
+
/**
|
|
391
|
+
* Gets the current environment based on __DEV__ flag.
|
|
392
|
+
*/
|
|
393
|
+
declare function getEnvironment(): "development" | "production";
|
|
394
|
+
/**
|
|
395
|
+
* Collects device and environment information.
|
|
396
|
+
* Only includes fields that are in the server's allowlist.
|
|
397
|
+
*/
|
|
398
|
+
declare function collectDeviceInfo(): DeviceInfo;
|
|
399
|
+
declare function getCachedDeviceInfo(): DeviceInfo;
|
|
400
|
+
/**
|
|
401
|
+
* Clears the cached device info, forcing re-collection on next call.
|
|
402
|
+
*/
|
|
403
|
+
declare function clearDeviceInfoCache(): void;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* CatDoes Watch SDK - Breadcrumb Management
|
|
407
|
+
*
|
|
408
|
+
* Manages a rolling buffer of breadcrumbs that are attached to error events.
|
|
409
|
+
* Breadcrumbs help understand the sequence of events leading to an error.
|
|
410
|
+
*/
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Manages a collection of breadcrumbs with a maximum size.
|
|
414
|
+
*/
|
|
415
|
+
declare class BreadcrumbManager {
|
|
416
|
+
private breadcrumbs;
|
|
417
|
+
private maxBreadcrumbs;
|
|
418
|
+
constructor(maxBreadcrumbs?: number);
|
|
419
|
+
/**
|
|
420
|
+
* Adds a new breadcrumb to the collection.
|
|
421
|
+
* If the collection is at max capacity, the oldest breadcrumb is removed.
|
|
422
|
+
*/
|
|
423
|
+
add(input: BreadcrumbInput): void;
|
|
424
|
+
/**
|
|
425
|
+
* Gets a copy of all current breadcrumbs.
|
|
426
|
+
*/
|
|
427
|
+
getAll(): Breadcrumb[];
|
|
428
|
+
/**
|
|
429
|
+
* Clears all breadcrumbs.
|
|
430
|
+
*/
|
|
431
|
+
clear(): void;
|
|
432
|
+
/**
|
|
433
|
+
* Gets the current count of breadcrumbs.
|
|
434
|
+
*/
|
|
435
|
+
get count(): number;
|
|
436
|
+
/**
|
|
437
|
+
* Updates the maximum number of breadcrumbs.
|
|
438
|
+
*/
|
|
439
|
+
setMaxBreadcrumbs(max: number): void;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Creates a navigation breadcrumb.
|
|
443
|
+
*/
|
|
444
|
+
declare function createNavigationBreadcrumb(from: string, to: string): BreadcrumbInput;
|
|
445
|
+
/**
|
|
446
|
+
* Creates a UI interaction breadcrumb.
|
|
447
|
+
*/
|
|
448
|
+
declare function createUIBreadcrumb(action: string, target?: string): BreadcrumbInput;
|
|
449
|
+
/**
|
|
450
|
+
* Creates an HTTP request breadcrumb.
|
|
451
|
+
*/
|
|
452
|
+
declare function createHttpBreadcrumb(method: string, url: string, statusCode?: number): BreadcrumbInput;
|
|
453
|
+
/**
|
|
454
|
+
* Creates a console breadcrumb.
|
|
455
|
+
*/
|
|
456
|
+
declare function createConsoleBreadcrumb(level: "log" | "warn" | "error" | "info", message: string): BreadcrumbInput;
|
|
457
|
+
/**
|
|
458
|
+
* Creates a custom breadcrumb.
|
|
459
|
+
*/
|
|
460
|
+
declare function createCustomBreadcrumb(message: string, data?: Record<string, unknown>): BreadcrumbInput;
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* CatDoes Watch SDK - Symbolication Helpers
|
|
464
|
+
*
|
|
465
|
+
* Utilities for processing stack traces and file paths.
|
|
466
|
+
*/
|
|
467
|
+
/**
|
|
468
|
+
* Produces a readable file path from a Metro/URL-style file reference.
|
|
469
|
+
* - Strips query params
|
|
470
|
+
* - Prefers repo-relative paths like app/... or src/...
|
|
471
|
+
* - Falls back to URL pathname
|
|
472
|
+
*/
|
|
473
|
+
declare function deriveReadableFile(file: string): string;
|
|
474
|
+
/**
|
|
475
|
+
* Checks if a derived filename is usable (not a noisy bundle/node_modules path)
|
|
476
|
+
*/
|
|
477
|
+
declare function isUsableFilename(filename: string): boolean;
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* CatDoes Watch SDK - Version
|
|
481
|
+
*
|
|
482
|
+
* Keep this value updated when making SDK changes.
|
|
483
|
+
*/
|
|
484
|
+
declare const SDK_VERSION = "1.0.0";
|
|
485
|
+
|
|
486
|
+
export { type Breadcrumb, type BreadcrumbInput, BreadcrumbManager, type DeviceInfo, type IngestResponse, SDK_VERSION, Watch, WatchClient, type WatchConfig, type WatchConfigResolved, type WatchEvent, clearDeviceInfoCache, collectDeviceInfo, createConsoleBreadcrumb, createCustomBreadcrumb, createHttpBreadcrumb, createNavigationBreadcrumb, createUIBreadcrumb, deriveReadableFile, getCachedDeviceInfo, getEnvironment, getPlatform, getSessionId, isUsableFilename, removeGlobalHandlers, resetSession, setSessionId, setupConsoleErrorCapture, setupGlobalHandlers };
|