@metamask-previews/error-reporting-service 3.0.0-preview-de995bed → 3.0.0-preview-cb4a07d5

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 CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Changed
11
+
12
+ - Add deprecation notice ([#7427](https://github.com/MetaMask/core/pull/7427))
13
+ - This package is deprecated, and can be replaced with the
14
+ `Messenger.captureException` method from `@metamask/messenger`.
15
+
10
16
  ## [3.0.0]
11
17
 
12
18
  ### Changed
package/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # `@metamask/error-reporting-service`
2
2
 
3
+ > [!WARNING]
4
+ > This package is deprecated. To report errors, please use
5
+ > [`Messenger.captureException`](https://github.com/MetaMask/core/blob/8b3ad82c35d9d75c9a5096d847e7e8651e29cc5e/packages/messenger/src/Messenger.ts#L258-L263)
6
+ > instead.
7
+
3
8
  Reports errors to an external app such as Sentry but in an agnostic fashion.
4
9
 
5
10
  ## Installation
@@ -104,6 +104,9 @@ exports.ErrorReportingService = void 0;
104
104
  * // Now this will report an error without throwing it.
105
105
  * exampleController.doSomething();
106
106
  * ```
107
+ *
108
+ * @deprecated This service is deprecated and will be removed in a future
109
+ * release. Please use `Messenger.captureException` directly instead.
107
110
  */
108
111
  class ErrorReportingService {
109
112
  /**
@@ -128,6 +131,8 @@ class ErrorReportingService {
128
131
  * Reports the given error to an external location.
129
132
  *
130
133
  * @param error - The error to report.
134
+ * @deprecated This function is deprecated and will be removed in a future
135
+ * release. Please use `Messenger.captureException` directly instead.
131
136
  */
132
137
  captureException(error) {
133
138
  __classPrivateFieldGet(this, _ErrorReportingService_captureException, "f").call(this, error);
@@ -1 +1 @@
1
- {"version":3,"file":"error-reporting-service.cjs","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAqDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,MAAa,qBAAqB;IAShC;;;;;;;;OAQG;IACH,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAgC;QAjBzE,SAAI,GAA4B,uBAAgC,CAAC;QAEjE,UAAK,GAAG,IAAI,CAAC;QAEJ,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;AApCD,sDAoCC","sourcesContent":["import type { Messenger } from '@metamask/messenger';\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 = Messenger<\n 'ErrorReportingService',\n ErrorReportingServiceActions | AllowedActions,\n ErrorReportingServiceEvents | AllowedEvents\n>;\n\n/**\n * The options that {@link ErrorReportingService} takes.\n */\ntype ErrorReportingServiceOptions = {\n captureException: ErrorReportingService['captureException'];\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 = Messenger<\n * 'ExampleController',\n * AllowedActions,\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.messenger.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 * type RootMessenger = Messenger<\n * 'Root',\n * MessengerActions<ErrorReportingServiceMessenger>,\n * MessengerEvents<ErrorReportingServiceMessenger>\n * >;\n *\n * // Create a root messenger.\n * const rootMessenger = new Messenger();\n *\n * // Register handler for the `ErrorReportingService:captureException`\n * // action in the root messenger.\n * const errorReportingServiceMessenger = new Messenger<\n * 'ErrorReportingService',\n * MessengerActions<ErrorReportingServiceMessenger>,\n * MessengerEvents<ErrorReportingServiceMessenger>,\n * RootMessenger\n * >({\n * namespace: 'ErrorReportingService',\n * parent: rootMessenger,\n * });\n * const errorReportingService = new ErrorReportingService({\n * messenger: errorReportingServiceMessenger,\n * captureException,\n * });\n *\n * const exampleControllerMessenger = new Messenger<\n * 'ExampleController',\n * MessengerActions<ExampleControllerMessenger>,\n * MessengerEvents<ExampleControllerMessenger>,\n * RootMessenger\n * >({\n * namespace: 'ExampleController',\n * parent: rootMessenger,\n * });\n * rootMessenger.delegate({\n * messenger: exampleControllerMessenger,\n * actions: ['ErrorReportingService:captureException'],\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 name: 'ErrorReportingService' = 'ErrorReportingService' as const;\n\n state = null;\n\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"]}
1
+ {"version":3,"file":"error-reporting-service.cjs","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAwDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8FG;AACH,MAAa,qBAAqB;IAShC;;;;;;;;OAQG;IACH,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAgC;QAjBzE,SAAI,GAA4B,uBAAgC,CAAC;QAEjE,UAAK,GAAG,IAAI,CAAC;QAEJ,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;;;;;;OAMG;IACH,gBAAgB,CAAC,KAAY;QAC3B,uBAAA,IAAI,+CAAkB,MAAtB,IAAI,EAAmB,KAAK,CAAC,CAAC;IAChC,CAAC;CACF;AAtCD,sDAsCC","sourcesContent":["import type { Messenger } from '@metamask/messenger';\n\n/**\n * The action which can be used to report an error.\n *\n * @deprecated This action is deprecated and will be removed in a future\n * release. Please use `Messenger.captureException` directly instead.\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 = Messenger<\n 'ErrorReportingService',\n ErrorReportingServiceActions | AllowedActions,\n ErrorReportingServiceEvents | AllowedEvents\n>;\n\n/**\n * The options that {@link ErrorReportingService} takes.\n */\ntype ErrorReportingServiceOptions = {\n captureException: ErrorReportingService['captureException'];\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 = Messenger<\n * 'ExampleController',\n * AllowedActions,\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.messenger.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 * type RootMessenger = Messenger<\n * 'Root',\n * MessengerActions<ErrorReportingServiceMessenger>,\n * MessengerEvents<ErrorReportingServiceMessenger>\n * >;\n *\n * // Create a root messenger.\n * const rootMessenger = new Messenger();\n *\n * // Register handler for the `ErrorReportingService:captureException`\n * // action in the root messenger.\n * const errorReportingServiceMessenger = new Messenger<\n * 'ErrorReportingService',\n * MessengerActions<ErrorReportingServiceMessenger>,\n * MessengerEvents<ErrorReportingServiceMessenger>,\n * RootMessenger\n * >({\n * namespace: 'ErrorReportingService',\n * parent: rootMessenger,\n * });\n * const errorReportingService = new ErrorReportingService({\n * messenger: errorReportingServiceMessenger,\n * captureException,\n * });\n *\n * const exampleControllerMessenger = new Messenger<\n * 'ExampleController',\n * MessengerActions<ExampleControllerMessenger>,\n * MessengerEvents<ExampleControllerMessenger>,\n * RootMessenger\n * >({\n * namespace: 'ExampleController',\n * parent: rootMessenger,\n * });\n * rootMessenger.delegate({\n * messenger: exampleControllerMessenger,\n * actions: ['ErrorReportingService:captureException'],\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 *\n * @deprecated This service is deprecated and will be removed in a future\n * release. Please use `Messenger.captureException` directly instead.\n */\nexport class ErrorReportingService {\n name: 'ErrorReportingService' = 'ErrorReportingService' as const;\n\n state = null;\n\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 * @deprecated This function is deprecated and will be removed in a future\n * release. Please use `Messenger.captureException` directly instead.\n */\n captureException(error: Error): void {\n this.#captureException(error);\n }\n}\n"]}
@@ -1,6 +1,9 @@
1
1
  import type { Messenger } from "@metamask/messenger";
2
2
  /**
3
3
  * The action which can be used to report an error.
4
+ *
5
+ * @deprecated This action is deprecated and will be removed in a future
6
+ * release. Please use `Messenger.captureException` directly instead.
4
7
  */
5
8
  export type ErrorReportingServiceCaptureExceptionAction = {
6
9
  type: 'ErrorReportingService:captureException';
@@ -129,6 +132,9 @@ type ErrorReportingServiceOptions = {
129
132
  * // Now this will report an error without throwing it.
130
133
  * exampleController.doSomething();
131
134
  * ```
135
+ *
136
+ * @deprecated This service is deprecated and will be removed in a future
137
+ * release. Please use `Messenger.captureException` directly instead.
132
138
  */
133
139
  export declare class ErrorReportingService {
134
140
  #private;
@@ -148,6 +154,8 @@ export declare class ErrorReportingService {
148
154
  * Reports the given error to an external location.
149
155
  *
150
156
  * @param error - The error to report.
157
+ * @deprecated This function is deprecated and will be removed in a future
158
+ * release. Please use `Messenger.captureException` directly instead.
151
159
  */
152
160
  captureException(error: Error): void;
153
161
  }
@@ -1 +1 @@
1
- {"version":3,"file":"error-reporting-service.d.cts","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD;;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,SAAS,CACpD,uBAAuB,EACvB,4BAA4B,GAAG,cAAc,EAC7C,2BAA2B,GAAG,aAAa,CAC5C,CAAC;AAEF;;GAEG;AACH,KAAK,4BAA4B,GAAG;IAClC,gBAAgB,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;IAC5D,SAAS,EAAE,8BAA8B,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,qBAAa,qBAAqB;;IAChC,IAAI,EAAE,uBAAuB,CAAoC;IAEjE,KAAK,OAAQ;IAMb;;;;;;;;OAQG;gBACS,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,4BAA4B;IAUzE;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;CAGrC"}
1
+ {"version":3,"file":"error-reporting-service.d.cts","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD;;;;;GAKG;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,SAAS,CACpD,uBAAuB,EACvB,4BAA4B,GAAG,cAAc,EAC7C,2BAA2B,GAAG,aAAa,CAC5C,CAAC;AAEF;;GAEG;AACH,KAAK,4BAA4B,GAAG;IAClC,gBAAgB,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;IAC5D,SAAS,EAAE,8BAA8B,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8FG;AACH,qBAAa,qBAAqB;;IAChC,IAAI,EAAE,uBAAuB,CAAoC;IAEjE,KAAK,OAAQ;IAMb;;;;;;;;OAQG;gBACS,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,4BAA4B;IAUzE;;;;;;OAMG;IACH,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;CAGrC"}
@@ -1,6 +1,9 @@
1
1
  import type { Messenger } from "@metamask/messenger";
2
2
  /**
3
3
  * The action which can be used to report an error.
4
+ *
5
+ * @deprecated This action is deprecated and will be removed in a future
6
+ * release. Please use `Messenger.captureException` directly instead.
4
7
  */
5
8
  export type ErrorReportingServiceCaptureExceptionAction = {
6
9
  type: 'ErrorReportingService:captureException';
@@ -129,6 +132,9 @@ type ErrorReportingServiceOptions = {
129
132
  * // Now this will report an error without throwing it.
130
133
  * exampleController.doSomething();
131
134
  * ```
135
+ *
136
+ * @deprecated This service is deprecated and will be removed in a future
137
+ * release. Please use `Messenger.captureException` directly instead.
132
138
  */
133
139
  export declare class ErrorReportingService {
134
140
  #private;
@@ -148,6 +154,8 @@ export declare class ErrorReportingService {
148
154
  * Reports the given error to an external location.
149
155
  *
150
156
  * @param error - The error to report.
157
+ * @deprecated This function is deprecated and will be removed in a future
158
+ * release. Please use `Messenger.captureException` directly instead.
151
159
  */
152
160
  captureException(error: Error): void;
153
161
  }
@@ -1 +1 @@
1
- {"version":3,"file":"error-reporting-service.d.mts","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD;;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,SAAS,CACpD,uBAAuB,EACvB,4BAA4B,GAAG,cAAc,EAC7C,2BAA2B,GAAG,aAAa,CAC5C,CAAC;AAEF;;GAEG;AACH,KAAK,4BAA4B,GAAG;IAClC,gBAAgB,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;IAC5D,SAAS,EAAE,8BAA8B,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,qBAAa,qBAAqB;;IAChC,IAAI,EAAE,uBAAuB,CAAoC;IAEjE,KAAK,OAAQ;IAMb;;;;;;;;OAQG;gBACS,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,4BAA4B;IAUzE;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;CAGrC"}
1
+ {"version":3,"file":"error-reporting-service.d.mts","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD;;;;;GAKG;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,SAAS,CACpD,uBAAuB,EACvB,4BAA4B,GAAG,cAAc,EAC7C,2BAA2B,GAAG,aAAa,CAC5C,CAAC;AAEF;;GAEG;AACH,KAAK,4BAA4B,GAAG;IAClC,gBAAgB,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;IAC5D,SAAS,EAAE,8BAA8B,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8FG;AACH,qBAAa,qBAAqB;;IAChC,IAAI,EAAE,uBAAuB,CAAoC;IAEjE,KAAK,OAAQ;IAMb;;;;;;;;OAQG;gBACS,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,4BAA4B;IAUzE;;;;;;OAMG;IACH,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;CAGrC"}
@@ -101,6 +101,9 @@ var _ErrorReportingService_captureException, _ErrorReportingService_messenger;
101
101
  * // Now this will report an error without throwing it.
102
102
  * exampleController.doSomething();
103
103
  * ```
104
+ *
105
+ * @deprecated This service is deprecated and will be removed in a future
106
+ * release. Please use `Messenger.captureException` directly instead.
104
107
  */
105
108
  export class ErrorReportingService {
106
109
  /**
@@ -125,6 +128,8 @@ export class ErrorReportingService {
125
128
  * Reports the given error to an external location.
126
129
  *
127
130
  * @param error - The error to report.
131
+ * @deprecated This function is deprecated and will be removed in a future
132
+ * release. Please use `Messenger.captureException` directly instead.
128
133
  */
129
134
  captureException(error) {
130
135
  __classPrivateFieldGet(this, _ErrorReportingService_captureException, "f").call(this, error);
@@ -1 +1 @@
1
- {"version":3,"file":"error-reporting-service.mjs","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAqDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,MAAM,OAAO,qBAAqB;IAShC;;;;;;;;OAQG;IACH,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAgC;QAjBzE,SAAI,GAA4B,uBAAgC,CAAC;QAEjE,UAAK,GAAG,IAAI,CAAC;QAEJ,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 { Messenger } from '@metamask/messenger';\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 = Messenger<\n 'ErrorReportingService',\n ErrorReportingServiceActions | AllowedActions,\n ErrorReportingServiceEvents | AllowedEvents\n>;\n\n/**\n * The options that {@link ErrorReportingService} takes.\n */\ntype ErrorReportingServiceOptions = {\n captureException: ErrorReportingService['captureException'];\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 = Messenger<\n * 'ExampleController',\n * AllowedActions,\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.messenger.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 * type RootMessenger = Messenger<\n * 'Root',\n * MessengerActions<ErrorReportingServiceMessenger>,\n * MessengerEvents<ErrorReportingServiceMessenger>\n * >;\n *\n * // Create a root messenger.\n * const rootMessenger = new Messenger();\n *\n * // Register handler for the `ErrorReportingService:captureException`\n * // action in the root messenger.\n * const errorReportingServiceMessenger = new Messenger<\n * 'ErrorReportingService',\n * MessengerActions<ErrorReportingServiceMessenger>,\n * MessengerEvents<ErrorReportingServiceMessenger>,\n * RootMessenger\n * >({\n * namespace: 'ErrorReportingService',\n * parent: rootMessenger,\n * });\n * const errorReportingService = new ErrorReportingService({\n * messenger: errorReportingServiceMessenger,\n * captureException,\n * });\n *\n * const exampleControllerMessenger = new Messenger<\n * 'ExampleController',\n * MessengerActions<ExampleControllerMessenger>,\n * MessengerEvents<ExampleControllerMessenger>,\n * RootMessenger\n * >({\n * namespace: 'ExampleController',\n * parent: rootMessenger,\n * });\n * rootMessenger.delegate({\n * messenger: exampleControllerMessenger,\n * actions: ['ErrorReportingService:captureException'],\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 name: 'ErrorReportingService' = 'ErrorReportingService' as const;\n\n state = null;\n\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"]}
1
+ {"version":3,"file":"error-reporting-service.mjs","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAwDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8FG;AACH,MAAM,OAAO,qBAAqB;IAShC;;;;;;;;OAQG;IACH,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAgC;QAjBzE,SAAI,GAA4B,uBAAgC,CAAC;QAEjE,UAAK,GAAG,IAAI,CAAC;QAEJ,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;;;;;;OAMG;IACH,gBAAgB,CAAC,KAAY;QAC3B,uBAAA,IAAI,+CAAkB,MAAtB,IAAI,EAAmB,KAAK,CAAC,CAAC;IAChC,CAAC;CACF","sourcesContent":["import type { Messenger } from '@metamask/messenger';\n\n/**\n * The action which can be used to report an error.\n *\n * @deprecated This action is deprecated and will be removed in a future\n * release. Please use `Messenger.captureException` directly instead.\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 = Messenger<\n 'ErrorReportingService',\n ErrorReportingServiceActions | AllowedActions,\n ErrorReportingServiceEvents | AllowedEvents\n>;\n\n/**\n * The options that {@link ErrorReportingService} takes.\n */\ntype ErrorReportingServiceOptions = {\n captureException: ErrorReportingService['captureException'];\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 = Messenger<\n * 'ExampleController',\n * AllowedActions,\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.messenger.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 * type RootMessenger = Messenger<\n * 'Root',\n * MessengerActions<ErrorReportingServiceMessenger>,\n * MessengerEvents<ErrorReportingServiceMessenger>\n * >;\n *\n * // Create a root messenger.\n * const rootMessenger = new Messenger();\n *\n * // Register handler for the `ErrorReportingService:captureException`\n * // action in the root messenger.\n * const errorReportingServiceMessenger = new Messenger<\n * 'ErrorReportingService',\n * MessengerActions<ErrorReportingServiceMessenger>,\n * MessengerEvents<ErrorReportingServiceMessenger>,\n * RootMessenger\n * >({\n * namespace: 'ErrorReportingService',\n * parent: rootMessenger,\n * });\n * const errorReportingService = new ErrorReportingService({\n * messenger: errorReportingServiceMessenger,\n * captureException,\n * });\n *\n * const exampleControllerMessenger = new Messenger<\n * 'ExampleController',\n * MessengerActions<ExampleControllerMessenger>,\n * MessengerEvents<ExampleControllerMessenger>,\n * RootMessenger\n * >({\n * namespace: 'ExampleController',\n * parent: rootMessenger,\n * });\n * rootMessenger.delegate({\n * messenger: exampleControllerMessenger,\n * actions: ['ErrorReportingService:captureException'],\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 *\n * @deprecated This service is deprecated and will be removed in a future\n * release. Please use `Messenger.captureException` directly instead.\n */\nexport class ErrorReportingService {\n name: 'ErrorReportingService' = 'ErrorReportingService' as const;\n\n state = null;\n\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 * @deprecated This function is deprecated and will be removed in a future\n * release. Please use `Messenger.captureException` directly instead.\n */\n captureException(error: Error): void {\n this.#captureException(error);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/error-reporting-service",
3
- "version": "3.0.0-preview-de995bed",
3
+ "version": "3.0.0-preview-cb4a07d5",
4
4
  "description": "Logs errors to an error reporting service such as Sentry",
5
5
  "keywords": [
6
6
  "MetaMask",