根据 React FE 项目的 Sentry 设置指南
import * as Sentry from "@sentry/react";
Sentry.init({
dsn: "SOME_SENTRY_DNS",
// Setting this option to true will send default PII data to Sentry.
// For example, automatic IP address collection on events
sendDefaultPii: true
});
const container = document.getElementById(“app”);
const root = createRoot(container);
root.render(<App />);
我已经调整为
const SENTRY_DSN = process.env.REACT_APP_SENTRY_DSN;
const SENTRY_ENV = process.env.REACT_APP_SENTRY_ENVIRONMENT || "development";
Sentry.init({
dsn: SENTRY_DSN,
environment: SENTRY_ENV,
sendDefaultPii: true,
debug: true,
autoSessionTracking: false,
beforeSend(event) {
console.log("Sentry about to send event:", event);
return event;
},
});
但仍然不断
Sentry Logger [warn]: Discarded session because of missing or non-string release
为了修复它,我必须包含一个版本,就像这样
现在它按预期工作