天天看點

【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