# errorgap for Ruby on Rails

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-ruby` · current version: `0.5.0`.

## Install

```sh
bundle add errorgap
```

## Configure

Create `config/initializers/errorgap.rb`:

```ruby
Errorgap.configure do |config|
  config.endpoint     = ENV.fetch("ERRORGAP_ENDPOINT")
  config.project_slug = ENV.fetch("ERRORGAP_PROJECT_SLUG")
  config.api_key      = ENV.fetch("ERRORGAP_API_KEY")
end
```

Set `ERRORGAP_API_KEY` and `ERRORGAP_ENDPOINT` in the app's environment (e.g. `.env` via dotenv-rails, or Rails credentials). Do not hardcode the key in the initializer.

The SDK installs Rack middleware automatically and reports unhandled exceptions from every environment. To skip reporting (errors and APM) in some environments, set `config.ignore_environments = %w[test development]` (also settable via `ERRORGAP_IGNORE_ENVIRONMENTS="test,development"`). Note that `rails generate errorgap:install` produces an initializer that ignores `test` and `development` by default — when verifying the integration from a development machine, remove or adjust that line first.

## Trigger a test error

From `rails console` (or a throwaway route/controller action):

```ruby
raise "Errorgap test error"
```

Unhandled exceptions in a request cycle are reported automatically; in the console, wrap with `Errorgap.notify(StandardError.new("Errorgap test error"))` if the SDK exposes manual reporting.

## 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).
