2022-08-04 07:54:30 +08:00
|
|
|
import type { Handler } from 'https://raw.githubusercontent.com/honojs/hono/v2.0.6/deno_dist/mod.ts'
|
2022-08-11 03:54:58 +08:00
|
|
|
import * as Sentry from 'https://deno.land/x/sentry_deno/main.ts'
|
2022-08-04 07:54:30 +08:00
|
|
|
|
2022-08-10 00:32:06 +08:00
|
|
|
export const sentry = (): Handler => {
|
2022-08-04 07:54:30 +08:00
|
|
|
return async (c, next) => {
|
2022-08-11 03:54:58 +08:00
|
|
|
Sentry.init({
|
|
|
|
dsn: c.env.SENTRY_DSN || c.env.NEXT_PUBLIC_SENTRY_DSN,
|
|
|
|
tracesSampleRate: 1.0,
|
|
|
|
})
|
|
|
|
try {
|
|
|
|
await next()
|
|
|
|
} catch (error) {
|
|
|
|
Sentry.captureException(error)
|
|
|
|
throw error
|
|
|
|
}
|
2022-08-04 07:54:30 +08:00
|
|
|
}
|
|
|
|
}
|