from Sentry
2021-02-08 Sentry Memo
$ npm install --save @sentry/react @sentry/tracingNext, import and initialize the Sentry module as early as possible, before initializing React: ts
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: "https://*****.ingest.sentry.io/5627136",
integrations: [new Integrations.BrowserTracing()],
// We recommend adjusting this value in production, or using tracesSampler
// for finer control
tracesSampleRate: 1.0,
});
ReactDOM.render(<App />, document.getElementById("root"));
- > 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.
// @ts-ignore
console.log([][0].TalkID);
- 
- 
- 開発サーバでやってるのに`New alert from keicho-webclient in production`ってメールが届いてしまう
ts
Sentry.init({ ...
environment: process.env.NODE_ENV,
});
Sentryでエラー時にUser Feedbackのフォームを出す Sentryでパフォーマンス計測
追加の情報を送る
Sentry.setContext("Info", { TalkID: TalkID });Server side
$ pip install --upgrade sentry-sdk
Import and initialize the Sentry SDK early in your application's setup:
python
import sentry_sdk
sentry_sdk.init(
"https://013cb069fe1841fb920fd5d7e369debc@o376998.ingest.sentry.io/5628690",
traces_sample_rate=1.0
)
python
@app.route('/')
def root():
1 / 0
return "OK"
ローカルのサーバでエラーを出してSentryへの報告がうまく動いてるか確認したいが、Flaskの開発モードだとエラーがキャッチされてデバッグ画面になってしまう
一旦FLASK_ENV=developmentを外す
逆に言えばこれがついてることでローカルサーバでのエラーは報告されない、普段はそれで良い
追加の情報を送る
sentry_sdk.set_context("info", {"talk": talk, "text": text})