@metamask-previews/error-reporting-service 0.0.0-preview-d0685d1

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/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+
12
+ - Initial release ([#5849](https://github.com/MetaMask/core/pull/5849))
13
+
14
+ [Unreleased]: https://github.com/MetaMask/core/
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 MetaMask
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
package/README.md ADDED
@@ -0,0 +1,204 @@
1
+ # `@metamask/error-reporting-service`
2
+
3
+ Reports errors to an external app such as Sentry but in an agnostic fashion.
4
+
5
+ ## Installation
6
+
7
+ `yarn add @metamask/error-reporting-service`
8
+
9
+ or
10
+
11
+ `npm install @metamask/error-reporting-service`
12
+
13
+ ## Usage
14
+
15
+ This package is designed to be used in another module via a messenger, but can also be used on its own if needed.
16
+
17
+ ### Using the service via a messenger
18
+
19
+ In most cases, you will want to use the error reporting service in your module via a messenger object.
20
+
21
+ In this example, we have a controller, and something bad happens, but we want to report an error instead of throwing it.
22
+
23
+ #### 1. Controller file
24
+
25
+ ```typescript
26
+ // We need to get the type for the `ErrorReportingService:captureException`
27
+ // action.
28
+ import type { ErrorReportingServiceCaptureExceptionAction } from '@metamask/error-reporting-service';
29
+
30
+ // Now let's set up our controller, starting with the messenger.
31
+ // Note that we grant the `ErrorReportingService:captureException` action to the
32
+ // messenger.
33
+ type AllowedActions = ErrorReportingServiceCaptureExceptionAction;
34
+ type ExampleControllerMessenger = RestrictedMessenger<
35
+ 'ExampleController',
36
+ AllowedActions,
37
+ never,
38
+ AllowedActions['type'],
39
+ never
40
+ >;
41
+
42
+ // Finally, we define our controller.
43
+ class ExampleController extends BaseController<
44
+ 'ExampleController',
45
+ ExampleControllerState,
46
+ ExampleControllerMessenger
47
+ > {
48
+ doSomething() {
49
+ // Now imagine that we do something that produces an error and we want to
50
+ // report the error.
51
+ this.messagingSystem.call(
52
+ 'ErrorReportingService:captureException',
53
+ new Error('Something went wrong'),
54
+ );
55
+ }
56
+ }
57
+ ```
58
+
59
+ #### 2A. Initialization file (browser)
60
+
61
+ ```typescript
62
+ // We need a version of `captureException` from somewhere. Here, we are getting
63
+ // it from `@sentry/browser`.
64
+ import { captureException } from '@sentry/browser';
65
+
66
+ // We also need to get the ErrorReportingService.
67
+ import { ErrorReportingService } from '@metamask/error-reporting-service';
68
+
69
+ // And we need our controller.
70
+ import { ExampleController } from './example-controller';
71
+
72
+ // We need to have a global messenger.
73
+ const globalMessenger = new Messenger();
74
+
75
+ // We need to create a restricted messenger for the ErrorReportingService, and
76
+ // then we can create the service itself.
77
+ const errorReportingServiceMessenger = globalMessenger.getRestricted({
78
+ allowedActions: [],
79
+ allowedEvents: [],
80
+ });
81
+ const errorReportingService = new ErrorReportingService({
82
+ messenger: errorReportingServiceMessenger,
83
+ captureException,
84
+ });
85
+
86
+ // Now we can create a restricted messenger for our controller, and then
87
+ // we can create the controller too.
88
+ // Note that we grant the `ErrorReportingService:captureException` action to the
89
+ // messenger.
90
+ const exampleControllerMessenger = globalMessenger.getRestricted({
91
+ allowedActions: ['ErrorReportingService:captureException'],
92
+ allowedEvents: [],
93
+ });
94
+ const exampleController = new ExampleController({
95
+ messenger: exampleControllerMessenger,
96
+ });
97
+ ```
98
+
99
+ #### 2B. Initialization file (React Native)
100
+
101
+ ```typescript
102
+ // We need a version of `captureException` from somewhere. Here, we are getting
103
+ // it from `@sentry/react-native`.
104
+ import { captureException } from '@sentry/react-native';
105
+
106
+ // We also need to get the ErrorReportingService.
107
+ import { ErrorReportingService } from '@metamask/error-reporting-service';
108
+
109
+ // And we need our controller.
110
+ import { ExampleController } from './example-controller';
111
+
112
+ // We need to have a global messenger.
113
+ const globalMessenger = new Messenger();
114
+
115
+ // We need to create a restricted messenger for the ErrorReportingService, and
116
+ // then we can create the service itself.
117
+ const errorReportingServiceMessenger = globalMessenger.getRestricted({
118
+ allowedActions: [],
119
+ allowedEvents: [],
120
+ });
121
+ const errorReportingService = new ErrorReportingService({
122
+ messenger: errorReportingServiceMessenger,
123
+ captureException,
124
+ });
125
+
126
+ // Now we can create a restricted messenger for our controller, and then
127
+ // we can create the controller too.
128
+ // Note that we grant the `ErrorReportingService:captureException` action to the
129
+ // messenger.
130
+ const exampleControllerMessenger = globalMessenger.getRestricted({
131
+ allowedActions: ['ErrorReportingService:captureException'],
132
+ allowedEvents: [],
133
+ });
134
+ const exampleController = new ExampleController({
135
+ messenger: exampleControllerMessenger,
136
+ });
137
+ ```
138
+
139
+ #### 3. Using the controller
140
+
141
+ ```typescript
142
+ // Now this will report an error without throwing it.
143
+ exampleController.doSomething();
144
+ ```
145
+
146
+ ### Using the service directly
147
+
148
+ You probably don't need to use the service directly, but if you do, here's how.
149
+
150
+ In this example, we have a function, and we use the error reporting service there.
151
+
152
+ #### 1. Function file
153
+
154
+ ```typescript
155
+ export function doSomething(
156
+ errorReportingService: AbstractErrorReportingService,
157
+ ) {
158
+ errorReportingService.captureException(new Error('Something went wrong'));
159
+ }
160
+ ```
161
+
162
+ #### 2A. Calling file (browser)
163
+
164
+ ```typescript
165
+ // We need a version of `captureException` from somewhere. Here, we are getting
166
+ it from `@sentry/browser`.
167
+ import { captureException } from '@sentry/browser';
168
+
169
+ // We also need to get the ErrorReportingService.
170
+ import { ErrorReportingService } from '@metamask/error-reporting-service';
171
+
172
+ // We also bring in our function.
173
+ import { doSomething } from './do-something';
174
+
175
+ // We create a new instance of the ErrorReportingService.
176
+ const errorReportingService = new ErrorReportingService({ captureException });
177
+
178
+ // Now we call our function, and it will report the error in Sentry.
179
+ doSomething(errorReportingService);
180
+ ```
181
+
182
+ #### 2A. Calling file (React Native)
183
+
184
+ ```typescript
185
+ // We need a version of `captureException` from somewhere. Here, we are getting
186
+ it from `@sentry/react-native`.
187
+ import { captureException } from '@sentry/react-native';
188
+
189
+ // We also need to get the ErrorReportingService.
190
+ import { ErrorReportingService } from '@metamask/error-reporting-service';
191
+
192
+ // We also bring in our function.
193
+ import { doSomething } from './do-something';
194
+
195
+ // We create a new instance of the ErrorReportingService.
196
+ const errorReportingService = new ErrorReportingService({ captureException });
197
+
198
+ // Now we call our function, and it will report the error in Sentry.
199
+ doSomething(errorReportingService);
200
+ ```
201
+
202
+ ## Contributing
203
+
204
+ This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _ErrorReportingService_captureException, _ErrorReportingService_messenger;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ErrorReportingService = void 0;
16
+ /**
17
+ * `ErrorReportingService` is designed to log an error to an error reporting app
18
+ * such as Sentry, but in an agnostic fashion.
19
+ *
20
+ * @example
21
+ *
22
+ * In this example, we have a controller, and something bad happens, but we want
23
+ * to report an error instead of throwing it.
24
+ *
25
+ * ``` ts
26
+ * // === Controller file ===
27
+ *
28
+ * import type { ErrorReportingServiceCaptureExceptionAction } from '@metamask/error-reporting-service';
29
+ *
30
+ * // Define the messenger type for the controller.
31
+ * type AllowedActions = ErrorReportingServiceCaptureExceptionAction;
32
+ * type ExampleControllerMessenger = RestrictedMessenger<
33
+ * 'ExampleController',
34
+ * AllowedActions,
35
+ * never,
36
+ * AllowedActions['type'],
37
+ * never
38
+ * >;
39
+ *
40
+ * // Define the controller.
41
+ * class ExampleController extends BaseController<
42
+ * 'ExampleController',
43
+ * ExampleControllerState,
44
+ * ExampleControllerMessenger
45
+ * > {
46
+ * doSomething() {
47
+ * // Imagine that we do something that produces an error and we want to
48
+ * // report the error.
49
+ * this.messagingSystem.call(
50
+ * 'ErrorReportingService:captureException',
51
+ * new Error('Something went wrong'),
52
+ * );
53
+ * }
54
+ * }
55
+ *
56
+ * // === Initialization file ===
57
+ *
58
+ * import { captureException } from '@sentry/browser';
59
+ * import { ErrorReportingService } from '@metamask/error-reporting-service';
60
+ * import { ExampleController } from './example-controller';
61
+ *
62
+ * // Create a global messenger.
63
+ * const globalMessenger = new Messenger();
64
+ *
65
+ * // Register handler for the `ErrorReportingService:captureException`
66
+ * // action in the global messenger.
67
+ * const errorReportingServiceMessenger = globalMessenger.getRestricted({
68
+ * allowedActions: [],
69
+ * allowedEvents: [],
70
+ * });
71
+ * const errorReportingService = new ErrorReportingService({
72
+ * messenger: errorReportingServiceMessenger,
73
+ * captureException,
74
+ * });
75
+ *
76
+ * const exampleControllerMessenger = globalMessenger.getRestricted({
77
+ * allowedActions: ['ErrorReportingService:captureException'],
78
+ * allowedEvents: [],
79
+ * });
80
+ * const exampleController = new ExampleController({
81
+ * messenger: exampleControllerMessenger,
82
+ * });
83
+ *
84
+ * // === Somewhere else ===
85
+ *
86
+ * // Now this will report an error without throwing it.
87
+ * exampleController.doSomething();
88
+ * ```
89
+ */
90
+ class ErrorReportingService {
91
+ /**
92
+ * Constructs a new ErrorReportingService.
93
+ *
94
+ * @param options - The options.
95
+ * @param options.messenger - The messenger suited to this
96
+ * ErrorReportingService.
97
+ * @param options.captureException - A function that stores the given error in
98
+ * the error reporting service.
99
+ */
100
+ constructor({ messenger, captureException }) {
101
+ _ErrorReportingService_captureException.set(this, void 0);
102
+ _ErrorReportingService_messenger.set(this, void 0);
103
+ __classPrivateFieldSet(this, _ErrorReportingService_messenger, messenger, "f");
104
+ __classPrivateFieldSet(this, _ErrorReportingService_captureException, captureException, "f");
105
+ __classPrivateFieldGet(this, _ErrorReportingService_messenger, "f").registerActionHandler('ErrorReportingService:captureException', __classPrivateFieldGet(this, _ErrorReportingService_captureException, "f").bind(this));
106
+ }
107
+ /**
108
+ * Reports the given error to an external location.
109
+ *
110
+ * @param error - The error to report.
111
+ */
112
+ captureException(error) {
113
+ __classPrivateFieldGet(this, _ErrorReportingService_captureException, "f").call(this, error);
114
+ }
115
+ }
116
+ exports.ErrorReportingService = ErrorReportingService;
117
+ _ErrorReportingService_captureException = new WeakMap(), _ErrorReportingService_messenger = new WeakMap();
118
+ //# sourceMappingURL=error-reporting-service.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-reporting-service.cjs","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAuDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,MAAa,qBAAqB;IAKhC;;;;;;;;OAQG;IACH,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAgC;QAbhE,0DAAoE;QAEpE,mDAA2C;QAYlD,uBAAA,IAAI,oCAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,2CAAqB,gBAAgB,MAAA,CAAC;QAE1C,uBAAA,IAAI,wCAAW,CAAC,qBAAqB,CACnC,wCAAwC,EACxC,uBAAA,IAAI,+CAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAClC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,gBAAgB,CAAC,KAAY;QAC3B,uBAAA,IAAI,+CAAkB,MAAtB,IAAI,EAAmB,KAAK,CAAC,CAAC;IAChC,CAAC;CACF;AAhCD,sDAgCC","sourcesContent":["import type { RestrictedMessenger } from '@metamask/base-controller';\n\n/**\n * The action which can be used to report an error.\n */\nexport type ErrorReportingServiceCaptureExceptionAction = {\n type: 'ErrorReportingService:captureException';\n handler: ErrorReportingService['captureException'];\n};\n\n/**\n * All actions that {@link ErrorReportingService} registers so that other\n * modules can call them.\n */\nexport type ErrorReportingServiceActions =\n ErrorReportingServiceCaptureExceptionAction;\n\n/**\n * All events that {@link ErrorReportingService} publishes so that other modules\n * can subscribe to them.\n */\nexport type ErrorReportingServiceEvents = never;\n\n/**\n * All actions registered by other modules that {@link ErrorReportingService}\n * calls.\n */\ntype AllowedActions = never;\n\n/**\n * All events published by other modules that {@link ErrorReportingService}\n * subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events that\n * {@link ErrorReportingService} needs to access.\n */\nexport type ErrorReportingServiceMessenger = RestrictedMessenger<\n 'ErrorReportingService',\n ErrorReportingServiceActions | AllowedActions,\n ErrorReportingServiceEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\n/**\n * The options that {@link ErrorReportingService} takes.\n */\ntype ErrorReportingServiceOptions = {\n captureException: (error: unknown) => string;\n messenger: ErrorReportingServiceMessenger;\n};\n\n/**\n * `ErrorReportingService` is designed to log an error to an error reporting app\n * such as Sentry, but in an agnostic fashion.\n *\n * @example\n *\n * In this example, we have a controller, and something bad happens, but we want\n * to report an error instead of throwing it.\n *\n * ``` ts\n * // === Controller file ===\n *\n * import type { ErrorReportingServiceCaptureExceptionAction } from '@metamask/error-reporting-service';\n *\n * // Define the messenger type for the controller.\n * type AllowedActions = ErrorReportingServiceCaptureExceptionAction;\n * type ExampleControllerMessenger = RestrictedMessenger<\n * 'ExampleController',\n * AllowedActions,\n * never,\n * AllowedActions['type'],\n * never\n * >;\n *\n * // Define the controller.\n * class ExampleController extends BaseController<\n * 'ExampleController',\n * ExampleControllerState,\n * ExampleControllerMessenger\n * > {\n * doSomething() {\n * // Imagine that we do something that produces an error and we want to\n * // report the error.\n * this.messagingSystem.call(\n * 'ErrorReportingService:captureException',\n * new Error('Something went wrong'),\n * );\n * }\n * }\n *\n * // === Initialization file ===\n *\n * import { captureException } from '@sentry/browser';\n * import { ErrorReportingService } from '@metamask/error-reporting-service';\n * import { ExampleController } from './example-controller';\n *\n * // Create a global messenger.\n * const globalMessenger = new Messenger();\n *\n * // Register handler for the `ErrorReportingService:captureException`\n * // action in the global messenger.\n * const errorReportingServiceMessenger = globalMessenger.getRestricted({\n * allowedActions: [],\n * allowedEvents: [],\n * });\n * const errorReportingService = new ErrorReportingService({\n * messenger: errorReportingServiceMessenger,\n * captureException,\n * });\n *\n * const exampleControllerMessenger = globalMessenger.getRestricted({\n * allowedActions: ['ErrorReportingService:captureException'],\n * allowedEvents: [],\n * });\n * const exampleController = new ExampleController({\n * messenger: exampleControllerMessenger,\n * });\n *\n * // === Somewhere else ===\n *\n * // Now this will report an error without throwing it.\n * exampleController.doSomething();\n * ```\n */\nexport class ErrorReportingService {\n readonly #captureException: ErrorReportingServiceOptions['captureException'];\n\n readonly #messenger: ErrorReportingServiceMessenger;\n\n /**\n * Constructs a new ErrorReportingService.\n *\n * @param options - The options.\n * @param options.messenger - The messenger suited to this\n * ErrorReportingService.\n * @param options.captureException - A function that stores the given error in\n * the error reporting service.\n */\n constructor({ messenger, captureException }: ErrorReportingServiceOptions) {\n this.#messenger = messenger;\n this.#captureException = captureException;\n\n this.#messenger.registerActionHandler(\n 'ErrorReportingService:captureException',\n this.#captureException.bind(this),\n );\n }\n\n /**\n * Reports the given error to an external location.\n *\n * @param error - The error to report.\n */\n captureException(error: Error): void {\n this.#captureException(error);\n }\n}\n"]}
@@ -0,0 +1,135 @@
1
+ import type { RestrictedMessenger } from "@metamask/base-controller";
2
+ /**
3
+ * The action which can be used to report an error.
4
+ */
5
+ export type ErrorReportingServiceCaptureExceptionAction = {
6
+ type: 'ErrorReportingService:captureException';
7
+ handler: ErrorReportingService['captureException'];
8
+ };
9
+ /**
10
+ * All actions that {@link ErrorReportingService} registers so that other
11
+ * modules can call them.
12
+ */
13
+ export type ErrorReportingServiceActions = ErrorReportingServiceCaptureExceptionAction;
14
+ /**
15
+ * All events that {@link ErrorReportingService} publishes so that other modules
16
+ * can subscribe to them.
17
+ */
18
+ export type ErrorReportingServiceEvents = never;
19
+ /**
20
+ * All actions registered by other modules that {@link ErrorReportingService}
21
+ * calls.
22
+ */
23
+ type AllowedActions = never;
24
+ /**
25
+ * All events published by other modules that {@link ErrorReportingService}
26
+ * subscribes to.
27
+ */
28
+ type AllowedEvents = never;
29
+ /**
30
+ * The messenger restricted to actions and events that
31
+ * {@link ErrorReportingService} needs to access.
32
+ */
33
+ export type ErrorReportingServiceMessenger = RestrictedMessenger<'ErrorReportingService', ErrorReportingServiceActions | AllowedActions, ErrorReportingServiceEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
34
+ /**
35
+ * The options that {@link ErrorReportingService} takes.
36
+ */
37
+ type ErrorReportingServiceOptions = {
38
+ captureException: (error: unknown) => string;
39
+ messenger: ErrorReportingServiceMessenger;
40
+ };
41
+ /**
42
+ * `ErrorReportingService` is designed to log an error to an error reporting app
43
+ * such as Sentry, but in an agnostic fashion.
44
+ *
45
+ * @example
46
+ *
47
+ * In this example, we have a controller, and something bad happens, but we want
48
+ * to report an error instead of throwing it.
49
+ *
50
+ * ``` ts
51
+ * // === Controller file ===
52
+ *
53
+ * import type { ErrorReportingServiceCaptureExceptionAction } from '@metamask/error-reporting-service';
54
+ *
55
+ * // Define the messenger type for the controller.
56
+ * type AllowedActions = ErrorReportingServiceCaptureExceptionAction;
57
+ * type ExampleControllerMessenger = RestrictedMessenger<
58
+ * 'ExampleController',
59
+ * AllowedActions,
60
+ * never,
61
+ * AllowedActions['type'],
62
+ * never
63
+ * >;
64
+ *
65
+ * // Define the controller.
66
+ * class ExampleController extends BaseController<
67
+ * 'ExampleController',
68
+ * ExampleControllerState,
69
+ * ExampleControllerMessenger
70
+ * > {
71
+ * doSomething() {
72
+ * // Imagine that we do something that produces an error and we want to
73
+ * // report the error.
74
+ * this.messagingSystem.call(
75
+ * 'ErrorReportingService:captureException',
76
+ * new Error('Something went wrong'),
77
+ * );
78
+ * }
79
+ * }
80
+ *
81
+ * // === Initialization file ===
82
+ *
83
+ * import { captureException } from '@sentry/browser';
84
+ * import { ErrorReportingService } from '@metamask/error-reporting-service';
85
+ * import { ExampleController } from './example-controller';
86
+ *
87
+ * // Create a global messenger.
88
+ * const globalMessenger = new Messenger();
89
+ *
90
+ * // Register handler for the `ErrorReportingService:captureException`
91
+ * // action in the global messenger.
92
+ * const errorReportingServiceMessenger = globalMessenger.getRestricted({
93
+ * allowedActions: [],
94
+ * allowedEvents: [],
95
+ * });
96
+ * const errorReportingService = new ErrorReportingService({
97
+ * messenger: errorReportingServiceMessenger,
98
+ * captureException,
99
+ * });
100
+ *
101
+ * const exampleControllerMessenger = globalMessenger.getRestricted({
102
+ * allowedActions: ['ErrorReportingService:captureException'],
103
+ * allowedEvents: [],
104
+ * });
105
+ * const exampleController = new ExampleController({
106
+ * messenger: exampleControllerMessenger,
107
+ * });
108
+ *
109
+ * // === Somewhere else ===
110
+ *
111
+ * // Now this will report an error without throwing it.
112
+ * exampleController.doSomething();
113
+ * ```
114
+ */
115
+ export declare class ErrorReportingService {
116
+ #private;
117
+ /**
118
+ * Constructs a new ErrorReportingService.
119
+ *
120
+ * @param options - The options.
121
+ * @param options.messenger - The messenger suited to this
122
+ * ErrorReportingService.
123
+ * @param options.captureException - A function that stores the given error in
124
+ * the error reporting service.
125
+ */
126
+ constructor({ messenger, captureException }: ErrorReportingServiceOptions);
127
+ /**
128
+ * Reports the given error to an external location.
129
+ *
130
+ * @param error - The error to report.
131
+ */
132
+ captureException(error: Error): void;
133
+ }
134
+ export {};
135
+ //# sourceMappingURL=error-reporting-service.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-reporting-service.d.cts","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAkC;AAErE;;GAEG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;CACpD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GACtC,2CAA2C,CAAC;AAE9C;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,KAAK,CAAC;AAEhD;;;GAGG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;;GAGG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG,mBAAmB,CAC9D,uBAAuB,EACvB,4BAA4B,GAAG,cAAc,EAC7C,2BAA2B,GAAG,aAAa,EAC3C,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC;AAEF;;GAEG;AACH,KAAK,4BAA4B,GAAG;IAClC,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;IAC7C,SAAS,EAAE,8BAA8B,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,qBAAa,qBAAqB;;IAKhC;;;;;;;;OAQG;gBACS,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,4BAA4B;IAUzE;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;CAGrC"}
@@ -0,0 +1,135 @@
1
+ import type { RestrictedMessenger } from "@metamask/base-controller";
2
+ /**
3
+ * The action which can be used to report an error.
4
+ */
5
+ export type ErrorReportingServiceCaptureExceptionAction = {
6
+ type: 'ErrorReportingService:captureException';
7
+ handler: ErrorReportingService['captureException'];
8
+ };
9
+ /**
10
+ * All actions that {@link ErrorReportingService} registers so that other
11
+ * modules can call them.
12
+ */
13
+ export type ErrorReportingServiceActions = ErrorReportingServiceCaptureExceptionAction;
14
+ /**
15
+ * All events that {@link ErrorReportingService} publishes so that other modules
16
+ * can subscribe to them.
17
+ */
18
+ export type ErrorReportingServiceEvents = never;
19
+ /**
20
+ * All actions registered by other modules that {@link ErrorReportingService}
21
+ * calls.
22
+ */
23
+ type AllowedActions = never;
24
+ /**
25
+ * All events published by other modules that {@link ErrorReportingService}
26
+ * subscribes to.
27
+ */
28
+ type AllowedEvents = never;
29
+ /**
30
+ * The messenger restricted to actions and events that
31
+ * {@link ErrorReportingService} needs to access.
32
+ */
33
+ export type ErrorReportingServiceMessenger = RestrictedMessenger<'ErrorReportingService', ErrorReportingServiceActions | AllowedActions, ErrorReportingServiceEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
34
+ /**
35
+ * The options that {@link ErrorReportingService} takes.
36
+ */
37
+ type ErrorReportingServiceOptions = {
38
+ captureException: (error: unknown) => string;
39
+ messenger: ErrorReportingServiceMessenger;
40
+ };
41
+ /**
42
+ * `ErrorReportingService` is designed to log an error to an error reporting app
43
+ * such as Sentry, but in an agnostic fashion.
44
+ *
45
+ * @example
46
+ *
47
+ * In this example, we have a controller, and something bad happens, but we want
48
+ * to report an error instead of throwing it.
49
+ *
50
+ * ``` ts
51
+ * // === Controller file ===
52
+ *
53
+ * import type { ErrorReportingServiceCaptureExceptionAction } from '@metamask/error-reporting-service';
54
+ *
55
+ * // Define the messenger type for the controller.
56
+ * type AllowedActions = ErrorReportingServiceCaptureExceptionAction;
57
+ * type ExampleControllerMessenger = RestrictedMessenger<
58
+ * 'ExampleController',
59
+ * AllowedActions,
60
+ * never,
61
+ * AllowedActions['type'],
62
+ * never
63
+ * >;
64
+ *
65
+ * // Define the controller.
66
+ * class ExampleController extends BaseController<
67
+ * 'ExampleController',
68
+ * ExampleControllerState,
69
+ * ExampleControllerMessenger
70
+ * > {
71
+ * doSomething() {
72
+ * // Imagine that we do something that produces an error and we want to
73
+ * // report the error.
74
+ * this.messagingSystem.call(
75
+ * 'ErrorReportingService:captureException',
76
+ * new Error('Something went wrong'),
77
+ * );
78
+ * }
79
+ * }
80
+ *
81
+ * // === Initialization file ===
82
+ *
83
+ * import { captureException } from '@sentry/browser';
84
+ * import { ErrorReportingService } from '@metamask/error-reporting-service';
85
+ * import { ExampleController } from './example-controller';
86
+ *
87
+ * // Create a global messenger.
88
+ * const globalMessenger = new Messenger();
89
+ *
90
+ * // Register handler for the `ErrorReportingService:captureException`
91
+ * // action in the global messenger.
92
+ * const errorReportingServiceMessenger = globalMessenger.getRestricted({
93
+ * allowedActions: [],
94
+ * allowedEvents: [],
95
+ * });
96
+ * const errorReportingService = new ErrorReportingService({
97
+ * messenger: errorReportingServiceMessenger,
98
+ * captureException,
99
+ * });
100
+ *
101
+ * const exampleControllerMessenger = globalMessenger.getRestricted({
102
+ * allowedActions: ['ErrorReportingService:captureException'],
103
+ * allowedEvents: [],
104
+ * });
105
+ * const exampleController = new ExampleController({
106
+ * messenger: exampleControllerMessenger,
107
+ * });
108
+ *
109
+ * // === Somewhere else ===
110
+ *
111
+ * // Now this will report an error without throwing it.
112
+ * exampleController.doSomething();
113
+ * ```
114
+ */
115
+ export declare class ErrorReportingService {
116
+ #private;
117
+ /**
118
+ * Constructs a new ErrorReportingService.
119
+ *
120
+ * @param options - The options.
121
+ * @param options.messenger - The messenger suited to this
122
+ * ErrorReportingService.
123
+ * @param options.captureException - A function that stores the given error in
124
+ * the error reporting service.
125
+ */
126
+ constructor({ messenger, captureException }: ErrorReportingServiceOptions);
127
+ /**
128
+ * Reports the given error to an external location.
129
+ *
130
+ * @param error - The error to report.
131
+ */
132
+ captureException(error: Error): void;
133
+ }
134
+ export {};
135
+ //# sourceMappingURL=error-reporting-service.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-reporting-service.d.mts","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAkC;AAErE;;GAEG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;CACpD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GACtC,2CAA2C,CAAC;AAE9C;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,KAAK,CAAC;AAEhD;;;GAGG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;;GAGG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG,mBAAmB,CAC9D,uBAAuB,EACvB,4BAA4B,GAAG,cAAc,EAC7C,2BAA2B,GAAG,aAAa,EAC3C,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC;AAEF;;GAEG;AACH,KAAK,4BAA4B,GAAG;IAClC,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;IAC7C,SAAS,EAAE,8BAA8B,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,qBAAa,qBAAqB;;IAKhC;;;;;;;;OAQG;gBACS,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,4BAA4B;IAUzE;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;CAGrC"}
@@ -0,0 +1,114 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _ErrorReportingService_captureException, _ErrorReportingService_messenger;
13
+ /**
14
+ * `ErrorReportingService` is designed to log an error to an error reporting app
15
+ * such as Sentry, but in an agnostic fashion.
16
+ *
17
+ * @example
18
+ *
19
+ * In this example, we have a controller, and something bad happens, but we want
20
+ * to report an error instead of throwing it.
21
+ *
22
+ * ``` ts
23
+ * // === Controller file ===
24
+ *
25
+ * import type { ErrorReportingServiceCaptureExceptionAction } from '@metamask/error-reporting-service';
26
+ *
27
+ * // Define the messenger type for the controller.
28
+ * type AllowedActions = ErrorReportingServiceCaptureExceptionAction;
29
+ * type ExampleControllerMessenger = RestrictedMessenger<
30
+ * 'ExampleController',
31
+ * AllowedActions,
32
+ * never,
33
+ * AllowedActions['type'],
34
+ * never
35
+ * >;
36
+ *
37
+ * // Define the controller.
38
+ * class ExampleController extends BaseController<
39
+ * 'ExampleController',
40
+ * ExampleControllerState,
41
+ * ExampleControllerMessenger
42
+ * > {
43
+ * doSomething() {
44
+ * // Imagine that we do something that produces an error and we want to
45
+ * // report the error.
46
+ * this.messagingSystem.call(
47
+ * 'ErrorReportingService:captureException',
48
+ * new Error('Something went wrong'),
49
+ * );
50
+ * }
51
+ * }
52
+ *
53
+ * // === Initialization file ===
54
+ *
55
+ * import { captureException } from '@sentry/browser';
56
+ * import { ErrorReportingService } from '@metamask/error-reporting-service';
57
+ * import { ExampleController } from './example-controller';
58
+ *
59
+ * // Create a global messenger.
60
+ * const globalMessenger = new Messenger();
61
+ *
62
+ * // Register handler for the `ErrorReportingService:captureException`
63
+ * // action in the global messenger.
64
+ * const errorReportingServiceMessenger = globalMessenger.getRestricted({
65
+ * allowedActions: [],
66
+ * allowedEvents: [],
67
+ * });
68
+ * const errorReportingService = new ErrorReportingService({
69
+ * messenger: errorReportingServiceMessenger,
70
+ * captureException,
71
+ * });
72
+ *
73
+ * const exampleControllerMessenger = globalMessenger.getRestricted({
74
+ * allowedActions: ['ErrorReportingService:captureException'],
75
+ * allowedEvents: [],
76
+ * });
77
+ * const exampleController = new ExampleController({
78
+ * messenger: exampleControllerMessenger,
79
+ * });
80
+ *
81
+ * // === Somewhere else ===
82
+ *
83
+ * // Now this will report an error without throwing it.
84
+ * exampleController.doSomething();
85
+ * ```
86
+ */
87
+ export class ErrorReportingService {
88
+ /**
89
+ * Constructs a new ErrorReportingService.
90
+ *
91
+ * @param options - The options.
92
+ * @param options.messenger - The messenger suited to this
93
+ * ErrorReportingService.
94
+ * @param options.captureException - A function that stores the given error in
95
+ * the error reporting service.
96
+ */
97
+ constructor({ messenger, captureException }) {
98
+ _ErrorReportingService_captureException.set(this, void 0);
99
+ _ErrorReportingService_messenger.set(this, void 0);
100
+ __classPrivateFieldSet(this, _ErrorReportingService_messenger, messenger, "f");
101
+ __classPrivateFieldSet(this, _ErrorReportingService_captureException, captureException, "f");
102
+ __classPrivateFieldGet(this, _ErrorReportingService_messenger, "f").registerActionHandler('ErrorReportingService:captureException', __classPrivateFieldGet(this, _ErrorReportingService_captureException, "f").bind(this));
103
+ }
104
+ /**
105
+ * Reports the given error to an external location.
106
+ *
107
+ * @param error - The error to report.
108
+ */
109
+ captureException(error) {
110
+ __classPrivateFieldGet(this, _ErrorReportingService_captureException, "f").call(this, error);
111
+ }
112
+ }
113
+ _ErrorReportingService_captureException = new WeakMap(), _ErrorReportingService_messenger = new WeakMap();
114
+ //# sourceMappingURL=error-reporting-service.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-reporting-service.mjs","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAuDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,MAAM,OAAO,qBAAqB;IAKhC;;;;;;;;OAQG;IACH,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAgC;QAbhE,0DAAoE;QAEpE,mDAA2C;QAYlD,uBAAA,IAAI,oCAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,2CAAqB,gBAAgB,MAAA,CAAC;QAE1C,uBAAA,IAAI,wCAAW,CAAC,qBAAqB,CACnC,wCAAwC,EACxC,uBAAA,IAAI,+CAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAClC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,gBAAgB,CAAC,KAAY;QAC3B,uBAAA,IAAI,+CAAkB,MAAtB,IAAI,EAAmB,KAAK,CAAC,CAAC;IAChC,CAAC;CACF","sourcesContent":["import type { RestrictedMessenger } from '@metamask/base-controller';\n\n/**\n * The action which can be used to report an error.\n */\nexport type ErrorReportingServiceCaptureExceptionAction = {\n type: 'ErrorReportingService:captureException';\n handler: ErrorReportingService['captureException'];\n};\n\n/**\n * All actions that {@link ErrorReportingService} registers so that other\n * modules can call them.\n */\nexport type ErrorReportingServiceActions =\n ErrorReportingServiceCaptureExceptionAction;\n\n/**\n * All events that {@link ErrorReportingService} publishes so that other modules\n * can subscribe to them.\n */\nexport type ErrorReportingServiceEvents = never;\n\n/**\n * All actions registered by other modules that {@link ErrorReportingService}\n * calls.\n */\ntype AllowedActions = never;\n\n/**\n * All events published by other modules that {@link ErrorReportingService}\n * subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events that\n * {@link ErrorReportingService} needs to access.\n */\nexport type ErrorReportingServiceMessenger = RestrictedMessenger<\n 'ErrorReportingService',\n ErrorReportingServiceActions | AllowedActions,\n ErrorReportingServiceEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\n/**\n * The options that {@link ErrorReportingService} takes.\n */\ntype ErrorReportingServiceOptions = {\n captureException: (error: unknown) => string;\n messenger: ErrorReportingServiceMessenger;\n};\n\n/**\n * `ErrorReportingService` is designed to log an error to an error reporting app\n * such as Sentry, but in an agnostic fashion.\n *\n * @example\n *\n * In this example, we have a controller, and something bad happens, but we want\n * to report an error instead of throwing it.\n *\n * ``` ts\n * // === Controller file ===\n *\n * import type { ErrorReportingServiceCaptureExceptionAction } from '@metamask/error-reporting-service';\n *\n * // Define the messenger type for the controller.\n * type AllowedActions = ErrorReportingServiceCaptureExceptionAction;\n * type ExampleControllerMessenger = RestrictedMessenger<\n * 'ExampleController',\n * AllowedActions,\n * never,\n * AllowedActions['type'],\n * never\n * >;\n *\n * // Define the controller.\n * class ExampleController extends BaseController<\n * 'ExampleController',\n * ExampleControllerState,\n * ExampleControllerMessenger\n * > {\n * doSomething() {\n * // Imagine that we do something that produces an error and we want to\n * // report the error.\n * this.messagingSystem.call(\n * 'ErrorReportingService:captureException',\n * new Error('Something went wrong'),\n * );\n * }\n * }\n *\n * // === Initialization file ===\n *\n * import { captureException } from '@sentry/browser';\n * import { ErrorReportingService } from '@metamask/error-reporting-service';\n * import { ExampleController } from './example-controller';\n *\n * // Create a global messenger.\n * const globalMessenger = new Messenger();\n *\n * // Register handler for the `ErrorReportingService:captureException`\n * // action in the global messenger.\n * const errorReportingServiceMessenger = globalMessenger.getRestricted({\n * allowedActions: [],\n * allowedEvents: [],\n * });\n * const errorReportingService = new ErrorReportingService({\n * messenger: errorReportingServiceMessenger,\n * captureException,\n * });\n *\n * const exampleControllerMessenger = globalMessenger.getRestricted({\n * allowedActions: ['ErrorReportingService:captureException'],\n * allowedEvents: [],\n * });\n * const exampleController = new ExampleController({\n * messenger: exampleControllerMessenger,\n * });\n *\n * // === Somewhere else ===\n *\n * // Now this will report an error without throwing it.\n * exampleController.doSomething();\n * ```\n */\nexport class ErrorReportingService {\n readonly #captureException: ErrorReportingServiceOptions['captureException'];\n\n readonly #messenger: ErrorReportingServiceMessenger;\n\n /**\n * Constructs a new ErrorReportingService.\n *\n * @param options - The options.\n * @param options.messenger - The messenger suited to this\n * ErrorReportingService.\n * @param options.captureException - A function that stores the given error in\n * the error reporting service.\n */\n constructor({ messenger, captureException }: ErrorReportingServiceOptions) {\n this.#messenger = messenger;\n this.#captureException = captureException;\n\n this.#messenger.registerActionHandler(\n 'ErrorReportingService:captureException',\n this.#captureException.bind(this),\n );\n }\n\n /**\n * Reports the given error to an external location.\n *\n * @param error - The error to report.\n */\n captureException(error: Error): void {\n this.#captureException(error);\n }\n}\n"]}
package/dist/index.cjs ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorReportingService = void 0;
4
+ var error_reporting_service_1 = require("./error-reporting-service.cjs");
5
+ Object.defineProperty(exports, "ErrorReportingService", { enumerable: true, get: function () { return error_reporting_service_1.ErrorReportingService; } });
6
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yEAAkE;AAAzD,gIAAA,qBAAqB,OAAA","sourcesContent":["export { ErrorReportingService } from './error-reporting-service';\nexport type {\n ErrorReportingServiceActions,\n ErrorReportingServiceCaptureExceptionAction,\n ErrorReportingServiceEvents,\n ErrorReportingServiceMessenger,\n} from './error-reporting-service';\n"]}
@@ -0,0 +1,3 @@
1
+ export { ErrorReportingService } from "./error-reporting-service.cjs";
2
+ export type { ErrorReportingServiceActions, ErrorReportingServiceCaptureExceptionAction, ErrorReportingServiceEvents, ErrorReportingServiceMessenger, } from "./error-reporting-service.cjs";
3
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,sCAAkC;AAClE,YAAY,EACV,4BAA4B,EAC5B,2CAA2C,EAC3C,2BAA2B,EAC3B,8BAA8B,GAC/B,sCAAkC"}
@@ -0,0 +1,3 @@
1
+ export { ErrorReportingService } from "./error-reporting-service.mjs";
2
+ export type { ErrorReportingServiceActions, ErrorReportingServiceCaptureExceptionAction, ErrorReportingServiceEvents, ErrorReportingServiceMessenger, } from "./error-reporting-service.mjs";
3
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,sCAAkC;AAClE,YAAY,EACV,4BAA4B,EAC5B,2CAA2C,EAC3C,2BAA2B,EAC3B,8BAA8B,GAC/B,sCAAkC"}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ export { ErrorReportingService } from "./error-reporting-service.mjs";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,sCAAkC","sourcesContent":["export { ErrorReportingService } from './error-reporting-service';\nexport type {\n ErrorReportingServiceActions,\n ErrorReportingServiceCaptureExceptionAction,\n ErrorReportingServiceEvents,\n ErrorReportingServiceMessenger,\n} from './error-reporting-service';\n"]}
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@metamask-previews/error-reporting-service",
3
+ "version": "0.0.0-preview-d0685d1",
4
+ "description": "Logs errors to an error reporting service such as Sentry",
5
+ "keywords": [
6
+ "MetaMask",
7
+ "Ethereum"
8
+ ],
9
+ "homepage": "https://github.com/MetaMask/core/tree/main/packages/error-reporting-service#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/MetaMask/core/issues"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/MetaMask/core.git"
16
+ },
17
+ "license": "MIT",
18
+ "sideEffects": false,
19
+ "exports": {
20
+ ".": {
21
+ "import": {
22
+ "types": "./dist/index.d.mts",
23
+ "default": "./dist/index.mjs"
24
+ },
25
+ "require": {
26
+ "types": "./dist/index.d.cts",
27
+ "default": "./dist/index.cjs"
28
+ }
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "main": "./dist/index.cjs",
33
+ "types": "./dist/index.d.cts",
34
+ "files": [
35
+ "dist/"
36
+ ],
37
+ "scripts": {
38
+ "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
39
+ "build:docs": "typedoc",
40
+ "changelog:update": "../../scripts/update-changelog.sh @metamask/error-reporting-service",
41
+ "changelog:validate": "../../scripts/validate-changelog.sh @metamask/error-reporting-service",
42
+ "publish:preview": "yarn npm publish --tag preview",
43
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
44
+ "test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
45
+ "test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
46
+ "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
47
+ "since-latest-release": "../../scripts/since-latest-release.sh"
48
+ },
49
+ "dependencies": {
50
+ "@metamask/base-controller": "^8.0.1"
51
+ },
52
+ "devDependencies": {
53
+ "@metamask/auto-changelog": "^3.4.4",
54
+ "@sentry/core": "^9.22.0",
55
+ "@types/jest": "^27.4.1",
56
+ "deepmerge": "^4.2.2",
57
+ "jest": "^27.5.1",
58
+ "ts-jest": "^27.1.4",
59
+ "typedoc": "^0.24.8",
60
+ "typedoc-plugin-missing-exports": "^2.0.0",
61
+ "typescript": "~5.2.2"
62
+ },
63
+ "engines": {
64
+ "node": "^18.18 || >=20"
65
+ },
66
+ "publishConfig": {
67
+ "access": "public",
68
+ "registry": "https://registry.npmjs.org/"
69
+ }
70
+ }