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 one object. Only key is required. A second init() call is ignored until you call destroy(). Most applications change options in their next build.
key
- Type:
string - Required
endpoint
- Type:
string - Default value: the current page’s origin
https://appsignal-endpoint.net. If you proxy AppSignal traffic through your domain, leave it unset to use the current 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
init() call. When false, initialization returns without changing the page, starting timers, or making requests. A second init() call cannot switch off an SDK that is already running. 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
serviceName
- Type:
string - Default value:
"Browser"
serviceName: "Checkout UI" shows Checkout UI instead of the default Browser in the trace timeline. Use a different value for each front end you monitor. The SDK sends it with every error report. See distributed tracing for Browser.
tracePropagationTargets
- Type:
string[] - Default value:
[]
traceparent header. Each pattern needs a host and a path. For example, ["api.example.com/**"] matches every path on api.example.com. api.example.com alone matches nothing.
If a matching request returns a 5xx response or times out, the SDK reports a browser error. To see back-end spans in its trace, instrument the receiving service to read the header.
The default empty list adds no traceparent headers. See distributed tracing for Browser for setup and examples.
beforeError
- Type:
(event: IncomingError) => IncomingError | null
null to drop the error, or change its fields 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 calls, except canceled requests. This option does not control the initial document-load breadcrumb. The SDK does not read request or response bodies.
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:
[]
fetch and XMLHttpRequest calls that are not recorded as breadcrumbs or failed request errors. Matched against host and path. The calls still happen. This option does not filter the initial document-load breadcrumb.
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
Except forinit(), these functions do nothing until the SDK has initialized with active: true.