@minecraft/diagnostics 1.0.0-beta.1.12.111-stable

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.
Files changed (3) hide show
  1. package/README.md +9 -0
  2. package/index.d.ts +217 -0
  3. package/package.json +20 -0
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # `@minecraft/diagnostics`
2
+
3
+ Contains diagnostics functionality for discovering and diagnosing issues with content.
4
+
5
+ ## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.**
6
+
7
+ See full documentation for this module here:
8
+
9
+ https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/diagnostics/minecraft-diagnostics
package/index.d.ts ADDED
@@ -0,0 +1,217 @@
1
+ // Type definitions for Minecraft Bedrock Edition script APIs
2
+ // Project: https://docs.microsoft.com/minecraft/creator/
3
+ // Definitions by: Jake Shirley <https://github.com/JakeShirley>
4
+ // Mike Ammerlaan <https://github.com/mammerla>
5
+
6
+ /* *****************************************************************************
7
+ Copyright (c) Microsoft Corporation.
8
+ ***************************************************************************** */
9
+ /**
10
+ * @beta
11
+ * @packageDocumentation
12
+ * Contains diagnostics functionality for discovering and
13
+ * diagnosing issues with content.
14
+ *
15
+ * Manifest Details
16
+ * ```json
17
+ * {
18
+ * "module_name": "@minecraft/diagnostics",
19
+ * "version": "1.0.0-beta"
20
+ * }
21
+ * ```
22
+ *
23
+ */
24
+ import * as minecraftcommon from '@minecraft/common';
25
+ import * as minecraftserveradmin from '@minecraft/server-admin';
26
+ /**
27
+ * This defines the severity level of an error, event,
28
+ * exception, or breadcrumb. Levels are used in the UI to
29
+ * emphasize and deemphasize breadcrumbs. See Sentry
30
+ * documentation for more information:
31
+ * https://docs.sentry.io/product/issues/issue-details/breadcrumbs/
32
+ */
33
+ export enum SentryEventLevel {
34
+ debug = 'debug',
35
+ error = 'error',
36
+ fatal = 'fatal',
37
+ info = 'info',
38
+ warning = 'warning',
39
+ }
40
+
41
+ /**
42
+ * A class that allows hooking up reporting to Sentry. See
43
+ * https://sentry.io/ for more information.
44
+ */
45
+ export class Sentry {
46
+ private constructor();
47
+ /**
48
+ * @remarks
49
+ * Adds a breadcrumb to the next Sentry error reported. This
50
+ * can be useful for understanding a "trail" of events leading
51
+ * up to an error. See Sentry documentation for more details:
52
+ * https://docs.sentry.io/product/issues/issue-details/breadcrumbs/
53
+ *
54
+ * This function can be called in early-execution mode.
55
+ *
56
+ * @param message
57
+ * The message to add to the breadcrumb.
58
+ * @param category
59
+ * The category of the breadcrumb.
60
+ * @throws This function can throw errors.
61
+ *
62
+ * {@link SentryUninitializedError}
63
+ */
64
+ addBreadcrumb(level: SentryEventLevel, message: string, category?: string): void;
65
+ /**
66
+ * @remarks
67
+ * Adds a tag to the Sentry session. See Sentry documentation
68
+ * for more details:
69
+ * https://docs.sentry.io/platforms/javascript/enriching-events/tags/
70
+ *
71
+ * This function can be called in early-execution mode.
72
+ *
73
+ * @throws This function can throw errors.
74
+ *
75
+ * {@link SentryUninitializedError}
76
+ */
77
+ addTag(name: string, value: string): void;
78
+ /**
79
+ * @remarks
80
+ * Captures an exception event and send it to Sentry. Note that
81
+ * you can pass not only `Error` objects, but also other types
82
+ * of thrown objects - in that case, an attempt will be made to
83
+ * serialize the object for you, and stack traces are likely to
84
+ * be missing. See Sentry documentation for more details:
85
+ * https://docs.sentry.io/platforms/javascript/apis/#capturing-events
86
+ *
87
+ * This function can be called in early-execution mode.
88
+ *
89
+ * @throws This function can throw errors.
90
+ *
91
+ * {@link SentryUninitializedError}
92
+ */
93
+ captureException(exception: unknown, captureContext?: SentryCaptureContext): void;
94
+ /**
95
+ * @remarks
96
+ * Gets the list of all session tags. See Sentry documentation
97
+ * for more details:
98
+ * https://docs.sentry.io/platforms/javascript/enriching-events/tags/
99
+ *
100
+ * This function can be called in early-execution mode.
101
+ *
102
+ * @throws This function can throw errors.
103
+ *
104
+ * {@link SentryUninitializedError}
105
+ */
106
+ getTags(): Record<string, string>;
107
+ /**
108
+ * @remarks
109
+ * Initializes Sentry for use. This must be successfully
110
+ * called before any other Sentry functions are called.
111
+ *
112
+ * This function can be called in early-execution mode.
113
+ *
114
+ * @throws This function can throw errors.
115
+ *
116
+ * {@link minecraftcommon.InvalidArgumentError}
117
+ *
118
+ * {@link SentryAlreadyInitializedError}
119
+ */
120
+ init(options: SentryOptions): void;
121
+ /**
122
+ * @remarks
123
+ * Removes a tag to the Sentry session. See Sentry
124
+ * documentation for more details:
125
+ * https://docs.sentry.io/platforms/javascript/enriching-events/tags/
126
+ *
127
+ * This function can be called in early-execution mode.
128
+ *
129
+ * @throws This function can throw errors.
130
+ *
131
+ * {@link SentryUninitializedError}
132
+ */
133
+ removeTag(name: string): void;
134
+ }
135
+
136
+ /**
137
+ * Context relating to a captured exception that should be sent
138
+ * to Sentry.
139
+ */
140
+ export interface SentryCaptureContext {
141
+ /**
142
+ * @remarks
143
+ * Additional data that should be sent with the exception.
144
+ *
145
+ */
146
+ extraData?: Record<string, boolean | number | string>;
147
+ /**
148
+ * @remarks
149
+ * The indicated level of severity of the captured exception.
150
+ *
151
+ */
152
+ level?: SentryEventLevel;
153
+ /**
154
+ * @remarks
155
+ * Additional tags that should be sent with the exception.
156
+ *
157
+ */
158
+ tags?: Record<string, string>;
159
+ }
160
+
161
+ /**
162
+ * Describes options for configuring Sentry for this scripting
163
+ * module.
164
+ */
165
+ export interface SentryOptions {
166
+ /**
167
+ * @remarks
168
+ * When set to true, additional content logging from the Sentry
169
+ * system will be enabled. Defaults to false.
170
+ *
171
+ */
172
+ debug?: boolean;
173
+ /**
174
+ * @remarks
175
+ * The fully qualified DSN for a Sentry project. See Sentry
176
+ * documentation for more information:
177
+ * https://docs.sentry.io/concepts/key-terms/dsn-explainer/
178
+ *
179
+ */
180
+ dsn: minecraftserveradmin.SecretString | string;
181
+ /**
182
+ * @remarks
183
+ * The maximum number of breadcrumbs (submitted via {@link
184
+ * Sentry.addBreadcrumb}) to store and report per error event
185
+ * to Sentry. Default is 20, supported values range from 0 (no
186
+ * breadcrumbs) to 100.
187
+ *
188
+ */
189
+ maxBreadcrumbs?: number;
190
+ /**
191
+ * @remarks
192
+ * A number between 0 and 1 that indicates the percentage of
193
+ * events that should be sent to Sentry. For example, a value
194
+ * of 0.5 means that 50% of events will be sent. Default is 1
195
+ * (100% of events). 0 means no events will be sent.
196
+ *
197
+ */
198
+ sampleRate?: number;
199
+ }
200
+
201
+ // @ts-ignore Class inheritance allowed for native defined classes
202
+ export class SentryAlreadyInitializedError extends Error {
203
+ private constructor();
204
+ }
205
+
206
+ // @ts-ignore Class inheritance allowed for native defined classes
207
+ export class SentryUninitializedError extends Error {
208
+ private constructor();
209
+ }
210
+
211
+ /**
212
+ * @remarks
213
+ * A class that allows hooking up reporting to Sentry. See
214
+ * https://sentry.io/ for more information.
215
+ *
216
+ */
217
+ export const sentry: Sentry;
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@minecraft/diagnostics",
3
+ "version": "1.0.0-beta.1.12.111-stable",
4
+ "description": "",
5
+ "contributors": [
6
+ {
7
+ "name": "Jake Shirley",
8
+ "email": "jake@xbox.com"
9
+ },
10
+ {
11
+ "name": "Mike Ammerlaan",
12
+ "email": "mikeam@microsoft.com"
13
+ }
14
+ ],
15
+ "peerDependencies": {
16
+ "@minecraft/common": "^1.0.0",
17
+ "@minecraft/server-admin": "^1.0.0-beta.1.12.111-stable"
18
+ },
19
+ "license": "MIT"
20
+ }