glitchgrab 1.1.0 → 1.2.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 +153 -102
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# glitchgrab
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Turn messy bugs into structured GitHub issues with AI. Drop-in SDK for Next.js apps.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ bun add glitchgrab
|
|
|
12
12
|
|
|
13
13
|
## Quick Start
|
|
14
14
|
|
|
15
|
-
Wrap your app with `GlitchgrabProvider
|
|
15
|
+
Wrap your app with `GlitchgrabProvider`:
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
18
|
// app/layout.tsx
|
|
@@ -20,148 +20,199 @@ import { GlitchgrabProvider } from "glitchgrab";
|
|
|
20
20
|
|
|
21
21
|
export default function RootLayout({ children }) {
|
|
22
22
|
return (
|
|
23
|
-
<GlitchgrabProvider token=
|
|
23
|
+
<GlitchgrabProvider token={process.env.NEXT_PUBLIC_GLITCHGRAB_TOKEN!}>
|
|
24
|
+
{children}
|
|
25
|
+
</GlitchgrabProvider>
|
|
24
26
|
);
|
|
25
27
|
}
|
|
26
28
|
```
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
## Session (User Tracking)
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
- Error boundary around your entire app
|
|
32
|
-
- Page visit tracking for reproduction context
|
|
33
|
-
- URL sanitization (strips tokens, keys, passwords)
|
|
34
|
-
|
|
35
|
-
## Get a Token
|
|
36
|
-
|
|
37
|
-
1. Go to [glitchgrab.dev](https://glitchgrab.dev)
|
|
38
|
-
2. Sign in with GitHub
|
|
39
|
-
3. Connect a repo
|
|
40
|
-
4. Generate an API token
|
|
41
|
-
|
|
42
|
-
## Usage
|
|
43
|
-
|
|
44
|
-
### 1. Auto-Capture (zero config)
|
|
45
|
-
|
|
46
|
-
Just add the provider. Production errors are captured automatically with:
|
|
47
|
-
|
|
48
|
-
- Error message and stack trace
|
|
49
|
-
- Current URL (sanitized)
|
|
50
|
-
- User agent
|
|
51
|
-
- Visited pages history
|
|
52
|
-
|
|
53
|
-
### 2. Manual Bug Reporting (`useGlitchgrab` hook)
|
|
54
|
-
|
|
55
|
-
Build your own report button or trigger:
|
|
32
|
+
Pass a `session` prop so bug reports include the reporter's identity. This lets you trace which user reported each bug.
|
|
56
33
|
|
|
57
34
|
```tsx
|
|
58
|
-
|
|
59
|
-
import {
|
|
60
|
-
|
|
61
|
-
function
|
|
62
|
-
const {
|
|
35
|
+
import { GlitchgrabProvider, type GlitchgrabSession } from "glitchgrab";
|
|
36
|
+
import { useSession } from "next-auth/react"; // or your auth library
|
|
37
|
+
|
|
38
|
+
function Providers({ children }) {
|
|
39
|
+
const { data: authSession } = useSession();
|
|
40
|
+
|
|
41
|
+
// Map your auth session to GlitchgrabSession
|
|
42
|
+
const session: GlitchgrabSession | null = authSession?.user
|
|
43
|
+
? {
|
|
44
|
+
userId: authSession.user.id, // required - your DB primary key
|
|
45
|
+
name: authSession.user.name, // required - display name
|
|
46
|
+
email: authSession.user.email, // optional
|
|
47
|
+
phone: authSession.user.phone, // optional
|
|
48
|
+
}
|
|
49
|
+
: null;
|
|
63
50
|
|
|
64
51
|
return (
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
52
|
+
<GlitchgrabProvider
|
|
53
|
+
token={process.env.NEXT_PUBLIC_GLITCHGRAB_TOKEN!}
|
|
54
|
+
session={session}
|
|
55
|
+
>
|
|
56
|
+
{children}
|
|
57
|
+
</GlitchgrabProvider>
|
|
68
58
|
);
|
|
69
59
|
}
|
|
70
60
|
```
|
|
71
61
|
|
|
72
|
-
|
|
62
|
+
### GlitchgrabSession type
|
|
73
63
|
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
userId:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
64
|
+
```ts
|
|
65
|
+
interface GlitchgrabSession {
|
|
66
|
+
userId: string; // required - primary key from your database
|
|
67
|
+
name: string; // required - reporter's display name
|
|
68
|
+
email?: string | null; // optional
|
|
69
|
+
phone?: string | null; // optional
|
|
70
|
+
[key: string]: unknown; // any extra fields
|
|
71
|
+
}
|
|
80
72
|
```
|
|
81
73
|
|
|
82
|
-
|
|
74
|
+
The `userId` is stored with every report. Use it to look up which user reported a bug in your own database.
|
|
83
75
|
|
|
84
|
-
|
|
76
|
+
## Report Button
|
|
77
|
+
|
|
78
|
+
### Default floating button
|
|
85
79
|
|
|
86
80
|
```tsx
|
|
87
|
-
import {
|
|
81
|
+
import { ReportButton } from "glitchgrab";
|
|
88
82
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
<ReportButton />
|
|
92
|
-
</GlitchgrabProvider>;
|
|
83
|
+
// Floating button at bottom-right (default)
|
|
84
|
+
<ReportButton position="bottom-right" label="Report Bug" />
|
|
93
85
|
```
|
|
94
86
|
|
|
95
|
-
|
|
87
|
+
### Custom trigger (headless)
|
|
88
|
+
|
|
89
|
+
Use the render prop to bring your own button UI:
|
|
96
90
|
|
|
97
91
|
```tsx
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
92
|
+
import { ReportButton } from "glitchgrab";
|
|
93
|
+
|
|
94
|
+
<ReportButton>
|
|
95
|
+
{({ onClick, capturing }) => (
|
|
96
|
+
<button onClick={onClick} disabled={capturing}>
|
|
97
|
+
{capturing ? "Capturing..." : "Report a Bug"}
|
|
98
|
+
</button>
|
|
99
|
+
)}
|
|
100
|
+
</ReportButton>
|
|
102
101
|
```
|
|
103
102
|
|
|
104
|
-
|
|
103
|
+
The modal handles screenshot capture, preview, upload, retake, and submission. Your custom button just triggers it.
|
|
105
104
|
|
|
106
|
-
|
|
105
|
+
## Programmatic Reporting
|
|
106
|
+
|
|
107
|
+
Use the `useGlitchgrab` hook to report bugs from code:
|
|
107
108
|
|
|
108
109
|
```tsx
|
|
109
|
-
import {
|
|
110
|
+
import { useGlitchgrab } from "glitchgrab";
|
|
110
111
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
fallback={<div>Something went wrong in this section</div>}
|
|
114
|
-
>
|
|
115
|
-
<DangerousComponent />
|
|
116
|
-
</GlitchgrabErrorBoundary>;
|
|
117
|
-
```
|
|
112
|
+
function MyComponent() {
|
|
113
|
+
const { reportBug, report, addBreadcrumb } = useGlitchgrab();
|
|
118
114
|
|
|
119
|
-
|
|
115
|
+
// Report a bug
|
|
116
|
+
await reportBug("Button not working on mobile");
|
|
120
117
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
console.log("Captured:", error.message);
|
|
128
|
-
}}
|
|
129
|
-
fallback={<ErrorPage />} // Optional — what to show when the app crashes
|
|
130
|
-
>
|
|
131
|
-
{children}
|
|
132
|
-
</GlitchgrabProvider>
|
|
118
|
+
// Report with a specific type
|
|
119
|
+
await report("FEATURE_REQUEST", "Add dark mode support");
|
|
120
|
+
|
|
121
|
+
// Add custom breadcrumbs for debugging context
|
|
122
|
+
addBreadcrumb("User clicked checkout", { cartSize: "3" });
|
|
123
|
+
}
|
|
133
124
|
```
|
|
134
125
|
|
|
135
|
-
##
|
|
126
|
+
## Fetching Reports by User
|
|
127
|
+
|
|
128
|
+
Use the REST API to fetch reports for a specific user by their primary key:
|
|
136
129
|
|
|
137
|
-
|
|
130
|
+
```bash
|
|
131
|
+
# Fetch all reports
|
|
132
|
+
curl -H "Authorization: Bearer gg_your_token" \
|
|
133
|
+
https://glitchgrab.dev/api/v1/sdk/reports
|
|
134
|
+
|
|
135
|
+
# Fetch reports by a specific user
|
|
136
|
+
curl -H "Authorization: Bearer gg_your_token" \
|
|
137
|
+
"https://glitchgrab.dev/api/v1/sdk/reports?reporterPrimaryKey=user_123"
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
| `GlitchgrabErrorBoundary` | Standalone error boundary for specific sections. |
|
|
139
|
+
# Filter by status
|
|
140
|
+
curl -H "Authorization: Bearer gg_your_token" \
|
|
141
|
+
"https://glitchgrab.dev/api/v1/sdk/reports?status=CREATED&limit=20"
|
|
142
|
+
```
|
|
144
143
|
|
|
145
|
-
###
|
|
144
|
+
### Response
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"success": true,
|
|
149
|
+
"data": [
|
|
150
|
+
{
|
|
151
|
+
"id": "cmn7abc123",
|
|
152
|
+
"source": "SDK_USER_REPORT",
|
|
153
|
+
"status": "CREATED",
|
|
154
|
+
"rawInput": "Button not working",
|
|
155
|
+
"reporterPrimaryKey": "user_123",
|
|
156
|
+
"reporterName": "John Doe",
|
|
157
|
+
"reporterEmail": "john@example.com",
|
|
158
|
+
"reporterPhone": null,
|
|
159
|
+
"pageUrl": "/dashboard/settings",
|
|
160
|
+
"createdAt": "2026-03-26T12:00:00.000Z",
|
|
161
|
+
"issue": {
|
|
162
|
+
"githubNumber": 42,
|
|
163
|
+
"githubUrl": "https://github.com/your/repo/issues/42",
|
|
164
|
+
"title": "Button not working"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
```
|
|
146
170
|
|
|
147
|
-
|
|
148
|
-
| ----------------- | ------------------------------- | -------------------------------------- |
|
|
149
|
-
| `useGlitchgrab()` | `{ reportBug, token, baseUrl }` | Access bug reporting in any component. |
|
|
171
|
+
## Error Boundary
|
|
150
172
|
|
|
151
|
-
|
|
173
|
+
Wrap components to auto-capture React errors:
|
|
152
174
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
| `sanitizeUrl(url)` | Strips sensitive query params from URLs. |
|
|
156
|
-
| `captureContext(pages)` | Returns current URL, user agent, timestamp. |
|
|
157
|
-
| `sendReport(payload, baseUrl)` | Low-level function to send a report. |
|
|
175
|
+
```tsx
|
|
176
|
+
import { GlitchgrabErrorBoundary } from "glitchgrab";
|
|
158
177
|
|
|
159
|
-
|
|
178
|
+
<GlitchgrabErrorBoundary fallback={<p>Something went wrong</p>}>
|
|
179
|
+
<MyComponent />
|
|
180
|
+
</GlitchgrabErrorBoundary>
|
|
181
|
+
```
|
|
160
182
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
183
|
+
## Configuration
|
|
184
|
+
|
|
185
|
+
| Prop | Type | Default | Description |
|
|
186
|
+
|------|------|---------|-------------|
|
|
187
|
+
| `token` | `string` | required | Your Glitchgrab API token (`gg_...`) |
|
|
188
|
+
| `session` | `GlitchgrabSession \| null` | `null` | Logged-in user info for report attribution |
|
|
189
|
+
| `baseUrl` | `string` | `https://glitchgrab.dev` | API base URL |
|
|
190
|
+
| `breadcrumbs` | `boolean` | `true` | Enable automatic breadcrumb tracking |
|
|
191
|
+
| `maxBreadcrumbs` | `number` | `50` | Max breadcrumbs to keep |
|
|
192
|
+
| `onError` | `(error: Error) => void` | - | Called on unhandled errors |
|
|
193
|
+
| `onReportSent` | `(result: ReportResult) => void` | - | Called after a report is sent |
|
|
194
|
+
| `fallback` | `ReactNode` | - | Error boundary fallback UI |
|
|
195
|
+
|
|
196
|
+
## Auto-Capture
|
|
197
|
+
|
|
198
|
+
In production (`NODE_ENV=production`), the SDK automatically captures:
|
|
199
|
+
- Unhandled JavaScript errors
|
|
200
|
+
- Unhandled promise rejections
|
|
201
|
+
- Console errors (as breadcrumbs)
|
|
202
|
+
- Navigation events (as breadcrumbs)
|
|
203
|
+
- API calls (as breadcrumbs)
|
|
204
|
+
|
|
205
|
+
Auto-capture is **disabled in development** to avoid noisy issues.
|
|
206
|
+
|
|
207
|
+
## What gets included in each report
|
|
208
|
+
|
|
209
|
+
- Description from the user
|
|
210
|
+
- Screenshot (auto-captured or uploaded)
|
|
211
|
+
- Page URL and user agent
|
|
212
|
+
- Device info (screen size, viewport, platform, language, color scheme)
|
|
213
|
+
- Page navigation history
|
|
214
|
+
- Activity log (last 15 breadcrumbs)
|
|
215
|
+
- Session info (userId, name, email, phone)
|
|
165
216
|
|
|
166
217
|
## License
|
|
167
218
|
|