Sentry middleware: fix undefined DSN environment variable error (#89)

* Use optional chaining for determining Sentry DSN from environment

* Bump Hono version for Sentry middleware

* Fix tests on Deno

* Add changeset for Sentry middleware patch

* Denoify the new Sentry patch
pull/88/head
Markkus Millend 2023-06-01 23:31:51 +02:00 committed by GitHub
parent b7fe359dbc
commit 963b1ac0de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 5 deletions

View File

@ -0,0 +1,5 @@
---
'@hono/sentry': patch
---
Use optional chaining for determining Sentry DSN from environment (#89)

View File

@ -41,7 +41,7 @@ export const sentry = (
hasExecutionContext = false
}
const sentry = new Toucan({
dsn: c.env.SENTRY_DSN ?? c.env.NEXT_PUBLIC_SENTRY_DSN,
dsn: c.env?.SENTRY_DSN ?? c.env?.NEXT_PUBLIC_SENTRY_DSN,
allowedHeaders: ['user-agent'],
allowedSearchParams: /(.*)/,
request: c.req.raw,

View File

@ -1,2 +1,2 @@
export { assert, assertEquals } from 'https://deno.land/std@0.148.0/testing/asserts.ts'
export { Hono } from 'https://deno.land/x/hono@v2.6.1/mod.ts'
export { Hono } from 'https://deno.land/x/hono@v3.2.3/mod.ts'

View File

@ -33,7 +33,7 @@
"access": "public"
},
"peerDependencies": {
"hono": "^3.0.2"
"hono": "^3.2.3"
},
"dependencies": {
"toucan-js": "^2.6.1"
@ -61,4 +61,4 @@
"ts-jest": "^28.0.5",
"typescript": "^4.7.4"
}
}
}

View File

@ -41,7 +41,7 @@ export const sentry = (
hasExecutionContext = false
}
const sentry = new Toucan({
dsn: c.env.SENTRY_DSN ?? c.env.NEXT_PUBLIC_SENTRY_DSN,
dsn: c.env?.SENTRY_DSN ?? c.env?.NEXT_PUBLIC_SENTRY_DSN,
allowedHeaders: ['user-agent'],
allowedSearchParams: /(.*)/,
request: c.req.raw,