npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@toss/sentry

v1.1.0

Published

브라우저와 Node.js 모두에서 사용할 수 있는 Sentry 모듈입니다.

Downloads

37

Readme

@toss/sentry

브라우저와 Node.js 모두에서 사용할 수 있는 Sentry 모듈입니다.

사용 방법

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

Sentry.init(...);
Sentry.captureException(...);
  • 일반 React 앱: @toss/sentry 를 사용하세요.
  • Next.js 앱: @toss/sentry/nextjs를 사용하세요.

패키지의 목적

일반적으로 @sentry/node는 Node.js 서버를 위해 만들어져 있어서, 각종 Node.js API를 사용합니다. 반대로 @sentry/browser는 브라우저를 위해 만들어져 있어서, 각종 브라우저 API를 사용합니다.

제공하는 API의 모습은 같아도 내부 구현이 다르기 때문에, 각 플랫폼에 맞는 패키지를 사용해야 합니다.

@toss/sentryImport conditions를 이용하여 서버에서 사용하는 경우 서버용 @sentry/node, 브라우저에서 사용하는 경우 브라우저용 @sentry/browser 를 반환합니다. 그래서 import를 분기하지 않고도 쉽게 플랫폼에 맞는 Sentry를 사용할 수 있습니다.

추가 최적화: 브라우저의 경우

@toss/sentry를 브라우저에서 사용하는 경우 Sentry의 Lazy-loading 기능에 의존합니다.

Lazy loading 스크립트가 없는 곳에서 @toss/sentry 를 사용하게 되면 에러가 발생하므로, 반드시 스크립트를 추가해주시기 바랍니다.

테스트하기

@toss/sentry/testing 모듈로 테스트할 수 있습니다.

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);
    });
  });
});