type Primitive = number | string | boolean | bigint | symbol | null | undefined; type Tags = Record; type Context = Record; type Contexts = Record; type Resolvable = T | (() => T | undefined); /** * Represents the context for host monitoring. */ interface HostMonitoringContext { /** * The unique identifier for the application. */ appId: string; /** * The version of the application. */ appVersion?: string; /** * The unique identifier for the application instance. */ appInstanceId?: string; /** * The unique identifier for the extension. */ extensionId?: string; /** * The name of the extension. */ extensionName?: string; /** * The type of the extension on the platform. (e.g. backend: ['api', 'events], dashboard: ['widget', 'page'], site: ['component', 'widget']) */ extensionType?: string; /** * Additional data related to the extension. */ extensionData?: Record; /** * The type of the platform the extension is running on. */ platform?: 'BACKEND' | 'DASHBOARD' | 'SITE_VIEWER' | 'SITE_EDITOR'; /** * The type of the tenant. * Can be 'ACCOUNT' or 'SITE'. */ tenantType?: 'ACCOUNT' | 'SITE'; /** * The unique identifier for the tenant. */ tenantId?: string; /** * The URL of the site. */ siteUrl?: string; } interface SpanContextData { traceId: string; spanId: string; } interface Span { spanContext(): SpanContextData; end(): void; } interface ManualSpan { end(): void; fail(error: unknown): void; } interface SpanOptions { name: string; tags?: Resolvable; } interface EndSpanOptions { name: string; } interface Breadcrumb { type?: string; category?: string; message: string; level?: 'info' | 'warning' | 'error'; data?: Record; } interface CaptureContext { level?: 'info' | 'warning' | 'error'; tags?: Resolvable; contexts?: Resolvable; } interface MonitoringClient { /** * Captures an exception event and sends it to Sentry. * @param error The error to capture * @param captureContext Optional additional data to attach to the Sentry e vent. */ captureException(error: unknown, captureContext?: CaptureContext): void; /** * Captures a message event and sends it to Sentry. * @param message The message to capture * @param captureContext Define the level of the message or pass in additional data to attach to the message. */ captureMessage(message: string, captureContext?: CaptureContext): void; /** * Wraps a function with a span and finishes the span after the function is done. The created span is the active span and will be used as parent by other spans created inside the function, as long as the function is executed while the scope is active. * @param spanOptions The options for the span * @param callback The function to wrap with a span * @returns The return value of the callback */ startSpan(spanOptions: SpanOptions, callback: (span: Span | undefined) => T): T; /** * Starts a manual span. The span needs to be finished manually by either calling end() or fail() using the returned span object or by calling endSpanManual(). * @param spanOptions The options for the span * @returns A span object that allows to end the span successfully or fail it. */ startSpanManual(spanOptions: SpanOptions): ManualSpan; /** * Ends a manual span and sends it to Sentry. Spans can be ended using a MonitoringClient instance which wasn't necessarily used to start the span. * Calling this method will end the last span with the same name that was started using startSpanManual() and will ignore the others. * @param spanOptions The options for the span */ endSpanManual(spanOptions: EndSpanOptions): void; /** * 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. * @param breadcrumb The breadcrumb to record. */ addBreadcrumb(breadcrumb: Breadcrumb): void; } interface EventTags extends Tags { 'app.id': string; 'app.version'?: string; 'app.instanceId'?: string; 'extension.id'?: string; 'extension.name'?: string; 'extension.type'?: string; platform?: string; } interface EventContexts extends Contexts { extension?: { type?: string; data?: Record; }; identity?: { type?: string; id?: string; }; site?: { url?: string; id?: string; }; account?: { id?: string; }; } interface EventData { tags: EventTags; contexts: EventContexts; } /** * Represents the Sentry configuration for app's monitoring. */ interface AppMonitoringSentryConfig { /** * The type of monitoring provider. */ type: 'SENTRY'; /** * The options for the Sentry monitoring provider. */ sentryOptions: { /** * The Data Source Name (DSN) for the Sentry monitoring provider. */ dsn: string; }; } /** * Represents the Panorama configuration for app's monitoring. */ interface AppMonitoringPanoramaConfig { /** * The type of monitoring provider. */ type: 'PANORAMA'; /** * The options for the Panorama monitoring provider. */ panoramaOptions: { sentry?: { /** * The Data Source Name (DSN) for Sentry. */ dsn: string; }; project: { groupId: string; artifactId: string; fingerprint: string; }; }; } interface AppMonitoringUnknownConfig { type: 'UNKNOWN_PROVIDER'; } /** * Represents the Wix configuration for app's monitoring. */ interface AppMonitoringWixConfig { /** * The type of monitoring provider. */ type: 'WIX'; /** * The options for the Wix monitoring provider. */ wixOptions: {}; } /** * Represents the configuration for app's monitoring. * The configuration includes the type of monitoring provider and its options. * Currently, only Sentry is supported as a monitoring provider. */ type AppMonitoringConfig = AppMonitoringSentryConfig | AppMonitoringPanoramaConfig | AppMonitoringUnknownConfig | AppMonitoringWixConfig; export type { AppMonitoringConfig, AppMonitoringPanoramaConfig, AppMonitoringSentryConfig, AppMonitoringUnknownConfig, AppMonitoringWixConfig, Breadcrumb, CaptureContext, Context, Contexts, EndSpanOptions, EventContexts, EventData, EventTags, HostMonitoringContext, ManualSpan, MonitoringClient, Primitive, Resolvable, Span, SpanContextData, SpanOptions, Tags };