API reference
Exports
import { flare, Flare, DEFAULT_URL_DENYLIST } from '@flareapp/js';
| Export | Description |
|---|---|
flare |
Ready-to-use singleton instance. Automatically assigned to window.flare in the browser. |
Flare |
The Flare class. Use this to create additional instances (e.g. for reporting to a second project). |
DEFAULT_URL_DENYLIST |
The RegExp used by default to redact sensitive query-string parameter values. Exported so you can compose a custom pattern on top of it. |
Methods
light(key?, debug?): Flare
Initializes the Flare client with your project's public key. The key parameter defaults to the build-time constant injected by the Vite plugin, so when using the plugin you can call flare.light() without arguments.
If debug is passed, it sets the debug config option.
configure(config): Flare
Merges the provided options into the current configuration. See the installation page for all available options.
Note: configure() does a shallow merge — nested objects are fully replaced, not deep-merged.
report(error, attributes?): Promise<void>
Reports an error to Flare. The error parameter is typed as Error, but non-Error values (strings, objects) are automatically converted to Error instances. The optional attributes object is merged into the report's attributes for this report only.
The beforeEvaluate and beforeSubmit client hooks both run during this call.
reportMessage(message, level?, attributes?): Promise<void>
Sends a log-style message to Flare. The level parameter is optional — if omitted, no level is set on the report. Messages are grouped under the 'Log' exception class in the Flare dashboard.
The beforeEvaluate hook does not fire for reportMessage() calls. The beforeSubmit hook still runs.
createReportFromError(error, attributes?): Promise<Report | false>
Builds a full report (stacktrace, context, attributes) without sending it. Returns false if the error is invalid.
sendReport(report): Promise<void>
Sends a pre-built report to Flare. The beforeSubmit hook still runs, so you can use it alongside your existing hooks.
glow(name, level?, data?): Flare
Adds a breadcrumb. See Adding glows.
name—string— a short description of the event.level—MessageLevel(default:'info') — the severity level.data—object | object[](default:[]) — additional data to attach.
addContext(name, value): Flare
Adds a key-value pair to the Generic context group. The value parameter accepts any type.
addContextGroup(groupName, value): Flare
Adds or replaces a named context group. See Adding custom context.
clearGlows(): Flare
Removes all collected glows.
test(): Promise<void>
Sends a real test error ("The Flare client is set up correctly!") to Flare. Use this to verify your setup.
Method chaining
Most methods return the Flare instance, so you can chain calls:
flare
.light('YOUR PROJECT PUBLIC KEY')
.configure({ stage: 'production' })
.addContext('build-id', 'abc123');
Methods that support chaining (return the Flare instance):
light(), configure(), glow(), clearGlows(), addContext(), addContextGroup()
Methods that break the chain (return Promise<void>):
report(), reportMessage(), test()
Using the Flare class directly
The @flareapp/js package exports both a ready-to-use flare singleton and the Flare class itself. If you need a separate instance (e.g. for reporting to a second project), you can create one:
import { Flare } from '@flareapp/js';
const secondFlare = new Flare();
secondFlare.light('ANOTHER PROJECT PUBLIC KEY');
- On this page
- Exports
- Methods
- Method chaining
- Using the Flare class directly