From b47e0004e219d8d26b1763a24926b71cf7213776 Mon Sep 17 00:00:00 2001 From: Samuel Lippert Date: Wed, 10 Aug 2022 14:54:58 -0500 Subject: [PATCH] Deno library + re-throw error --- README.md | 15 +++++++++++++++ deno_dist/index.ts | 24 +++++++++++------------- src/index.ts | 1 + 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index dcda10d8..27d4f37d 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,21 @@ app.get('/', (c) => c.text('foo')) export default app ``` +## Deno + +```ts +import { serve } from 'https://deno.land/std/http/server.ts' +import { sentry } from 'https://deno.land/x/hono_sentry/mod.ts' +import { Hono } from 'https://deno.land/x/hono/mod.ts' + +const app = new Hono() + +app.use('*', sentry()) +app.get('/', (c) => c.text('foo')) + +serve(app.fetch) +``` + ## Author Yusuke Wada diff --git a/deno_dist/index.ts b/deno_dist/index.ts index 4caeeee3..4fcf0fd1 100644 --- a/deno_dist/index.ts +++ b/deno_dist/index.ts @@ -1,19 +1,17 @@ import type { Handler } from 'https://raw.githubusercontent.com/honojs/hono/v2.0.6/deno_dist/mod.ts' -// import Toucan from '../node_modules/toucan-js/dist/index.d.ts' +import * as Sentry from 'https://deno.land/x/sentry_deno/main.ts' export const sentry = (): Handler => { return async (c, next) => { - // const sentry = new Toucan({ - // dsn: c.env.SENTRY_DSN || || c.env.NEXT_PUBLIC_SENTRY_DSN, - // request: c.req, - // allowedHeaders: ['user-agent'], - // allowedSearchParams: /(.*)/, - // }) - - // try { - await next() - // } catch (error) { - // sentry.captureException(error) - // } + 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 + } } } diff --git a/src/index.ts b/src/index.ts index 61ccc962..a62ee427 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,6 +14,7 @@ export const sentry = (): Handler => { await next() } catch (error) { sentry.captureException(error) + throw error } } }