Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
feat: disable sentry if telemetry is off
Andrew Bastin1a1baa715d38
diff --git a/packages/hoppscotch-app/helpers/sentry.ts b/packages/hoppscotch-app/helpers/sentry.tsnew file mode 100644index 000000000..18c17afa4--- /dev/null+++ b/packages/hoppscotch-app/helpers/sentry.ts@@ -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+}diff --git a/packages/hoppscotch-app/layouts/default.vue b/packages/hoppscotch-app/layouts/default.vueindex 72e8460da..0be719766 100644--- a/packages/hoppscotch-app/layouts/default.vue+++ b/packages/hoppscotch-app/layouts/default.vue@@ -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"),diff --git a/packages/hoppscotch-app/nuxt.config.js b/packages/hoppscotch-app/nuxt.config.jsindex 8558cd4f0..7a1255eda 100644--- a/packages/hoppscotch-app/nuxt.config.js+++ b/packages/hoppscotch-app/nuxt.config.js@@ -202,7 +202,7 @@ export default {// Sentry module configurationsentry: {dsn: process.env.SENTRY_DSN,- lazy: true,+ // lazy: true,},// Sitemap module configuration (https://github.com/nuxt-community/sitemap-module)diff --git a/packages/hoppscotch-app/package.json b/packages/hoppscotch-app/package.jsonindex 13cdcf1d6..6bc503fe6 100644--- a/packages/hoppscotch-app/package.json+++ b/packages/hoppscotch-app/package.json@@ -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",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 452ef8da7..ee5b8d5c6 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -93,6 +93,7 @@ importers:'@nuxtjs/svg': ^0.3.0'@nuxtjs/toast': ^3.3.1'@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@@ -259,6 +260,7 @@ importers:'@nuxtjs/stylelint-module': [email protected]'@nuxtjs/svg': 0.3.0'@relmify/jest-fp-ts': [email protected][email protected]+ '@sentry/browser': 6.16.1'@testing-library/jest-dom': 5.16.1'@types/codemirror': 5.60.5'@types/cookie': 0.4.1@@ -4159,7 +4161,6 @@ packages:'@sentry/types': 6.16.1'@sentry/utils': 6.16.1tslib: 1.14.1- dev: false/@sentry/cli/1.71.0:resolution: {integrity: sha512-Z8TzH7PkiRfjWSzjXOfPWWp6wxjr+n39Jdrt26OcInVQZM1sx/gZULrDiQZ1L2dy9Fe9AR4SF4nt2/7h2GmLQQ==}@@ -4186,7 +4187,6 @@ packages:'@sentry/types': 6.16.1'@sentry/utils': 6.16.1tslib: 1.14.1- dev: false/@sentry/hub/6.16.1:resolution: {integrity: sha512-4PGtg6AfpqMkreTpL7ymDeQ/U1uXv03bKUuFdtsSTn/FRf9TLS4JB0KuTZCxfp1IRgAA+iFg6B784dDkT8R9eg==}@@ -4195,7 +4195,6 @@ packages:'@sentry/types': 6.16.1'@sentry/utils': 6.16.1tslib: 1.14.1- dev: false/@sentry/integrations/6.16.1:resolution: {integrity: sha512-YobbH3jWMRJxCeFzr8USlju1Up0EJoxaAT4y+LQQ0ZLfyfOdPX0d0iFnWMCar8gwR1nRujFS0HM0BBKY3an0LA==}@@ -4214,7 +4213,6 @@ packages:'@sentry/hub': 6.16.1'@sentry/types': 6.16.1tslib: 1.14.1- dev: false/@sentry/node/6.16.1:resolution: {integrity: sha512-SeDDoug2kUxeF1D7JGPa3h5EXxKtmA01mITBPYx5xbJ0sMksnv5I5bC1SJ8arRRzq6+W1C4IEeDBQtrVCk6ixA==}@@ -4247,7 +4245,6 @@ packages:/@sentry/types/6.16.1:resolution: {integrity: sha512-Wh354g30UsJ5kYJbercektGX4ZMc9MHU++1NjeN2bTMnbofEcpUDWIiKeulZEY65IC1iU+1zRQQgtYO+/hgCUQ==}engines: {node: '>=6'}- dev: false/@sentry/utils/6.16.1:resolution: {integrity: sha512-7ngq/i4R8JZitJo9Sl8PDnjSbDehOxgr1vsoMmerIsyRZ651C/8B+jVkMhaAPgSdyJ0AlE3O7DKKTP1FXFw9qw==}@@ -4255,7 +4252,6 @@ packages:dependencies:'@sentry/types': 6.16.1tslib: 1.14.1- dev: false/@sentry/webpack-plugin/1.18.3:resolution: {integrity: sha512-Qk3Jevislc5DZK0X/WwRVcOtO7iatnWARsEgTV/TuXvDN+fUDDpD/2MytAWAbpLaLy3xEB/cXGeLsbv6d1XNkQ==}