# Custom context



Flare collects a lot of Laravel and user specific information for you automatically. On top of that, you can attach your own key/value data so it shows up on every error report, trace, and log Flare receives.

This is especially useful in applications that serve multiple tenants, or whenever you want a value (like the active tenant, an experiment variant, or a feature flag state) to be available everywhere without having to remember to add it at the call site.

## Adding context

Use the `Flare` facade to add a context item:

```php
use Spatie\LaravelFlare\Facades\Flare;

Flare::context('tenant', 'My-Tenant-Identifier');
```

The next time an error is reported, a trace is flushed, or a log is sent, this value will be included and available in the "Context" tab.

You can also set multiple context items at once:

```php
use Spatie\LaravelFlare\Facades\Flare;

Flare::context([
    'tenant_id' => 'My-Tenant-Identifier',
    'tenant_name' => 'My-Tenant-Name',
]);
```

A common place to set custom context is in a service provider or a middleware, so the values are populated for the rest of the request, command, or job.
