New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@toss/sentry

Package Overview
Dependencies
Maintainers
5
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@toss/sentry

latest
Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
5
-82.76%
Maintainers
5
Weekly downloads
 
Created
Source

@toss/sentry

A Sentry module that can be used in both the browser and Node.js.

Usage

import { Sentry } from '@toss/sentry';

Sentry.init(...);
Sentry.captureException(...);
  • Normal React app: Use @toss/sentry.
  • Next.js app: Use @toss/sentry/nextjs.
Why do I need to distinguish between regular apps and Next.js apps?
  • On a normal server, `@sentry/node` will group errors by Node.js process, not by request. (You will need to manually use Sentry.Handlers.requestHandler)
  • When grouping server errors, `@sentry/nextjs` groups them by the request that came into Next.js.

Purpose of the package

Generally speaking, @sentry/node is created for Node.js servers and uses various Node.js APIs. In contrast, @sentry/browser is built for browsers and uses various browser APIs.

While the APIs look the same, the internal implementation is different, so you'll need to use the appropriate package for each platform.

Using Import conditions, @toss/sentry will return @sentry/node for the server if used on the server, or @sentry/browser for the browser if used on the browser. This makes it easy to use platform-specific Sentry without having to branch the import.

Additional optimizations: For browsers

When using @toss/sentry in a browser, it relies on Sentry's Lazy-loading feature.

If you use @toss/sentry where there is no lazy loading script, you will get an error, so be sure to add one.

Testing

You can test with the @toss/sentry/testing module.

import Sentry from '@toss/sentry';
import { useFakeSentry } from '@toss/sentry/testing';
import waitFor from 'wait-for-expect';

beforeAll(() => {
  useFakeSentry();
});

describe('Sentry는', () => {
  beforeEach(() => {
    Sentry.init({
      dsn: FAKE_DSN,
    });
  });

  it('captureException할 수 있다.', async () => {
    await Sentry.captureException(new Error('hello'));

    await waitFor(() => {
      expect(sentryServer.reports()).toHaveLength(1);
    });
  });
});

FAQs

Package last updated on 24 Oct 2024

Did you know?

Socket

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