getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.9k stars 1.56k forks source link

[Next.js] Use OTEL for Vercel Edge SDK #13740

Open lforst opened 1 week ago

lforst commented 1 week ago

Description

We need this for Turbopack support.

lforst commented 3 days ago

I did some work on this in https://github.com/getsentry/sentry-javascript/pull/13742 to discover that @opentelemetry/core relies on the performance API for its browser export in the global scope which is not available in the edge runtime. Next.js 14+ and the @vercel/otel package seem to add a polyfill to make this work, however, in our situation it is a bit more tricky to polyfill, since we are using externalized versions of the @sentry/opentelemetry. We would need to bundle all dependencies into one file and add the polyfill to the top as a banner.

EDIT: Got it working by bundling and putting the polyfill on top as a banner.