Flare by Spatie
  • Features
  • Pricing
  • Docs
  • Blog
  • LOG IN
  • START TRACKING
  • Home
  • Features
  • Pricing
  • Docs
  • Blog
    • Try Flare for free
    • Sign in
Flare Flare Laravel Laravel PHP PHP JavaScript JavaScript
  • General
  • Introduction
  • Installation
  • Censoring collected data
  • Ignoring collected data
  • Laravel Octane
  • Errors
  • Adding custom context
  • Customising error grouping
  • Handling errors
  • Linking to errors
  • Reporting errors
  • Sending logs to Flare
  • Performance
  • Introduction
  • Sampling
  • Limits
  • Modify spans and span events
  • Data Collection
  • Application info
  • Cache events
  • Console commands
  • Customise error report
  • Database transactions
  • Dumps
  • Errors when tracing
  • Exception context
  • External http requests
  • Filesystem operations
  • Git information
  • Glows
  • Identifying users
  • Jobs and queues
  • Laravel context
  • Livewire
  • Logs
  • Queries
  • Redis commands
  • Requests
  • Server info
  • Solutions
  • Spans
  • Stacktrace arguments
  • Views
  • Older Packages
  • Laravel Flare V1
  • Ignition

Adding custom context

When you send an error to Flare, we already collect a lot of Laravel and user-specific information for you and send it along with the errors that happened in your application. You can also add custom context to your application. This can be very useful if you want to provide key-value-related information that helps you debug a possible error.

For example, your application could be in a multi-tenant environment. In addition to reporting the user, you want to provide a key that quickly lets you identify which tenant was active when the error occurred.

Flare allows you to set custom context items using the following:

use Spatie\LaravelFlare\Facades\Flare;

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

This could be set automatically in a Laravel service provider or an event. The next time an exception occurs, this value will be sent along to Flare, and you can find it on the "Context" tab.

It is also possible to send multiple context items at once:

use Spatie\LaravelFlare\Facades\Flare;

Flare::context([
    'tenant_id' => 'My-Tenant-Identifier',
    'tenant_name' => 'My-Tenant-Name'
]); 
Laravel Octane Customising error grouping

Monitor your web apps and sites from errors to slowdowns with Flare, the easiest application monitoring platform for Laravel, PHP & Javascript.

  • Platform
  • Error Tracking
  • Performance Monitoring
  • Pricing
  • Support
  • Resources
  • Blog
  • Changelog
  • Documentation
  • Affiliate program
  • Service status
  • Terms of use
  • DPA
  • Privacy & Cookie Policy
Flare