Official Sentry SDK for Node

Installation
npm install @sentry/node
yarn add @sentry/node
Usage
Sentry should be initialized as early in your app as possible. It is essential that you call Sentry.init before you
require any other modules in your application, otherwise auto-instrumentation of these modules will not work.
You need to create a file named instrument.js that imports and initializes Sentry:
const Sentry = require('@sentry/node');
import * as Sentry from '@sentry/node';
Sentry.init({
dsn: '__DSN__',
});
You need to require or import the instrument.js file before importing any other modules in your application. This is
necessary to ensure that Sentry can automatically instrument all modules in your application:
import './instrument';
import http from 'http';
ESM Support
When running your application in ESM mode, you should use the Node.js
--import command line option to ensure that Sentry is loaded before
the application code is evaluated.
Adjust the Node.js call for your application to use the --import parameter and point it at instrument.js, which
contains your Sentry.init() code:
node --import ./instrument.mjs app.mjs
If it is not possible for you to pass the --import flag to the Node.js binary, you can alternatively use the
NODE_OPTIONS environment variable as follows:
NODE_OPTIONS="--import ./instrument.mjs" npm run start
Links
10.21.0
Important Changes
-
feat(browserProfiling): Add trace lifecycle mode for UI profiling (#17619)
Adds a new trace lifecycle mode for UI profiling, allowing profiles to be captured for the duration of a trace. A manual mode will be added in a future release.
-
feat(nuxt): Instrument Database (#17899)
Adds instrumentation for Nuxt database operations, enabling better performance tracking of database queries.
-
feat(nuxt): Instrument server cache API (#17886)
Adds instrumentation for Nuxt's server cache API, providing visibility into cache operations.
-
feat(nuxt): Instrument storage API (#17858)
Adds instrumentation for Nuxt's storage API, enabling tracking of storage operations.
Other Changes
- feat(browser): Add
onRequestSpanEnd hook to browser tracing integration (#17884)
- feat(nextjs): Support Next.js proxy files (#17926)
- feat(replay): Record outcome when event buffer size exceeded (#17946)
- fix(cloudflare): copy execution context in durable objects and handlers (#17786)
- fix(core): Fix and add missing cache attributes in Vercel AI (#17982)
- fix(core): Improve uuid performance (#17938)
- fix(ember): Use updated version for
clean-css (#17979)
- fix(nextjs): Don't set experimental instrumentation hook flag for next 16 (#17978)
- fix(nextjs): Inconsistent transaction naming for i18n routing (#17927)
- fix(nextjs): Update bundler detection (#17976)
<details>
<summary> <strong>Internal Changes</strong> </summary>
- build: Update to typescript 5.8.0 (#17710)
- chore: Add external contributor to CHANGELOG.md (#17949)
- chore(build): Upgrade nodemon to 3.1.10 (#17956)
- chore(ci): Fix external contributor action when multiple contributions existed (#17950)
- chore(solid): Remove unnecessary import from README (#17947)
- test(nextjs): Fix proxy/middleware test (#17970)
</details>
Work in this release was contributed by @0xbad0c0d3. Thank you for your contribution!