From e183d875aa9214722f5a7b06660d893a8441dc87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0tamcar?= Date: Mon, 2 Sep 2024 22:15:52 +0200 Subject: [PATCH] Remove unnecessary data from Sentry events --- website/src/registerSentry.ts | 26 ++++++++++---------------- website/vite.config.ts | 4 +++- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/website/src/registerSentry.ts b/website/src/registerSentry.ts index d77682c..7fffe08 100644 --- a/website/src/registerSentry.ts +++ b/website/src/registerSentry.ts @@ -19,11 +19,6 @@ import { reportingObserverIntegration, thirdPartyErrorFilterIntegration, } from '@sentry/vue' -import { - usePreferredColorScheme, - usePreferredContrast, - usePreferredReducedMotion, -} from '@vueuse/core' import type { App } from 'vue' import type { Router } from 'vue-router' @@ -35,11 +30,6 @@ export default function registerSentry(app: App, router: Router) { const { dataCollectionCrashes, dataCollectionPerformance } = useSettingsStore() if (!dataCollectionCrashes && !dataCollectionPerformance) return - // Initialize stores for some interesting media queries - const preferredColor = usePreferredColorScheme() - const preferredContrast = usePreferredContrast() - const preferredMotion = usePreferredReducedMotion() - // Get release prefixes and suffixes from config const releasePrefix = import.meta.env.VITE_SENTRY_RELEASE_PREFIX || '' const releaseSuffix = import.meta.env.VITE_SENTRY_RELEASE_SUFFIX || '' @@ -160,16 +150,20 @@ export default function registerSentry(app: App, router: Router) { 'window-controls-overlay', 'picture-in-picture', ] - for (const mode of displayModes) { - if (window.matchMedia(`(display-mode: ${mode})`).matches) { - event.tags['media.display_mode'] = mode + for (const displayMode of displayModes) { + if (window.matchMedia(`(display-mode: ${displayMode})`).matches) { + event.tags['media.display_mode'] = displayMode break } } - event.tags['media.color_scheme'] = preferredColor.value - event.tags['media.contrast'] = preferredContrast.value - event.tags['media.reduced_motion'] = preferredMotion.value + const colorSchemes = ['light', 'dark'] + for (const colorScheme of colorSchemes) { + if (window.matchMedia(`(prefers-color-scheme: ${colorScheme})`).matches) { + event.tags['media.color_scheme'] = colorScheme + break + } + } // Return the modified event return event diff --git a/website/vite.config.ts b/website/vite.config.ts index 69c8dc4..6fbd114 100644 --- a/website/vite.config.ts +++ b/website/vite.config.ts @@ -106,7 +106,7 @@ export default defineConfig(({ mode }) => { Vuetify(), Html(htmlConfig), VitePWA(pwaConfig), - ApachePreload(preloadConfig) + ApachePreload(preloadConfig), ] // Upload sourcemaps for the current release to Sentry if enabled @@ -144,6 +144,8 @@ export default defineConfig(({ mode }) => { 'import.meta.env.VITE_SENTRY_TRACES_SAMPLE_RATE': parseFloat(env.VITE_SENTRY_TRACES_SAMPLE_RATE) || 0, 'import.meta.env.VITE_SENTRY_PROFILES_SAMPLE_RATE': parseFloat(env.VITE_SENTRY_PROFILES_SAMPLE_RATE) || 0, 'import.meta.env.VITE_SENTRY_TRACE_PROPAGATION_TARGETS': env.VITE_SENTRY_TRACE_PROPAGATION_TARGETS?.split(','), + // Disable Sentry debug mode in production + '__SENTRY_DEBUG__': mode === 'production' ? 'false' : 'true', }, build: {