@exodus/error-tracking 3.2.0 → 3.3.1

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,16 @@
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
+ ## [3.3.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/error-tracking@3.3.0...@exodus/error-tracking@3.3.1) (2026-02-10)
7
+
8
+ **Note:** Version bump only for package @exodus/error-tracking
9
+
10
+ ## [3.3.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/error-tracking@3.2.0...@exodus/error-tracking@3.3.0) (2025-11-20)
11
+
12
+ ### Features
13
+
14
+ - feat: allow exporting `traceId` in errors context (#14099)
15
+
6
16
  ## [3.2.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/error-tracking@3.1.2...@exodus/error-tracking@3.2.0) (2025-10-14)
7
17
 
8
18
  ### Features
package/README.md CHANGED
@@ -16,20 +16,46 @@ This feature is designed to be used together with `@exodus/headless`. See [using
16
16
 
17
17
  1. Open the playground https://exodus-hydra.pages.dev/features/errors
18
18
  2. Try out the some methods via the UI. These corresponds 1:1 with the `exodus.errors` API.
19
- 3. Run `await exodus.errors.track({ namespace: 'balances', error: 'Encountered an issue when computing total balances', context: {} })` in the Dev Tools Console.
19
+ 3. Run in the Dev Tools Console:
20
+
21
+ ```ts
22
+ await exodus.errors.track({
23
+ namespace: safeString`balances`,
24
+ error: new Error('Encountered an issue when computing total balances'),
25
+ context: {},
26
+ })
27
+ ```
20
28
 
21
29
  ### API Side
22
30
 
23
31
  See [using the sdk](../../docs/development/using-the-sdk.md#setup-the-api-side) for more details on how features plug into the SDK and the API interface in the [type declaration](./api/index.d.ts).
24
32
 
25
33
  ```ts
34
+ import { safeString } from '@exodus/safe-string'
26
35
  import type { SafeContextType } from '@exodus/errors'
27
36
 
28
37
  // Track error with optional context (see SafeContextType for available properties).
29
38
  const context: SafeContextType = {
30
39
  /* ... */
31
40
  }
32
- await exodus.errors.track({ namespace: 'wallet', error, context })
41
+ await exodus.errors.track({ namespace: safeString`wallet`, error, context })
42
+ ```
43
+
44
+ **Important:** The `namespace` parameter must be a SafeString to prevent dynamic values from being used. Use the `safeString` template tag from `@exodus/safe-string`:
45
+
46
+ ```ts
47
+ // ✅ Correct - safe string namespace
48
+ await exodus.errors.track({
49
+ namespace: safeString`balances`,
50
+ error: new Error('Failed to compute balances'),
51
+ })
52
+
53
+ // ❌ Incorrect - plain strings not allowed
54
+ const NAMESPACE = 'my-namespace'
55
+ await exodus.errors.track({
56
+ namespace: NAMESPACE,
57
+ error: new Error('Some error'),
58
+ })
33
59
  ```
34
60
 
35
61
  If you're building a feature and like to use error tracking inside that feature, you can depend on `errorTracking` and will receive the module with a track method that is auto-namespaced to your feature id.
package/api/index.d.ts CHANGED
@@ -1,16 +1,20 @@
1
+ import type { SafeString } from '@exodus/safe-string'
2
+
1
3
  export interface ErrorTrackingApi {
2
4
  /**
3
5
  * Track an error
4
6
  * @example
5
7
  * ```typescript
8
+ * import { safeString } from '@exodus/safe-string'
9
+ *
6
10
  * exodus.errors.track({
7
- * namespace: 'balances',
11
+ * namespace: safeString`balances`,
8
12
  * error: new Error('Encountered an issue when computing total balances'),
9
13
  * context: {},
10
14
  * })
11
15
  * ```
12
16
  */
13
- track(params: { error: Error; namespace: string; context?: any }): Promise<void>
17
+ track(params: { error: Error; namespace: SafeString; context?: any }): Promise<void>
14
18
  }
15
19
 
16
20
  declare const errorTrackingApiDefinition: {
@@ -1,3 +1,5 @@
1
+ import { isSafe } from '@exodus/safe-string'
2
+
1
3
  const MODULE_ID = 'errorTracking'
2
4
 
3
5
  const createErrorTracking = ({
@@ -16,7 +18,15 @@ const createErrorTracking = ({
16
18
  logger.error(error)
17
19
 
18
20
  if (namespace !== undefined && typeof namespace !== 'string') {
19
- return onError(new Error('namespace must be a string'))
21
+ return onError(new TypeError('namespace must be a string'))
22
+ }
23
+
24
+ if (namespace !== undefined && !isSafe(namespace)) {
25
+ return onError(
26
+ new TypeError(
27
+ 'namespace must be a safe string. Use safeString`your-namespace` from @exodus/safe-string'
28
+ )
29
+ )
20
30
  }
21
31
 
22
32
  if (!(error instanceof Error)) {
package/module/index.d.ts CHANGED
@@ -1,19 +1,22 @@
1
1
  import type { ErrorsAtom } from '../atoms/index.js'
2
2
  import type { SafeContextType } from '@exodus/errors'
3
+ import type { SafeString } from '@exodus/safe-string'
3
4
 
4
5
  export interface ErrorTrackingModule {
5
6
  /**
6
7
  * Track an error
7
8
  * @example
8
9
  * ```typescript
10
+ * import { safeString } from '@exodus/safe-string'
11
+ *
9
12
  * errorTracking.track({
10
- * namespace: 'balances',
13
+ * namespace: safeString`balances`,
11
14
  * error: new Error('Encountered an issue when computing total balances'),
12
15
  * context: {},
13
16
  * })
14
17
  * ```
15
18
  */
16
- track(params: { error: Error; namespace: string; context?: SafeContextType }): Promise<void>
19
+ track(params: { error: Error; namespace: SafeString; context?: SafeContextType }): Promise<void>
17
20
  }
18
21
 
19
22
  declare const errorTrackingModuleDefinition: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/error-tracking",
3
- "version": "3.2.0",
3
+ "version": "3.3.1",
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.",
@@ -35,6 +35,7 @@
35
35
  "@exodus/atoms": "^9.0.0",
36
36
  "@exodus/basic-utils": "^3.0.1",
37
37
  "@exodus/errors": "^3.4.0",
38
+ "@exodus/safe-string": "^1.2.1",
38
39
  "@exodus/sentry-client": "^6.2.0",
39
40
  "@exodus/typeforce": "^1.19.0",
40
41
  "@exodus/zod": "^3.24.2"
@@ -43,5 +44,5 @@
43
44
  "access": "public",
44
45
  "provenance": false
45
46
  },
46
- "gitHead": "1c7823e1ee4d02280aff05d67169e915ed7909ca"
47
+ "gitHead": "526b4891a8940214343e20e27ff694937c01aad3"
47
48
  }
package/report/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { SafeError } from '@exodus/errors'
1
+ import { SafeError, SafeContext } from '@exodus/errors'
2
2
  import { memoize } from '@exodus/basic-utils'
3
3
  import { z } from '@exodus/zod'
4
4
 
@@ -14,6 +14,7 @@ const errorTrackingReportDefinition = {
14
14
  namespace,
15
15
  error: SafeError.from(error),
16
16
  time,
17
+ context,
17
18
  })),
18
19
  }
19
20
  },
@@ -26,6 +27,7 @@ const errorTrackingReportDefinition = {
26
27
  namespace: z.string(),
27
28
  error: z.instanceof(SafeError),
28
29
  time: z.number(),
30
+ context: SafeContext.getSchema(),
29
31
  })
30
32
  .strict()
31
33
  ),