@wix/monitoring-types 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.d.mts CHANGED
@@ -14,11 +14,11 @@ interface HostMonitoringContext {
14
14
  /**
15
15
  * The version of the application.
16
16
  */
17
- appVersion: string;
17
+ appVersion?: string;
18
18
  /**
19
19
  * The unique identifier for the application instance.
20
20
  */
21
- appInstanceId: string;
21
+ appInstanceId?: string;
22
22
  /**
23
23
  * The unique identifier for the extension.
24
24
  */
@@ -27,10 +27,6 @@ interface HostMonitoringContext {
27
27
  * The name of the extension.
28
28
  */
29
29
  extensionName?: string;
30
- /**
31
- * The platform the extension is on. (e.g. 'dashboard', 'editor', 'site', 'backend)
32
- */
33
- extensionPlatform?: string;
34
30
  /**
35
31
  * The type of the extension on the platform. (e.g. backend: ['api', 'events], dashboard: ['widget', 'page'], site: ['component', 'widget'])
36
32
  */
@@ -88,19 +84,41 @@ interface CaptureContext {
88
84
  contexts?: Contexts;
89
85
  }
90
86
  interface MonitoringClient {
91
- captureException(error: unknown, context?: CaptureContext): void;
92
- captureMessage(message: string, context?: CaptureContext): void;
93
- startSpan<T>(options: SpanOptions, callback: (span: Span | undefined) => T): T;
87
+ /**
88
+ * Captures an exception event and sends it to Sentry.
89
+ * @param error The error to capture
90
+ * @param captureContext Optional additional data to attach to the Sentry e vent.
91
+ * @returns the id of the captured Sentry event.
92
+ */
93
+ captureException(error: unknown, captureContext?: CaptureContext): string;
94
+ /**
95
+ * Captures a message event and sends it to Sentry.
96
+ * @param message The message to capture
97
+ * @param captureContext Define the level of the message or pass in additional data to attach to the message.
98
+ * @returns the id of the captured message.
99
+ */
100
+ captureMessage(message: string, captureContext?: CaptureContext): string;
101
+ /**
102
+ * 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.
103
+ * @param spanOptions The options for the span
104
+ * @param callback The function to wrap with a span
105
+ * @returns The return value of the callback
106
+ */
107
+ startSpan<T>(spanOptions: SpanOptions, callback: (span: Span | undefined) => T): T;
108
+ /**
109
+ * Records a new breadcrumb which will be attached to future events.
110
+ * Breadcrumbs will be added to subsequent events to provide more context on user's actions prior to an error or crash.
111
+ * @param breadcrumb The breadcrumb to record.
112
+ */
94
113
  addBreadcrumb(breadcrumb: Breadcrumb): void;
95
114
  }
96
115
 
97
116
  interface EventTags extends Tags {
98
117
  'app.id': string;
99
- 'app.version': string;
100
- 'app.instanceId': string;
118
+ 'app.version'?: string;
119
+ 'app.instanceId'?: string;
101
120
  'extension.id'?: string;
102
121
  'extension.name'?: string;
103
- 'extension.platform'?: string;
104
122
  'extension.type'?: string;
105
123
  }
106
124
  interface EventContexts extends Contexts {
@@ -125,4 +143,25 @@ interface EventData {
125
143
  contexts: EventContexts;
126
144
  }
127
145
 
128
- export type { Breadcrumb, CaptureContext, Context, Contexts, EventContexts, EventData, EventTags, HostMonitoringContext, MonitoringClient, Primitive, Span, SpanContextData, SpanOptions, Tags };
146
+ /**
147
+ * Represents the configuration for app's monitoring.
148
+ * The configuration includes the type of monitoring provider and its options.
149
+ * Currently, only Sentry is supported as a monitoring provider.
150
+ */
151
+ interface AppMonitoringConfig {
152
+ /**
153
+ * The type of monitoring provider.
154
+ */
155
+ type: 'SENTRY' | 'UNKNOWN_PROVIDER';
156
+ /**
157
+ * The options for the Sentry monitoring provider.
158
+ */
159
+ sentryOptions?: {
160
+ /**
161
+ * The Data Source Name (DSN) for the Sentry monitoring provider.
162
+ */
163
+ dsn: string;
164
+ };
165
+ }
166
+
167
+ export type { AppMonitoringConfig, Breadcrumb, CaptureContext, Context, Contexts, EventContexts, EventData, EventTags, HostMonitoringContext, MonitoringClient, Primitive, Span, SpanContextData, SpanOptions, Tags };
package/build/index.d.ts CHANGED
@@ -14,11 +14,11 @@ interface HostMonitoringContext {
14
14
  /**
15
15
  * The version of the application.
16
16
  */
17
- appVersion: string;
17
+ appVersion?: string;
18
18
  /**
19
19
  * The unique identifier for the application instance.
20
20
  */
21
- appInstanceId: string;
21
+ appInstanceId?: string;
22
22
  /**
23
23
  * The unique identifier for the extension.
24
24
  */
@@ -27,10 +27,6 @@ interface HostMonitoringContext {
27
27
  * The name of the extension.
28
28
  */
29
29
  extensionName?: string;
30
- /**
31
- * The platform the extension is on. (e.g. 'dashboard', 'editor', 'site', 'backend)
32
- */
33
- extensionPlatform?: string;
34
30
  /**
35
31
  * The type of the extension on the platform. (e.g. backend: ['api', 'events], dashboard: ['widget', 'page'], site: ['component', 'widget'])
36
32
  */
@@ -88,19 +84,41 @@ interface CaptureContext {
88
84
  contexts?: Contexts;
89
85
  }
90
86
  interface MonitoringClient {
91
- captureException(error: unknown, context?: CaptureContext): void;
92
- captureMessage(message: string, context?: CaptureContext): void;
93
- startSpan<T>(options: SpanOptions, callback: (span: Span | undefined) => T): T;
87
+ /**
88
+ * Captures an exception event and sends it to Sentry.
89
+ * @param error The error to capture
90
+ * @param captureContext Optional additional data to attach to the Sentry e vent.
91
+ * @returns the id of the captured Sentry event.
92
+ */
93
+ captureException(error: unknown, captureContext?: CaptureContext): string;
94
+ /**
95
+ * Captures a message event and sends it to Sentry.
96
+ * @param message The message to capture
97
+ * @param captureContext Define the level of the message or pass in additional data to attach to the message.
98
+ * @returns the id of the captured message.
99
+ */
100
+ captureMessage(message: string, captureContext?: CaptureContext): string;
101
+ /**
102
+ * 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.
103
+ * @param spanOptions The options for the span
104
+ * @param callback The function to wrap with a span
105
+ * @returns The return value of the callback
106
+ */
107
+ startSpan<T>(spanOptions: SpanOptions, callback: (span: Span | undefined) => T): T;
108
+ /**
109
+ * Records a new breadcrumb which will be attached to future events.
110
+ * Breadcrumbs will be added to subsequent events to provide more context on user's actions prior to an error or crash.
111
+ * @param breadcrumb The breadcrumb to record.
112
+ */
94
113
  addBreadcrumb(breadcrumb: Breadcrumb): void;
95
114
  }
96
115
 
97
116
  interface EventTags extends Tags {
98
117
  'app.id': string;
99
- 'app.version': string;
100
- 'app.instanceId': string;
118
+ 'app.version'?: string;
119
+ 'app.instanceId'?: string;
101
120
  'extension.id'?: string;
102
121
  'extension.name'?: string;
103
- 'extension.platform'?: string;
104
122
  'extension.type'?: string;
105
123
  }
106
124
  interface EventContexts extends Contexts {
@@ -125,4 +143,25 @@ interface EventData {
125
143
  contexts: EventContexts;
126
144
  }
127
145
 
128
- export type { Breadcrumb, CaptureContext, Context, Contexts, EventContexts, EventData, EventTags, HostMonitoringContext, MonitoringClient, Primitive, Span, SpanContextData, SpanOptions, Tags };
146
+ /**
147
+ * Represents the configuration for app's monitoring.
148
+ * The configuration includes the type of monitoring provider and its options.
149
+ * Currently, only Sentry is supported as a monitoring provider.
150
+ */
151
+ interface AppMonitoringConfig {
152
+ /**
153
+ * The type of monitoring provider.
154
+ */
155
+ type: 'SENTRY' | 'UNKNOWN_PROVIDER';
156
+ /**
157
+ * The options for the Sentry monitoring provider.
158
+ */
159
+ sentryOptions?: {
160
+ /**
161
+ * The Data Source Name (DSN) for the Sentry monitoring provider.
162
+ */
163
+ dsn: string;
164
+ };
165
+ }
166
+
167
+ export type { AppMonitoringConfig, Breadcrumb, CaptureContext, Context, Contexts, EventContexts, EventData, EventTags, HostMonitoringContext, MonitoringClient, Primitive, Span, SpanContextData, SpanOptions, Tags };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/monitoring-types",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "license": "UNLICENSED",
5
5
  "author": {
6
6
  "name": "Gili Shohat",
@@ -29,12 +29,12 @@
29
29
  "*.{js,ts}": "yarn lint"
30
30
  },
31
31
  "devDependencies": {
32
- "@types/node": "^20.17.9",
32
+ "@types/node": "^20.17.12",
33
33
  "eslint": "^8.57.1",
34
34
  "eslint-config-sdk": "0.0.0",
35
35
  "tsup": "^7.3.0",
36
- "type-fest": "^4.30.0",
37
- "typescript": "^5.7.2"
36
+ "type-fest": "^4.32.0",
37
+ "typescript": "^5.7.3"
38
38
  },
39
39
  "eslintConfig": {
40
40
  "extends": "sdk"
@@ -53,5 +53,5 @@
53
53
  ]
54
54
  }
55
55
  },
56
- "falconPackageHash": "82857561d35e1c7eec17ace7a7370e97f288aded7c93ce35dcc5be6e"
56
+ "falconPackageHash": "f5b6aae3eca514279438277851c0c6ab98b89f570229a737e9274223"
57
57
  }