Migrate to @logdash/node

The @logdash/node package replaces @logdash/js-sdk and puts logging and metrics behind one class. Here is everything that changed, and a prompt that does the work for you.

What changed

Aspect@logdash/js-sdk@logdash/node
Package@logdash/js-sdk@logdash/node
Importimport { createLogDash } from '@logdash/js-sdk'import { Logdash } from '@logdash/node'
Initializationconst { logger, metrics } = createLogDash({ apiKey: '...' })const logdash = new Logdash('...')
Logginglogger.info() / logger.error() / logger.warn()logdash.info() / logdash.error() / logdash.warn()
Set Metricmetrics.set('users', 0)logdash.setMetric('users', 0)
Mutate Metricmetrics.mutate('users', 1)logdash.mutateMetric('users', 1)

New in @logdash/node

Namespaced Logging Create scoped loggers for different parts of your application.
const authLogdash = logdash.withNamespace('auth');
authLogdash.info('User logged in');
Graceful Shutdown Ensure all logs and metrics are sent before your application exits.
await logdash.flush();

Migrate with AI

Copy the prompt into Claude, ChatGPT or Cursor and let it rewrite the imports and calls across your codebase.

Migration prompt
Migrate my codebase from @logdash/js-sdk to @logdash/node. Apply these changes:

docs: @https://raw.githubusercontent.com/logdash-io/node-sdk/refs/heads/main/README.md

1. Replace package: Change `@logdash/js-sdk` to `@logdash/node`
2. Replace import: Change `import { createLogDash } from '@logdash/js-sdk'` to `import { Logdash } from '@logdash/node'`
3. Replace initialization: Change `const { logger, metrics } = createLogDash({ apiKey: '...' })` to `const logdash = new Logdash('...')`
4. Replace logger calls: Change `logger.info/error/warn/debug()` to `logdash.info/error/warn/debug()`
5. Replace metrics calls: Change `metrics.set()` to `logdash.setMetric()` and `metrics.mutate()` to `logdash.mutateMetric()`
6. On program exit, call `logdash.flush()` to ensure all logs and metrics are sent.
7. Utilize namespaces to organize logs by domain: Create scoped loggers using `const authLogdash = logdash.withNamespace('auth')` for different parts of your application (e.g., 'auth', 'payments', 'api'). Use these namespaced instances for logging within their respective modules.
namespaces should be plural, so e.g. log -> logs, metrics -> metrics, etc. but e.g. auth -> auth.

Keep the same API key values. The new SDK uses a class-based API where logging and metrics are methods on the same Logdash instance.