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

sentry-middleware: Switch from toucan-js to @sentry/cloudflare #943

Open
jbergstroem opened this issue Jan 22, 2025 · 9 comments
Open

sentry-middleware: Switch from toucan-js to @sentry/cloudflare #943

jbergstroem opened this issue Jan 22, 2025 · 9 comments
Labels
enhancement New feature or request

Comments

@jbergstroem
Copy link

Which middleware is the feature for?

@hono/sentry

What is the feature you are proposing?

Upstream is deprecating toucan-js in favor of @sentry/cloudflare.

New library: https://github.com/getsentry/sentry-javascript/tree/develop/packages/cloudflare

@jbergstroem jbergstroem added the enhancement New feature or request label Jan 22, 2025
@yusukebe
Copy link
Member

@jbergstroem Thank you for the issue.

Hi @sam-lippert, Can you handle this?

@sam-lippert
Copy link
Contributor

@yusukebe I'll start taking a look this weekend.

@yusukebe
Copy link
Member

@sam-lippert Thanks!

@schettn
Copy link

schettn commented Feb 19, 2025

Hi @sam-lippert. Is there any progress yet?

Sentry is currently working on a Hono guide that utilizes @sentry/cloudflare. The issue I have with it is that this only works with Cloudflare and it is no longer a hono middleware approach, instead the default export gets wrapped.

@yusukebe @sam-lippert do you see a way to add a cross platform middleware or at least support node, bun, Cloudflare Workers and maybe deno?

@sam-lippert
Copy link
Contributor

@schettn I had done a little digging and found that @sentry/cloudflare does not export its init method from the library itself, and so swapping out toucan-js is a slight challenge. toucan-js calls itself "a Sentry client for Cloudflare Workers," and so I'm hoping that once I can call init on a Cloudflare-supported library, the middleware should work cross-platform as it does now.
I'll look into other libraries too like @sentry/browser to see if something else would be a good fit. Otherwise, if I can't find a workaround, I might need to open a pull request with Sentry and see if they can export init so that it can be used in the middleware.

@Lms24
Copy link

Lms24 commented Feb 20, 2025

Hi, thanks for the tag! I'm a bit booked with stuff so excuse my naive question: What is the concrete ask from Sentry? Do you need an exported init function?

I'm not deeply involved with cloudflare or hono, so I can forward the request to the respective experts once I know what you need :)

@sam-lippert
Copy link
Contributor

Hi @Lms24, the ask is to be able to init Sentry in a cross-platform Hono middleware rather than requiring the withSentry wrapper function only for Cloudflare environments. There is an implementation using toucan-js, and it works in node, deno, bun, and wrangler, but that package will be deprecated at the end of this year:

const sentry = new Toucan({
dsn: c.env?.SENTRY_DSN ?? c.env?.NEXT_PUBLIC_SENTRY_DSN,
requestDataOptions: {
allowedHeaders: ['user-agent'],
allowedSearchParams: /(.*)/,
},
request: c.req.raw,
context: hasExecutionContext ? c.executionCtx : new MockContext(),
...options,
})

I'm not sure yet if exporting init is specifically required. If there is another cross-platform way to achieve the same goal, then I can use that.

@lforst
Copy link

lforst commented Feb 25, 2025

@sam-lippert a middleware shouldn't be too much effort. I'll put it onto my backlog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants