robertcepa / toucan-js

Cloudflare Workers client for Sentry
MIT License
413 stars 24 forks source link

RewriteFrames from @sentry/integrations >= 7.74.0 is no longer compatible with toucan-js #221

Closed olivierbeaulieu closed 3 months ago

olivierbeaulieu commented 9 months ago

Using from the RewriteFrames the latest @sentry/integrations no longer works. The integration's processEvent is never called.

I believe this is because of a recent refactoring from Sentry where the integration's setupOnce become a noop (source)

Toucan depends on setupOnce calling the function that is passed to it, otherwise the event processor is never added to the SDK's scope (source).

timfish commented 9 months ago

If you use a version of @sentry/integrations that matches the the one in use in toucan-js (ie. v7.76.0), you should not see this issue as the APIs will match.

Once this auto-generated PR is merged and a release cut, you'll be able to use newer versions.

olivierbeaulieu commented 9 months ago

Aligning sentry versions didn't work for me.

RewriteFrames from v.7.76.0 has the noop setupOnce, which toucan-js@3.3.1 expects to not be a noop. Unless I'm misunderstanding something?

Thanks!

timfish commented 9 months ago

Ah yes sorry you are correct, I didn't realise setupIntegrations was overridden in the client. I guess this code need to be copied from Sentry core: https://github.com/getsentry/sentry-javascript/blob/7303cdacb3ba2da1e71844e9daa5ffdb91d9a8a7/packages/core/src/integration.ts#L106-L130

maciejp-ro commented 8 months ago

Bumped into this as well – took me more than a day of trying to figure it out on Dec 8, a few days before this issue was filed; resumed that work today and found this, thank you for reporting!

FYI the title should be ">= 7.74.0" or "> 7.73.0" – 7.74.0 is the first version with noop setupOnce.

With yarn, the following override in package.json makes it work:

  "resolutions": {
    "toucan-js/@sentry/core": "7.73",
    "toucan-js/@sentry/integrations": "7.73",
    "toucan-js/@sentry/types": "7.73",
    "toucan-js/@sentry/utils": "7.73"
  }
olivierbeaulieu commented 8 months ago

Issue title updated, good catch.

robertcepa commented 3 months ago

Sentry removed class-based integrations in v8. We just released a new version of Toucan that uses new function-based integrations in https://github.com/robertcepa/toucan-js/releases/tag/toucan-js%404.0.0

Upgrading to v4.0.0 should resolve this problem. Note that RewriteFrames is now called rewriteFramesIntegration.