Skip to content
karancdevPublic

About

Free, open-source 14 KB bug report widget. Auto-detects crashes, dead buttons & failed APIs, then sends AI-ready Markdown to GitHub Issues or webhooks.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

BugSnap

License: MIT

BugSnap is a free, open-source bug-report button for any website. Visitors click it, describe the problem, and send. You get the report in an inbox with a page snapshot, browser details, and the last 20 JavaScript errors, ready to copy as Markdown into an issue.

No SDK, no build step, no tracking. One script tag.

Embed

<script src="https://your-bugsnap-host/widget.js" data-project-key="YOUR_PROJECT_KEY" defer></script>

The dashboard generates this tag for each project. Optional attributes: data-api-url (API origin, if different from the script origin), data-position="bottom-left", data-accent="#175846", and data-trigger:

  • data-trigger="floating" (default): a "Report Bug" button always sits in the corner.
  • data-trigger="on-error": nothing shows until the page logs an error or throws, then a small "Something broke? Report bug" popup appears. Visitors can dismiss it.
  • data-trigger="custom": no built-in button. Add data-bugsnap-open to any element, such as <button data-bugsnap-open>Report a bug</button>.

In every mode, clicking an element with data-bugsnap-open or calling window.BugSnap.open() opens the report form. After a report is sent, the widget closes and hides its button or popup for the rest of the page visit.

Screenshot privacy

Screenshots are redrawn from the DOM, so input values, frames, images, and video are never copied. Sensitive areas are also drawn as solid gray blocks. The live page is never modified, so nothing flickers.

  • Masked automatically: password, email, and phone inputs; fields whose autocomplete, name, id, or placeholder mentions cc-, card, CVC/CVV, billing, IBAN, SSN, secret, token, or password; Stripe, Braintree, PayPal, Adyen, Square, Klarna, and similar payment iframes; and Stripe Elements, Braintree hosted fields, and Adyen containers.
  • data-bugsnap-mask (or the older data-bugsnap-private) on any element masks it and everything inside it.
  • data-bugsnap-unmask on an element turns the automatic rules off for it and its children. Password fields, data-bugsnap-mask, and your own selectors still apply.
  • data-mask=".order-summary, #address" on the script tag masks extra CSS selectors. Invalid selectors are ignored.
  • data-mask-all-inputs on the script tag masks every visible form field.
  • Masking is always on. Visitors cannot turn it off.
  • In the report form, right under the description, the visitor sees a small masked preview and a three-way switch:
    • Cropped: a crop around the broken element, with about 96 px of padding and a red outline. It is the default when there is a broken element: the target of the latest dead click, unresponsive button, or broken image or asset, or the control pressed up to 3 seconds before a JavaScript or network error. It is disabled when there is no such element or it is off-screen.
    • Full: the whole visible page.
    • No screenshot: the report carries only the technical details. Switching updates the preview at once, and both images are masked. The image sent is the one in the preview.
  • data-screenshot-mode sets the starting choice: element (default, Cropped when possible, otherwise Full), viewport (Full), or none (no screenshot and no switch).
  • The same options can be set in JavaScript, before or after the script loads: window.BugSnapConfig = { mask: ['.order-summary'], maskAllInputs: true, screenshotMode: 'element' }.
<form>
  <input name="email" type="email">                <!-- masked automatically -->
  <input autocomplete="cc-number">                  <!-- masked automatically -->
  <div data-bugsnap-mask>Ship to Jane Doe…</div>     <!-- masked by you -->
</form>
<script src="https://your-bugsnap-host/widget.js" data-project-key="YOUR_PROJECT_KEY"
  data-mask=".order-summary" defer></script>

Captured error text is scrubbed before it is stored in the report: Authorization, Cookie, token, secret, API key, password, CVC, and session values become [redacted], as do Bearer tokens and JWTs. Card numbers that pass a Luhn check become [card], email addresses become [email], and query strings are dropped from URLs. Network entries only ever record the method, origin, path, and status, never headers or bodies.

Hosted or self-hosted

  • Free hosted: sign up and paste the snippet. Each account gets up to 5 projects and 100 reports a month (fair use). The "Powered by BugSnap" badge is optional.
  • Self-host (MIT): run it on Node 24 or Cloudflare Workers with D1. No limits beyond the ones you set. Webhooks (generic JSON + Markdown, Slack, Discord) and GitHub issues work on both.

Quickstart: Node 24

git clone https://github.com/karancdev/bugsnap.git
cd bugsnap
npm ci
npm run build
export BUGSNAP_ADMIN_KEY="$(openssl rand -hex 32)"
export BUGSNAP_SESSION_SECRET="$(openssl rand -hex 32)"
npm start

Open http://127.0.0.1:3000/signup to create an account, or sign in with the owner key through the "Owner key" link at /login. The server listens only on loopback (127.0.0.1); put a reverse proxy with HTTPS in front of it for public use and set BUGSNAP_PUBLIC_ORIGIN to that origin. Data is stored in a JSON file (.bugsnap/data.json by default). Stop the server with Ctrl+C.

For a local demo with fictional data, run BUGSNAP_PUBLIC_ORIGIN=http://127.0.0.1:3000 BUGSNAP_DEMO_MODE=true npm start. This turns on the homepage widget and skips sign-in. It is refused unless the origin is plain HTTP on localhost or 127.0.0.1.

Quickstart: Cloudflare Workers + D1

npm ci && npm run build
npx wrangler d1 create bugsnap            # copy the database_id into wrangler.toml
npx wrangler d1 migrations apply bugsnap --remote
npx wrangler secret put BUGSNAP_SESSION_SECRET
npx wrangler secret put BUGSNAP_ADMIN_KEY # optional owner account
npx wrangler secret put RESEND_API_KEY # optional, enables password reset emails
npx wrangler deploy

Before deploying, set BUGSNAP_PUBLIC_ORIGIN in wrangler.toml to the HTTPS origin of your route and replace the placeholder database_id. The Worker refuses to start without BUGSNAP_SESSION_SECRET or BUGSNAP_ADMIN_KEY. For local testing, use npx wrangler d1 migrations apply bugsnap --local, put secrets in an ignored .dev.vars file, and run npx wrangler dev.

Migrations, applied in order:

  • 0001_init.sql: projects, reports, monthly per-project usage
  • 0002_revoked_sessions.sql: signed-out sessions
  • 0003_users_and_billing.sql: accounts and projects.user_id (its old plan and Stripe columns are no longer used; the filename stays so existing databases do not re-run it)
  • 0004_account_usage.sql: monthly per-account report counter
  • 0005_rate_limits.sql: sign-in and sign-up rate-limit counters shared by all Worker isolates
  • 0006_password_resets.sql: single-use password reset tokens
  • 0007_github_automation.sql: projects.github_repo and projects.github_token for automatic GitHub issues

Apply new migrations before deploying code that needs them. Webhooks and GitHub issues run on Workers too: they are sent after the 201 response through ctx.waitUntil, so a slow endpoint never delays the reporter.

Deploying to Cloudflare Pages instead

The same Worker also runs as a Pages project with an advanced-mode _worker.js. Give the project the nodejs_compat and enable_nodejs_http_server_modules compatibility flags, a D1 binding named DB, and the same variables and secrets. Then bundle the Worker yourself and upload it with --no-bundle:

npm run build
npx esbuild src/worker/index.ts --bundle --format=esm --platform=node --target=es2022 \
  --external:cloudflare:node --outfile=dist/worker-assets/_worker.js
npx wrangler pages deploy dist/worker-assets --project-name <your-project> --branch main --no-bundle

Do not drop --no-bundle. Without it, Pages re-bundles _worker.js, replaces node:http with a stub, and every page fails with error 1101.

Configuration

Variable Default Purpose
BUGSNAP_SESSION_SECRET none Long random value that signs session cookies. Required on Workers (unless an owner key is set); recommended on Node so sessions survive restarts.
BUGSNAP_ADMIN_KEY (or ADMIN_PASSWORD) none Owner key. The owner account has no project or report limits and owns projects created before accounts existed. Without it, owner sign-in stays locked.
BUGSNAP_PUBLIC_ORIGIN none Public origin, such as https://bugs.example.com. Required on Workers.
BUGSNAP_MONTHLY_REPORT_CAP 100 Reports each account can receive per UTC calendar month, across all its projects. Deleted reports and projects still count.
BUGSNAP_MAX_PROJECTS 5 Projects each account can create.
BUGSNAP_REPORTS_PER_MINUTE 30 Report submissions per IP per minute.
BUGSNAP_TRUST_PROXY false Node only. Set to true behind a single reverse proxy so rate limits use the last X-Forwarded-For address instead of the proxy's. Leave it off when clients can reach Node directly.
RESEND_API_KEY none Resend API key for password reset emails. Without it, "Forgot password?" answers that reset email is not configured yet. Set it as a Worker secret.
RESEND_FROM_EMAIL BugSnap <onboarding@resend.dev> Sender for reset emails. Use an address on a domain verified in Resend.
BUGSNAP_DATA .bugsnap/data.json JSON store path (Node only).
PORT 3000 Listen port (Node only).
BUGSNAP_DEMO_MODE false Local demo mode, described above.
NODE_ENV production development allows webhooks to local addresses for testing.

Self-hosters can raise the caps as high as they like.

API

  • POST /api/reports: submit a report (the only write allowed cross-origin).
  • GET /api/projects/:key/config: badge setting for the widget.
  • POST /api/auth/register, POST /api/auth/login, POST /api/auth/logout, POST /api/session (owner key), DELETE /api/session.
  • GET /api/me: email, project count and limit, and reports this month and limit.
  • GET|POST /api/projects, PATCH|DELETE /api/projects/:key, plus report list, resolve, reopen, and delete routes used by the dashboard.
  • PATCH /api/projects/:key/github with { "repo": "owner/repo", "token": "github_pat_…" } connects GitHub; { "repo": null } disconnects and deletes the token. Leave token out to change only the repo.

Automation: send bugs to your AI agent

  • Webhook: every new report is POSTed as { "event": "report.created", "projectId", "projectName", "report", "markdown" }. Slack and Discord URLs get a formatted message instead. Point it at your AI agent, OpenBot, or Zapier.
  • GitHub issue: with a fine-grained token that has Issues: Read and write on one repo, each report opens an issue titled [BugSnap] <first line> with the Markdown report and the labels bugsnap and the category (retried without labels if the repo refuses them). Pair it with GitHub Copilot coding agent, Factory Droid, or Claude Code Action to get a fix PR.

Over the project limit, project creation returns 403. Over the monthly report limit, submission returns 429.

Security

  • Passwords are hashed with PBKDF2-SHA256 (100,000 iterations, random 16-byte salt). Passwords need at least 6 characters.
  • Password reset links are single-use, expire after one hour, and are stored only as SHA-256 hashes. Reset requests are limited to 5 an hour per network and per email, and the answer is the same whether or not the account exists.
  • Sign-in allows 10 failed attempts per IP and 10 per email address in a 15-minute window, for both email and owner-key sign-in. Sign-up allows 5 attempts per IP per hour. Over a limit, the API answers 429 with Retry-After. These counters live in the database (D1 on Workers, the JSON store on Node), so every Worker isolate shares them. IPv6 clients are grouped by /64, and keys are stored as hashes, not raw IPs or emails. A per-isolate burst limit of 8 auth requests per IP per minute also applies.
  • On Workers and HTTPS origins, responses include Strict-Transport-Security: max-age=31536000; includeSubDomains.
  • Sessions are signed, HTTP-only cookies that last eight hours. Signing out revokes the session. Workers keep revocations in D1; Node keeps them in memory until restart, so rotate BUGSNAP_SESSION_SECRET to end every session.
  • Each account sees only its own projects and reports. Another account's project or report answers 404.
  • Snapshots redraw visible page backgrounds and text instead of capturing browser pixels. They omit form values, frames, and images, and draw password, email, phone, card, and payment fields, payment iframes, and anything marked data-bugsnap-mask or matched by data-mask as solid blocks (see Screenshot privacy). By default the image is cropped to the broken element. Reporters see a masked preview and can switch between Cropped, Full, and No screenshot, and data-screenshot-mode="none" turns screenshots off. Page URL query strings and fragments are dropped, and error text is scrubbed of credentials, card numbers, and emails. Other visible text and unusual error formats can still contain private data, so mask anything sensitive.
  • Webhooks carry the full report, including the reporter's email and screenshot, so only point them at endpoints you trust. In production they require a public HTTPS hostname (no IP literals, ports, credentials, localhost, .local, or .internal), time out after 5 seconds, and never follow redirects. Node also pins DNS to public addresses for each delivery. Stored webhook URLs are never returned by the API.
  • GitHub tokens are stored server-side (the github_token column on D1) and are never returned by the API; the dashboard only shows ✓ Connected to owner/repo. Use a fine-grained token limited to one repository and Issues access.
  • The widget needs the host page's content security policy to allow the script, requests to the API, inline styles, and JPEG data images.

Please report security issues privately through GitHub security advisories rather than public issues.

Development

npm ci
npm run build   # type check + bundle
npm test        # vitest

License

MIT © 2026 Karan Choudhary

About

Free, open-source 14 KB bug report widget. Auto-detects crashes, dead buttons & failed APIs, then sends AI-ready Markdown to GitHub Issues or webhooks.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages