=== bugd.one – Bug Reports & Error Tracking ===
Contributors: mignutimedia, eduardditler
Tags: bug report, error tracking, crash reporting, woocommerce, debugging
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.2.3
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Let visitors report bugs with one click and get PHP and JavaScript errors from your WordPress site delivered to your bugd.one dashboard.

== Description ==

**bugd.one** is a bug tracker and crash reporter hosted in the EU. This plugin connects your WordPress site with a bugd.one project:

* **One-click setup** – "Connect with bugd.one": sign in, pick or create a project, done. The keys are stored automatically and your domain is allowed – no copying of keys.
* **Bug-report widget** – a small button on your site. Visitors describe a problem, take a screenshot of the page with one tap (password and payment fields are blacked out) or attach images, and the report lands in your bugd.one dashboard with browser, page and recent console errors. If you enable support requests or feedback for your project, visitors can also send photos and voice messages. Reporters can be notified by e-mail when the status changes.
* **PHP error tracking** – fatal errors and uncaught exceptions on your server are sent to bugd.one with a stack trace, the affected plugin or theme, and your PHP and WordPress versions. Optionally warnings and notices, too.
* **JavaScript error tracking** (optional) – unhandled browser errors on your pages are reported with the bugd.one crash reporter, as well as scripts and stylesheets that fail to load and – unless you turn it off – failed requests to your site (server errors 5xx and network errors, e.g. when adding to cart or during checkout).
* **WooCommerce** – payment and shipping plugins often write failures only to the WooCommerce log. Log entries of level "error" and above are forwarded to bugd.one with the plugin that logged them (needs the server key, can be turned off).
* **Overview on your WordPress dashboard** – open errors, errors of the last 24 hours, open bug reports and the most recent errors at a glance right after logging in, with links into bugd.one (administrators only, needs the server key).
* **Environments** – staging and development sites are reported as "development" automatically (via `wp_get_environment_type()`), so they never trigger production notifications.
* **Visibility control** – show the widget to everyone, to logged-in users only, or to administrators only.
* **Privacy by design** – no cookies, no form data, no query strings and no IP addresses are sent with PHP errors; e-mail addresses and tokens in error messages are removed before sending.

The plugin never changes how WordPress or PHP handle errors: it only observes them (previously registered handlers are called as usual) and reports at most one event per error every 5 minutes and 30 events per 10 minutes, so an error loop cannot slow down your site.

You need a bugd.one account and a project (https://bugd.one). New accounts can try all Pro features free for 7 days, no credit card required; afterwards Pro (€9.90/month) or Team (€29.90/month) keeps the project accepting reports. The project provides two keys:

* the **project key** (publishable key, `bk_live_…`) for the widget and JavaScript errors – public by design;
* the **server key** (`bk_server_…`, optional) for PHP errors – a secret that is stored in your database and never printed on your pages.

The settings page guides you: a short setup assistant (connect, check, apply recommended settings), then a status card with the connected project, the active features and a "Test connection" button that checks the widget key (including the allowed domains) and sends a PHP test error. Settings are grouped in tabs: Connection, Error tracking, Bug-report widget, Privacy (with a text for your privacy policy to copy) and Advanced.

== External services ==

This plugin connects to the service **bugd.one**, operated by Mignuti Media, Germany (https://bugd.one). Data is stored with Cloudflare, Inc. under EU jurisdiction. The plugin does nothing until you connect it or enter your keys on Settings → bugd.one.

**0. "Connect with bugd.one" (only when an administrator clicks it)**
The administrator's browser is sent to `https://bugd.one/connect/wordpress` with your site's address (origin), the site name and a random one-time value. After the administrator signs in at bugd.one and confirms, bugd.one sends the browser back to your site's `wp-admin/admin-post.php` with a one-time code. Your server then sends this code and your site's origin to `https://bugd.one/api/v1/connect/exchange` and receives the project key, the project name and, if the administrator chose it, a new server key. If the bugd.one project keeps a list of allowed domains, your site's domain is added to it.

**1. Bug-report widget (script loaded from bugd.one)**
When the widget is enabled and a publishable key is set, the plugin loads `https://bugd.one/widget.umd.js` on the front end of your site. The script contacts `https://bugd.one/api/` to load its configuration and to submit reports. If bot protection is enabled for bugd.one, it additionally loads Cloudflare Turnstile (https://challenges.cloudflare.com) when a report is submitted. On submission the following is sent: the text the visitor enters, anything the visitor chooses to attach (a screenshot of the visible page, taken in the browser only when the visitor taps "Take screenshot", with password and payment fields blacked out; images; and – only if support requests or feedback are enabled for the project – photos and voice messages), an optional e-mail address (only if the visitor enters it and consents), the page address without query string and fragment, browser and operating system, recent browser console errors and failed requests (with e-mail addresses, tokens and query strings removed), the environment, and the release string of your site. Like any web request, loading the script and calling the API exposes the visitor's IP address to the bugd.one servers; bugd.one uses it only in a hashed form for rate limiting and does not store it in the report.

**2. JavaScript error tracking (optional, off by default)**
When enabled, the plugin loads `https://bugd.one/crash-reporter.umd.js` for all visitors. When a JavaScript error occurs in a visitor's browser, the error message, a stack trace, the page address without query string and fragment, browser and operating system the release string and the last steps before the error (pages visited within your site, an identifier of clicked controls such as `button#checkout` – never text content or input –, failed requests without query string, and console error and warning messages; e-mail addresses and tokens masked) are sent to `https://bugd.one/api/crash`. The plugin turns off the crash reporter's "session started" signal, so no data is sent while no error occurs. The same applies when a script or stylesheet of your site fails to load (its address without query string) and – if "Also report failed requests" is ticked – when a request from the page to your own site fails with a server error (5xx) or a network error: then the request method, the path without query string (numbers and IDs replaced by placeholders) and the status code are sent, never request or response bodies.

**3. PHP error tracking (on by default, but only active once a server key is saved)**
When a fatal PHP error or an uncaught exception occurs (and optionally a warning or notice), the plugin sends it from your server to `https://bugd.one/api/v1/crashes` with the server key as authorization. Sent: error message and type, a stack trace with file paths relative to your WordPress folder (no arguments), the page path without query string, request method, PHP and WordPress versions, the active theme, the plugin the error occurred in, whether the request is an admin request, the environment and the release string. Not sent: cookies, POST data, query strings, user names or IP addresses. E-mail addresses, tokens, API keys, passwords in connection strings and home-directory names found in messages are replaced by placeholders.

**4. WooCommerce log entries (on by default when WooCommerce is active, but only once a server key is saved)**
When WooCommerce or one of its extensions writes a log entry of level "error", "critical", "alert" or "emergency", the plugin sends it from your server to `https://bugd.one/api/v1/crashes` like a PHP error (see 3): the log message, its source (e.g. the payment plugin), the level, the WooCommerce version and where the entry was written from. The context of the log entry (which may contain order or customer data) is never sent; e-mail addresses and tokens in the message are replaced by placeholders.

**5. Dashboard widget (administrators only, once a server key is saved)**
When an administrator opens the WordPress dashboard, your server requests `https://bugd.one/api/v1/summary` with the server key (at most every 5 minutes, cached). The answer contains only counts and the most recent error groups of your project (type, message, time, number of occurrences). Nothing is sent from your visitors' browsers.

**6. Test buttons on the settings page**
"Test connection" sends one sample PHP error (as in 3, only when a server key is saved) and makes one request from your server to `https://bugd.one/api/widget-config` with your publishable key and your site's address (origin) to verify the key and the allowed domains; the answer contains only the project name. Both run only when an administrator clicks the button.

Terms of service: https://bugd.one/agb
Privacy policy: https://bugd.one/datenschutz

If you use the widget or error tracking, mention bugd.one in your privacy policy. The plugin adds suggested text under Settings → Privacy → Policy Guide.

== Installation ==

1. Upload the `bugdone` folder to `/wp-content/plugins/` or install the plugin from the Plugins screen, then activate it.
2. Open Settings → bugd.one and click "Connect with bugd.one". Sign in (or create an account – 7-day free trial), pick or create a project and confirm. Tick "Capture PHP errors" to also receive PHP errors.
3. Click "Apply recommended settings" in the setup assistant (or choose the features under "Error tracking"), then "Test connection". The PHP test crash appears in your bugd.one dashboard under Crashes (filter: development).
4. If you use a page-cache plugin, clear its cache.

Manual setup instead: copy the publishable key and the server key from Project → Settings in bugd.one, paste them on Settings → bugd.one and save. If the check then says "Domain not allowed", add your site's domain under "Allowed domains" in the bugd.one project settings.

== Frequently Asked Questions ==

= Do I have to copy keys? =

No. "Connect with bugd.one" sets up the keys automatically. It works when your admin area runs on the same address as your site; otherwise paste the keys by hand.

= Connecting replaced my server key – why? =

A bugd.one project has one server key. If you tick "Capture PHP errors" for a project that already has a server key, a new one is created and the old one stops working (bugd.one warns you before). Other servers that used the old key need the new one – or leave the option unticked and paste the existing key by hand.

= Can I track errors without showing the bug-report button? =

Yes. Untick "Show the bug-report button on the site". PHP, JavaScript and WooCommerce errors are still reported – visitors see nothing of the error tracking.

= Where do I find the keys? =

In your bugd.one dashboard under Project → Settings. The publishable key starts with `bk_live_`, the server key with `bk_server_`. Keys are shown once when created; rotate them if you lost one.

= The check says "Domain not allowed". What now? =

In bugd.one open your project → Settings → "Allowed domains" and add your site's domain (for example `https://example.com`). Leave the list empty to allow every domain.

= Which languages does the widget support? =

German, English, French, Spanish, Italian, Portuguese, Dutch and Polish. The widget uses your site language and falls back to English.

= How do I hide the widget on some pages? =

Under Settings → bugd.one → Advanced, enter one path per line (for example `/checkout`). Paths are matched by prefix.

= Is the server key safe? =

It is stored in the WordPress options table like other plugin settings, is never output to the front end and is masked in the settings form. Anyone with database access or administrator rights on your site can read it, so use a dedicated project for each site and rotate the key if you suspect a leak.

= Will this slow down my site? =

No work is done in the normal request path except registering error handlers. Reports are sent only when an error occurs, at the end of the request (after the page has been delivered where the server supports it), with a 2-second timeout, and each error is rate-limited locally.

= Does it work with Query Monitor, Sentry or other error handlers? =

Yes. The plugin chains to previously registered exception and error handlers and never changes WordPress' own error handling.

= Which environment is reported? =

"Automatic" maps `wp_get_environment_type()`: production stays production; staging, development and local are reported as development. You can override it in the settings. Only production events trigger e-mails, webhooks and chat notifications on bugd.one.

= What about page caching? =

If you show the widget only to logged-in users or administrators, make sure your caching plugin does not serve a cached page to other visitors (or exclude logged-in users from the cache).

= Can I use a self-hosted or test endpoint? =

Add `define( 'BUGDONE_API_HOST', 'https://example.com' );` to `wp-config.php` (scheme, host and optional port only). Plain `http://` is accepted only for local development hosts such as `http://localhost:8787`. By default `https://bugd.one` is used.

= How do I remove all data? =

Deleting the plugin removes its settings and temporary data from your database (on multisite from every site of the network). Reports and crashes stored at bugd.one are managed in your bugd.one account.

== Screenshots ==

1. Settings → bugd.one: connection status, active features and the error sources.
2. The bug-report form on your site – with one-tap screenshot and your own fields.
3. A PHP error in the bugd.one dashboard: stack trace, versions and the affected plugin.
4. Open errors and bug reports at a glance on your WordPress dashboard.

== Changelog ==

= 1.2.3 =
* Fix: connecting the site to a different bugd.one project without a new server key now removes the previous project's server key, so PHP errors and WooCommerce logs no longer go to the old project. Changing the project key by hand does the same. The settings page tells you to enter the server key of the new project.

= 1.2.2 =
* Privacy: the crash reporter's "session started" signal (release health) is turned off – with JavaScript error tracking, bugd.one now only receives data when an error occurs.
* Privacy text and readme now also name the last steps before an error (pages visited, identifier of clicked controls, failed requests, console messages) that the crash reporter sends with an error.

= 1.2.1 =
* Fix: with the environment set to "Automatic", sites on localhost, *.local, *.test or private IP addresses are now reported as "development" (no e-mails, webhooks or chat messages), like the other bugd.one SDKs. Before, WordPress reported "production" there by default.

= 1.2.0 =
* New: "Distance from bottom (px)" and "Distance from side (px)" in the Appearance settings move the bug-report button away from the corner (0–400 px, empty = 16 px), e.g. 90 when a chat, callback or cookie-settings button sits in the same corner. Not used for the side tab. Uses the bugd.one widget 1.4 (loaded automatically from bugd.one).

= 1.1.0 =
* New for shops: failed requests to your site (server errors 5xx and network errors, e.g. add to cart, checkout, wc-ajax, Store API) are reported together with JavaScript errors – on by default when JavaScript error tracking is enabled, can be turned off.
* New: WooCommerce log entries of level "error" and above (payment gateways, shipping plugins, WooCommerce itself) are forwarded to bugd.one with the plugin that wrote them. Needs the server key; WooCommerce's own logging keeps working unchanged. Fatal errors that WooCommerce also logs are not reported twice.
* JavaScript error tracking now also reports scripts and stylesheets that fail to load (crash reporter 1.4); failed shop requests show the WooCommerce route, e.g. `POST /?wc-ajax=checkout → 503`.
* New settings page: setup assistant on first start (connect → check → apply recommended settings), status card with "Test connection", dashboard link and the active features, tabs (Connection, Error tracking, Bug-report widget, Privacy, Advanced), the error sources in one card with a "server key" badge (links to the key field when it is missing), a Privacy tab with the suggested privacy policy text to copy, shorter help texts with details on demand, and a save bar that stays visible while scrolling. Clearer that error tracking works without the bug-report button.
* New: "bugd.one" widget on the WordPress dashboard with open errors, errors of the last 24 hours, open bug reports and the most recent errors (needs the server key).
* "Open in dashboard" and the link after the test error lead to the connected project instead of the project list (after connecting with bugd.one).
* The suggested privacy policy text adapts to the features that are turned on (e.g. no bug-report text when the button is hidden; failed requests and WooCommerce log entries are mentioned when active).
* The release now includes the WooCommerce version, e.g. "My Shop (WP 7.1.5, WC 11.3.1)" – bugd.one then shows errors that are new since a shop update.
* The setup assistant does not appear when the recommended settings are already active.
* Faster pages: the crash reporter no longer blocks rendering (loaded with defer, errors before it starts are buffered and reported) and the bug-report widget is loaded only after the page has finished loading. Warnings that repeat within a request no longer create a backtrace each time.

= 1.0.4 =
* New: "Connect with bugd.one" – one-click setup without copying keys. Sign in, pick or create a project, optionally create a server key for PHP errors; your domain is added to the project's allowed domains if the project keeps such a list. Disconnect at any time.
* The status card shows the connected project; a reminder to clear the cache when a page-cache plugin is active.
* Widget (loaded from bugd.one): "Take screenshot" of the visible page with automatic blacking-out of password and payment fields; support requests with photos and voice messages when enabled for the project.
* Privacy policy suggestion and the "External services" section now mention screenshots, photos and voice messages, the connect flow and the data processing agreement.
* Operator name corrected to Mignuti Media.

= 1.0.3 =
* Preparation for the WordPress.org directory: removed the manual translation loader (translations are delivered via translate.wordpress.org), contributor and license metadata.

= 1.0.2 =
* Onboarding: dismissible notice while no project key is set, and a status card with three steps on the settings page showing which keys are set and whether PHP capture is active.
* New "Check widget key" button (verifies the key and the allowed domains) next to "Send PHP test error", with spinner, clear error messages and a link to the dashboard. Tests are disabled while there are unsaved changes.
* A rejected key stays in the field after saving (with an error state).
* Settings: environment, release, position, color, button text moved into a collapsible "Advanced" section; larger touch targets on mobile; shorter descriptions.
* The widget now speaks all eight supported languages (de, en, fr, es, it, pt, nl, pl) based on the site language.
* New options: button style and "Hide widget on these pages".
* Hint when no privacy policy page is set.


= 1.0.1 =
* Error reports are now sent at the end of the request instead of while the page is generated (warnings no longer slow down page rendering).
* Fatal errors are reported before WordPress closes the object cache, so local rate limiting also works with Redis/Memcached.
* Fatal "out of memory" errors can now be reported.
* Better redaction: passwords in connection strings (e.g. mysql://user:pass@host), Authorization headers, well-known API keys and home-directory names; class names like Auth::check are no longer mangled.
* Very long error messages with special characters are no longer rejected by the API.
* Settings: validation notices were shown twice; backslashes in the button text and release were removed; short colors like #fff are now accepted by the widget.
* BUGDONE_API_HOST must be https (http only for local development hosts).
* The "Send test error" button can be used at most every 10 seconds.
* Uninstall on multisite removes the data of every site.

= 1.0.0 =
* First release: bug-report widget, PHP error tracking, optional JavaScript error tracking, environment detection, German translation.

== Upgrade Notice ==

= 1.2.3 =
Switching to another bugd.one project no longer keeps the previous project's server key.

= 1.2.2 =
JavaScript error tracking sends data only when an error occurs; please update the bugd.one paragraph in your privacy policy.

= 1.2.1 =
Test and local sites are reported as development automatically.

= 1.2.0 =
New: adjustable distance of the bug-report button from the bottom and side edge, so it no longer covers chat or callback buttons.

= 1.1.0 =
Shop errors: failed requests (add to cart, checkout) and WooCommerce log errors of payment and shipping plugins.

= 1.0.4 =
One-click "Connect with bugd.one", updated privacy texts (screenshots, photos, voice messages).

= 1.0.3 =
Maintenance release, no functional changes.

= 1.0.2 =
Guided setup with status card and connection test, more widget languages and options.

= 1.0.1 =
Reports are sent after the page is delivered, improved redaction and several small fixes.

= 1.0.0 =
First release.
