Add the error-tracking extension to capture uncaught errors and unhandled
promise rejections. The tracker batches them and drops noise from browser
extensions automatically.
import { errorTracking } from "@faststats/react/error";
<Analytics siteKey="your_site_key" extensions={[errorTracking()]} />;
Errors are grouped by their type and message so the same error from many
visitors does not flood your dashboard. Identical errors within a batch are
counted instead of repeated.
In Nuxt, pass the same object as extensions.errorTracking.
Batches are also flushed when the page is hidden. If the collector is
unreachable the queue is capped at maxQueueSize and the oldest errors are
dropped. A batch the collector rejects is not retried.
If you run Nitro, either standalone or through Nuxt, you can report errors thrown
in server routes with @faststats/nitro. The package ships a plugin for Nitro
v2 and one for Nitro v3.
The server plugin reads its settings from environment variables. The token is a
project token, not the browser site key, so keep it on the server only.
Variable
Default
Description
FASTSTATS_TOKEN
required
Project token used to authorize reports
FASTSTATS_ERROR_ENDPOINT
https://metrics.faststats.dev/v1/error
Where server errors are sent
FASTSTATS_BUILD_ID
none
Tags errors with a build for source maps
FASTSTATS_SESSION_ID
none
Session ID attached to every report
FASTSTATS_DEBUG
0
Set to 1 to log reporter activity
FASTSTATS_TOKEN=your_project_token
If FASTSTATS_TOKEN is not set the plugin stays silent and skips reporting, so
it is safe to leave installed in environments without a token.
getContext receives the error, the request path, and Nitro’s error tags.
Use createFaststatsNitroPluginV3 from @faststats/nitro/v3 on Nitro v3.
Option
Default
Description
token
env
Project token
errorEndpoint
env
Where server errors are sent
buildId
env
Build ID for source maps
sessionId
env
Session ID attached to every report
debug
false
Logs reporter activity
flushIntervalMs
5000
Milliseconds between batch uploads
maxBatchHashes
50
Distinct errors held before an early flush
circuitBreakerFailures
5
Consecutive failed sends before reporting pauses
circuitBreakerPauseMs
60000
How long reporting pauses once the breaker opens
getContext
none
Returns extra context attached to each error
The reporter batches errors, retries failed sends and opens a short circuit
breaker after repeated failures so a broken endpoint never slows your server
down.