Socket
Socket
Sign inDemoInstall

@sentry/node

Package Overview
Dependencies
103
Maintainers
11
Versions
496
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @sentry/node

Sentry Node SDK using OpenTelemetry for performance instrumentation


Version published
Weekly downloads
5.9M
increased by4.76%
Maintainers
11
Created
Weekly downloads
 

Package description

What is @sentry/node?

The @sentry/node package is a tool designed for real-time monitoring and fixing crashes in Node.js applications. It provides error tracking and performance monitoring, helping developers to quickly identify, diagnose, and fix problems in their applications. Sentry integrates seamlessly with your existing codebase, offering a range of features to enhance application reliability and user experience.

What are @sentry/node's main functionalities?

Error Tracking

Automatically capture exceptions and errors in your Node.js applications. The code initializes Sentry with your project's DSN and demonstrates how an uncaught exception is automatically reported to Sentry.

const Sentry = require('@sentry/node');
Sentry.init({ dsn: 'YOUR_DSN_HERE' });

app.get('/', function mainHandler(req, res) {
  throw new Error('Broke!');
});

Performance Monitoring

Track the performance of your application, including request times and slow operations. This code sample starts a transaction, simulates an operation with a timeout, and then finishes the transaction, which is then reported to Sentry for performance analysis.

const Sentry = require('@sentry/node');
const transaction = Sentry.startTransaction({ op: 'test', name: 'My First Test Transaction' });

setTimeout(() => {
  transaction.finish();
}, 99);

Custom Event Capturing

Send custom messages or events to Sentry. This is useful for capturing non-exception events that are significant for your application's health monitoring and diagnostics.

const Sentry = require('@sentry/node');

Sentry.captureMessage('Something went wrong', 'error');

Other packages similar to @sentry/node

Changelog

Source

8.0.0-alpha.5

This is the fifth alpha release of Sentry JavaScript SDK v8, which includes a variety of breaking changes.

Read the in-depth migration guide to find out how to address any breaking changes in your code.

Important Changes

  • feat(nextjs): Remove client.(server|client).config.ts functionality in favor of instrumentation.ts (#11059)
    • feat(nextjs): Bump minimum required Next.js version to 13.2.0 (#11097)

With version 8 of the SDK we will no longer support the use of sentry.server.config.ts and sentry.edge.config.ts files. Instead, please initialize the Sentry Next.js SDK for the serverside in a Next.js instrumentation hook. sentry.client.config.ts|js is still supported and encouraged for initializing the clientside SDK. Please see the Migration Guide for more details.

In addition, the Next.js SDK now requires a minimum Next.js version of 13.2.0.

  • feat(v8/angular): Merge angular and angular-ivy packages and start Angular support at v14 (#11091)

The @sentry/angular-ivy package has been removed. The @sentry/angular package now supports Ivy by default and requires at least Angular 14. See the Migration Guide for more details.

Removal/Refactoring of deprecated functionality

  • feat(aws-serverless): Remove deprecated rethrowAfterCapture option (#11126)
  • feat(node): Remove deprecated/duplicate/unused definitions (#11120)
  • feat(v8): Remove deprecated integration methods on client (#11134)
  • feat(v8/browser): Remove class export for linked errors (#11129)
  • feat(v8/browser): Remove deprecated wrap export (#11127)
  • feat(v8/core): Remove deprecated client.setupIntegrations method (#11179)
  • feat(v8/core): Remove deprecated integration classes (#11132)
  • feat(v8/ember): Remove InitSentryForEmber export (#11202)
  • feat(v8/nextjs): Remove usage of class integrations (#11182)
  • feat(v8/replay): Delete deprecated types (#11177)
  • feat(v8/utils): Remove deprecated util functions (#11143)
  • ref(node): Remove class based export for local variable integration (#11128)

Other Changes

  • feat(browser): Make fetch the default transport for offline (#11209)
  • feat(core): Filter out noisy GoogleTag error by default (#11208)
  • feat(deps): Bump @sentry/cli from 2.30.0 to 2.30.2 (#11168)
  • feat(nextjs): Prefix webpack plugin log messages with runtime (#11173)
  • feat(node-profiling): Output ESM and remove Sentry deps from output (#11135)
  • feat(node): Allow Anr worker to be stopped and restarted (#11214)
  • feat(node): Support tunnel option for ANR (#11163)
  • feat(opentelemetry): Do not capture exceptions for timed events (#11221)
  • feat(serverless): Add Node.js 20 to compatible runtimes (#11103)
  • feat(sveltekit): Switch to Otel-based @sentry/node package (#11075)
  • fix(attachments): Add missing view_hierarchy attachment type (#11197)
  • fix(build): Ensure tree shaking works properly for ESM output (#11122)
  • fix(feedback): Only allow screenshots in secure contexts (#11188)
  • fix(feedback): Reduce force layout in screenshots (#11181)
  • fix(feedback): Smoother cropping experience and better UI (#11165)
  • fix(feedback): Fix screenshot black bars in Safari (#11233)
  • fix(metrics): use correct statsd data category (#11184)
  • fix(metrics): use web-vitals ttfb calculation (#11185)
  • fix(node): Export initOpenTelemetry (#11158)
  • fix(node): Clear ANR timer on stop (#11229)
  • fix(node): Time zone handling for cron (#11225)
  • fix(node): Use unique variable for ANR context transfer (#11161)
  • fix(opentelemetry): Do not stomp span error status (#11169)
  • fix(types): Fix incorrect sampled type on Transaction (#11115)

Readme

Source

Sentry

Official Sentry SDK for Node

npm version npm dm npm dt

Installation

npm install @sentry/node

# Or yarn
yarn add @sentry/node

Usage

// CJS Syntax
const Sentry = require('@sentry/node');
// ESM Syntax
import * as Sentry from '@sentry/node';

Sentry.init({
  dsn: '__DSN__',
  // ...
});

Note that it is necessary to initialize Sentry before you import any package that may be instrumented by us.

More information on how to set up Sentry for Node in v8.

ESM Support

Due to the way OpenTelemetry handles instrumentation, this only works out of the box for CommonJS (require) applications.

There is experimental support for running OpenTelemetry with ESM ("type": "module"):

node --experimental-loader=@opentelemetry/instrumentation/hook.mjs ./app.js

You'll need to install @opentelemetry/instrumentation in your app to ensure this works.

See OpenTelemetry Instrumentation Docs for details on this - but note that this is a) experimental, and b) does not work with all integrations.

FAQs

Last updated on 22 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc