Context Nightwatch integrates with Laravel Context, enabling you to attach metadata to your requests, jobs, and commands. Context is available in the framework from Laravel 11.x onwards.

Examples

Augmenting user details

Add additional user context to help identify user types that are experiencing issues:
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:
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:
use Illuminate\Support\Facades\Context;

Context::add('tenant', [
    'id' => $tenant->id,
    'name' => $tenant->name,
    'plan' => $tenant->subscription_plan,
    'region' => $tenant->region,
]);
Size limits
Up to 65 KB of context data is supported per execution; data beyond this limit will be truncated.