@exodus/error-tracking 1.1.3 → 1.2.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 +10 -0
- package/api/index.js +24 -8
- package/index.js +40 -26
- package/module/create-error-tracking.js +1 -10
- package/package.json +2 -2
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
|
+
## [1.2.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/error-tracking@1.2.0...@exodus/error-tracking@1.2.1) (2024-08-13)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @exodus/error-tracking
|
|
9
|
+
|
|
10
|
+
## [1.2.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/error-tracking@1.1.3...@exodus/error-tracking@1.2.0) (2024-08-08)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- **error-tracking:** add remote error tracking api node ([#8169](https://github.com/ExodusMovement/exodus-hydra/issues/8169)) ([5a2d702](https://github.com/ExodusMovement/exodus-hydra/commit/5a2d702126d81bfb934c2598b732e62d23370f03))
|
|
15
|
+
|
|
6
16
|
## [1.1.3](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/error-tracking@1.1.2...@exodus/error-tracking@1.1.3) (2024-07-25)
|
|
7
17
|
|
|
8
18
|
### Bug Fixes
|
package/api/index.js
CHANGED
|
@@ -1,22 +1,38 @@
|
|
|
1
1
|
import { createErrorTracking } from '../module/create-error-tracking.js'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
// just its factory function. However, the issue is that adding errorTracking as a dependency to this API node
|
|
5
|
-
// will cause the error-tracking-preprocessor to change the track function definition, which is not what we require here.
|
|
6
|
-
|
|
7
|
-
const errorTrackingApiDefinition = {
|
|
3
|
+
export const errorTrackingApiDefinition = {
|
|
8
4
|
id: 'errorTrackingApi',
|
|
9
5
|
type: 'api',
|
|
10
|
-
factory: ({ errorsAtom, config }) => {
|
|
6
|
+
factory: ({ errorsAtom, config, logger, remoteErrorTracking }) => {
|
|
11
7
|
const { track } = createErrorTracking({ errorsAtom, config })
|
|
12
8
|
|
|
9
|
+
let trackRemote
|
|
10
|
+
if (remoteErrorTracking) {
|
|
11
|
+
trackRemote = async ({ error }) => {
|
|
12
|
+
try {
|
|
13
|
+
await remoteErrorTracking.captureError({
|
|
14
|
+
error,
|
|
15
|
+
})
|
|
16
|
+
} catch (err) {
|
|
17
|
+
logger.error('failed to remote track error', err)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
trackRemote = async ({ error }) => {
|
|
22
|
+
logger.debug('remote error tracking is disabled', error)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
13
26
|
return {
|
|
14
27
|
errors: {
|
|
15
28
|
track,
|
|
29
|
+
trackRemote,
|
|
16
30
|
},
|
|
17
31
|
}
|
|
18
32
|
},
|
|
19
|
-
dependencies: ['config', 'errorsAtom'],
|
|
33
|
+
dependencies: ['config', 'errorsAtom', 'logger', 'remoteErrorTracking?'],
|
|
20
34
|
}
|
|
21
35
|
|
|
22
|
-
|
|
36
|
+
// Implementation Note: It would have made more sense to add the `errorTracking` module as a dependency instead of
|
|
37
|
+
// just its factory function. However, the issue is that adding errorTracking as a dependency to this API node
|
|
38
|
+
// will cause the error-tracking-preprocessor to change the track function definition, which is not what we require here.
|
package/index.js
CHANGED
|
@@ -1,33 +1,47 @@
|
|
|
1
|
-
import
|
|
1
|
+
import typeforce from '@exodus/typeforce'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { isEmpty } from './is-empty.js'
|
|
4
|
+
import { errorTrackingApiDefinition } from './api/index.js'
|
|
4
5
|
import errorTrackingAtomDefinition from './atoms/index.js'
|
|
5
6
|
import errorTrackingReportDefinition from './report/index.js'
|
|
6
7
|
import { errorTrackingDefinition, remoteErrorTrackingDefinition } from './module/index.js'
|
|
7
8
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
9
|
+
const defaultConfig = { maxErrorsCount: 100 }
|
|
10
|
+
|
|
11
|
+
const configSchema = {
|
|
12
|
+
maxErrorsCount: (value) => typeof value === 'number' && value > 0 && value <= 9999,
|
|
13
|
+
sentryConfig: '?Object',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const errorTracking = (config = Object.create(null)) => {
|
|
17
|
+
config = { ...defaultConfig, ...config }
|
|
18
|
+
|
|
19
|
+
const { maxErrorsCount, sentryConfig } = typeforce.parse(configSchema, config)
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
id: 'errorTracking',
|
|
23
|
+
definitions: [
|
|
24
|
+
{
|
|
25
|
+
definition: errorTrackingAtomDefinition,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
definition: errorTrackingApiDefinition,
|
|
29
|
+
config: { maxErrorsCount },
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
definition: errorTrackingDefinition,
|
|
33
|
+
config: { maxErrorsCount },
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
if: sentryConfig !== undefined && sentryConfig !== null && !isEmpty(sentryConfig),
|
|
37
|
+
definition: remoteErrorTrackingDefinition,
|
|
38
|
+
config: sentryConfig,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
definition: errorTrackingReportDefinition,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
}
|
|
45
|
+
}
|
|
32
46
|
|
|
33
47
|
export default errorTracking
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import typeforce from '@exodus/typeforce'
|
|
2
|
-
|
|
3
1
|
export const createErrorTracking = ({ errorsAtom, config }) => {
|
|
4
|
-
const { maxErrorsCount } = typeforce.parse(
|
|
5
|
-
{
|
|
6
|
-
maxErrorsCount: (value) => typeof value === 'number' && value > 0 && value <= 9999,
|
|
7
|
-
},
|
|
8
|
-
config
|
|
9
|
-
)
|
|
10
|
-
|
|
11
2
|
const track = async ({ error, context, namespace }) => {
|
|
12
3
|
if (!namespace) {
|
|
13
4
|
throw new Error('no namespace provided')
|
|
@@ -21,7 +12,7 @@ export const createErrorTracking = ({ errorsAtom, config }) => {
|
|
|
21
12
|
errors: [{ namespace, error, context, time: Date.now() }]
|
|
22
13
|
// eslint-disable-next-line unicorn/prefer-spread
|
|
23
14
|
.concat(errors)
|
|
24
|
-
.slice(0, maxErrorsCount),
|
|
15
|
+
.slice(0, config.maxErrorsCount),
|
|
25
16
|
}
|
|
26
17
|
})
|
|
27
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/error-tracking",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.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.",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"@exodus/sentry-client": "^3.2.0",
|
|
39
39
|
"@exodus/typeforce": "^1.19.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "a667333565279122a2fc2da437dcb62f4ca864bb"
|
|
42
42
|
}
|