Skip to content

Commit 74aaf2e

Browse files
committed
프론트 Sentry SDK 연동
1 parent 6d296cc commit 74aaf2e

8 files changed

Lines changed: 136 additions & 31 deletions

File tree

frontend/build/webpack.base.conf.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,10 @@ function resolve(dir) {
1313
}
1414

1515
function getEntries() {
16-
const base = {
16+
return {
1717
oj: ["./src/pages/oj/index.js"],
1818
admin: ["./src/pages/admin/index.js"],
1919
}
20-
if (process.env.USE_SENTRY === "1") {
21-
Object.keys(base).forEach((entry) => {
22-
base[entry].push("./src/utils/sentry.js")
23-
})
24-
}
25-
return base
2620
}
2721

2822
// get all entries

frontend/build/webpack.dll.conf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const vendors = [
1717
"vuex",
1818
"axios",
1919
"moment",
20-
"raven-js",
2120
"browser-detect",
2221
]
2322

frontend/config/dev.env.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22
// let commit = require('child_process').execSync('git rev-parse HEAD').toString().slice(0, 5)
33
// let version = `"${date}-${commit}"`
44
let version = JSON.stringify(process.env.VUE_APP_VERSION || "dev")
5+
let useSentry = JSON.stringify(
6+
process.env.USE_SENTRY || (process.env.NODE_ENV === "production" ? "1" : "0"),
7+
)
8+
let sentryDsn = JSON.stringify(
9+
process.env.SENTRY_DSN ||
10+
"https://143814aaa2d6e0b4550b2e5effefe90d@o4511586463776768.ingest.us.sentry.io/4511586483634176",
11+
)
512

613
console.log(`current version is ${version}`)
714

815
module.exports = {
916
NODE_ENV: '"development"',
1017
VERSION: version,
11-
USE_SENTRY: "0",
18+
USE_SENTRY: useSentry,
19+
SENTRY_DSN: sentryDsn,
1220
}

frontend/package-lock.json

Lines changed: 95 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@fortawesome/fontawesome-svg-core": "^6.5.1",
1818
"@fortawesome/free-solid-svg-icons": "^6.5.1",
1919
"@fortawesome/vue-fontawesome": "^2.0.10",
20+
"@sentry/vue": "^10.58.0",
2021
"axios": "^0.33.0",
2122
"browser-detect": "^0.2.27",
2223
"core-js": "^3.49.0",
@@ -29,7 +30,6 @@
2930
"katex": "^0.10.0",
3031
"moment": "^2.22.1",
3132
"papaparse": "^5.5.3",
32-
"raven-js": "^3.25.0",
3333
"regenerator-runtime": "^0.14.1",
3434
"screenfull": "^3.3.2",
3535
"splitpanes": "^2.4.1",

frontend/src/pages/admin/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import "./style.less"
2424

2525
import ECharts from "vue-echarts"
2626
import "@/utils/echarts"
27+
import { initSentry } from "@/utils/sentry"
2728

2829
const legacyPanelTag = "Panel"
2930
const legacySaveTag = "Save"
@@ -66,4 +67,6 @@ Vue.prototype.$success = (msg) => {
6667
}
6768
}
6869

70+
initSentry(Vue)
71+
6972
new Vue(Vue.util.extend({ router, store, i18n }, App)).$mount("#app")

frontend/src/pages/oj/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import filters from "@/utils/filters.js"
2323

2424
import ECharts from "vue-echarts"
2525
import "@/utils/echarts"
26+
import { initSentry } from "@/utils/sentry"
2627

2728
const legacyPanelTag = "Panel"
2829

@@ -57,4 +58,6 @@ Vue.prototype.$error = (s) => Vue.prototype.$Message.error(s)
5758
Vue.prototype.$info = (s) => Vue.prototype.$Message.info(s)
5859
Vue.prototype.$success = (s) => Vue.prototype.$Message.success(s)
5960

61+
initSentry(Vue)
62+
6063
new Vue(Vue.util.extend({ router, store, i18n }, App)).$mount("#app")

frontend/src/utils/sentry.js

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import Vue from "vue"
2-
import Raven from "raven-js"
3-
import RavenVue from "raven-js/plugins/vue"
1+
import { init, setContext } from "@sentry/vue"
2+
3+
const SENTRY_DSN =
4+
"https://143814aaa2d6e0b4550b2e5effefe90d@o4511586463776768.ingest.us.sentry.io/4511586483634176"
45

56
const options = {
67
release: process.env.VERSION,
8+
environment: process.env.NODE_ENV,
79
ignoreUrls: [
810
// Chrome extensions
911
/extensions\//i,
@@ -13,16 +15,25 @@ const options = {
1315
// Ignore Google flakiness
1416
/\/(gtm|ga|analytics)\.js/i,
1517
],
18+
dataCollection: {
19+
userInfo: false,
20+
httpBodies: [],
21+
},
1622
}
1723

18-
Raven.config(
19-
"https://6234a51e61a743b089ed64c51d2f6ea9@sentry.io/258234",
20-
options,
21-
)
22-
.addPlugin(RavenVue, Vue)
23-
.install()
24+
export function initSentry(Vue) {
25+
if (process.env.USE_SENTRY !== "1") {
26+
return
27+
}
28+
29+
init({
30+
Vue,
31+
dsn: process.env.SENTRY_DSN || SENTRY_DSN,
32+
...options,
33+
})
2434

25-
Raven.setUserContext({
26-
version: process.env.VERSION,
27-
location: window.location,
28-
})
35+
setContext("app", {
36+
version: process.env.VERSION,
37+
location: window.location.href,
38+
})
39+
}

0 commit comments

Comments
 (0)