Skip to content

Commit

Permalink
Remove unnecessary data from Sentry events
Browse files Browse the repository at this point in the history
  • Loading branch information
filips123 committed Sep 2, 2024
1 parent cfa4083 commit e183d87
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
26 changes: 10 additions & 16 deletions website/src/registerSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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 || ''
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion website/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit e183d87

Please sign in to comment.