Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: switched to Sentry again for testing #1212

Merged
merged 1 commit into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@baselime/sveltekit-opentelemetry-middleware": "^0.1.6",
"@event-calendar/core": "^2.0.0",
"@event-calendar/time-grid": "^2.0.0",
"@jill64/sentry-sveltekit-cloudflare": "^1.7.11",
"@neodrag/svelte": "^2.0.3",
"@stripe/stripe-js": "^3.0.10",
"daisyui": "^4.7.2",
Expand Down
37 changes: 22 additions & 15 deletions src/hooks.client.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
// import type { Handle } from '@sveltejs/kit'
// import { get } from '$lib/api'
import { env } from '$env/dynamic/public'
import { init } from '@jill64/sentry-sveltekit-cloudflare/client'
import * as Sentry from '@sentry/browser'

// export const handle = async ({ event, resolve }: { event: any; resolve: any }) => {
// return await resolve(event, { ssr: false })
// }
const onError = init(env.PUBLIC_SENTRY_DSN || '', {
sentryOptions: {
// tunnel: '/tunnel',
integrations: [
Sentry.browserTracingIntegration(),
// Sentry.browserProfilingIntegration(),
Sentry.replayIntegration()
],
tracesSampleRate: 1.0,
profilesSampleRate: 1.0,
// we only care about errors
replaysSessionSampleRate: 0,
replaysOnErrorSampleRate: 1.0
},
enableInDevMode: false
})

// export const handleError = (({ error, event }) => {
// const errorId = crypto.randomUUID();
// // example integration with https://sentry.io/
// // Sentry.captureException(error, { event, errorId })

// return {
// message: 'Whoops!',
// errorId
// };
// }) satisfies HandleClientError
export const handleError = onError((e, sentryEventId) => {
// no special error handling
})
22 changes: 17 additions & 5 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ import { get } from '$lib/api'
import { user_role } from '$lib/stores/userStore'
import { env } from '$env/dynamic/public'

export const handle: Handle = async ({ event, resolve }) => {
import { init } from '@jill64/sentry-sveltekit-cloudflare/server'

const { onHandle, onError } = init(env.PUBLIC_SENTRY_DSN || '', {
toucanOptions: {
tracesSampleRate: 1.0
},
handleOptions: {
handleUnknownRoutes: false
},
enableInDevMode: false
})

export const handle = onHandle(async ({ event, resolve }) => {
const pathname = event.url.pathname
const userId = event.url.searchParams.get('userId') || event.cookies.get('userId') || ''
let token = event.url.searchParams.get('token') || event.cookies.get('token') || ''
Expand Down Expand Up @@ -73,11 +85,11 @@ export const handle: Handle = async ({ event, resolve }) => {
} else {
return await resolve(event)
}
}
})

export const handleError = ({ error }: { error: any }) => {
console.log('error', error)
export const handleError = onError((e, sentryEventId) => {
console.log('error', e)
return {
message: 'Whoops something went wrong!'
}
}
})
6 changes: 0 additions & 6 deletions src/instrumentation.ts

This file was deleted.

8 changes: 8 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ const config: UserConfig = {
},
build: {
assetsInlineLimit: 0
},
ssr: {
noExternal: ['@jill64/sentry-sveltekit-cloudflare']
},
server: {
headers: {
'Document-Policy': 'js-profiling'
}
}
}

Expand Down