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

sentry-sdk

v0.1.3

Published

An sentry sdk

Downloads

221

Readme

sentry-sdk

An sentry sdk

安装与使用

  1. npm 安装依赖
   npm install --save sentry-sdk
  1. .sentryclirc文件

项目根目录上添加.sentryclirc文件

[defaults]
url=http://xxxxxx:xxxx/ 
org=sentry
project=project

[auth]
token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

[upload]
sourcemapPath=./xxxxxx/js/

url: sentry部署地址
org: 管理设置项目所属组织
project: 管理台设置项目名称
token: {url}/settings/account/api/auth-tokens/ 下创建请求token sourcemapPath:项目打包js文件目录

  1. src/main.ts(main.js)入口文件
    import Vue from 'vue';
    import Report from 'sentry-sdk';
    Vue.use(Report, {
      // 用于source-map,匹配对应相应版本号 version 可设置package.json version对应
      release: '{version}', 
      dsn: 'http://xxxxxxxxx@{sentryt}:{port}/2', // 上传项目 url, 需要在sentry 管理台新建项目后获取
      allowUrls: [/www.baidu.com/i], // 可选项,如果设置,只有匹配到当期规则才会上传日志
      ... // 其他可以传入的配置项
    })

dsn: {url}/settings/{org}/projects/{project}/keys/

  1. 手动上传错误日志
   import Report from 'sentry-sdk';
   Report.log(new Error(), data); // 注意第一个错误必须继承Error

上传sourceMap

webpack配置自动上传

  1. webpack配置
   npm install --save-dev @sentry/webpack-plugin

   const SentryCliPlugin = require("@sentry/webpack-plugin")
   Plugins: [
      new SentryCliPlugin({
        release: '{version}', // 注意需要和Sentry 初始化时传入release对应
        include: './dist', // 作用文件夹,一般为项目打包文件夹 './dist'
        ignore: ['node_modules', 'vue.config.js'],
        urlPrefix: '~/' // 对应webpack publicPath配置
      })
   ] 
  1. 使用vue-cli 打包配置

注意配置文件设置** productionSourceMap: true **生成sourceMap, 然后上传后,注意删除sourceMap

   npm install --save-dev @sentry/webpack-plugin

   const SentryCliPlugin = require("@sentry/webpack-plugin");

   config.plugin('sentry').use(SentryCliPlugin, [{
      release: '{version}',  // package.js文件 version字段
      include: './dist', // 作用文件夹,一般为项目打包文件夹 './dist'
      ignore: ['node_modules', 'vue.config.js'],
      urlPrefix: '~/' // 对应webpack publicPath配置
   }]);

手动上传

  1. 首先安装sentry/cli
   npm install -g @sentry/cli
  1. 项目根目录下添加上传脚本

sentry-report.sh

#!/bin/bash

#export语句是将控制台语言环境设置为UTF-8格式,以免出现Podfile文件打开错误
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

if [ ! -f ".sentryclirc" ]; then

  echo "The need .sentryclirc file don't exit"

  sleep 3

  exit -1

fi

set -a && . ./.sentryclirc && set +a # 设置环境变量

which sentry-cli # 测试是否安装sentry-cli客户端

if [ $? -ne 0 ]; then

echo "sentry-cli don't install, please install sentry-cli"

sleep 3

exit -1

fi

echo "begining to upload-sourcemaps"

if [ -z "${version}" -a -f "package.json" ]; then

  version=$(cat package.json | grep 'version' | sed -e 's/[,"]//g' | awk '{print $2}')

fi

sentry-cli --auth-token ${token} \
      --url ${url} \
    releases files ${version} \
    upload-sourcemaps ./dist

echo "upload-sourcemaps success"

echo "beginin to clean sourcemaps"

find ${sourcemapPath} -name "*.map" -type f -print -exec rm -rf {} \;

echo "clean sourcemaps success"

sleep 3