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

@yhy2001/sentry-plugin

v1.0.6

Published

Sentry 插件

Downloads

4

Readme

Sentry Plugin

这是一个为 JavaScript 应用集成 Sentry 错误跟踪系统的插件。它提供了简单的 API 来配置和使用 Sentry,支持链式调用和 Sentry 自带的所有方法。

安装

使用 npm 安装:

npm install @yhy2001/sentry-plugin

或者使用 yarn:

yarn add @yhy2001/sentry-plugin

快速开始

首先,您需要在 Sentry 上创建一个项目并获取您的 DSN。然后,在您的应用中初始化 Sentry Plugin:

import { SentryPlugin, VueIntegration } from '@yhy2001/sentry-plugin';
SentryPlugin.init({
  dsn: 'YOUR_SENTRY_DSN',
  // 其他 Sentry 配置
}, new VueIntegration());

配置

您可以通过 init 方法传入配置对象来配置 Sentry。以下是一些常用的配置项:

  • dsn: 您的 Sentry DSN。
  • environment: 设置应用的环境,如 'production' 或 'development'。
  • release: 指定应用的版本。

完整的配置选项请参考 Sentry 官方文档

使用

设置用户信息

SentryPlugin.setUser({
  id: 'user_id',
  email: '[email protected]',
  // 其他用户信息
});

添加标签

SentryPlugin.setTags({
  key: 'value',
  // 其他标签
});

添加额外信息

SentryPlugin.setExtras({
  key: 'value',
  // 其他额外信息
});

记录面包屑

SentryPlugin.addBreadcrumb({
  message: 'User clicked the button',
  // 其他面包屑信息
});

手动记录错误

SentryPlugin.captureException(new Error('This is an error'));

手动发送消息

SentryPlugin.captureMessage('Something happened', 'info');

错误级别

SentryPlugin.warn('This is an warn');
SentryPlugin.info('This is an info', {
  tags: {
    "tagOne": 'tag'
  },
  user: {
    id: 1
  }
});
SentryPlugin.error('This is an error');

链式调用

Sentry Plugin 支持链式调用,您可以轻松地在一行代码中设置多个配置:

SentryPlugin
  .setUser({ id: 'user_id' })
  .setTags({ key: 'value' })
  .addBreadcrumb({ message: 'Breadcrumb' })
  .captureMessage('Something happened');

调用 Sentry 原生方法

如果您需要调用 Sentry 的其他方法,可以使用 callSentryMethod

SentryPlugin.callSentryMethod('showReportDialog');

贡献

欢迎通过 Pull Requests 或 Issues 来贡献您的代码或反馈。

许可证

MIT