-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(svelte): Make component tracking compatible with Svelte 5 #10312
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
Conversation
in addition blocked on jest (#10318) - moving to draft |
@@ -1,7 +1,6 @@ | |||
import { getCurrentScope } from '@sentry/browser'; | |||
import type { Span, Transaction } from '@sentry/types'; | |||
import { afterUpdate, beforeUpdate, onMount } from 'svelte'; | |||
import { current_component } from 'svelte/internal'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not conditionally access this via a version check?
In SvelteKit
we can inject stuff via vite plugin so we can inject a version into the bundle in if Svelte themselves does not expose it. Or is that problematic for other reasons?
@Lms24 anymore progress on this? |
e3bf653
to
b6f7fa8
Compare
Bundle ReportChanges will decrease total bundle size by 3.37MB ⬇️
|
size-limit report 📦
|
Superseded by #11807 |
depends on #10311
This PR adds compatibility for Svelte 5 by adjusting our component tracking functionality to work with Svelte 5.
TLDR: This change entails a minor behaviour "breaking" change for a subset of Svelte component tracking users.
Our previous implementation relied on an exported internal API (
current_component
) to automatically detect the name of the component name for the respective spans. This API was removed in Svelte 5, so we can no longer use it. Importing it causes a build error. This means that going forward, calls totrackComponent
need to set thecomponentName
option or the span will get the fallback<Svelte Component>
name. However, this only applies if the function is called manually.In case users use our
withSentryConfig
wrapper in theirsvelte.config.js
, we inject a preprocessor that already creates passes the component name from the component file name to the injectedtrackComponent
call. So nothing changes in this use case - component spans will still automatically get the correct name. We recommend this approach in our docs.ref #10275