Svelte: add sentry (#63126)

This adds basic sentry support to the Sveltekit webapp.
This commit is contained in:
Camden Cheek 2024-06-07 09:35:27 -06:00 committed by GitHub
parent a36b750842
commit 929258e8a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 843 additions and 38 deletions

View File

@ -84,6 +84,7 @@ BUILD_DEPS = [
":node_modules/@graphql-tools/utils",
":node_modules/@iconify-json/lucide",
":node_modules/@melt-ui/svelte",
":node_modules/@sentry/sveltekit",
":node_modules/@sourcegraph/branded",
":node_modules/@sourcegraph/client-api",
":node_modules/@sourcegraph/common",

View File

@ -75,6 +75,7 @@
"dependencies": {
"@floating-ui/dom": "^1.6.3",
"@melt-ui/svelte": "^0.76.0",
"@sentry/sveltekit": "^8.7.0",
"@sourcegraph/branded": "workspace:*",
"@sourcegraph/client-api": "workspace:*",
"@sourcegraph/common": "workspace:*",

View File

@ -0,0 +1,29 @@
import { handleErrorWithSentry } from '@sentry/sveltekit'
import * as Sentry from '@sentry/sveltekit'
Sentry.init({
// Disabled if dsn is undefined
dsn: window.context.sentryDSN ?? undefined,
release: window.context.version,
initialScope: {
user: window.context.currentUser
? {
id: window.context.currentUser.databaseID,
graphqlID: window.context.currentUser.id,
username: window.context.currentUser.username,
displayName: window.context.currentUser.displayName,
email: window.context.currentUser.emails.find(email => email.isPrimary)?.email,
}
: undefined,
tags: {
app: 'sveltekit',
siteID: window.context.siteID,
externalURL: window.context.externalURL,
},
},
tracesSampleRate: 1.0,
})
// If you have a custom error handler, pass it to `handleErrorWithSentry`
export const handleError = handleErrorWithSentry()

View File

@ -36,6 +36,9 @@ export default defineConfig(({ mode }) => {
graphqlCodegen(),
inspect(),
],
build: {
sourcemap: true,
},
define:
mode === 'test'
? {}

File diff suppressed because it is too large Load Diff