@ruqimobility/sentry

1.0.1 • Public • Published

@ruqimobility/sentry

使用

1. 安装

npm install --save @ruqimobility/sentry

yarn add @ruqimobility/sentry

2. 初始化

import { initSentry } from '@ruqimobility/sentry'

const isProd = import.meta.env.VITE_NODE_ENV === 'prod';

if (isProd) {
  initSentry({
    app,
    dsn: import.meta.VITE_SENTRY_DSN,
    environment: import.meta.env.VITE_NODE_ENV,
    router
  });
}

参数说明

app (App):createApp(App) dsn (string):sentry 密钥 router(Router):项目路由 environment (string):运行环境

3. sourcemap 上传

import { defineConfig, loadEnv } from 'vite';
import { sentryVitePlugin } from '@sentry/vite-plugin';

// https://vitejs.dev/config/
export default defineConfig(({ command, mode, ssrBuild }) => {
  const env = loadEnv(mode, process.cwd());
  console.log('env', env);
  return {
    plugins: [
      VitePluginClean({
        targetFiles: ['../dist/main-new']
      }),
      sentryVitePlugin({
        url: env.VITE_SENTRY_URL,
        org: 'sentry',
        project: 'main-new',
        authToken: env.VITE_SENTRY_AUTHTOKEN,
        release: {
          name: version,
          uploadLegacySourcemaps: {
            paths: ['../dist/main-new/'],
            urlPrefix: '~/'
          }
        },
        sourcemaps: {
          assets: '../dist/main-new/assets/**',
          ignore: ['node_modules']
        }
      })
    ],
  };
});

Readme

Keywords

Package Sidebar

Install

npm i @ruqimobility/sentry

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

3.52 kB

Total Files

3

Last publish

Collaborators

  • huangqx666
  • liangfei
  • ruqimobile