# `NervesHubLink.Extensions.ErrorReports.Config`
[🔗](https://github.com/nerves-hub/nerves_hub_link/blob/v2.14.0/lib/nerves_hub_link/extensions/error_reports/config.ex#L5)

How the Error Reports extension is configured.

    config :nerves_hub_link,
      error_reports: [
        max_reports: 100,
        interval_seconds: 60,
        context: {MyApp.Telemetry, :error_context, []}
      ]

Turning error reports on is naming the module in `extension_modules`, not a
key here.

# `context`

```elixir
@spec context() :: %{required(String.t()) =&gt; String.t()}
```

Device state to attach to every report, as a string map.

Uptime by default, because it is the one thing every runtime can answer
cheaply. Anything else is device-specific, and reading it is not free: the
health extension shells out to `free` for memory, which is not something to
do in the middle of a crash.

So the rest is yours to supply. Point `:context` at a function returning a
map and it is merged over the default:

    config :nerves_hub_link,
      error_reports: [context: {MyApp.Telemetry, :error_context, []}]

    def error_context() do
      %{"reboot_count" => Nerves.Runtime.KV.get("nerves_fw_validated"), "site" => "depot-4"}
    end

Keys named `uptime_ms`, `free_memory_bytes` and `reboot_count` are given
units in the NervesHub UI. Everything else is shown as it arrives.

Called on the extension's own process when a batch is sent, never in the
process that crashed. A function that raises costs the report its context and
nothing else.

# `interval`

```elixir
@spec interval() :: pos_integer()
```

How long to buffer before sending, in milliseconds.

Never less than 60 seconds, whatever is configured.

# `max_reports`

```elixir
@spec max_reports() :: pos_integer()
```

How many reports to hold before dropping the oldest.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
