glitchgrab 1.47.0 → 1.48.1

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 CHANGED
@@ -1,6 +1,8 @@
1
1
  # glitchgrab
2
2
 
3
- Turn messy bugs into structured GitHub issues with AI. Drop-in SDK for Next.js apps.
3
+ Turn production errors and your users' bug reports into structured GitHub issues. Drop-in SDK for Next.js apps.
4
+
5
+ This page covers the SDK. Step-by-step guides for everything else — the Chrome extension, QA testers, call recording, the AI report assistant, MCP for Claude — are at **[glitchgrab.dev/guides](https://glitchgrab.dev/guides)**.
4
6
 
5
7
  ## How do I install Glitchgrab?
6
8
 
@@ -10,6 +12,15 @@ npm install glitchgrab
10
12
  bun add glitchgrab
11
13
  ```
12
14
 
15
+ ## How do I get a token?
16
+
17
+ 1. Sign in at [glitchgrab.dev/login](https://glitchgrab.dev/login) with GitHub.
18
+ 2. Connect your GitHub org and install the Glitchgrab GitHub App on the repo that should receive issues.
19
+ 3. Open **API Tokens**, pick the repo and create a token. It starts with `gg_`.
20
+ 4. Put it in your environment as `NEXT_PUBLIC_GLITCHGRAB_TOKEN`.
21
+
22
+ With screenshots: [Connect your GitHub org](https://glitchgrab.dev/guides/connect-your-github-org) and [Create an API token](https://glitchgrab.dev/guides/create-an-api-token).
23
+
13
24
  ## How do I get started?
14
25
 
15
26
  Wrap your app with `GlitchgrabProvider`:
@@ -354,15 +365,15 @@ Use the REST API directly to fetch reports:
354
365
  ```bash
355
366
  # Fetch all reports
356
367
  curl -H "Authorization: Bearer gg_your_token" \
357
- https://www.glitchgrab.dev/api/v1/sdk/reports
368
+ https://glitchgrab.dev/api/v1/sdk/reports
358
369
 
359
370
  # Fetch reports by a specific user
360
371
  curl -H "Authorization: Bearer gg_your_token" \
361
- "https://www.glitchgrab.dev/api/v1/sdk/reports?reporterPrimaryKey=user_123"
372
+ "https://glitchgrab.dev/api/v1/sdk/reports?reporterPrimaryKey=user_123"
362
373
 
363
374
  # Filter by status
364
375
  curl -H "Authorization: Bearer gg_your_token" \
365
- "https://www.glitchgrab.dev/api/v1/sdk/reports?status=CREATED&limit=20"
376
+ "https://glitchgrab.dev/api/v1/sdk/reports?status=CREATED&limit=20"
366
377
  ```
367
378
 
368
379
  ### Response
@@ -454,7 +465,7 @@ curl -X POST \
454
465
  -H "Authorization: Bearer gg_your_token" \
455
466
  -H "Content-Type: application/json" \
456
467
  -d '{"action": "label", "label": "approved"}' \
457
- https://www.glitchgrab.dev/api/v1/reports/REPORT_ID/actions
468
+ https://glitchgrab.dev/api/v1/reports/REPORT_ID/actions
458
469
  ```
459
470
 
460
471
  #### Reject a report
@@ -464,7 +475,7 @@ curl -X POST \
464
475
  -H "Authorization: Bearer gg_your_token" \
465
476
  -H "Content-Type: application/json" \
466
477
  -d '{"action": "label", "label": "rejected"}' \
467
- https://www.glitchgrab.dev/api/v1/reports/REPORT_ID/actions
478
+ https://glitchgrab.dev/api/v1/reports/REPORT_ID/actions
468
479
  ```
469
480
 
470
481
  #### Close an issue
@@ -474,7 +485,7 @@ curl -X POST \
474
485
  -H "Authorization: Bearer gg_your_token" \
475
486
  -H "Content-Type: application/json" \
476
487
  -d '{"action": "close"}' \
477
- https://www.glitchgrab.dev/api/v1/reports/REPORT_ID/actions
488
+ https://glitchgrab.dev/api/v1/reports/REPORT_ID/actions
478
489
  ```
479
490
 
480
491
  #### Reopen an issue
@@ -484,7 +495,7 @@ curl -X POST \
484
495
  -H "Authorization: Bearer gg_your_token" \
485
496
  -H "Content-Type: application/json" \
486
497
  -d '{"action": "reopen"}' \
487
- https://www.glitchgrab.dev/api/v1/reports/REPORT_ID/actions
498
+ https://glitchgrab.dev/api/v1/reports/REPORT_ID/actions
488
499
  ```
489
500
 
490
501
  #### Remove a label
@@ -494,7 +505,7 @@ curl -X POST \
494
505
  -H "Authorization: Bearer gg_your_token" \
495
506
  -H "Content-Type: application/json" \
496
507
  -d '{"action": "unlabel", "label": "rejected"}' \
497
- https://www.glitchgrab.dev/api/v1/reports/REPORT_ID/actions
508
+ https://glitchgrab.dev/api/v1/reports/REPORT_ID/actions
498
509
  ```
499
510
 
500
511
  #### Add any custom label
@@ -504,7 +515,7 @@ curl -X POST \
504
515
  -H "Authorization: Bearer gg_your_token" \
505
516
  -H "Content-Type: application/json" \
506
517
  -d '{"action": "label", "label": "high-priority"}' \
507
- https://www.glitchgrab.dev/api/v1/reports/REPORT_ID/actions
518
+ https://glitchgrab.dev/api/v1/reports/REPORT_ID/actions
508
519
  ```
509
520
 
510
521
  ### How to get the report ID
@@ -526,7 +537,7 @@ Each report has a conversation thread powered by GitHub issue comments. No extra
526
537
 
527
538
  ```bash
528
539
  curl -H "Authorization: Bearer gg_your_token" \
529
- https://www.glitchgrab.dev/api/v1/sdk/reports/REPORT_ID
540
+ https://glitchgrab.dev/api/v1/sdk/reports/REPORT_ID
530
541
  ```
531
542
 
532
543
  Returns the full issue body + all comments:
@@ -565,7 +576,7 @@ curl -X POST \
565
576
  -H "Authorization: Bearer gg_your_token" \
566
577
  -H "Content-Type: application/json" \
567
578
  -d '{"message": "I can reproduce this, fixing now", "reporterName": "Vivek", "reporterEmail": "vivek@example.com"}' \
568
- https://www.glitchgrab.dev/api/v1/sdk/reports/REPORT_ID/comments
579
+ https://glitchgrab.dev/api/v1/sdk/reports/REPORT_ID/comments
569
580
  ```
570
581
 
571
582
  The comment is posted to the GitHub issue with attribution: "Commented by: **Vivek** (vivek@example.com)".
@@ -799,13 +810,91 @@ reportServerError(error: unknown, options?: {
799
810
  development, or the API refused it.
800
811
  - No React, no DOM, no `"use client"`. Safe in any Node runtime.
801
812
 
813
+ ## How do I show my guides on my own site?
814
+
815
+ Write guides in Glitchgrab (the Guides page, or an agent with `save_guide`), then
816
+ render them on your site from server components. Uses the same `GLITCHGRAB_TOKEN`
817
+ (or `NEXT_PUBLIC_GLITCHGRAB_TOKEN`) as the rest of the SDK, and reads published
818
+ guides only.
819
+
820
+ ```tsx
821
+ // app/guides/page.tsx
822
+ import { listGuides } from "glitchgrab/server";
823
+
824
+ export default async function GuidesPage() {
825
+ const guides = await listGuides();
826
+ return (
827
+ <ul>
828
+ {guides.map((g) => (
829
+ <li key={g.slug}>
830
+ <a href={`/guides/${g.slug}`}>{g.title}</a> — {g.summary}
831
+ </li>
832
+ ))}
833
+ </ul>
834
+ );
835
+ }
836
+ ```
837
+
838
+ ```tsx
839
+ // app/guides/[slug]/page.tsx
840
+ import { notFound } from "next/navigation";
841
+ import { escapeJsonForScript, getGuide } from "glitchgrab/server";
842
+
843
+ export default async function GuidePage({ params }: { params: Promise<{ slug: string }> }) {
844
+ const { slug } = await params;
845
+ const guide = await getGuide(slug);
846
+ if (!guide) notFound();
847
+
848
+ const jsonLd = { "@context": "https://schema.org", "@type": "HowTo", name: guide.title, description: guide.summary };
849
+
850
+ return (
851
+ <article>
852
+ <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: escapeJsonForScript(jsonLd) }} />
853
+ <h1>{guide.title}</h1>
854
+ <div dangerouslySetInnerHTML={{ __html: guide.html }} />
855
+ </article>
856
+ );
857
+ }
858
+ ```
859
+
860
+ - **Never throws.** `listGuides()` returns `[]` and `getGuide()` returns `null` on
861
+ any failure — no token, Glitchgrab down, a slow response (5s timeout), an
862
+ unexpected shape. An outage leaves the page empty instead of a 500.
863
+ - **Cached for 5 minutes** by default. The API route is dynamic, so the cache is
864
+ yours: pass `{ revalidate: 60 }`, or `0` to read fresh every request.
865
+ - **Use `escapeJsonForScript` for JSON-LD.** `JSON.stringify` leaves `</script>`
866
+ intact, so a guide title containing it would break out of the tag.
867
+ - **`html` is sanitized by Glitchgrab** — raw HTML in the markdown arrives as
868
+ text, and only http(s), mailto and relative links survive. On a domain that
869
+ holds your users' sessions, add your own sanitize pass as defence in depth;
870
+ the SDK ships no sanitizer to stay dependency-free.
871
+ - **Headings have ids** — `<h2 id="guide-before-you-start">` — for a table of
872
+ contents or a link to one step. The `guide-` prefix is there so a heading can
873
+ never shadow a `window` global on your page.
874
+ - `link` is where the guide lives on your site (its own link, else your guides
875
+ base URL + slug), or `null` when neither is set.
876
+
877
+ ```ts
878
+ listGuides(options?: GuideReadOptions): Promise<GuideSummary[]>
879
+ getGuide(slug: string, options?: GuideReadOptions): Promise<Guide | null>
880
+
881
+ interface GuideReadOptions {
882
+ token?: string; // default: GLITCHGRAB_TOKEN, then NEXT_PUBLIC_GLITCHGRAB_TOKEN
883
+ baseUrl?: string; // default: GLITCHGRAB_BASE_URL, then https://glitchgrab.dev
884
+ revalidate?: number; // seconds, default 300
885
+ timeoutMs?: number; // default 5000
886
+ }
887
+ ```
888
+
889
+ Never pass the `ggw_` guides write key here for a public page — it reads drafts too.
890
+
802
891
  ## What configuration options are available?
803
892
 
804
893
  | Prop | Type | Default | Description |
805
894
  |------|------|---------|-------------|
806
895
  | `token` | `string` | required | Your Glitchgrab API token (`gg_...`) |
807
896
  | `session` | `GlitchgrabSession \| null` | `null` | Logged-in user info for report attribution |
808
- | `baseUrl` | `string` | `https://www.glitchgrab.dev` | API base URL |
897
+ | `baseUrl` | `string` | `https://glitchgrab.dev` | API base URL |
809
898
  | `breadcrumbs` | `boolean` | `true` | Enable automatic breadcrumb tracking |
810
899
  | `maxBreadcrumbs` | `number` | `50` | Max breadcrumbs to keep |
811
900
  | `onError` | `(error: Error) => void` | - | Called on unhandled errors |