@exodus/error-tracking 1.5.0 → 2.0.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/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/error-tracking@1.5.1...@exodus/error-tracking@2.0.0) (2025-04-09)
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ - require `error` to be `Error` instances (#11965)
11
+
12
+ ### Features
13
+
14
+ - feat!: require `error` to be `Error` instances (#11965)
15
+
16
+ ### Bug Fixes
17
+
18
+ - fix: make `context` parameter optional in type definitions (#11975)
19
+
20
+ ## [1.5.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/error-tracking@1.5.0...@exodus/error-tracking@1.5.1) (2025-03-13)
21
+
22
+ **Note:** Version bump only for package @exodus/error-tracking
23
+
6
24
  ## [1.5.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/error-tracking@1.4.1...@exodus/error-tracking@1.5.0) (2025-02-27)
7
25
 
8
26
  ### Features
package/api/index.d.ts CHANGED
@@ -5,12 +5,12 @@ export interface ErrorTrackingApi {
5
5
  * ```typescript
6
6
  * exodus.errors.track({
7
7
  * namespace: 'balances',
8
- * error: 'Encountered an issue when computing total balances',
8
+ * error: new Error('Encountered an issue when computing total balances'),
9
9
  * context: {},
10
10
  * })
11
11
  * ```
12
12
  */
13
- track(params: { error: string | Error; namespace: string; context: any }): Promise<void>
13
+ track(params: { error: Error; namespace: string; context?: any }): Promise<void>
14
14
  /**
15
15
  * Track an error remotely using sentry if available
16
16
  * @example
@@ -0,0 +1,15 @@
1
+ import type { Atom } from '@exodus/atoms'
2
+
3
+ interface ErrorsSchema {
4
+ errors: { namespace: string; error: Error; context: any; time: number }[]
5
+ }
6
+
7
+ export type ErrorsAtom = Atom<ErrorsSchema>
8
+
9
+ declare const errorsAtomDefinition: {
10
+ id: 'errorsAtom'
11
+ type: 'atom'
12
+ factory(): ErrorsAtom
13
+ }
14
+
15
+ export default errorsAtomDefinition
package/index.d.ts CHANGED
@@ -1,8 +1,17 @@
1
1
  import type errorTrackingApiDefinition from './api/index.js'
2
+ import type errorTrackingModuleDefinition from './module/index.js'
3
+ import type errorsAtomDefinition from './atoms/index.js'
2
4
 
3
- declare const errorTracking: () => {
5
+ declare const errorTracking: (config?: { maxErrorsCount?: number }) => {
4
6
  id: 'errorTracking'
5
- definitions: [{ definition: typeof errorTrackingApiDefinition }]
7
+ definitions: [
8
+ { definition: typeof errorTrackingApiDefinition },
9
+ { definition: typeof errorTrackingModuleDefinition },
10
+ { definition: typeof errorsAtomDefinition },
11
+ ]
6
12
  }
7
13
 
14
+ export { ErrorTrackingModule } from './module/index.js'
15
+ export { ErrorsAtom } from './atoms/index.js'
16
+
8
17
  export default errorTracking
@@ -6,6 +6,10 @@ const createErrorTracking = ({ errorsAtom, config }) => {
6
6
  throw new Error('no namespace provided')
7
7
  }
8
8
 
9
+ if (!(error instanceof Error)) {
10
+ throw new TypeError('error must be an instance of Error')
11
+ }
12
+
9
13
  return errorsAtom.set(({ errors }) => {
10
14
  return {
11
15
  // this array can be big. not sure about prefering spread operator here
@@ -0,0 +1,26 @@
1
+ import type { ErrorsAtom } from '../atoms/index.js'
2
+
3
+ export interface ErrorTrackingModule {
4
+ /**
5
+ * Track an error
6
+ * @example
7
+ * ```typescript
8
+ * errorTracking.track({
9
+ * namespace: 'balances',
10
+ * error: new Error('Encountered an issue when computing total balances'),
11
+ * context: {},
12
+ * })
13
+ * ```
14
+ */
15
+ track(params: { error: Error; namespace: string; context?: any }): Promise<void>
16
+ }
17
+
18
+ declare const errorTrackingModuleDefinition: {
19
+ id: 'errorTracking'
20
+ type: 'module'
21
+ factory({ config, errorsAtom }: { config: { maxErrorsCount: number }; errorsAtom: ErrorsAtom }): {
22
+ errors: ErrorTrackingModule
23
+ }
24
+ }
25
+
26
+ export default errorTrackingModuleDefinition
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/error-tracking",
3
- "version": "1.5.0",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "description": "A simple error tracking package to let any feature collect errors and create the report",
6
6
  "author": "Exodus Movement, Inc.",
@@ -33,13 +33,15 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@exodus/atoms": "^9.0.0",
36
+ "@exodus/basic-utils": "^3.0.1",
36
37
  "@exodus/errors": "^2.0.1",
37
38
  "@exodus/fetch": "^1.3.1",
38
39
  "@exodus/sentry-client": "^4.0.0",
39
- "@exodus/typeforce": "^1.19.0"
40
+ "@exodus/typeforce": "^1.19.0",
41
+ "@exodus/zod": "^3.24.2"
40
42
  },
41
43
  "publishConfig": {
42
44
  "access": "public"
43
45
  },
44
- "gitHead": "b85ce886087a09896bff3f9a619a7d99ff705667"
46
+ "gitHead": "d76155ed627a340ea60a910b77a250967f5a692b"
45
47
  }
package/report/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { SafeError } from '@exodus/errors'
2
+ import { memoize } from '@exodus/basic-utils'
3
+ import { z } from '@exodus/zod'
2
4
 
3
5
  const errorTrackingReportDefinition = {
4
6
  type: 'report',
@@ -15,6 +17,21 @@ const errorTrackingReportDefinition = {
15
17
  })),
16
18
  }
17
19
  },
20
+ getSchema: memoize(() =>
21
+ z
22
+ .object({
23
+ errors: z.array(
24
+ z
25
+ .object({
26
+ namespace: z.string(),
27
+ error: z.instanceof(SafeError),
28
+ time: z.number(),
29
+ })
30
+ .strict()
31
+ ),
32
+ })
33
+ .strict()
34
+ ),
18
35
  }),
19
36
  dependencies: ['errorsAtom'],
20
37
  public: true,