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.

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) Event severity level. 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
messagestringMessage to capture.
captureContextCaptureContext(Optional) Additional context to attach to the Sentry event.
captureContext.levelstring(Optional) Event sverity level. 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
breadcrumbBreadcrumbBreadcrumb details. Learn more about these properties
breadcrumb.messagestringBreadcrumb message.
breadcrumb.typestring(Optional) Breadcrumb type.
breadcrumb.categorystring(Optional) Breadcrumb category.
breadcrumb.levelstring(Optional) Breadcrumb severity level. 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
spanOptionsSpanOptionsSpan options.
spanOptions.namestringSpan name.
spanOptions.tagsTags(Optional) Key-value string pairs to attach to the span.
callback(span: Span | undefined) => TCallback function to execute with the span.

Example

Copy

startSpanManual()

Starts a new span that requires manual completion. Complete this span manually by calling end() or fail() using the returned span object or by calling endSpanManual().

Syntax

Copy

Parameters

NameTypeDescription
spanOptionsSpanOptionsSpan options.
spanOptions.namestringSpan name.
spanOptions.tagsTags(Optional) Key-value string pairs to attach to the span.

Example

Copy

endSpanManual()

Ends the most recent span that was started using startSpanManual(). Any older manual spans with the same name will be ignored.

Syntax

Copy

Parameters

NameTypeDescription
spanOptionsSpanOptionsSpan options.
spanOptions.namestringSpan name.

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.
platformPlatform where the error originated. Possible Values: BACKEND, DASHBOARD, SITE_EDITOR, SITE_VIEWER.
urlURL of the site where the error originated. Only relevant for site extensions.
Did this help?