Skip to content

Commit

Permalink
update sentry (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 authored Feb 15, 2025
1 parent 6634bb8 commit 92f965e
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 71 deletions.
6 changes: 3 additions & 3 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@babel/preset-env": "^7.7.7",
"@babel/preset-react": "^7.7.4",
"@sentry/cli": "^2.21.2",
"@sentry/webpack-plugin": "^2.9.0",
"@sentry/webpack-plugin": "^2.23.0",
"@types/react": "^16.14.42",
"@welldone-software/why-did-you-render": "^6.2.3",
"autoprefixer": "^10.4.14",
Expand All @@ -55,8 +55,8 @@
"mini-css-extract-plugin": "^2.7.6",
"postcss-loader": "^7.3.2",
"prettier": "^2.8.8",
"sass": "^1.62.1",
"sass-loader": "^13.3.1",
"sass": "1.62.0",
"sass-loader": "13.3.3",
"terser-webpack-plugin": "^5.3.9",
"webpack": "^5.85.0",
"webpack-bundle-analyzer": "^4.9.0",
Expand Down
35 changes: 22 additions & 13 deletions frontend/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,32 @@ import FPPropChart from "./js/ichart.js"
import initAutocomplete from "./js/algolia.js"
import LineageChart from "./js/lineage.js"
import initFRET from "./js/fret.js"
import * as Sentry from "@sentry/browser";

window.FPBASE = window.FPBASE || {}

if (process.env.NODE_ENV === "production" && Boolean(process.env.SENTRY_DSN)) {
import("@sentry/browser").then(Sentry => {
window.Sentry = Sentry
Sentry.init({
dsn: process.env.SENTRY_DSN,
release: process.env.SOURCE_VERSION
})
if (window.FPBASE.user !== undefined) {
Sentry.configureScope(scope => {
scope.setUser(window.FPBASE.user)
})

(async () => {
if (process.env.NODE_ENV === "production" && Boolean(process.env.SENTRY_DSN)) {
try {
await import("@sentry/browser");

Sentry.init({
dsn: process.env.SENTRY_DSN,
release: process.env.SOURCE_VERSION,
environment: process.env.NODE_ENV,
});

if (window.FPBASE.user) {
Sentry.setUser(window.FPBASE.user);
}

window.Sentry = Sentry;
} catch (error) {
console.error("Failed to initialize Sentry:", error);
}
})
}
}
})();

window.FPBASE = {
...window.FPBASE,
Expand Down
57 changes: 17 additions & 40 deletions frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const { CleanWebpackPlugin } = require("clean-webpack-plugin")
const CopyPlugin = require("copy-webpack-plugin")
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin")
// const { sentryWebpackPlugin } = require("@sentry/webpack-plugin")
const TerserJSPlugin = require("terser-webpack-plugin")
const { sentryWebpackPlugin } = require("@sentry/webpack-plugin")

const devMode = process.env.NODE_ENV !== "production"
const hotReload = process.env.HOT_RELOAD === "1"
Expand Down Expand Up @@ -74,45 +74,19 @@ const plugins = [
chunkFilename: "[id].[chunkhash].css",
}),
new CleanWebpackPlugin(),
new CopyPlugin({
patterns: [
{
from: "./src/js/sentry.*.js",
to: path.resolve("./dist/sentry.js"),
},
],
}),
]

if (devMode) {
} else {
if (!devMode) {
plugins.push(
new webpack.EnvironmentPlugin({
NODE_ENV: "development",
SOURCE_VERSION: false,
SENTRY_DSN: false,
SENTRY_AUTH_TOKEN: false,
sentryWebpackPlugin({
org: "talley-lambert",
project: "fpbase",
authToken: process.env.SENTRY_AUTH_TOKEN,
include: "./dist",
ignore: ["node_modules", "webpack.config.js"],
release: process.env.SOURCE_VERSION,
})
)

// if (process.env.SENTRY_AUTH_TOKEN && !process.env.CI) {
// plugins.push(
// sentryWebpackPlugin({
// authToken: process.env.SENTRY_AUTH_TOKEN,
// org: process.env.SENTRY_ORG,
// project: process.env.SENTRY_PROJECT,
// sourcemaps: {
// paths: "src/",
// ignore: [
// "node_modules",
// "webpack.config.js",
// "src/js/pdb/LiteMol-plugin.js",
// ],
// },
// release: process.env.SOURCE_VERSION,
// })
// )
// }
}

module.exports = {
Expand All @@ -136,8 +110,14 @@ module.exports = {
extensions: [".webpack.js", ".web.js", ".mjs", ".js", ".jsx", ".json"],
alias: {
jquery: "jquery/src/jquery",
"@fpbase/spectra": path.resolve(__dirname, "../packages/spectra/src/index.jsx"),
"@fpbase/blast": path.resolve(__dirname, "../packages/blast/src/index.js"),
"@fpbase/spectra": path.resolve(
__dirname,
"../packages/spectra/src/index.jsx"
),
"@fpbase/blast": path.resolve(
__dirname,
"../packages/blast/src/index.js"
),
},
fallback: {
url: require.resolve("url/"),
Expand All @@ -162,9 +142,6 @@ module.exports = {
assetRule,
],
},
externals: {
Sentry: "Sentry",
},
plugins,
optimization: {
minimizer: [new TerserJSPlugin(), new CssMinimizerPlugin()],
Expand Down
33 changes: 24 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@ django-reversion==5.0.10 \
django-reversion-compare==0.16.2 \
--hash=sha256:5629f226fc73bd7b95de47b2e21e2eba2fa39f004ba0fee6d460e96676c0dc9b \
--hash=sha256:9d7d096534f5d0e49d7419a8a29b4517580e6a7855529e594d10bfb373f980ab
django-storages==1.14.4 \
--hash=sha256:69aca94d26e6714d14ad63f33d13619e697508ee33ede184e462ed766dc2a73f \
--hash=sha256:d61930acb4a25e3aebebc6addaf946a3b1df31c803a6bf1af2f31c9047febaa3
django-storages==1.14.5 \
--hash=sha256:5ce9c69426f24f379821fd688442314e4aa03de87ae43183c4e16915f4c165d4 \
--hash=sha256:ace80dbee311258453e30cd5cfd91096b834180ccf09bc1f4d2cb6d38d68571a
django-webpack-loader==2.0.1 \
--hash=sha256:0e8dfb2fcdb39dbfd01be7603c060132a4664f483811ce3c75f2d3c0d39ab762 \
--hash=sha256:2704c5b0e699a9a3a70aa21b75825d8637cd0df8134c3308b5c2976ecc20b5f7
Expand Down
6 changes: 3 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 92f965e

Please sign in to comment.