Reporting errors
Once registered using flare.light()
, the @flareapp/js
will automatically catch and report errors that bubble up to the window
object. This includes most errors in vanilla JavaScript code that isn't wrapped in a try…catch
block.
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);
}
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');
This method has 2 optional parameters: a context object, and an exceptionClass
string:
flare.reportMessage(
'log message',
{
moreCustomContext: [1, 2, 3],
},
'CriticalLog',
);
Reporting errors caused by browser extensions
If you're using @flareapp/js
version 1.1.0 or higher, Flare will ignore errors that 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,
});