feat: disable sentry if telemetry is off

This commit is contained in:
Andrew Bastin
2021-12-16 18:02:01 +05:30
parent 29b5913fac
commit 1a1baa715d
5 changed files with 31 additions and 7 deletions

View File

@@ -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"),