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

Identifying users

When a user logs in to your Laravel application and an error/trace occurs, helpful information about the user is sent to Flare.

By default, the following will be sent:

  • id
  • email
  • name

When you implement the toFlare method on the user model, additional attributes can be sent:

class User extends BaseUser
{
    public function toFlare()
    {
        return [
            'name' => $this->name,
            'email' => $this->email
        ];
    }
}

It is possible to customise which data will be used for the current user by implementing a custom UserAttributesProvider:

use Spatie\FlareClient\AttributesProviders\ UserAttributesProvider;

class CustomUserAttributesProvider extends UserAttributesProvider
{
    public function id(mixed $user): string|int|null
    {
        return $user->id;
    }

    public function fullName(mixed $user): string|null
    {
        return "{$user->first_name} {$user->last_name}";
    }

    public function email(mixed $user): string|null
    {
        return $user->email;
    }

    public function attributes(mixed $user): array
    {
        return [
            'team_id' => $user->team_id
        ];
    }
}

The custom provider then should be registered within the Flare config as such:

'attribute_providers' => [
    'user' => CustomUserAttributesProvider::class,
    // Other attribute providers ...
],

When you don't want to send any user data, you can use the EmptyUserAttributesProvider:

use Spatie\FlareClient\AttributesProviders\EmptyUserAttributesProvider;

'attribute_providers' => [
    'user' => EmptyUserAttributesProvider::class,
    // Other attribute providers ...
],
Glows Jobs and queues

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