@exodus/error-tracking 1.2.0 → 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 CHANGED
@@ -3,6 +3,10 @@
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
+
6
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)
7
11
 
8
12
  ### Features
package/index.js CHANGED
@@ -1,34 +1,47 @@
1
- import { isEmpty } from './is-empty.js'
1
+ import typeforce from '@exodus/typeforce'
2
2
 
3
+ import { isEmpty } from './is-empty.js'
3
4
  import { errorTrackingApiDefinition } from './api/index.js'
4
-
5
5
  import errorTrackingAtomDefinition from './atoms/index.js'
6
6
  import errorTrackingReportDefinition from './report/index.js'
7
7
  import { errorTrackingDefinition, remoteErrorTrackingDefinition } from './module/index.js'
8
8
 
9
- const errorTracking = ({ maxErrorsCount = 100, sentryConfig } = Object.create(null)) => ({
10
- id: 'errorTracking',
11
- definitions: [
12
- {
13
- definition: errorTrackingAtomDefinition,
14
- },
15
- {
16
- definition: errorTrackingApiDefinition,
17
- config: { maxErrorsCount },
18
- },
19
- {
20
- definition: errorTrackingDefinition,
21
- config: { maxErrorsCount },
22
- },
23
- {
24
- if: sentryConfig !== undefined && sentryConfig !== null && !isEmpty(sentryConfig),
25
- definition: remoteErrorTrackingDefinition,
26
- config: sentryConfig,
27
- },
28
- {
29
- definition: errorTrackingReportDefinition,
30
- },
31
- ],
32
- })
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
+ }
33
46
 
34
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.2.0",
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": "795fabca74101cee3be6c9a0581b327e9cc3293f"
41
+ "gitHead": "a667333565279122a2fc2da437dcb62f4ca864bb"
42
42
  }