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
  • Installation
  • Framework integrations
  • Resolving bundled code
  • Errors
  • Reporting errors
  • Client hooks
  • Data Collection
  • Adding custom context
  • Adding glows
  • Solution providers

Client hooks

The @flareapp/js provides a couple hooks to help you finetune your integration with Flare.

flare.beforeEvaluate

beforeEvaluate: (error: Error) => Error | false | Promise<Error | false>;

Depending on the size of the report, submitting an error can take a second, and has a chance of slowing down your application. If you want to stop some errors from being evaluated, use the flare.beforeEvaluate function. If you return (a Promise returning) false from that function, Flare won't create or report the passed error:

flare.beforeEvaluate = error => {
    if (error.message.includes('Boring error')) {
        return false;
    }
    
    return error;
};

flare.beforeSubmit

beforeSubmit: (report: ErrorReport) => ErrorReport | false | Promise<ErrorReport | false>

You can also stop a report from being sent to Flare, or edit it right before it's submitted using the flare.beforeSubmit function:

flare.beforeSubmit = report => {
    report.stacktrace = []; // remove the stacktrace for all reports
    
    return report;
}

Using this hook, you can also add additional context to your error report. Read more about customizing the report here.

Reporting errors Adding custom context

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