@exodus/error-tracking 3.1.2 → 3.3.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 +12 -0
- package/README.md +34 -3
- package/api/index.d.ts +6 -2
- package/module/error-tracking.js +12 -3
- package/module/index.d.ts +6 -2
- package/module/remote-error-tracking.js +3 -6
- package/package.json +7 -6
- package/report/index.js +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/error-tracking@3.2.0...@exodus/error-tracking@3.3.0) (2025-11-20)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- feat: allow exporting `traceId` in errors context (#14099)
|
|
11
|
+
|
|
12
|
+
## [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)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- feat: support capturing error context (#13933)
|
|
17
|
+
|
|
6
18
|
## [3.1.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/error-tracking@3.1.1...@exodus/error-tracking@3.1.2) (2025-09-09)
|
|
7
19
|
|
|
8
20
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -16,15 +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
|
|
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
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
import { safeString } from '@exodus/safe-string'
|
|
35
|
+
import type { SafeContextType } from '@exodus/errors'
|
|
36
|
+
|
|
37
|
+
// Track error with optional context (see SafeContextType for available properties).
|
|
38
|
+
const context: SafeContextType = {
|
|
39
|
+
/* ... */
|
|
40
|
+
}
|
|
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
|
+
})
|
|
28
59
|
```
|
|
29
60
|
|
|
30
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:
|
|
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:
|
|
17
|
+
track(params: { error: Error; namespace: SafeString; context?: any }): Promise<void>
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
declare const errorTrackingApiDefinition: {
|
package/module/error-tracking.js
CHANGED
|
@@ -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,14 +18,21 @@ const createErrorTracking = ({
|
|
|
16
18
|
logger.error(error)
|
|
17
19
|
|
|
18
20
|
if (namespace !== undefined && typeof namespace !== 'string') {
|
|
19
|
-
return onError(new
|
|
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)) {
|
|
23
33
|
return onError(new TypeError('error must be an instance of Error'))
|
|
24
34
|
}
|
|
25
35
|
|
|
26
|
-
// TODO: figure out what to do with `context`
|
|
27
36
|
// TODO: eventually kill this and only track remote
|
|
28
37
|
const localPromise = errorsAtom.set(({ errors }) => {
|
|
29
38
|
return {
|
|
@@ -39,7 +48,7 @@ const createErrorTracking = ({
|
|
|
39
48
|
const remotePromise = remoteErrorTracking
|
|
40
49
|
? remoteErrorTrackingEnabledAtom
|
|
41
50
|
.get()
|
|
42
|
-
.then((enabled) => enabled && remoteErrorTracking.track({ error }))
|
|
51
|
+
.then((enabled) => enabled && remoteErrorTracking.track({ error, context }))
|
|
43
52
|
: Promise.resolve()
|
|
44
53
|
|
|
45
54
|
let timeoutId
|
package/module/index.d.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import type { ErrorsAtom } from '../atoms/index.js'
|
|
2
|
+
import type { SafeContextType } from '@exodus/errors'
|
|
3
|
+
import type { SafeString } from '@exodus/safe-string'
|
|
2
4
|
|
|
3
5
|
export interface ErrorTrackingModule {
|
|
4
6
|
/**
|
|
5
7
|
* Track an error
|
|
6
8
|
* @example
|
|
7
9
|
* ```typescript
|
|
10
|
+
* import { safeString } from '@exodus/safe-string'
|
|
11
|
+
*
|
|
8
12
|
* errorTracking.track({
|
|
9
|
-
* namespace:
|
|
13
|
+
* namespace: safeString`balances`,
|
|
10
14
|
* error: new Error('Encountered an issue when computing total balances'),
|
|
11
15
|
* context: {},
|
|
12
16
|
* })
|
|
13
17
|
* ```
|
|
14
18
|
*/
|
|
15
|
-
track(params: { error: Error; namespace:
|
|
19
|
+
track(params: { error: Error; namespace: SafeString; context?: SafeContextType }): Promise<void>
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
declare const errorTrackingModuleDefinition: {
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import createSentryClient from '@exodus/sentry-client'
|
|
2
|
-
import createFetchival from '@exodus/fetch/create-fetchival'
|
|
3
2
|
|
|
4
3
|
export const remoteErrorTrackingDefinition = {
|
|
5
4
|
id: 'remoteErrorTracking',
|
|
6
5
|
type: 'module',
|
|
7
|
-
factory: ({ config
|
|
8
|
-
const fetchival = createFetchival({ fetch })
|
|
6
|
+
factory: ({ config }) => {
|
|
9
7
|
const client = createSentryClient({
|
|
10
8
|
config,
|
|
11
|
-
fetchival,
|
|
12
9
|
})
|
|
13
10
|
|
|
14
11
|
return {
|
|
15
|
-
track: ({ error }) => client.captureError({ error }),
|
|
12
|
+
track: ({ error, context }) => client.captureError({ error, context }),
|
|
16
13
|
}
|
|
17
14
|
},
|
|
18
|
-
dependencies: ['config'
|
|
15
|
+
dependencies: ['config'],
|
|
19
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/error-tracking",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.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.",
|
|
@@ -34,14 +34,15 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@exodus/atoms": "^9.0.0",
|
|
36
36
|
"@exodus/basic-utils": "^3.0.1",
|
|
37
|
-
"@exodus/errors": "^3.
|
|
38
|
-
"@exodus/
|
|
39
|
-
"@exodus/sentry-client": "^6.
|
|
37
|
+
"@exodus/errors": "^3.4.0",
|
|
38
|
+
"@exodus/safe-string": "^1.2.1",
|
|
39
|
+
"@exodus/sentry-client": "^6.2.0",
|
|
40
40
|
"@exodus/typeforce": "^1.19.0",
|
|
41
41
|
"@exodus/zod": "^3.24.2"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
|
-
"access": "public"
|
|
44
|
+
"access": "public",
|
|
45
|
+
"provenance": false
|
|
45
46
|
},
|
|
46
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "9ed826a1dfe2f679a84361594d376a58e4b51cb3"
|
|
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
|
),
|