Socket
Socket
Sign inDemoInstall

@sentry/utils

Package Overview
Dependencies
1
Maintainers
11
Versions
472
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @sentry/utils

Utilities for all Sentry JavaScript SDKs


Version published
Weekly downloads
8.9M
decreased by-20.77%
Maintainers
11
Created
Weekly downloads
 

Package description

What is @sentry/utils?

The @sentry/utils package provides a collection of utility functions and classes that are used across the Sentry JavaScript SDK. These utilities help with various tasks such as data manipulation, browser and node environment checks, and integration with Sentry's error tracking and performance monitoring features.

What are @sentry/utils's main functionalities?

Data Manipulation

Provides utility functions for checking data types and manipulating data. For example, the `isString` function can be used to check if a variable is a string.

import { isString } from '@sentry/utils';

function logMessage(message) {
  if (isString(message)) {
    console.log(message);
  } else {
    console.log('Not a string');
  }
}

Environment Checks

Includes functions to check the current runtime environment, such as whether the code is running in a browser or Node.js environment. This is useful for writing isomorphic code that runs both on the client and server.

import { isNodeEnv } from '@sentry/utils';

if (isNodeEnv()) {
  console.log('Running in a Node environment');
} else {
  console.log('Not running in a Node environment');
}

Integration Helpers

Provides functions and classes to help integrate with Sentry, including adding global event processors that can modify or filter events before they are sent to Sentry.

import { addGlobalEventProcessor } from '@sentry/utils';

addGlobalEventProcessor(event => {
  // Modify the event object or return null to skip sending the event
  return event;
});

Other packages similar to @sentry/utils

Changelog

Source

7.88.0

Important Changes

  • feat(browser): Add browser metrics sdk (#9794)

The release adds alpha support for Sentry developer metrics in the Browser SDKs (@sentry/browser and related framework SDKs). Via the newly introduced APIs, you can now flush metrics directly to Sentry.

To enable capturing metrics, you first need to add the MetricsAggregator integration.

Sentry.init({
  dsn: '__DSN__',
  integrations: [new Sentry.metrics.MetricsAggregator()],
});

Then you'll be able to add counters, sets, distributions, and gauges under the Sentry.metrics namespace.

// Add 4 to a counter named `hits`
Sentry.metrics.increment('hits', 4);

// Add 2 to gauge named `parallel_requests`, tagged with `happy: "no"`
Sentry.metrics.gauge('parallel_requests', 2, { tags: { happy: 'no' } });

// Add 4.6 to a distribution named `response_time` with unit seconds
Sentry.metrics.distribution('response_time', 4.6, { unit: 'seconds' });

// Add 2 to a set named `valuable.ids`
Sentry.metrics.set('valuable.ids', 2);

In a future release we'll add support for server runtimes (Node, Deno, Bun, Vercel Edge, etc.)

  • feat(deno): Optionally instrument Deno.cron (#9808)

This releases add support for instrumenting Deno cron's with Sentry cron monitors. This requires v1.38 of Deno run with the --unstable flag and the usage of the DenoCron Sentry integration.

// Import from the Deno registry
import * as Sentry from 'https://deno.land/x/sentry/index.mjs';

Sentry.init({
  dsn: '__DSN__',
  integrations: [new Sentry.DenoCron()],
});

Other Changes

  • feat(replay): Bump rrweb to 2.6.0 (#9847)
  • fix(nextjs): Guard against injecting multiple times (#9807)
  • ref(remix): Bump Sentry CLI to ^2.23.0 (#9773)

Readme

Source

Sentry

Sentry JavaScript SDK Utilities

npm version npm dm npm dt

General

Common utilities used by the Sentry JavaScript SDKs.

Note: This package is only meant to be used internally, and as such is not part of our public API contract and does not follow semver.

FAQs

Last updated on 14 Dec 2023

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