# errorgap for WordPress

See [index.md](./index.md) for API details and the placeholder values (`ERRORGAP_API_KEY`, `ERRORGAP_ENDPOINT`, `ERRORGAP_PROJECT_SLUG`).

SDK source: `github.com/errorgaphq/errorgap-wordpress` · current version: `0.2.0`.

## Install

Upload and activate the Errorgap plugin (via the WordPress admin → Plugins → Add New → Upload, or by placing it in `wp-content/plugins/` in a folder named `errorgap` and activating it; with WP-CLI: `wp plugin activate errorgap`).

## Configure

Add to `wp-config.php`, above the `/* That's all, stop editing! */` line:

```php
define('ERRORGAP_ENDPOINT', 'ERRORGAP_ENDPOINT');
define('ERRORGAP_PROJECT_SLUG', 'ERRORGAP_PROJECT_SLUG');
define('ERRORGAP_API_KEY', getenv('ERRORGAP_API_KEY'));
```

Set the `ERRORGAP_API_KEY` environment variable in the hosting environment — the endpoint and project slug are not secrets and can be literals. These constants override the plugin's settings screen, and reporting turns on automatically when both `ERRORGAP_ENDPOINT` and `ERRORGAP_PROJECT_SLUG` are defined. If neither constants nor env vars are workable, the same values can be saved on Settings → Errorgap instead (check "Enabled" there) — avoid committing `wp-config.php` with a hardcoded key.

## Trigger a test error

From WP-CLI:

```sh
wp eval 'throw new \Exception("Errorgap test error");'
```

Or temporarily add `throw new \Exception('Errorgap test error');` to a theme's `functions.php` and load any page (remove it afterwards).

## Verify

Run the verification curl from [index.md](./index.md) and confirm HTTP 201 with a `group_id`. Then trigger the test error above and confirm the errorgap onboarding screen advances (it polls for the first event every 3 seconds).
