> ## Documentation Index
> Fetch the complete documentation index at: https://nightwatch.laravel.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Context

> Add additional metadata to your events to make them easier to debug

<img src="https://mintcdn.com/nightwatch/Qtc1X91BNDsWQmmd/images/feature-context.png?fit=max&auto=format&n=Qtc1X91BNDsWQmmd&q=85&s=9ba9e73e2f6c32191d4c6a5ec111f18b" alt="Context" width="3006" height="1532" data-path="images/feature-context.png" />

Nightwatch integrates with [**Laravel Context**](https://laravel.com/docs/context), enabling you to attach metadata to your requests, jobs, and commands. Context is available in the framework from **Laravel 11.x** onwards.

## Examples

### Augment user details

Add additional user context to help identify user types that are experiencing issues:

```php theme={null}
use Illuminate\Support\Facades\Context;

Context::add('locale', App::currentLocale());

Context::add('user', [
    'role' => Auth::user()->role,
    'subscription_tier' => Auth::user()->subscription_tier,
]);
```

### Track feature flags

Track which feature flags were active during a request:

```php theme={null}
use Illuminate\Support\Facades\Context;
use Laravel\Pennant\Feature;

Context::add('feature_flags', [
    'new_dashboard' => Feature::active('new_dashboard'),
    'enhanced_search' => Feature::active('enhanced_search'),
    'beta_checkout' => Feature::active('beta_checkout'),
]);
```

### Debug multi-tenant issues

Add tenant context to help debug tenant-specific issues:

```php theme={null}
use Illuminate\Support\Facades\Context;

Context::add('tenant', [
    'id' => $tenant->id,
    'name' => $tenant->name,
    'plan' => $tenant->subscription_plan,
    'region' => $tenant->region,
]);
```

<Info>
  **Size limits**\ Up to 65 KB of context data is supported per execution; data
  beyond this limit will be truncated.
</Info>
