Browser monitoring is a beta AppSignal Labs feature. The
@appsignal/browser package is published under the beta tag on npm, and its
configuration and API may still change between beta releases. Share feedback
in our Discord community.init() as a single object. Only key is required. Configuration is read once, when init() runs, so changing an option means deploying a new build.
key
- Type:
string - Required
endpoint
- Type:
string - Default value: the current page’s origin
https://appsignal-endpoint.net unless you proxy AppSignal traffic through your own domain, in which case leaving it unset posts to your own origin. A trailing slash is stripped.
Errors are sent to POST /ingest/browser/errors, and web vitals to POST /ingest/browser. The key rides along as an api_key query parameter, which is worth knowing if you maintain a connect-src allowlist.
active
- Type:
boolean - Default value:
true
false, init() returns straight away and does nothing at all: it changes nothing on the page, starts no timers, and makes no requests. Every other function does nothing too, so you can call them anywhere without checking first.
Set this from your build environment so development, test, and CI runs send nothing:
appVersion
- Type:
string
beforeError
- Type:
(event: IncomingError) => IncomingError | null
null to drop the error, or mutate fields on the event to redact them. Read more in filtering errors.
This callback must be synchronous. A returned promise is detected, logged as a console.error, and the error is dropped.
beforeBreadcrumb
- Type:
(breadcrumb: Breadcrumb) => Breadcrumb | null
null to throw it away, or change message and data to remove sensitive text. This runs often, so keep it fast.
errors.enabled
- Type:
boolean - Default value:
true
false, the SDK still listens for them but sends nothing.
errors.sampleRate
- Type:
numberbetween0and1 - Default value:
1.0
0.25 reports roughly a quarter of them. This happens before the rate limits and before beforeError runs.
breadcrumbs.network
- Type:
boolean - Default value:
true
fetch and XMLHttpRequest call. Request and response bodies are never captured.
breadcrumbs.console
- Type:
boolean - Default value:
true
console.warn and console.error. console.log is not patched.
breadcrumbs.clicks
- Type:
boolean - Default value:
true
breadcrumbs.longTasks
- Type:
boolean - Default value:
true
privacy.queryParamsAllowlist
- Type:
string[] - Default value:
[]
* to match several names at once, so "utm_*" keeps every UTM parameter. The default list is empty, which removes all of them. Read more in privacy and filtering.
privacy.networkBlocklist
- Type:
string[] - Default value:
[]
privacy.dom.maskText
- Type:
string[] - Default value:
[]
[masked] in click breadcrumbs. The breadcrumb is still recorded, so you keep the fact that an interaction happened.
privacy.dom.blockElement
- Type:
string[] - Default value:
[]
API reference
Every function below does nothing untilinit() has run with active set to true.