天天看点

【sentry】sentry部署笔记

前言

  • 本篇记录部署时的过程,以及遇到的一些坑。

过程

  • 首先必须要有docker,怎么安装看以前文章。
  • 拉取仓库:
git clone https://github.com/getsentry/onpremise.git
cd onpremise
           
  • 执行脚本:
./install.sh
           
  • 此时可能会说没有docker-compose命令,需要装docker-compose,怎么安装看以前文章。
  • 这个脚本会执行相当长的时间。
  • 有可能会遇到错误:
ERROR: for sentry-cleanup  UnixHTTPConnectionPool(host='localhost', port=None): Pool is closed.
Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
An error occurred, caught SIGERR on line 217
Cleaning up...
           
  • 这个问题是人家脚本写的都是相对路径,所以需要在家目录下的第一级文件夹下执行install.sh。。。。
  • 如果执行脚本过程中没让你输入邮箱密码什么的,说明安装有问题,需要把docker里那十几个容器全删了重新安装。。。。我第一次安装因为开了个jenkins结果内存不够,删了重新装就好了。
  • 然后使用

    docker-compose up -d

    启动
  • 安装完毕后访问9000端口
    【sentry】sentry部署笔记
  • 然后创建项目,他会有一套教程:
To use Sentry with your React application, you will need to use @sentry/react (Sentry’s Browser React SDK).

Note
`@sentry/react` is a wrapper around the `@sentry/browser` package, with added functionality related to React. All methods available in the `@sentry/browser` package can also be imported from `@sentry/react`.
Add the Sentry SDK as a dependency using yarn or npm:

# Using yarn
$ yarn add @sentry/react @sentry/tracing

# Using npm
$ npm install --save @sentry/react @sentry/tracing
Connecting the SDK to Sentry
You should init the Sentry browser SDK as soon as possible during your application load up, before initializing React:

import React from "react";
import ReactDOM from "react-dom";
import * as Sentry from "@sentry/react";
import { Integrations } from "@sentry/tracing";
import App from "./App";

Sentry.init({
  dsn: "http://xxxxxxxxxxxxxxx",
  integrations: [
    new Integrations.BrowserTracing(),
  ],
  tracesSampleRate: 1.0,
});

ReactDOM.render(<App />, document.getElementById("root"));

// Can also use with React Concurrent Mode
// ReactDOM.createRoot(document.getElementById('root')).render(<App />);
The above configuration captures both error and performance data. To reduce the volume of performance data captured, change tracesSampleRate to a value between 0 and 1.

On its own, @sentry/react will report any uncaught exceptions triggered by your application.

You can trigger your first event from your development environment by raising an exception somewhere within your application. An example of this would be rendering a button:

return <button onClick={methodDoesNotExist}>Break the world</button>;
           
  • 简单说就是项目里装个包初始化一下就ok。
  • 首先cra初始化个项目,安装@sentry/react @sentry/tracing
  • 教程里的复制粘贴进index.tsx,app中故意写个错误,刷新sentry,即可看见错误被捕获进issue:
    【sentry】sentry部署笔记
  • 更多设置需要使用webpack插件:https://github.com/getsentry/sentry-webpack-plugin