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 Protocol Protocol
  • General
  • Installation
  • Resolving bundled code
  • API reference
  • Errors
  • Reporting errors
  • Client hooks
  • Data Collection
  • Adding custom context
  • Adding glows

Reporting errors

Once registered using flare.light(), the @flareapp/js client will automatically catch and report:

  • Unhandled errors that bubble up to the window object (window.onerror),
  • Unhandled promise rejections (window.onunhandledrejection).

This includes most errors in vanilla JavaScript code that isn't wrapped in a try catch block, as well as promises that reject without a .catch() handler.

Errors that are caught by, for example, Axios' catch block, will not be reported automatically. Keep on reading to find out how to send those errors to Flare too.

Reporting caught errors

You can report errors in catch statements or error boundaries using the flare.report() method:

import { flare } from "@flareapp/js";

try {
    functionThatMightThrow();
} catch (error) {
    flare.report(error);
}

You can also pass an attributes object as the second parameter to attach one-off context to a specific error report:

try {
    processOrder(order);
} catch (error) {
    flare.report(error, {
        'context.custom': { order: { id: order.id, total: order.total } },
    });
}

The report method returns a Promise<void> and can be awaited if needed.

Sending logs to Flare

If you don't have an error object, but you just want to send a simple log message to Flare, you can use the reportMessage method instead:

flare.reportMessage('log message');

Like report, reportMessage is async and returns a Promise<void>.

This method has 2 optional parameters: a level string (one of the message levels), and an attributes object. Messages are always grouped under the 'Log' exception class in the Flare dashboard:

flare.reportMessage('Payment retry limit reached', 'warning', {
    'context.custom': { retries: 3 },
});

Advanced: manual report creation

For advanced use cases, the Flare client exposes two lower-level methods that let you create and send reports separately:

// Create a report without sending it
const report = await flare.createReportFromError(error);

if (report) {
    // Modify the report as needed
    report.attributes['context.custom'] = { buildId: 'abc123' };

    // Send the report
    await flare.sendReport(report);
}

createReportFromError(error, attributes?) returns a Promise<Report | false>. It builds the full report (stacktrace, context) without sending it. Returns false if the error is invalid.

sendReport(report) sends a pre-built report to Flare. The beforeSubmit hook still runs, so you can use it alongside your existing hooks.

Network failures

If a report fails to send (network error, non-201 response), it is logged to console.error and dropped. Reports are not retried or queued. This is by design: a broken error reporter should not crash your application.

Reporting errors caused by browser extensions

By default, Flare ignores errors that are likely caused by browser extensions. If you want to opt out of this behaviour, you may configure the JavaScript client to report them.

import { flare } from "@flareapp/js";

flare.configure({
    reportBrowserExtensionErrors: true,
});
API reference Client hooks
  • On this page
  • Reporting caught errors
  • Sending logs to Flare
  • Advanced: manual report creation
  • Network failures
  • Reporting errors caused by browser extensions

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