diff --git a/.changeset/serious-cars-rescue.md b/.changeset/serious-cars-rescue.md new file mode 100644 index 00000000..ea17229d --- /dev/null +++ b/.changeset/serious-cars-rescue.md @@ -0,0 +1,5 @@ +--- +'@hono/sentry': minor +--- + +feat: support latest Hono version diff --git a/packages/sentry/deno_dist/README.md b/packages/sentry/deno_dist/README.md index 56ca52f6..a6806de0 100644 --- a/packages/sentry/deno_dist/README.md +++ b/packages/sentry/deno_dist/README.md @@ -1,21 +1,13 @@ # Sentry middleware for Hono -## Information - -Sentry Middleware `@honojs/sentry` is renamed to `@hono/sentry`. -`@honojs/sentry` is not maintained, please use `@hono/sentry`. -Also, for Deno, you can use import with `npm:` prefix like `npm:@hono/sentry`. - ---- - Sentry middleware for [Hono](https://github.com/honojs/hono). This middleware sends captured exceptions to the specified Sentry data source name via [toucan-js](https://github.com/robertcepa/toucan-js). ## Usage ```ts -import { sentry } from '@hono/sentry' import { Hono } from 'hono' +import { sentry } from '@hono/sentry' const app = new Hono() diff --git a/packages/sentry/deno_dist/index.ts b/packages/sentry/deno_dist/index.ts index e3816702..75f82148 100644 --- a/packages/sentry/deno_dist/index.ts +++ b/packages/sentry/deno_dist/index.ts @@ -7,11 +7,6 @@ declare module 'https://deno.land/x/hono/mod.ts' { } } -interface Bindings { - SENTRY_DSN?: string - NEXT_PUBLIC_SENTRY_DSN?: string -} - class MockContext implements ExecutionContext { passThroughOnException(): void { throw new Error('Method not implemented.') @@ -37,7 +32,7 @@ export type Options = { export const sentry = ( options?: Options, callback?: (sentry: Toucan) => void -): MiddlewareHandler => { +): MiddlewareHandler => { return async (c, next) => { let hasExecutionContext = true try { @@ -49,7 +44,7 @@ export const sentry = ( dsn: c.env.SENTRY_DSN ?? c.env.NEXT_PUBLIC_SENTRY_DSN, allowedHeaders: ['user-agent'], allowedSearchParams: /(.*)/, - request: c.req, + request: c.req.raw, context: hasExecutionContext ? c.executionCtx : new MockContext(), ...options, }) diff --git a/packages/sentry/package.json b/packages/sentry/package.json index 2399b26b..4ffaeb27 100644 --- a/packages/sentry/package.json +++ b/packages/sentry/package.json @@ -33,7 +33,7 @@ "access": "public" }, "peerDependencies": { - "hono": "^2.6.1" + "hono": "^3.0.2" }, "dependencies": { "toucan-js": "^2.6.1" @@ -52,7 +52,7 @@ "eslint-plugin-flowtype": "^8.0.3", "eslint-plugin-import": "^2.26.0", "eslint-plugin-node": "^11.1.0", - "hono": "^2.6.1", + "hono": "^3.0.2", "jest": "^28.1.2", "jest-environment-miniflare": "^2.6.0", "np": "^7.6.2", diff --git a/packages/sentry/src/index.ts b/packages/sentry/src/index.ts index 07e99f7e..2ede2807 100644 --- a/packages/sentry/src/index.ts +++ b/packages/sentry/src/index.ts @@ -7,11 +7,6 @@ declare module 'hono' { } } -interface Bindings { - SENTRY_DSN?: string - NEXT_PUBLIC_SENTRY_DSN?: string -} - class MockContext implements ExecutionContext { passThroughOnException(): void { throw new Error('Method not implemented.') @@ -37,7 +32,7 @@ export type Options = { export const sentry = ( options?: Options, callback?: (sentry: Toucan) => void -): MiddlewareHandler => { +): MiddlewareHandler => { return async (c, next) => { let hasExecutionContext = true try { @@ -49,7 +44,7 @@ export const sentry = ( dsn: c.env.SENTRY_DSN ?? c.env.NEXT_PUBLIC_SENTRY_DSN, allowedHeaders: ['user-agent'], allowedSearchParams: /(.*)/, - request: c.req, + request: c.req.raw, context: hasExecutionContext ? c.executionCtx : new MockContext(), ...options, }) diff --git a/yarn.lock b/yarn.lock index 65c77104..b55b3d9e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5217,11 +5217,6 @@ hono@3.0.0-rc.4: resolved "https://registry.yarnpkg.com/hono/-/hono-3.0.0-rc.4.tgz#7bfe8c89d4b004ff90d587c8ba45279a175fbce7" integrity sha512-76R3mb8kPeuD9TOmQ1WZi59w4QbpaUOlyX3wC7zQpt7IM7iFVBTxj2fpv++6ROPtd5iUBMCrmH/65ZrNXYYgmg== -hono@^2.6.1: - version "2.7.5" - resolved "https://registry.yarnpkg.com/hono/-/hono-2.7.5.tgz#2b0c39d39a057575962a7025373be4304dedca9c" - integrity sha512-UYrhUT1Xtalh7Xw/YGXee25wlWMiVIRfr0FbAJMEMyRpX9TFZ/6JKmVdCK7ioRnhAw7PfWBasjSBhdNXQ8/okQ== - hono@^2.7.2: version "2.7.2" resolved "https://registry.yarnpkg.com/hono/-/hono-2.7.2.tgz#09796d79a2f220c353efaf4aeb82434062ceb911" @@ -5232,6 +5227,11 @@ hono@^3.0.0: resolved "https://registry.yarnpkg.com/hono/-/hono-3.0.0.tgz#f81e49e7540603203b9b576c81b289fa7daf0446" integrity sha512-OBWEvcRydCOLdOiazqOmKy8PXciR8uIyUM9HpmXot7UmwNBGOdEJvTrVRIgjV603w+go6cTXBOvFiQClSABT6Q== +hono@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/hono/-/hono-3.0.2.tgz#807a1b0514c6563917d8c278e6da7101bdac1d19" + integrity sha512-jhb0eCiUTOzbOXZyXQCOk1gf3MKjV4ZXY3PRT6lzma0XPsnnHuDOHYF7RCMHYe7jhl4Y0IAzrmWXneXhOMHypA== + hosted-git-info@^2.1.4: version "2.8.9" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"