Flare by Spatie
    • Error Tracking
    • Performance Monitoring
    • Logs Coming soon
  • Pricing
  • Docs
  • Insights
  • Changelog
  • Back to Flare ⌘↵ Shortcut: Command or Control Enter
  • Sign in
  • Try Flare for free
  • Error Tracking
  • Performance Monitoring
  • Logs Coming soon
  • Pricing
  • Docs
  • Insights
  • Changelog
    • Back to Flare ⌘↵ Shortcut: Command or Control Enter
    • Try Flare for free
    • Sign in
Flare Flare Laravel Laravel PHP PHP JavaScript JavaScript React React Vue Vue Svelte Svelte Protocol Protocol
  • General
  • Installation
  • Resolving bundled code
  • API reference
  • Errors
  • Reporting errors
  • Client hooks
  • Data Collection
  • Adding custom context
  • Adding glows

Client hooks

The @flareapp/js client provides hooks to help you finetune your integration with Flare. Configure them using flare.configure():

beforeEvaluate

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

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 beforeEvaluate hook. If you return (a Promise returning) false or null from the callback, Flare won't create or report the passed error:

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

        return error;
    },
});

beforeSubmit

beforeSubmit: (report: Report) => Report | false | null | Promise<Report | false | null>;

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

flare.configure({
    beforeSubmit: (report) => {
        const edited = structuredClone(report);

        // Redact cookies from every report
        delete edited.attributes['http.request.cookies'];

        return edited;
    },
});

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

Report structure

The report object passed to beforeSubmit has the following shape:

type Report = {
    exceptionClass?: string | null;          // Error constructor name (e.g. "TypeError")
    message?: string | null;                 // Error message
    seenAtUnixNano: number;                  // Timestamp in nanoseconds
    stacktrace: StackFrame[];                // Parsed stack frames
    events: SpanEvent[];                     // Breadcrumbs (converted from glows)
    attributes: Attributes;                  // Flat key-value context (request data, cookies, custom context, SDK info, etc.)
    code?: string;                           // Source code snippet around the error
    isLog?: boolean;                         // true for reportMessage() calls
    level?: MessageLevel;                    // Severity level (for log messages)
    sourcemapVersionId?: string;             // Sourcemap version for resolution
    trackingUuid?: string;                   // Tracking identifier
    handled?: boolean;                       // Whether the error was caught
    openFrameIndex?: number;                 // Index of the application frame to highlight
    applicationPath?: string;                // Application base path
    overriddenGrouping?: OverriddenGrouping | null; // Custom grouping strategy
};

Hook behavior with reportMessage

The beforeEvaluate hook only fires for errors reported via flare.report(). When using flare.reportMessage(), the beforeEvaluate hook is not called, but beforeSubmit still runs before the report is sent.

Reporting errors Adding custom context
  • On this page
  • Report structure
  • Hook behavior with

Catch errors and fix slowdowns with Flare, the full-stack application monitoring platform for Laravel, PHP & JavaScript.

  • Platform
  • Error Tracking
  • Performance Monitoring
  • Pricing
  • Support
  • Resources
  • Insights
  • Newsletter
  • Changelog
  • Documentation
  • Affiliate program
  • uptime status badge Service status
  • Terms of use
  • DPA
  • Privacy & cookie Policy
Made in by
Flare