monitoring

Developer Preview
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Note: This API is not intended for use in site development or when coding in Blocks.

The monitoring submodule allows you to report errors, log messages, track performance metrics and get notified of uncaught exceptions and unhandled rejections in your application code with Sentry. Use the SDK to report errors, log messages, and track performance metrics in your application code.

See Monitoring Your App for setup and configuration requirements.

Note that when Wix recognizes the changes to your wix.config.json file, Wix will report unhandled errors to your Sentry project automatically.

Important: Before making calls to the methods defined below using this solution, make sure you have the latest version of @wix/essentials and the Wix CLI installed.

Import statement

Copy

Initializing a monitoring client

In order to use the monitoring client and report events, you need to initialize it.

Copy

Methods

captureException()

Captures an exception event and sends it to Sentry.

Syntax

Copy

Parameters

NameTypeDescription
errorErrorThe error to capture.
captureContextCaptureContext(Optional) Additional context to attach to the Sentry event.
captureContext.levelstring(Optional) The severity level of the event. Default: error. Options: info, warning, error.
captureContext.tagsobject(Optional) Key-value pairs to attach to the Sentry event. Learn more about usage and limitations.
captureContext.contextsobject(Optional) Additional context to attach to the Sentry event. Learn more about usage and limitations.

Example

Copy

captureMessage()

Captures a message event as an event in Sentry.

Syntax

Copy

Parameters

NameTypeDescription
messagestringThe message to capture.
captureContextCaptureContext(Optional) Additional context to attach to the Sentry event.
captureContext.levelstring(Optional) The severity level of the event. Default: error. Options: info, warning, error.
captureContext.tagsobject(Optional) Key-value string pairs to attach to the Sentry event. Learn more about usage and limitations .
captureContext.contextsobject(Optional) Additional context to attach to the Sentry event. Learn more about usage and limitations.

Example

Copy

addBreadcrumb()

Records a new breadcrumb which will be attached to future events. Breadcrumbs will be added to subsequent events to provide more context on user's actions prior to an error or crash.

Syntax

Copy

Parameters

NameTypeDescription
breadcrumbBreadcrumbThe breadcrumb details. Learn more about these properties
breadcrumb.messagestringThe message of the breadcrumb.
breadcrumb.typestring(Optional) The type of the breadcrumb.
breadcrumb.categorystring(Optional) The category of the breadcrumb.
breadcrumb.levelstring(Optional) The severity level of the breadcrumb. Options: info, warning, error.
breadcrumb.dataobject(Optional) Additional data to attach to the breadcrumb.

Example

Copy

startSpan()

Starts a new span and executes the provided callback function with the span as an argument.

Syntax

Copy

Parameters

NameTypeDescription
spanOptionsSpanOptionsThe options for the span.
spanOptions.namestringThe name of the span.
spanOptions.tagsTags(Optional) Key-value string pairs to attach to the span.
callback(span: Span | undefined) => TThe callback function to execute with the span.

Example

Copy

Additional context

Each report we send to Sentry is enriched with additional information that will help you find the root of the problem. The context object will vary slightly depending on the report, but will generally include the following:

NameDescription
app.idYour app ID.
extension.idYour unique extension ID.
extension.nameYour extension name. For backend extensions this could also be the name of an endpoint or webhook.
extension.typeExtension type. For backend extensions types include: cli-api, cli-event, cli-service-plugin.
platformThe platform where the error originated. Possible Values: BACKEND, DASHBOARD, SITE_EDITOR, SITE_VIEWER.
urlThe URL of the site where the error originated. Only relevant for site extensions.
Did this help?