A simple error tracking package to let any feature collect errors and create the report
npm install @exodus/error-trackingA simple namespaces error tracking package to let any feature collect errors and create the report
``sh`
yarn add @exodus/error-tracking
This feature is designed to be used together with @exodus/headless. See using the sdk.
1. Open the playground https://exodus-hydra.pages.dev/features/errors
2. Try out the some methods via the UI. These corresponds 1:1 with the exodus.errors API.
3. Run in the Dev Tools Console:
`tsbalances
await exodus.errors.track({
namespace: safeString,`
error: new Error('Encountered an issue when computing total balances'),
context: {},
})
See using the sdk for more details on how features plug into the SDK and the API interface in the type declaration.
`ts
import { safeString } from '@exodus/safe-string'
import type { SafeContextType } from '@exodus/errors'
// Track error with optional context (see SafeContextType for available properties).
const context: SafeContextType = {
/ ... /
}
await exodus.errors.track({ namespace: safeStringwallet, error, context })`
Important: The namespace parameter must be a SafeString to prevent dynamic values from being used. Use the safeString template tag from @exodus/safe-string:
`tsbalances
// ✅ Correct - safe string namespace
await exodus.errors.track({
namespace: safeString,
error: new Error('Failed to compute balances'),
})
// ❌ Incorrect - plain strings not allowed
const NAMESPACE = 'my-namespace'
await exodus.errors.track({
namespace: NAMESPACE,
error: new Error('Some error'),
})
`
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.