feat: disable sentry if telemetry is off
This commit is contained in:
8
packages/hoppscotch-app/helpers/sentry.ts
Normal file
8
packages/hoppscotch-app/helpers/sentry.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { useContext } from "@nuxtjs/composition-api"
|
||||
import * as Sentry from "@sentry/browser"
|
||||
|
||||
export function useSentry() {
|
||||
// TODO: Make Sentry load lazy at some point ? (see nuxt/sentry)
|
||||
const { $sentry } = useContext()
|
||||
return $sentry as any as typeof Sentry
|
||||
}
|
||||
@@ -57,6 +57,7 @@ import { logPageView } from "~/helpers/fb/analytics"
|
||||
import { hookKeybindingsListener } from "~/helpers/keybindings"
|
||||
import { defineActionHandler } from "~/helpers/actions"
|
||||
import useWindowSize from "~/helpers/utils/useWindowSize"
|
||||
import { useSentry } from "~/helpers/sentry"
|
||||
|
||||
function appLayout() {
|
||||
const rightSidebar = useSetting("SIDEBAR")
|
||||
@@ -80,6 +81,23 @@ function appLayout() {
|
||||
})
|
||||
}
|
||||
|
||||
function setupSentry() {
|
||||
const sentry = useSentry()
|
||||
const telemetryEnabled = useSetting("TELEMETRY_ENABLED")
|
||||
|
||||
// Disable sentry error reporting if no telemetry allowed
|
||||
watch(
|
||||
telemetryEnabled,
|
||||
() => {
|
||||
const client = sentry.getCurrentHub()?.getClient()
|
||||
if (!client) return
|
||||
|
||||
client.getOptions().enabled = telemetryEnabled.value
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
}
|
||||
|
||||
function updateThemes() {
|
||||
const { $colorMode } = useContext() as any
|
||||
|
||||
@@ -140,6 +158,7 @@ export default defineComponent({
|
||||
|
||||
updateThemes()
|
||||
|
||||
setupSentry()
|
||||
return {
|
||||
windowInnerWidth: useWindowSize(),
|
||||
ZEN_MODE: useSetting("ZEN_MODE"),
|
||||
|
||||
@@ -202,7 +202,7 @@ export default {
|
||||
// Sentry module configuration
|
||||
sentry: {
|
||||
dsn: process.env.SENTRY_DSN,
|
||||
lazy: true,
|
||||
// lazy: true,
|
||||
},
|
||||
|
||||
// Sitemap module configuration (https://github.com/nuxt-community/sitemap-module)
|
||||
|
||||
@@ -127,6 +127,7 @@
|
||||
"@nuxtjs/stylelint-module": "^4.1.0",
|
||||
"@nuxtjs/svg": "^0.3.0",
|
||||
"@relmify/jest-fp-ts": "^1.1.1",
|
||||
"@sentry/browser": "^6.16.1",
|
||||
"@testing-library/jest-dom": "^5.16.0",
|
||||
"@types/codemirror": "^5.60.5",
|
||||
"@types/cookie": "^0.4.1",
|
||||
|
||||
Reference in New Issue
Block a user