0.0.2 • Published 1 month ago

umi-plugin-sentry-react v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 month ago

umi-plugin-sentry-react

umi项目接入监控快捷配置,支持umi3.x和umi4.x

Install

pnpm i umi-plugin-sentry-react

Usage

配置.umirc.ts, 启用插件

export default {
  plugins: [
    ['umi-plugin-sentry-react'],
  ],
  sentry: {
    sourceMap: { ... }
  }
}

Options

sourceMap: 同@sentry/webpack-plugin

配置sourceMap且环境为production时启用sourcemap上传

Initialize

src目录下创建app.js文件,并导出getSentryInitConfig用于初始化sentry

export function getSentryInitConfig() {
  return {
    dsn: 'your-dsn',
    integrations: [
      // 根据自己项目使用的router版本选择对应的integration
      Sentry.reactRouterV6BrowserTracingIntegration({
        useEffect: React.useEffect,
        useLocation,
        useNavigationType,
        createRoutesFromChildren,
        matchRoutes
      }),
      Sentry.browserTracingIntegration(),
      Sentry.replayIntegration({
        maskAllText: false,
        blockAllMedia: false,
      }),
      rewriteFramesIntegration()
    ],
    // Performance Monitoring
    tracesSampleRate: 1.0, //  Capture 100% of the transactions
    // Session Replay
    replaysSessionSampleRate: 1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
    replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
  }
}

LICENSE

MIT

0.0.2

1 month ago

0.0.1

1 month ago