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.15.0
Important Changes
-
feat(cloudflare): Add honoIntegration with error-filtering function (#17743)
This release adds a honoIntegration to @sentry/cloudflare, which exposes a shouldHandleError function that lets you define which errors in onError should be captured.
By default, Sentry captures exceptions with error.status >= 500 || error.status <= 299.
The integration is added by default, and it's possible to modify this behavior like this:
integrations: [
honoIntegration({
shouldHandleError: (err) => true; // always capture exceptions in onError
})
]
-
feat(node): Add instrumentation for hono handler (#17428)
This PR enhances the Hono integration by adding comprehensive handler instrumentation, error handling capabilities.
This PR adds a feature to the browser SDKs only: Making an inactive span active. We do this to enable use cases where having a span only being active in the callback is not practical.
Other Changes
- fix(browser): Improve handling of
0 and undefined resource timing values (#17751)
- ref(nextjs): Display build compatibility warning for webpack (#17746)
<details>
<summary> <strong>Internal Changes</strong> </summary>
- docs: Reword changelog for google gen ai instrumentation (#17753)
- build: Add
@typescript-eslint/no-unnecessary-type-assertion rule (#17728)
- build: Update TS target to
es2020 everywhere (#17709)
- chore: Add external contributor to CHANGELOG.md (#17745)
</details>
Work in this release was contributed by @Karibash. Thank you for your contribution!